akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const int INF = 1e9;
int dp[6100];

int main()
{
    //freopen("testCase.txt", "r", stdin);

    int n, t;
    cin >> n >> t;

    //cout << -INF << '\n';

    memset(dp, -INF, sizeof(dp));
    dp[0] = 0LL;

    vpii v(n);

    for(int i = 0; i < n; ++i)
    {
        ll a, b;
        cin >> a >> b;
        v[i] = mp(a, b);
    }

    sort(all(v));

    for(int i = 0; i < n; ++i)
    {
        int a = v[i].fi, b = v[i].se;

        for(int j = t-1; j >= 0; --j)
        {
            if(dp[j] != -INF)
            {
                dp[j+a] = max(dp[j+a], dp[j] + b);
            }
        }
    }

    int najveci = -INF;

    for(int i = 0; i < 6100; ++i)
    {
        najveci = max(najveci, dp[i]);
    }

    cout << najveci << '\n';

    return 0;
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<math.h>
#define PA 3.1415926535
int main()
{
	double a, b, c,C;
	double S, L, h;
	double rad;
	scanf("%lf %lf %lf",&a,&b,&C);
	rad = C * 2 * PA / 360;
	S = a * b * sin(rad) / 2;
	h = 2 * S / a;
	c = sqrt(a*a + b*b - 2 * a*b*cos(rad));
	L = a + b + c;
	printf("%lf %lf %lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;


int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n+2); // 0 v[1] v[2] ... v[n] 0
    int dsum = 0;
    REP(i,n) {
        cin >> v[i+1];
        dsum += abs(v[i+1] - v[i]);
    }
    dsum += abs(v[n]);

    REP(i,n) {
        int d1 = abs(v[i+1] - v[i]);
        int d2 = abs(v[i+2] - v[i+1]);
        int d3 = abs(v[i+2] - v[i]);
        int ans = dsum - d1 - d2 + d3;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int a;
  int ans;
  for (int i = 0; i < 5; i++) {
    cin >> a;
    if (a == 0) {
      ans = i + 1;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3540
class UnionFindTree:
    def __init__(self, n):
        self.nodes = [-1] * n #根にサイズを負の値で格納する。
    def find(self, i):
        if self.nodes[i] < 0: #値が負の場合は根
            return i
        else:
            self.nodes[i] = self.find(self.nodes[i]) #縮約
            return self.nodes[i]

    def union(self, i, j):
        i = self.find(i)
        j = self.find(j)
        if i == j:
            return
        if self.nodes[i] > self.nodes[j]: #サイズ比較してiの方がサイズが大きいようにする
            i, j = j, i
        self.nodes[i] += self.nodes[j] #大きい方に小さい方を統合しサイズを登録する。
        self.nodes[j] = i # jの親はi
    
    def size(self, i): # 所属する集合の大きさを返す
        i = self.find(i)
        return -self.nodes[i]


n, k, l = map(int, input().split())
roads = UnionFindTree(n)
railways = UnionFindTree(n)
ans = []
for _ in range(k):
    a, b = map(lambda x : int(x) - 1, input().split())
    roads.union(a, b)
    
for _ in range(l):
    a, b = map(lambda x : int(x) - 1, input().split())
    railways.union(a, b)

counter = dict()
for i in range(n):
    p = (roads.find(i), railways.find(i))
    if not p in counter:
        counter[p] = 1
    else:
        counter[p] += 1

ans = [counter[(roads.find(i), railways.find(i))] for i in range(n)]
print(" ".join(map(str, ans)))

Measured memory_bytes: 124196
def func(n):
    if n % 2 == 0:
        return n//2
    else:
        return 3*n + 1

s = int(input())

A = [s]
tmp = s
ind = 1

while not(tmp in A[:-1]) or ind == 1:
    ind += 1
    tmp = func(tmp)
    A.append(tmp)

print(ind)


Measured memory_bytes: 3060
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int x=sc.nextInt();
        if(k*500<x)
        System.out.println("No");
        else
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int N;
  cin >> N;
  if(N==1) print("Hello World");
  else {
    int A,B;
    cin >> A >> B;
    print(A+B);
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char* argv[]){
  int N;
  long int x;
  scanf("%d %ld", &N, &x);
  long int a[N];
  int i,n;
  for(i=0; i<N; ++i){
    scanf("%ld", &a[i]);
  }
  long int ans = 0;
  for(n=0; n<N; ++n){
    ans += a[n];
  }
  long int subans;
  long int suban1;
  for(i=1; i<N; ++i){
    suban1 = a[N-1];
    if(a[N-1] > a[0]){
      suban1 = a[0];
    }
    subans = x * i;
    for(n=1; n<N; ++n){
      if(a[n-1] > a[n]){
        a[n-1] = a[n];
      }
      subans += a[n-1];
    }
    a[N-1] = suban1;
    subans += a[N-1];
    if(subans < ans){
      ans = subans;
    }
  }
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 128
n,m=gets.chomp.split(" ").map { |e| e.to_i }
py = []

m.times do |i|
  p,y=gets.chomp.split(" ").map { |e| e.to_i }
  py[i] = ("%06d" % p) + ("%010d" % y) + ("%06d" % i)
end

ans = Array.new(m)

hoge = "000001"
temp = 1
a = py.sort

for x in a do
  if hoge != x[0..5]
    hoge = x[0..5]
    temp = 1
  end
  index = x[16..21].to_i
  ans[index] = x[0..5] + ("%06d" % temp)
  temp += 1
end

puts ans


Measured memory_bytes: 18156
#include <iostream>
#include <string>
#define llint long long
#define mod 1000000007

using namespace std;

llint t1, t2;
llint a1, a2, b1, b2;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	if(a1 < b1) swap(a1, b1), swap(a2, b2);
	
	llint d1 = a1-b1, d2 = a2-b2;
	llint dif = d1*t1+d2*t2;
	
	if(dif == 0){
		cout << "infinity" << endl;
		return 0;
	}
	if(dif > 0){
		cout << 0 << endl;
		return 0;
	}
	
	dif *= -1;
	
	llint top = d1*t1;
	llint ans = (top+dif-1)/dif*2;
	if(top % dif == 0) ans++;
	cout << ans-1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*its_Rashid*/
#include <bits/stdc++.h>
using namespace std ;

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 , num3 ;
    cin >> num1 >> num2 >> num3 ;
    cout << min(num1 * num2 , num3) ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;

int solve(int n) {
    int a = n % 39;
    if (a == 0) a += 39;
    return a;
}

int main() {
    int n;
    while (cin >> n) {
        printf("3C%02d\n", solve(n));
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
	int x,z[3000]={0},i,y[3000]={0};
	for(x=0;10000>=x;x++){
			scanf("%d %d",&y[x],&z[x]);
		if(y[x]==0&&z[x]==0){
			break;}
}
		for(i=0;i<=x;i++){
			if(y[i]==0&&z[i]==0){
				break;}
			if(y[i]>z[i]){

				printf("%d %d\n",z[i],y[i]);
			}else{
				printf("%d %d\n",y[i],z[i]);
			
		}}
	return 0;
}

Measured memory_bytes: 2624
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        HashMap<Integer,Integer> h=new HashMap<>();
        int count=0;
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        for(int i=1;i<=n;i++){
            h.put(i,0);
        }

        for(int i=0;i<k;i++){
            int d=sc.nextInt();
            for(int j=0;j<d;j++){
                int c=sc.nextInt();
                h.put(c,1);
            }
        }

        for(int i=1;i<=n;i++){
            if(h.get(i)==0){
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 46800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
bool com(pii a,pii b){
    return a.first+a.second < b.first+b.second;
}
int main(){
    int n;
    sci(n);
    vpii a(n);
    rep(i,0,n-1){
        scii(a[i].first,a[i].second);
    }
    sort(all(a),com);
    vll dp(n+1,INF);//dp[i] = minimum #of cushions when total of 'i' participants could contribute.
    dp[0] = 0LL;
    for(pii i:a){
        for(int j=n;j>0;--j){
            if(dp[j-1] <= i.first){
                dp[j] = min(dp[j],dp[j-1]+i.second);
            }
        }
    }
    rrep(i,n,0){
        if(dp[i]<INF){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3744
N,W=list(map(int,input().split()))
VW=[list(map(int,input().split())) for _ in range(N)]
dp=[[0 for _ in range(W+1)] for _ in range(N+1)]

def solve(p,w):
  if dp[p][w]:
    return dp[p][w]
  if p == N:
    dp[p][w]= 0
  elif w < VW[p][1]:
    dp[p][w] = solve(p+1,w)
  else:
    dp[p][w] = max(solve(p+1,w),solve(p+1,w-VW[p][1])+VW[p][0])
  return dp[p][w]

print(solve(0,W))


Measured memory_bytes: 24096
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int A[200000], N, s[200000], sz, v[200000];
int add(int k, int z){
  if(k==0){
    return 0;
  }
  if(sz==0 || s[sz-1] < k){
    s[sz] = k;
    v[sz] = 1;
    sz++;
    return 1;
  }
  v[sz-1]++;
  if(v[sz-1]==z){
    sz--;
    return add(k-1,z);
  }
  return 1;
}
int main(){
  int i, j, k, x, y, z;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  x = 1;
  y = N+10;
  while(x < y){
    z = (x+y) / 2;
    sz = 0;
    for(i=1;i<N;i++){
      if(A[i-1] < A[i]){
        continue;
      }
      while(sz && s[sz-1] > A[i]){
        sz--;
      }
      if(z==1){
        break;
      }
      if(!add(A[i],z)){
        break;
      }
    }
    if(i==N){
      y = z;
    }
    else{
      x = z + 1;
    }
  }
  wt_L(x);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int N, A[2d5];
// int s[2d5], v[2d5], sz;
// 
// int add(int k, int z){
//   if(k==0) return 0;
//   
//   if(sz==0 || s[sz-1] < k){
//     s[sz] = k;
//     v[sz] = 1;
//     sz++;
//     return 1;
//   }
//   v[sz-1]++;
//   if(v[sz-1]==z){
//     sz--;
//     return add(k-1,z);
//   }
//   return 1;
// }
// 
// {
//   int i, j, k;
//   int x, y, z;
// 
//   rd(N,A(N));
//   x = 1;
//   y = N+10;
//   while(x < y){
//     z = (x+y) / 2;
// 
//     sz = 0;
//     rep(i,1,N){
//       if(A[i-1] < A[i]) continue;
//       while(sz && s[sz-1] > A[i]) sz--;
//       if(z==1) break;
//       if(!add(A[i],z)) break;
//     }
// 
//     if(i==N) y = z; else x = z + 1;
//   }
// 
//   wt(x);
// }


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
    long long cnt = 0;
    bool flag = false;
    long long MIN = pow(10, 9);
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] < 0) {
            cnt++;
            MIN = min(MIN, abs(A[i]));
        }
        else if (A[i] > 0) {
            MIN = min(MIN, A[i]);
        }
        else if (A[i] == 0) flag = true;
    }

    long long sum = 0;
    for (int i = 0; i < N; i++) sum += abs(A[i]);
    if (cnt % 2 == 0) cout << sum << endl;
    else {
        if (flag) cout << sum << endl;
        else cout << sum - 2 * MIN << endl;
        
    }
}

Measured memory_bytes: 1024
mod = 10**9+7
N = int(input())
prime = [2]
for i in range(3,N+1):
    flag = True
    for x in prime:
        if i%x == 0:
            flag = False
    if flag:
        prime.append(i)
ans = 1
for p in prime:
    e = 1
    cnt = 0
    while p**e <= N:
        cnt += N//(p**e)
        e += 1
    ans = ans *(cnt+1)%mod
print(ans)

Measured memory_bytes: 39024
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        List<Integer> list = new ArrayList();

        for(int i = 0; i < n; i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);
      
        int ans = 0;
        for(int j = 0; j < k; j++){
            ans += list.get(j);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 38944
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string str;
	cin>>str;
	int max_len=0;
	int len=0;
	for(int i=0;i<str.length();i++){
		if(str[i]=='A' ||str[i]=='T' ||str[i]=='G' ||str[i]=='C'){
			len=0;
			for(int j=i;j<str.length();j++){
				if(str[j]=='A' ||str[j]=='T' ||str[j]=='G' ||str[j]=='C')
					len++;
				else
					break;
			}
			if(len>max_len)
				max_len=len;
		}
	}
	cout<<max_len;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N ,M;
    cin >> N >> M;
    vector<vector<int>> to(N, vector<int>());

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);      
    }
    queue<int> r;
    r.push(0);
    vector<int> ans(N, -1);
    while (!r.empty())
    {
        int room = r.front();
        r.pop();
        if (to[room].empty())
        {
            cout << "No" << endl;
            return 0;
        }
        
        for (int x : to[room])
        {
            if (ans[x] != -1)
            {
                continue;
            }
            
            ans[x] = room;
            r.push(x);
        }
    }
    
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++)
    {
        cout << ans[i] + 1 << endl;
    }
    
    return 0;   
}

Measured memory_bytes: 10108
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<int> data;
      for(int i=0;i<n;i++)
	{
	  int tmp;
	  cin>>tmp;
	  data.push_back(tmp);
	}
      int cnt=0;
      while(true)
	{
	  bool flag =true;
	  int tmp=0;
	  int sizecnt=1;
	  for(int i=0;i<data.size();i++)
	    {
	      if(data[i]!=sizecnt)
		flag=false;
	      
	      data[i]--;
	      tmp++;
	      if(data[i]<=0)
		{
		  data.erase(data.begin()+i);
		  i--;
		}
	      sizecnt++;
	    }
	  if(flag)
	    break;
	  data.push_back(tmp);
	  

	  
	  cnt++;
	  if(cnt>10000)
	    {
	      cnt=-1;
	      break;
	    }
	}
      cout<<cnt<<endl;

    }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    map<P, int> mp;
    for(int i = 1; i <= n; i++) {
        if(i%10==0) continue;
        int a = i%10;
        int ni = i;
        while(ni/10>0) {
            ni/=10;
        }
        int b = ni;
        P p = P(a, b);
        mp[p]++;
    }
    ll ans = 0;
    for(auto p : mp) {
        int a = p.first.first;
        int b = p.first.second;
        ans += mp[P(a, b)]*mp[P(b, a)];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    

    if(a>12){
        printf("%d\n",b);
    }else if(a<6){
        printf("0\n");
    }else{
        printf("%d\n",b/2);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n,m,k; cin>>n>>m>>k;
    rep(i,n+1)rep(j,m+1){
        if(i*(m-j)+j*(n-i) == k){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	string s;
	cin >> s;
	if(s != "AAA" && s != "BBB") cout << "Yes" << endl;
	else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
int main(){
   int A,B;
    cin >> A >> B;
    cout << A*B << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;



int main(){
    ll N; cin >> N;
    ll d = N%10;
    if(d == 3) cout << "bon" << endl;
    else if(d == 0 || d == 1 || d == 6 || d == 8) cout << "pon" << endl;
    else cout << "hon" << endl;

}


Measured memory_bytes: 3592
A, B, K = gets.split.map(&:to_i)
waru = []
i = 0
abMin = [A, B].min
while abMin > 0
  if A % abMin == 0 && B % abMin == 0
    waru[i] = abMin
    i += 1
  end
  abMin -= 1
end
puts waru[K - 1]

Measured memory_bytes: 1788
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int iTotal,iPriceA,iPriceB;
	register int i, j;
	cin >> iTotal >> iPriceA >> iPriceB;
	iTotal -= iPriceA;
	iTotal %= iPriceB;
	cout << iTotal << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
/*
_________________________
|   LIVE FREE OR DIE     |
|       327 2153         |
|          New           |
|_______HAMPSHIRE________|

*/
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MAX 20
#define int long long
#define MOD 998244353

int32_t main()
{
	IOS
	string s;cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 

  vector<int> v(3);
  for (int i = 0; i < 3; ++i) cin >> v[i];

  sort(begin(v), end(v));

  if (v[0] + v[1] == v[2]) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}

	

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<ll,int> P;

const ll MAX_N=131072;
int bit[MAX_N*2-1];
ll n;
int main(){
  set<int> s;
  rep(i,3){
    int x;cin>>x;
    s.insert(x);
  }
  cout<<s.size()<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

string s;

int main() {
  cin >> s;
  for(int i = 0; i < 3; ++i) {
    if(s[i] == '1')
      cout << 9;
    else
      cout << 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	my$m=@lms;
	for(0..$m-1){
		$lms_map[$lms[$_]]=$_;
	}
	@sa=$induce->(@lms);
	if($m){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms[$lms_map[$l]+1]//$n;
			my$end_r=$lms[$lms_map[$r]+1]//$n;
			my$different;
			if($end_l-$l!=$end_r-$r){
				$different=1;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$different=$l==$n||$s[$l]!=$s[$r];
			}
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper+=$different;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array($){
	my@s=map ord,split"",$_[0];
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array($@){
	my@s=map ord,split"",shift;
	return lcp(@s,@_);
}
package main;
my$s=<>;
chomp$s;
my@lcp=LcpArray::lcp_array($s,SuffixArray::suffix_array($s));
my$ans=0;
my$i=0;
$ans+=++$i-$_ for@lcp;
print$ans+$i+1,$/;


Measured memory_bytes: 263040
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,t,s[100000];
	memset(s,0,sizeof(s));
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d",&t);
		s[t]++;
	}
	int ans=0,l;
	for(int i=1; i<99999; i++) {
		l=s[i-1]+s[i]+s[i+1];
		if(l>ans) ans=l;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int main() {
#define int long long
	vector<pair<long long, long long>> wow;
	int n, k;
	cin >> n >> k;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		wow.push_back(make_pair(a, b));
	}
	sort(wow.begin(), wow.end());
	long long ans = -1;
	for (int i = 0;i <= n - k;++i) {
		vector<long long> nya;
		if (k != 1) {
			for (int q = i;q < i + k - 1;++q) {
				nya.push_back(wow[q].second);
			}
		}
		for (int t = i + k - 1;t < n;++t) {
			nya.push_back(wow[t].second);
			sort(nya.begin(), nya.end());
			for (int j = 0;j <= t - i - k + 1;++j) {
				long long hoge = nya[j+k-1] - nya[j];
				long long yoko = wow[t].first - wow[i].first;
				if (ans == -1) {
					ans = hoge*yoko;
				}
				ans = min(ans, hoge*yoko);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   ll N;
   vector<ll> count(5);
   ll ans;
   string tmp;

   cin >> N;
   rep(i, N) {
     cin >> tmp;
     if (tmp.at(0) == 'M') count.at(0)++;
     if (tmp.at(0) == 'A') count.at(1)++;
     if (tmp.at(0) == 'R') count.at(2)++;
     if (tmp.at(0) == 'C') count.at(3)++;
     if (tmp.at(0) == 'H') count.at(4)++;
   }

   for (int i = 0; i <= 2; i++) {
     for (int j = i + 1; j <= 3; j++) {
       for (int k = j + 1; k <= 4; k++) {
         ans += count.at(i) * count.at(j) * count.at(k);
       }
     }
   }


   cout << ans << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<char> s(n);
  for(int i = 0; i < n; i++){
    cin >> s.at(i);
    if(i + 1 == k){
      s.at(i) -= 'A' - 'a';
    }
  }
  for(int i = 0; i < n; i++){
    cout << s.at(i);
  }
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc044/tasks/abc044_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int n, k, x, y, total = 0;

  cin >> n >> k >> x >> y;

  if (k < n)
    total = k * x + (n - k) * y;
  else
    total = n * x;

  cout << total << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
#define rad(x) (x*atan(1.0)*4.0/180.0)

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
void koch(double x1,double y1,double x4,double y4,int d){
	if(d==n){
		printf("%.5f %.5f\n",x4,y4);
		return ;
	}
	double x2 =(x4-x1)/3.0+x1;
	double y2 =(y4-y1)/3.0+y1;
	double x3=(x4-x1)*2/3.0+x1;
	double y3 =(y4-y1)*2.0/3.0+y1;
	double x = (x3-x2)*cos(rad(60.0)) - (y3-y2)*sin(rad(60.0)) + x2;
	double y = (x3-x2)*sin(rad(60.0)) + (y3-y2)*cos(rad(60.0)) + y2;
	koch( x1, y1, x2, y2, d+1 );
	koch( x2, y2, x,  y,  d+1 );
	koch( x,  y,  x3, y3, d+1 );
	koch( x3, y3, x4, y4, d+1 );
}

int main(){
	cin>>n;
	printf("%.5f %.5f\n",0.0,0.0);
	koch(0.0,0.0,100.0,0.0,0);
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main() {
	int X,N,r,y=0;
	cin >> X >> N;
	set<int> p;
	r = X;

	rep(i,N) {
		int t;
		cin >> t;
		p.insert(t);
	}

	y = 0;
	while(1) {
		if(!p.count(X-y)) {
			r = X-y;
			break;
		}
		if(!p.count(X+y)) {
			r = X+y;
			break;
		}
		++y;
	}

	cout << r << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int s,w;
int main(void){
	cin>>s>>w;
	if(w>=s)cout<<"unsafe";
	else cout<<"safe";
	return 0;
} 

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a,b;
  cin>>a>>b;
  if(a>12){
    cout<<b<<endl;
  }
  else if(a<6){
    cout<<0<<endl;
  }
  else{
    cout<<b/2<<endl;
  }
}

Measured memory_bytes: 256
Sum = 0
inc = 0

N,M = map(int,input().split(" "))
A_l = list(map(int,input().split(" ")))
A_l.sort(reverse=True)
for i in range(N):
    Sum += A_l[i]
    
for j in range(M):
    
    if A_l[j] < Sum / (4 * M):
        inc += 1

        
if inc == 0:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 3064
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, bCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isNumber = (x: unknown): x is number => typeof x === "number";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isBigint = (x: unknown): x is bigint => typeof x === "bigint";
type NumberOrBigintOrElse<T> = number | bigint extends T
  ? undefined
  : T extends number
  ? number
  : T extends bigint
  ? bigint
  : undefined;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.max(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc >= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.min(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc <= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const abs = <T extends number | bigint>(t: T) =>
  (isNumber(t)
    ? Math.abs(t)
    : isBigint(t)
    ? t >= 0n
      ? t
      : -t
    : undefined) as NumberOrBigintOrElse<T>;

/**
 * Program
 */

const P = 10n ** 9n + 7n;
const addP = (x: bigint, y: bigint) => ((((x % P) + (y % P)) % P) + P) % P;
const subP = (x: bigint, y: bigint) => ((((x % P) - (y % P)) % P) + P) % P;
const prodP = (x: bigint, y: bigint) => ((((x % P) * (y % P)) % P) + P) % P;
const powP = (x: bigint, n: bigint): bigint => {
  let tmpN = n;
  const isEvens: boolean[] = [];
  while (tmpN !== 1n) {
    isEvens.push(tmpN % 2n === 0n);
    tmpN /= 2n;
  }
  return isEvens.reduceRight((acc, b) => {
    const tmp = prodP(acc, acc);
    return b ? tmp : prodP(x, tmp);
  }, x);
};
const getAns = (N: bigint): string =>
  addP(subP(powP(10n, N), prodP(2n, powP(9n, N))), powP(8n, N)).toString();
{
  const N = bCin();
  const ans = getAns(N);
  console.log(ans);
}


Measured memory_bytes: 29640
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n;
vector<vector<pi>> g;
vi d;

void dfs(int v,int p){
  for(pi i:g[v]){
    int u=i.fi,w=i.se;
    if(u!=p){
      d[u]=d[v]+w;
      dfs(u,v);
    }
  }
}

void run(){
  cin>>n;
  g.resize(n);
  d.resize(n);
  rep(i,n-1){
    int u,v,w;
    cin>>u>>v>>w;
    u--,v--;
    g[u].pb({v,w});
    g[v].pb({u,w});
  }
  dfs(0,0);
  rep(i,n)cout<<d[i]%2<<endl;
}


Measured memory_bytes: 9984
fn main() {
    let n: usize = read();
    let k: i32 = read();
    let mut v: Vec<i32> = Vec::new();
    for i in 0..n {
        let s: i32 = read();
        v.push(s);
    }

    let mut ans = 0;
    for i in 0..n {
        ans += min(v[i], k-v[i]) * 2;
    }
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define    fios ios_base::sync_with_stdio(false); cin.tie(0);
#define    sf(x) scanf("%d",&x)
#define    sfl(x) scanf("%lld",&x)
#define    pf(x) printf("%d\n",x)
#define    pfl(x) printf("%lld\n",x)
#define    ll long long
#define    nl "\n"
#define    PB(x) push_back(x)
#define    For(i,n) for(int i=0; i<n; i++)
#define    PI acos(-1)
using namespace std;


int main()
{
    int x,y;
    cin>>x>>y;

    if(y%2==0)
    {
        if(x*2<=y && x*4>=y)
            cout<<"Yes"<<nl;
        else
            cout<<"No"<<nl;

    }
    else
        cout<<"No"<<nl;


    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
    	if(S[i] == '?')
    		S[i] = 'D';
    }
    cout << S << endl;   
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << '\n';
    return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

const int N = 1e4 + 100;
const int D = 128;

int dp[N][D][2];

int main() {
    ios::sync_with_stdio(false);
    string s;
    int d;
    cin >> s >> d;
    int n = s.size();
    dp[0][0][1] = 1;
    for (int i=0; i<n; i++) {
        for (int m=0; m<d; m++) {
            for (int eq=0; eq<=1; eq++) {
                for (int x=0; x<=9; x++) {
                    if (eq && x > s[i]-'0') {
                        continue;
                    }
                    int m2 = (m + x) % d;
                    int eq2 = eq && x == s[i]-'0';
                    dp[i+1][m2][eq2] = (dp[i+1][m2][eq2] + dp[i][m][eq]) % MOD;
                }
            }
        }
    }
    ll ans = (dp[n][0][0] + dp[n][0][1] + MOD - 1) % MOD;
    cout << ans << '\n';
}


Measured memory_bytes: 10240
//#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 2e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void quit() {cout << "No"; exit(0);}
int n, T;
ll dp[maxn][33];
vpi a;
vi v;
int ovf(ll x, ll y, ll t) {
	return t+1 <= (T-y)/(x+1);
}
int get(int x) {
	int i = 0;
	while(i < v.size() && x >= v[i]+1) x -= 1+v[i++];
	return i;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> T;
	a.resize(n);
	for(auto &i : a) {
		cin >> i.first >> i.second;
		if(i.first==0) v.pb(i.second);
	}
	sort(all(v));
	sort(all(a), [](const pi& a, const pi &b) {
		return (a.second+1)*b.first < (b.second+1)*a.first;
	});
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j <= 30; j++) {
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			if(a[i].first&&ovf(a[i].first, a[i].second, dp[i][j])) {
				dp[i+1][j+1] = min(dp[i+1][j+1], (a[i].first+1)*(1+dp[i][j]) + a[i].second);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= 30; i++) if(T>=dp[n][i]) {
		ans = max(ans,i + get(T-dp[n][i]));
	}
	cout << ans;
}



Measured memory_bytes: 56688
#include<iostream>
using namespace std;
//--------------------

int main() {
	long res = 0;
	long link = 0;
	long N; cin >> N;
	long a[100009]; for (int i = 1; i <= N; i++) cin >> a[i];
	for (int i = 1; i <= N; i++) if (a[i] == i) link++; else { res += (link + 1) / 2; link = 0; }
    res += (link + 1) / 2;
    
	cout << res << endl;
}

Measured memory_bytes: 1024
# AOJ 0571 JJOOII
# Python3 2018.6.20 bal4u

import re

pat = "(J*)(O*)(I*)"
ans = 0
for s in re.findall(pat, input()):
	j = len(s[0])
	o = len(s[1])
	i = len(s[2])
	if j >= o and i >= o: ans = max(ans, o)
print(ans)


Measured memory_bytes: 56216
#include <bits/stdc++.h>

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n , k ;
	cin >> n >> k ;
	vector<int> a(n);
	int index = -1 ;
	rep(i,n) {
		cin >> a[i]; 
		if (a[i] == 1 ){
			index = i ; 
		}
	}
	//1が何番目にあるかだけが大切.
	//前にはi個、後ろにはn - i - 1 個　ある。 
	//一回でk - 1個変化
	int ans = 0;
	ans += (index + k - 1 - 1 ) / ( k -1 ) ;
	index = ans * ( k - 1) ;
	ans += (n - index - 1 + k - 1 -1 ) / ( k -1 );
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;

int main() {
  int N;
  string s;
  cin >> N >> s;

  int x = 0, maxi = 0;
  for (int i = 0; i < s.size(); i++) {
    x += (s[i] == 'I' ? 1 : -1);
    maxi = max(maxi, x);
  }

  // 解答
  cout << maxi << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;
int		cnt;

int		main(void)
{
	string	S;
	cin >> S;
	for (auto &i : S)
	{
		cnt++;
		if (cnt % 2)
		{
			if (!(i == 'R' || i == 'U' || i == 'D'))
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			if (!(i == 'L' || i == 'U' || i == 'D'))
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7;

lint H, W;
char char_map[400][400];
bool visited[400][400];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> char_map[i][j];
			visited[i][j] = false;
		}
	}
	lint sum = 0;
	REP(i, H) {
		REP(j, W) {
			if (visited[i][j]) continue;
			queue<pint> que;
			que.push(pint(i, j));
			visited[i][j] = true;
			lint white = 0, black = 0;
			int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
			while (!que.empty()) {
				pint curr = que.front(); que.pop();
				int x = curr.second, y = curr.first;
				bool flag = (char_map[y][x] == '#');
				if (flag) black++;
				else white++;
				REP(k, 4) {
					int next_x = x + dx[k], next_y = y + dy[k];
					if (0 <= next_x && next_x < W && 0 <= next_y && next_y < H && !visited[next_y][next_x]) {
						if ((flag && char_map[next_y][next_x] == '.') || (!flag && char_map[next_y][next_x] == '#')) {
							que.push(pint(next_y, next_x));
							visited[next_y][next_x] = true;
						}
					}
				}
			}
			sum += black * white;
		}
	}
	cout << sum;
}


Measured memory_bytes: 640