akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  int Sx,Sy,Gx,Gy;
  cin>>Sx>>Sy>>Gx>>Gy;
  --Sx,--Sy,--Gx,--Gy;
  
  vector<string> S(H);
  for(int i=0; i<H; ++i) cin>>S[i];
  
  vector<vector<int>> D(H, vector<int>(W,1e9));
  vector<vector<bool>> Data(H, vector<bool>(W,false));
  queue<pair<int,int>> q;
  q.push(make_pair(Sx, Sy));
  D[Sx][Sy]=0;
  
  while(!q.empty()){
    int x=q.front().first;
    int y=q.front().second;
    q.pop();
    if((x==Gx)&&(y==Gy)){
      cout<<D[Gx][Gy]<<endl;
      return 0;
    }
    
    for(int l=0; l<4; ++l){
      int x1=x;
      int y1=y;
      for(int m=1; m<=K; ++m){
        x1+=dx[l];
        y1+=dy[l];
        if((0>x1)||(H<=x1)||(0>y1)||(W<=y1)) break;
        if(S[x1][y1]=='@') break;
        if(Data[x1][y1] && (D[x1][y1]!=(D[x][y]+1))) break;
        if(!Data[x1][y1]){
          D[x1][y1]=D[x][y]+1;
          q.push(make_pair(x1,y1));
          Data[x1][y1]=true;
        }
      }
    }
  }
  
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 12156
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;


int main()
{
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<int> a(N), b(N), c(N);
    for( int i = 0; i < N-1; ++i ){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    for( int i = 0; i < N; ++i ) cin >> c[i];

    
    int start, size = N;
    for( int i = 0; i < N; ++i ){
        if( G[i].size() < size ){
            size = G[i].size();
            start = i;
        }
    }

    vector<int> ans(N);
    sort( c.begin(), c.end(), greater<int>() );
    ans[start] = c[0];
    int idx = 1;

    vector<bool> isVisited(N, false);
    queue<int> q;
    q.push(start);
    while( !q.empty() ){
        int tmp = q.front();
        q.pop();
        if( isVisited[tmp] ) continue;
        isVisited[tmp] = true;
        for( auto v: G[tmp]){
            if( !isVisited[v] ){
                ans[v] = c[idx++];
                q.push(v);
            }
        }
    }

    int M = 0;
    for( int i = 0; i < N-1; ++i ){
        M += min( ans[a[i]], ans[b[i]] );
    }

    cout << M << endl;
    for( int i = 0; i < N; ++i ) cout << ans[i] << " ";

    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
	int a=0;
	char A[5];
	for (int i = 0; i < 5; i++) {
		scanf("%c\n", &A[i]);
	}
	
	for(int i = 0; i < 5; i++) {
		if (A[i] =='A' &&A[i + 1]=='C') {
			a = 1;
		
		}
	}
	if (a == 1) {
		printf("Yes");

	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
ll A[2010];
ll dp[2010][2010];

int main() {
    while (cin >> N) {
        REP(i, 0, N) {
            cin >> A[i];
        }
        if (N == 2) {
            p(max(A[0], A[1]));
            continue;
        }
        REP(i, 0, N) REP(j, 0, N) dp[i][j] = 0;
        for (ll k = 0; k < N; k += 2) {
            REP(L, 0, N) {
                ll R = (L + k) % N;
                //JOI
                dp[L][R] = max({dp[L][R], dp[(L + 1) % N][R] + A[L], dp[L][(R - 1 + N) % N] + A[R]});
                //IOI
                if(k+1>N) break;
                if (A[(L - 1 + N) % N] < A[(R + 1) % N]) {
                    dp[L][(R + 1) % N] = max(dp[L][(R + 1) % N], dp[L][R]);
                } else {
                    dp[(L - 1 + N) % N][R] = max(dp[(L - 1 + N) % N][R], dp[L][R]);
                }
            }
        }
        ll tsu = 0;
        if (N % 2 == 0) tsu++;
        ll ans = 0;
        REP(L, 0, N) {
            ans = max(ans, dp[L][(L + N - 1 - tsu) % N]);
        }
        p(ans);
    }
}


Measured memory_bytes: 34512
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define ftype  long double
#define endl '\n'
#define pr pair<ll,ll>
#define debug(x) cout<<#x<<" "<<x<<endl;
using namespace std;
void masterstroke(){
	string a;cin>>a;
	map <ll,ll> ass; 
	for(auto j:a){
		ass[j-'a']++;
	}
	if(ass.size()==2){
		for(auto j:ass){
			if(j.ss==2ll){cout<<"Yes";return;}
		}
	}
	cout<<"No";
	
}
int main(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 ll t=1;//cin>>t;
	 for(ll i=0;i<t;i++)masterstroke();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;
typedef pair<ll, ll> pint;


ll threeNumbers(){
    
    int N;
    cin >> N;
    priority_queue<int> a1;
    priority_queue<int> a2;
    ll akmade[100010] = {0};
    ll akkara[100010] = {0};
    int a[300010];
    REP(i, 3 * N){
        cin >> a[i];
    }
    ll score = -llINF;
    REP(i, N){
        a1.push(-a[i]);
        a2.push(a[3 * N - i -1]);
        akmade[0] += a[i];
        akkara[0] += a[3 * N - i - 1];
    }
    REP(i, N){
        akmade[i + 1] = akmade[i] + a[i + N];
        a1.push(-a[i + N]);
        akmade[i + 1] += a1.top();
        a1.pop();
    }
    
    REP(i, N){
        akkara[i + 1] = akkara[i] + a[2 * N - i - 1];
        a2.push(a[2 * N - i - 1]);
        akkara[i + 1] -= a2.top();
        a2.pop();
    }
    
    REP(i, N + 1){
        if(score < akmade[i] - akkara[N - i])score = akmade[i] - akkara[N - i];
    }
    return score;
}

class factorypque
{
private:
    ll heap[100010][2];
    int sz = 0;
    
public:
    void push(ll a, ll b);
    pint pop();
};

void factorypque::push(ll a, ll b){
    int i = sz;
    sz ++;
    while(i > 0){
        
        int p = (i - 1) / 2;
        if(heap[p][0] <= a)break;
        heap[i][0] = heap[p][0];
        heap[i][1] = heap[p][1];
        i = p;
    }
    heap[i][0] = a;
    heap[i][1] = b;
}

pint factorypque::pop(){
    ll ret1 = heap[0][0];
    ll ret2 = heap[0][1];
    ll x = heap[sz - 1][0];
    ll y = heap[sz - 1][1];
    int i = 0;
    while(i * 2 + 1 < sz){
        int a = i  * 2 + 1, b = i * 2 + 2;
        if(b < sz && heap[b][0] < heap[a][0]){
            a = b;
        }
        if(heap[a][0] >= x)break;
        heap[i][0] = heap[a][0];
        heap[i][1] = heap[a][1];
        i = a;
    }
    
    
    heap[i][0] = x;
    heap[i][1] = y;
    sz --;
    
    return pint(ret1, ret2);
}

ll factory(){
    int N, K;
    cin >> N >> K;
    factorypque kikaijikan;
    
    REP(i, N){
        int a,b;
        cin >> a >> b;
        kikaijikan.push(a,b);
    }
    ll saishoujikan = 0;
    REP(i, K){
        
        pint tuginokikai = kikaijikan.pop();
        saishoujikan += tuginokikai.first;
        kikaijikan.push(tuginokikai.first + tuginokikai.second, tuginokikai.second);
    }
    
    return saishoujikan;
}


int main(){
    printf("%lld\n",threeNumbers());
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n>>m;
	ll left=-1e7,right=1e7 ;
	while(m--){
		cin>>x>>y;
		left=max(left,x),right=min(right,y);
	}
	if(left>right)ans=0;
	else ans=right-left+1;
	cout<<ans<<nw;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5

int main(){
	int x,a;
	cin>>x>>a;
	if(x<a) cout<<0<<endl;
	else cout<<10<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int n =s.size();
  int win =0;
  for(int i=0;i<s.size();i++){
    if( s.at(i) == 'o'){
      win++;
    }
  }
  if( win + 15 -s.size() >= 8){
    cout <<"YES";
  }
  else{
    cout <<"NO";
  }
}

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


int main(){
  
  int X, N, i;
  cin >> X >> N;
  vector<int> p(N);

  
  int flag = 0; 
  for (i = 0; i < N; i++){
    
    cin >> p.at(i);
    if (p.at(i) == X) flag = 1;

  }

  if(flag == 0 || N == 0){
    cout << X << endl;
    return 0;
  }
  
  int l = X, r = X;
  while (l != -1 && r != 101){
    
    l--; r++;
    if(l < 0) l = -1;
    if(r > 100) r = 101;
    
    int flagl = 0, flagr = 0;
    for (i = 0; i < N; i++){
      if(l == p.at(i)){
        flagl = 1;
        break;
      }
    }
    
    if (flagl != 1){
      cout << l << endl;
      return 0;
    }
    
    for (i = 0; i < N; i++){
      if(r == p.at(i)){
        flagr = 1;
        break;
      }
    }
    if (flagr != 1){
      cout << r << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
using System;

class Program {
    static void Main() {
        for (string line; (line = Console.ReadLine()) != "0";) {
            var n = int.Parse(line);

            for (var i = 0; i < n; i++) {
                var l = Console.ReadLine().Split(' ');
                var pm = int.Parse(l[0]);
                var pe = int.Parse(l[1]);
                var pj = int.Parse(l[2]);

                Console.WriteLine(GetClass(pm, pe, pj));
            }
        }
    }

    static char GetClass(int pm, int pe, int pj) {
        if (pm == 100 || pe == 100 || pj == 100)
            return 'A';
        if (pm + pe >= 180 || pm + pe + pj >= 240)
            return 'A';
        if (pm + pe + pj >= 210)
            return 'B';
        if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80))
            return 'B';
        return 'C';
    }
}

Measured memory_bytes: 8960
#include<cstdio>
#include<cstring>
int main(){
    int n,ans=0;
    char s[26];
    scanf("%d %s",&n,s);
    int l=strlen(s);
    for(int i=0;i<n;i++){
        char t[101];
        scanf(" %s",t);
        int r=strlen(t);
        bool flag=false;
        for(int j=0;j<r;j++){
            for(int k=1;j+k*(l-1)<r;k++){
                for(int c=0;c<l;c++){
                    if(s[c]!=t[j+k*c]) break;
                    if(c==l-1){
                        flag=true;
                    }
                }
                if(flag) break;
            }
            if(flag) break;
        }
        if(flag) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1028
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a>b){
        cout << "a > b" <<endl;
    }else if(b>a){
        cout << "a < b" <<endl;
    }else{
        cout << "a == b" <<endl;
    }
}



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

int main() {
  int N;
  cin >> N;
//  cout << N << endl;
  
  vector<int> a(N+1);
  for(int i=1; i<N+1; ++i) {
    cin >> a.at(i);
//    cout << a.at(i) << endl;
  }

  int tmp = 1, cnt = 1, result = -1;
  while (1) {
    int tmp_cnt = tmp;
    tmp = a.at(tmp_cnt);
    a.at(tmp_cnt) = 1; // ループを検出
    if (tmp == 2) {
      result = cnt;
      break;
    } else if (tmp == 1) {
      result = -1;
      break;
    } else {
    }
    ++cnt;
  }
  
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

int mod = 1e9+7;
vector<ll> fact;
vector<ll> inv;
vector<ll> finv;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

void init(int n){
  fact = vector<ll>(n,1);
  finv = vector<ll>(n,1);
  inv  = vector<ll>(n,1);
  for(int i=2;i<n;i++){
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod - inv[mod%i]* (mod/i) % mod;
    finv[i] = finv[i-1]*inv[i] %mod;
  }
}

ll COM(int n, int k){
  return (fact[n] * (finv[k] * finv[n-k] %mod ) %mod )%mod;
}


int main(void){
  int N,M,num=0;
  cin >> N >> M;
  vector<P> v;
  int i,m = M;
  ll mul=1;
  for(i=2;i<=(int)sqrt(M);i++){
    if(m==1) break;
    if(m%i==0) v.push_back(P(i,0));
    while(m%i==0){
      v[v.size()-1].second++;
      num++;
      m/=i;
    }
  }
  init(num+N);

  if(m!=1) v.push_back(P(m,1));
  REP(i,v.size()){
    mul *= COM(v[i].second+N-1,v[i].second);
    mul %= mod;
  }
  cout << mul << endl;
  return 0;
}


Measured memory_bytes: 2560
from collections import defaultdict

def possible():
    if N%2==0:
        for cnt in cnt_dict.values():
            if cnt != 2:
                return False
        return True
    else:
        for i, cnt in enumerate(cnt_dict.values()):
            if i==0:
                if cnt != 1:
                    return False
            else:
                if cnt != 2:
                    return False
        return True

N = int(input())
A = list(map(int, input().split()))
num = N//2

cnt_dict = defaultdict(list)

if N%2==0:
    for i in range(1, N, 2):
        cnt_dict[i] = 0
else:
    for i in range(0, N, 2):
        cnt_dict[i] = 0
for a in A:
    if not(a in cnt_dict.keys()):
        flag=False
    else:
        cnt_dict[a]+=1
        flag=True

if __name__ == "__main__":    

    if possible() and flag:
        mod = 10**9+7
        res = 1
        for i in range(1, num+1):
            res = res*2%mod
        print(res)
    else:
        print(0)

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

#define MAX 100
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX], d[MAX], color[MAX];

void shortestPath(int s){
    int u, minv;
    //距離を初期化
    for(int i = 0; i < n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[s] = 0;

    while(1){
        int u = -1;
        int minv = INFTY;
        //最も距離が近いものを更新
        for(int i = 0; i < n; i++){
            if(color[i] != BLACK && d[i] < INFTY){
                if(d[i] < minv){
                    u = i;
                    minv = d[i];
                }
            }
        }

        if(u == -1) break;
        color[u] = BLACK;

        for(int v = 0; v < n; v++){
            d[v] = min(d[v], d[u] + M[u][v]);
        }
    }
}

int main(){
    cin >> n;
    //隣接行列を作製

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = INFTY;
        }
    }

    for(int i = 0; i < n; i++){
        int u, k, v, c;
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    shortestPath(0);

    rep(i,n){
        cout << i << " " << d[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <bits/stdc++.h>
using namespace std;

using namespace std;

int main(){
    int s;cin>>s;
    int a[1000500];
    a[0]=s;
    for(int i=1;i<1000001;i++){
      if(a[i-1]%2==0)a[i]=a[i-1]/2;
        else a[i]=3*a[i-1]+1;
    }
    int k;
     for(int i=1000000-1;i>=0;i--){
       if(a[1000000]==a[i]){k=1000000-i;
       break;}
        }
    for(int i=0;i<1000000;i++){
        if(a[i]==a[i+k]){std::cout << i+k+1 << std::endl;return 0;}
     }
    
}
    

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main(){
	
string X;
char Z=' ';
cin>>X;
for(int i=0;i<X.length();i++){
if(X[i]==',')
X[i]=Z;

}
cout<<X;
	
	
	
	
	
	
	
}



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


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin>>N;
  int x,y;
  bool ans = false;
  for(int i=0;i<30;i++){
    for(int j=0;j<30;j++){
      int Val=4*i+7*j;
      if(Val==N)ans=true;
    }
  }

  if(ans==true){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
//
#include <bits/stdc++.h>
//
using namespace std;
//
#define krep(i,k,n)      for(int i=k;i<n;++i)
#define rep(i,n)         for(int i=0;i<n;++i)
#define toupp(s)         transform(s.begin(),s.end(),s.begin(),::toupper) // string
#define tolow(s)         transform(s.begin(),s.end(),s.begin(),::tolower) // string
#define pb(v)            push_back(v)
#define all(v)           v.begin(),v.end()
#define mp               make_pair
#define __sort(v)        sort(v.begin(),v.end()) // vector
#define __stable_sort(v) stable_sort(v.begin(),v.end()) // vector
#define __exists(c,v)    (find(all(c), (v)) != (c).end()) // vector
#define __unique(v)      __sort(v);v.erase(unique(v.begin(),v.end()),v.end()) // vector
#define __swap(a, b, tmp)  tmp=a;a=b;b=tmp;
#define __memset(a)      memset(a,0,sizeof(a));
//
#define dumpVar(v)       cerr<<setw(30)<<#v" = ["<<v<<"]"<<endl
#define dumpArr(v, n)    for(int i=0;i<n;++i){cerr<<v[i]<<", ";} cerr<<endl
#define dumpPair(p)      cout<<"<"<<p.first<<", "<<p.second<<">"<<endl
//
typedef long long              ll;
typedef vector<string>         vs;
typedef vector<double>         vd;
typedef vector<int>            vi;
typedef pair<int, int>         pii;
typedef pair<double, double>   pdd;
//
int main ()
{
	ios::sync_with_stdio ( false );
	//
	/* code start */
	
	int k,x;
	
	cin >> k >> x;
	dumpVar(k);
	dumpVar(x);
	
	vi arr;
	
	for(int i = - k + 1; i < k; ++i){
		arr.pb(x - i);
		__sort(arr);
	}
	for(int i = 0; i < arr.size(); ++i){
		if(i == 0)cout << arr[i];
		else cout << " " << arr[i];
	}
	
	cout << endl;
	/* code end   */
	//
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

// prime factorization (素因数分解)
// key: value of prime factor
// value: number of prime factor
std::map<ll, ll> prime_factorization(ll n) {
  std::map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

bool is_prime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  map<ll, ll> pf;
  for (int i = 2; i <= n; i++) {
    auto f = prime_factorization(i);
    FORm(it, f) {
      pf[it->first] += it->second;
    }
  }

  ll ans = 0;
  FORm(a, pf) {
    if (a->second < 4) {
      continue;
    }
    for (auto b = next(a); b != pf.end(); b++) {
      if (b->second < 4) {
        continue;
      }
      FORm(c, pf) {
        if (c->second < 2) {
          continue;
        }
        if (b->first == c->first || c->first == a->first) {
          continue;
        }
        ans++;
      }
    }
  }

  vector<P> p;
  p.push_back(make_pair(25ll, 3ll));
  p.push_back(make_pair(15ll, 5ll));

  FORm(it, p) {
    FORm(a, pf) {
      if (a->second < it->first - 1) {
        continue;
      }
      FORm(b, pf) {
        if (b->second < it->second - 1) {
          continue;
        }
        if (a->first == b->first) {
          continue;
        }
        ans++;
      }
    }
  }

  FORm(a, pf) {
    if (a->second >= 75 - 1) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;

    class Program
    {
        static void Main()
        {
            while(true)
            {
                string cards = Console.ReadLine();
                if (cards == "-")
                    break;
                else
                {
                    int m = int.Parse(Console.ReadLine());
                    for(int i =0;i<m;i++)
                    {
                        int h = int.Parse(Console.ReadLine());
                        string left = cards.Substring(0, h);
                        string right = cards.Substring(h);
                        cards = right + left;
                    }
                    Console.WriteLine(cards);
                }
            }
        }
    }

Measured memory_bytes: 8888
#include <bits/stdc++.h>
#define FOR(i, j, n) for (int i = (j); i < (int)(n); i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

struct Point {
  int x, y;
  Point(int _x = 0, int _y = 0) : x(_x), y(_y) {}
  friend istream& operator>>(istream& input, Point& p) {
    return input >> p.x >> p.y, input;
  }
  friend ostream& operator<<(ostream& output, const Point& p) {
    return output << '(' << p.x << ',' << p.y << ')';
  }
};

int m;
vector<Point> ps;
ll ans = 0;

void solve(vector<P> pairs) {
  // for (auto pr : pairs) cerr << '(' << pr.first << ',' << pr.second << ')' << ' ';
  // cerr << endl;
  map<P, ll> mp;
  for (auto pr : pairs) {
    int x = ps[pr.first].x - ps[pr.second].x;
    int y = ps[pr.first].y - ps[pr.second].y;
    int div = __gcd(abs(x), abs(y));
    if (y < 0) x = -x, y = -y;
    if (y == 0) x = abs(x);
    mp[P(x / div, y / div)]++;
    // cerr << '(' << x / div << ',' << y / div << ')' << ' ';
  }
  // cerr << endl;
  ll tmp = 0;
  for (auto v : mp) tmp += v.second * (v.second - 1) / 2;
  ans = max(ans, tmp);
}

void dfs(vector<P> pairs, vector<bool> used, int n) {
  if (n == 0) return solve(pairs);
  P pr;
  REP(i, m) {
    if (used[i]) continue;
    used[i] = true;
    pr.first = i;
    break;
  }
  REP(i, m) {
    if (used[i]) continue;
    used[i] = true;
    pr.second = i;
    pairs.push_back(pr);
    dfs(pairs, used, n - 2);
    used[i] = false;
    pairs.pop_back();
  }
}

int main() {
  cin >> m;
  ps.resize(m);
  REP(i, m) cin >> ps[i];
  vector<P> pairs;
  vector<bool> used(m, false);
  dfs(pairs, used, m);
  cout << ans << endl;
}



Measured memory_bytes: 3096
def find(S,K):
    pattern=[]
    cur=None
    cur_len=0
    for i in range(len(S)):
        if cur==None:
            cur=S[i]
            cur_len+=1
        elif cur==S[i]:
            cur_len+=1
        else:
            cur=S[i]
            pattern+=[cur_len]
            cur_len=1
    pattern+=[cur_len]
    #print(pattern)
    if K>=len(pattern)//2:
        return len(S)-1
    else:
        total=0
        for x in pattern:
            total+=x-1
        total+=2*K
        return total
    
n,K=list(map(int,input().strip().split(" ")))
S=input()
print(find(S,K))

Measured memory_bytes: 3956
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();

    let s: String = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    let mut count = 0;
    for c in s.chars() {
        if c == '1' {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
//#include "pch.h"
#include "stdio.h"
#include "stdlib.h"

int main()
{
	int N, L;
	scanf("%d %d", &N, &L);

	int sum = 0;
	int nmin = L;
	for (int i = L; i < N + L; i++)
	{
		sum += i;
		if (abs(i) < abs(nmin))
			nmin = i;
	}
	sum -= nmin;

	printf("%d", sum);

	return 0;
}

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

using namespace std;
 
 
 
int main(){
//freopen("input.txt","r",stdin);
int n;
string s;

cin>>n>>s;

if(n%2){
	cout<<"No"<<endl;
	return 0;
}

for(int i=0;i<n/2;i++){
	if(s[i]!=s[i+n/2]){
		cout<<"No"<<endl;
		return 0;
	}

}
	cout<<"Yes"<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
   if (A+B > C+D) {
   cout << "Left" << endl;
   }
   else if (A+B < C+D) {
   cout << "Right" << endl;
   }
   else {
   cout << "Balanced" << endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    char c;
    cin >> c;
    vector<char> v = {'a','i','u','e','o'};
    if(find(v.begin(),v.end(),c) != v.end())cout << "vowel\n";
    else cout << "consonant\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10,inf=1e9+10;

int n,m,sign[maxn],val[maxn];
vector<point> G[maxn];
bool mark[maxn];
//[l,r)
int l=1,r=inf;

void esh(int ll,int rr){
    l=max(l,ll);
    r=min(r,rr);
}

void dfs(int a){
    mark[a]=1;
    // x+val>0 -> x>-val
    // -x+val>0 -> x<val
    if(sign[a]==+1){
	esh(-val[a]+1,inf);
    }else{
	esh(0,val[a]);
    }
    for(point p:G[a]){
	int b=p.X,w=p.Y;
	if(!mark[b]){
	    sign[b]=-sign[a];
	    val[b]=w-val[a];
	    dfs(b);
	}else{
	    int sum=w;
	    sum-=val[b]+val[a];
	    if(sign[a]==sign[b]){
		if(sign[a]==-1){
		    sum=-sum;
		}
		if(sum%2==0){
		    sum/=2;
		    esh(sum,sum+1);
		}else{
		    l=r=0;
		}
	    }else if(sum!=0){
		l=r=0;
	    }
	}
    }
}

int32_t main(){
    scanf("%d%d",&n,&m);
    rep(i,0,m){
	int a,b,w;
	scanf("%d%d%d",&a,&b,&w);
	a--,b--;
	G[a].pb({b,w});
	G[b].pb({a,w});
    }
    sign[0]=1;
    dfs(0);
    if(l>=r){
	printf("0\n");
	return 0;
    }
    printf("%d\n",r-l);
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> count(n,0);
    bool flag1=false,flag2=false;
    for(int i=1;i<n;i++){
        count[i]=count[i-1];
        if(s[i-1]=='A'&&s[i]=='C'){
            count[i]++;
        }
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        cout<<count[r-1]-count[l-1]<<endl;

    }
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

double COS60 = cos(M_PI / 3.0), SIN60 = sin(M_PI / 3.0);

void print(double p[2]) {
  printf("%f %f\n", p[0], p[1]);
}

void add(double ret[2], double p1[2], double p2[2]) {
  ret[0] = p1[0] + p2[0];
  ret[1] = p1[1] + p2[1];
}

void subtract(double ret[2], double p1[2], double p2[2]) {
  ret[0] = p1[0] - p2[0];
  ret[1] = p1[1] - p2[1];
}

void multiply(double ret[2], double p[2], double a) {
  ret[0] = p[0] * a;
  ret[1] = p[1] * a;
}

void devide(double ret[2], double p[2], double a) {
  ret[0] = p[0] / a;
  ret[1] = p[1] / a;
}

void rot60(double ret[2], double x[2]) {
  double tmp[2] = {x[0], x[1]};
  ret[0] = COS60 * tmp[0] - SIN60 * tmp[1];
  ret[1] = SIN60 * tmp[0] + COS60 * tmp[1];
}

void koch(int n, double p1[2], double p2[2]) {
  if(n == 0) {
    return;
  }
  double s[2], t[2], u[2];

  // t = ( p2 - p1 ) / 3
  subtract(t, p2, p1);
  devide(t, t, 3.0);

  // calc s
  add(s, t, p1);
  // calc u
  multiply(u, t, 2);
  add(u, u, p1);
  // calc t
  rot60(t, t);
  add(t, t, s);

  n--;
  koch(n, p1, s);
  print(s);
  koch(n, s, t);
  print(t);
  koch(n, t, u);
  print(u);
  koch(n, u, p2);
}

int main(void) {
  int n;
  scanf("%d", &n);

  double p1[2] = {0.0, 0.0};
  double p2[2] = {100.0, 0.0};
  print(p1);
  koch(n, p1, p2);
  print(p2);
  return 0;
}

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

int main() {
  int X,A,B;
  cin >> X >> A >> B;
  if (A >= B){
    cout << "delicious" << endl;
  }else if ( X >= B - A){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n, q, com, x, y;

void main() {
    scan(n, q);

    auto sg = SegTree(n);

    while (q--) {
        scan(com, x, y);

        if (com == 0) {
            sg.update(x, y);
        }
        else {
            int ans = sg.getmin(x, y + 1);
            writeln(ans);
        }
    }
}

struct SegTree {
    private {
        int N = 1;
        int[] data;
        immutable inf = int.max;
    }

    this(int n) {
        while (N < n) N *= 2;
        data = new int[](2*N - 1);
        data[] = inf;
    }

    void update(int i, int x) {
        i += N - 1;
        data[i] = x;

        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = min(data[2*i + 1], data[2*i + 2]);
        }
    }

    int getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = N;
        if (b <= l || r <= a) return inf;
        if (a <= l && r <= b) return data[k];

        int v1 = getmin(a, b, 2*k + 1, l, l + (r - l) / 2);
        int v2 = getmin(a, b, 2*k + 2, l + (r - l) / 2, r);

        return min(v1, v2);
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 4136
#include<stdio.h>
int main(void){
	int a;
	int b;
	int c;
	int x;
	int y;
	int z;
	scanf("%d\n",&x);
	a=x/3600;
	y=x%3600;
	b=y/60;
	c=y%60;
	printf("%d:%d:%d\n",a,b,c);
	return 0;
	}


Measured memory_bytes: 2148
def dp_solve(row, col):
    dp = [[0]*col for _ in range(row)]
    dp[0][0] = 1

    g = [input() for _ in range(row)]

    for i in range(row):
        for j in range(col):
            if dp[i][j] >= 10**9+7:
                dp[i][j] %= 10**9+7
            if j+1 < col and g[i][j+1] == '.':
                dp[i][j+1] += dp[i][j]
            if i+1 < row and g[i+1][j] == '.':
                dp[i+1][j] += dp[i][j]

    return dp[-1][-1]


if __name__ == "__main__":
    row, col = map(int, input().split())
    print(dp_solve(row, col))


Measured memory_bytes: 43636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        var spList = Enumerable.Range(0, N)
            .Select(n => Console.ReadLine().Split(' '))            
            .Select((arr, idx) => new { I = idx + 1, S = arr[0], P = int.Parse(arr[1]) })
            .ToList();

        var ans = spList.OrderBy(sp => sp.S).ThenByDescending(sp => sp.P);
        

        foreach(var x in ans)
        {
            Console.WriteLine(x.I);
        }

    }
}


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

int main() {
    ll a,b;
    std::cin >> a>>b;
    
    if(a<b){
        for (int i = 0; i < b; i++) {
            std::cout << a;
        }
    }else{
        for (int i = 0; i < a; i++) {
            std::cout << b;
        }
    }
    std::cout << std::endl;
}

Measured memory_bytes: 256
import math
 
A, B, C, D = list(map(int,input().split()))
 
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)
 
def lcm_(x,y):
    return (x * y) // gcd_(x, y)
 
def f(x):
    if A % x:
        a = A + (x - A % x)
    else:
        a = A
    if B - a >= 0:
        temp = (B - a + 1) // x
        if (B - a + 1) % x:
            return temp + 1
        return temp
    else:
        return 0
    
ans = (B - A + 1) - f(C) - f(D) + f(lcm_(C, D))
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <numeric>
#include <ctime>
using namespace std;


//global var
string card[4][13];
char trump, T;
string ans_team;
int ans_score;
map<char, int> h;

//function
struct State{
	int n, id;
	char m;

	State(){};
	State(int n_, int id_, char m_){
		n = n_;
		id = id_;
		m = m_;
	};
};

bool operator < (const State &a, const State &b){
	if(a.m == trump){
		if(b.m == trump){
			return (a.n < b.n);
		}else{
			return false;
		}
	}else{
	
		if(b.m == trump){
			return true;
		}else{
	 		if(a.n == b.n){
	 			return (a.id > b.id);
	 		}
	 		
			return a.n < b.n;
	 	}
	 		
	}
}

//card state
State get_state(string c, int p, int start){
	int n = h[c[0]], id;
	char m = c[1];
	
	for(int i = 0, k = start; i < 4; i++, (k = (k + 1) % 4)){
		if(k == p){
			id = i;
			break;
		}
	}

	return State(n, id, m);
}

//solution func
void solve(){
	int start = 0;
	int NS = 0, EW = 0;
	
	for(int j = 0; j < 13; j++){
		int win;
		State win_s;
		
		bool flag = false;
		for(int i = 0; i < 4; i++){
			State s = get_state(card[i][j], i, start);
			
			if(s.m == T){
				flag = true;
				
				break;
			}
		}
		if(flag){
			trump = T;
		}else{
			State s = get_state(card[start][j], start, start);
			trump = s.m;
		}
		
		for(int i = 0; i < 4; i++){
			State s = get_state(card[i][j], i, start);
			
			if(i == 0){
				win = 0;
				win_s = s;
			}else if(win_s < s){
				win = i;
				win_s = s;
			}
		}
		/*
		// debug
		cout << j << " ";
		if(win == 0){
			cout << "N";
		}
		if(win == 1){
			cout << "E";
		}
		if(win == 2){
			cout << "S";
		}
		if(win == 3){
			cout << "W";
		}
		cout << " " << trump << endl;
		//
		*/
		
		if(win == 0 || win == 2){
			NS++;
		}
		else{
			EW++;
		}
		start = win;
	}
	
	if(EW < NS){
		ans_team = "NS";
		ans_score = NS - 6;
	}else{
		ans_team = "EW";
		ans_score = EW - 6;
	}
}

int main(){
	h['T'] = 10;
	h['J'] = 11;
	h['Q'] = 12;
	h['K'] = 13;
	h['A'] = 14;
	for(char c = '2'; c <= '9'; c++){
		h[c] = c - '0';
	}
	
	while(cin >> T){
		if(T == '#'){
			break;
		}
	
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				cin >> card[i][j];
			}	
		}
		
		solve();
	
		cout << ans_team << " " << ans_score << endl;
	}
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

string solve(string SS, string T) {
  string ret = "";
  REP(i, SS.length() - T.length() + 1) {
    bool ok = true;
    REP(j, T.length()) {
      if(SS[i + j] != '?' && SS[i + j] != T[j]) ok = false;
    }
    if(ok) {
      string tmp = SS;
      REP(j, T.length()) tmp[i + j] = T[j];
      REP(j, SS.length()) if(tmp[j] == '?') tmp[j] = 'a';
      if(ret == "" || tmp < ret) ret = tmp;
    }
  }
  if(ret != "") return ret;
  else return "UNRESTORABLE";
}

int main(){
  string SS, T;
  cin >> SS >> T;

  cout << solve(SS, T) << endl;
  return 0;
}



Measured memory_bytes: 256
S = str(input())
N = len(S)
cube = list(S)
ary = []

for s in cube:
    if len(ary) == 0:
        ary.append(s)
        continue
    if ary[-1] == s:
        ary.append(s)
    else:
        ary.pop()
print(len(cube) - len(ary))

Measured memory_bytes: 4724
N,M = map(int,input().split())
S = input()
T = input()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

L = N*M // gcd(N,M)

n = L // N
m = L // M

list_n = [i for i in range(0,L,n)]
list_m = [i for i in range(0,L,m)]

list_common = sorted(list(set(list_n) & set(list_m)))

for i in list_common:
    if i == 0:
        if S[0] != T[0]:
            print('-1')
            exit()
    elif S[i//n] != T[i//m]:
        print('-1')
        exit()

print(L)

Measured memory_bytes: 18672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    ll k;cin>>k;
    ll d[k];
    bool b[10];fill(b,b+10,true);
    rep(i,0,k-1){
        cin>>d[i];
        b[d[i]]=false;
    }
    ll ans=n;
    string s;
    string t;
    bool bol;
    while(true){
        s=to_string(ans);
        bol=true;
        rep(i,0,s.size()-1){
            t=s[i];
            if(!b[stoll(t)]){
                ans++;
                bol=false;
                break;
            }
        }
        if(bol)break;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  string s; cin >> s;
  int n = s.size();
  if ((s[0] == s[n-1] &&  n%2 != 0)
      || (s[0] != s[n-1] && n%2 == 0)) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
w, h, x, y = gets.chomp.split(" ").map(&:to_i)

ww = w / 2.to_f
menseki = ww * h
if w == x * 2 && h == y * 2
    print menseki
    print " "
    print "1"
else
    print menseki
    print " "
    print "0"
end


Measured memory_bytes: 14240
n ,m = map(int,input().split())
ll = 1
rr = n
for i in range(m):
    l,r = map(int, input().split())
    if l > ll:
        ll = l
    if r < rr:
        rr = r
ans = rr - ll +1
if ans > 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,c;
  while(cin>>n>>c,n||c){
    int s[n+2][n+2],i,j,k,l,x,y,z,tmp,ans=-n*n;
    bool u[n+2][n+2],f,d;
    int ax[]={-1,-1,0,0,1,1};
    int ay[]={-1,0,-1,1,0,1};
    memset(s,-1,sizeof(s));
    for(i=1;i<=n;i++)
      for(j=1;j<=i;j++)
	cin>>s[i][j];
    for(i=1;i<=n;i++){
      for(j=1;j<=i;j++){
	if(s[i][j]) continue;
	s[i][j]=c;
	memset(u,0,sizeof(u));
	tmp=0;
	for(k=1;k<=n;k++){
	  for(l=1;l<=k;l++){
	    if(!s[k][l]||u[k][l]) continue;
	    f=1;z=0;
	    queue<P> q;
	    q.push(P(k,l));
	    while(!q.empty()){
	      x=q.front().first;y=q.front().second;q.pop();
	      if(u[x][y]) continue;
	      if(!s[x][y]) {
		f=0;
		continue;
	      }
	      u[x][y]=1;z++;
	      for(int a=0;a<6;a++){
		if(s[k][l]==s[x+ax[a]][y+ay[a]]||!s[x+ax[a]][y+ay[a]])
		  q.push(P(x+ax[a],y+ay[a]));
	      }
	    }
	    //cout << i << j << "/" << s[k][l] << ":" << z << "f" << f << endl;
	    tmp+=z*f*(s[k][l]==c?-1:1);
	  }
	}
	ans=max(ans,tmp);
	s[i][j]=0;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3044
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();

        int ans = 0;
        X -= Z;
        while (X - (Y + Z) >= 0) {
            X -= Y + Z;
            ans++;
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 22996
N,A,B,C = map(int,input().split())
S = [input() for i in range(N)]

ans = []
for i,s in enumerate(S):
    if s=='AB':
        if A==0 and B==0:
            print('No')
            exit()
        if A==0:
            ans.append('A')
            A += 1
            B -= 1
        elif B==0:
            ans.append('B')
            B += 1
            A -= 1
        else:
            if A==B==1 and i+1 < N:
                if 'A' in S[i+1]:
                    ans.append('A')
                    A += 1
                    B -= 1
                else:
                    ans.append('B')
                    B += 1
                    A -= 1
            elif A>B:
                ans.append('B')
                B += 1
                A -= 1
            else:
                ans.append('A')
                A += 1
                B -= 1
    elif s=='AC':
        if A==0 and C==0:
            print('No')
            exit()
        if A==0:
            ans.append('A')
            A += 1
            C -= 1
        elif C==0:
            ans.append('C')
            C += 1
            A -= 1
        else:
            if A==C==1 and i+1 < N:
                if 'A' in S[i+1]:
                    ans.append('A')
                    A += 1
                    C -= 1
                else:
                    ans.append('C')
                    C += 1
                    A -= 1
            elif A>C:
                ans.append('C')
                C += 1
                A -= 1
            else:
                ans.append('A')
                A += 1
                C -= 1
    else:
        if C==0 and B==0:
            print('No')
            exit()
        if C==0:
            ans.append('C')
            C += 1
            B -= 1
        elif B==0:
            ans.append('B')
            B += 1
            C -= 1
        else:
            if C==B==1 and i+1 < N:
                if 'C' in S[i+1]:
                    ans.append('C')
                    C += 1
                    B -= 1
                else:
                    ans.append('B')
                    B += 1
                    C -= 1
            elif C>B:
                ans.append('B')
                B += 1
                C -= 1
            else:
                ans.append('C')
                C += 1
                B -= 1
print('Yes')
print(*ans, sep='\n')

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


int main() {
  int A, B;
  cin >> A >> B;
  int cur = A;
  int cnt = 1;
  if (B == 1) {
    cnt = 0;
  } else {
    while (cur < B) {
      cur += A - 1;
      ++cnt;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
sa = B-A
if A%2 == 0:
    if sa%4 == 0:
        ans = B
    elif sa%4 == 1:
        ans = 1
    elif sa%4 == 2:
        ans = B^1
    else:
        ans = 0
        
else:
    if sa%4 == 0:
        ans = A
    elif sa%4 == 1:
        ans = A^B
    elif sa%4 == 2:
        ans = A^1
    elif sa%4 == 3:
        ans = A^(B+1)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
  int n;
  int x;
  int l[100];
  int i;
  int a=1;
  int sum=0;
  
  scanf("%d %d",&n,&x);
  for(i=0;i<n;i++)
  {
    scanf("%d",&l[i]);
  }
  for(i=0;i<n;i++)
  {
    sum += l[i];
    if(sum<=x)
      a++;
    else
      break;
  }
  printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0000&lang=jp

#include <iostream>
using namespace std;

int main() {
  for (auto i=1; i<=9; i++) {
    for (auto j=1; j<=9; j++) {
      cout << i << "x" << j << "=" << i*j << endl;
    }
  }
}

Measured memory_bytes: 1108
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,x,i,satis=0,bo=0;
    cin>>n;
    ll a[n],b[n],c[n]= {0};
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        a[i]--;
    }
    for(i=0; i<n; i++)
        cin>>b[i];
    for(i=0; i<n-1; i++)
        cin>>c[i];
    for(i=0; i<n; i++)
    {
        satis+=b[i];
    }
    for(i=0; i<n; i++)
    {
        if(i>0&&a[i]==a[i-1]+1)
            satis+=c[a[i-1]];
    }
    cout<<satis<<endl;



    return 0;
}





Measured memory_bytes: 3600
int w,h,X,Y,C,t,b,d[9][9],q[9][9],a[]={-1,0,1,0};

int z(int x,int y){
	int i=0,s=1;
	if(q[y][x])return 0;
	q[y][x]=1;
	if(d[y][x])return y==Y&&x==X;
	for(;i<4;i++)s+=z(x+a[i],y+a[(i+1)%4]);
	return s;
}
int dfs(int x,int y,int c){
	int i=0;
	if(!c&&x==X&&y==Y)return 1;
	memset(q,0,324);
	if(d[y][x]||z(x,y) != c+(x!=X||y!=Y))return 0;
	if(b++ > 120000)return 2;
	for(d[y][x]=1;i<4;i++)if(t=dfs(x+a[i],y+a[(i+1)%4],c-1))return t;
	return d[y][x]=0;
}
int main(i,j){
	for(;C=b=j=0,memset(d,-1,324),scanf("%d%d\n",&w,&h),h;puts(C<4||dfs(X,Y,C)-1?"No":"Yes"))
		for(;j++<h;)for(i=0;i++<w;)scanf("%d",&t),(d[j][i]=t)||(++C,X=i,Y=j);
	exit(0);
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

int main(void)
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
    if(y == 0) {
        return x;
    }
    else {
        return gcd(y, x%y);
    }
}

ll lcm(ll x, ll y) {
    ll g = gcd(x, y);
    return x / g * y;
}

int main() {
    int N;
    cin >> N;
    ll ans = 1LL;

    rep(i, N) {
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }

    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256