akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define DIV_INIT 0
#define LOOP_INIT 0
#define INTERVAL_ARRAY_MAX 12
#define FIRST_ITEM 0
#define ONE 1
#define EXIT_SUCCESS 0
#define PREV_ITEM( x ) x - 1
#define THREE_TIMES( x ) x * 3
#define HALF( x ) x / 2

int main( void )
{
	unsigned long ulW_Dtc_cnt;
	int *aulW_Dtestcase;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Cloop_sub_cnt;
	unsigned long ulW_Csort_cnt = DIV_INIT;
	unsigned long ulW_Dinterval_num = ONE;//?????????????????????????????°
	unsigned long ulW_Dinterval_array[ INTERVAL_ARRAY_MAX ];//?????????????????????
	unsigned long ulW_Dshell_div;
	signed long slW_Dsort_div;
	unsigned long ulW_Dcalc;

	scanf( "%d", &ulW_Dtc_cnt );
	aulW_Dtestcase = malloc ( sizeof( int ) * ulW_Dtc_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		scanf( "%d", &aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	ulW_Dinterval_array[ FIRST_ITEM ] = ONE;
	ulW_Dcalc = THREE_TIMES( ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) ] ) + ONE;
	while( ulW_Dcalc < ulW_Dtc_cnt ){
		ulW_Dinterval_array[ ulW_Dinterval_num ] = THREE_TIMES( ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) ] ) + ONE;
		ulW_Dinterval_num++;
		ulW_Dcalc = THREE_TIMES( ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) ] ) + ONE;
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < HALF( ulW_Dinterval_num ); ulW_Cloop_cnt++ ){
		ulW_Dshell_div = ulW_Dinterval_array[ ulW_Cloop_cnt ];
		ulW_Dinterval_array[ ulW_Cloop_cnt ] = ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) - ulW_Cloop_cnt ];
		ulW_Dinterval_array[ PREV_ITEM( ulW_Dinterval_num ) - ulW_Cloop_cnt ] = ulW_Dshell_div;
	}

	printf( "%d\n", ulW_Dinterval_num );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dinterval_num; ulW_Cloop_cnt++ ){
		if( ulW_Cloop_cnt == PREV_ITEM( ulW_Dinterval_num ) ){
			printf( "%d\n", ulW_Dinterval_array[ ulW_Cloop_cnt ] );
		}
		else{
			printf( "%d ", ulW_Dinterval_array[ ulW_Cloop_cnt ] );
		}
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dinterval_num; ulW_Cloop_cnt++){
		for( ulW_Cloop_sub_cnt = ulW_Dinterval_array[ ulW_Cloop_cnt ]; ulW_Cloop_sub_cnt < ulW_Dtc_cnt; ulW_Cloop_sub_cnt++ ){
			ulW_Dshell_div = aulW_Dtestcase[ ulW_Cloop_sub_cnt ];
			slW_Dsort_div = ulW_Cloop_sub_cnt - ulW_Dinterval_array[ ulW_Cloop_cnt ];
			while( ( slW_Dsort_div >= FIRST_ITEM ) && ( aulW_Dtestcase[ slW_Dsort_div ] > ulW_Dshell_div ) ){
				aulW_Dtestcase[ slW_Dsort_div + ulW_Dinterval_array[ ulW_Cloop_cnt ] ] = aulW_Dtestcase[ slW_Dsort_div ];
				slW_Dsort_div -= ulW_Dinterval_array[ ulW_Cloop_cnt ];
				ulW_Csort_cnt++;
			}
			aulW_Dtestcase[ slW_Dsort_div + ulW_Dinterval_array[ ulW_Cloop_cnt ] ] = ulW_Dshell_div;
		}
	}

	printf( "%d\n", ulW_Csort_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		printf( "%d\n", aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	return EXIT_SUCCESS;
}

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

using namespace std;
#define ll long long
#define ld long double

ll binPow(ll a, ll b) {
    ll ans = 1;
    while(b > 0) {
        if(b & 1) ans *= a;
        a *= a;
        b >>= 1;
    }
    return ans;
}

ll binPowMod(ll a, ll b, ll m) {
    ll ans = 1;
    a %= m;
    while(b > 0) {
        if(b & 1) ans *= a % m;
        a *= a % m;
        b >>= 1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int h, n;
    cin >> h >> n;
    int sum = 0;
    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        sum += x;
    }
    cout << ((sum >= h) ? "Yes\n" : "No\n");
    return 0;
}


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 1001 * 1001  , MOD = 1e9 + 7 , sq = 333  ;


set < pair < int , pair < int , int > > > s ;

int par[MAXN] , sz[MAXN] ;

int root(int x)
{
    return (par[x]==-1?x:par[x]=root(par[x])) ;
}

int mrg(int x , int y)
{
    x = root(x) , y = root(y);
    if(x==y)
        return 0;
    if(sz[y]>sz[x])
        swap(x,y);
    par[y] = x ;
    sz[x] += sz[y] ;
    return 1;
}

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   memset(par,-1,sizeof par) ;
    memset(sz,1,sizeof sz) ;
   int n , m ;
   cin >> n >> m ;
   for(int i = 0; i < m ; i ++ )
   {
       int x ,y , z ;
       cin >> x >> y >> z ;
       s.insert({z,{x,y}});
       z++;
       x = (x+1) % n ;
       s.insert({z,{x,y}});
   }
   int mol = n , ans = 0 ;
   while(mol>1)
   {
       int z = s.begin()->F , x = s.begin()->S.F , y = s.begin()->S.S;
        s.erase(s.begin());
       if(!mrg(x,y)){
         continue ;

       }
    //    cout<<x<<' '<<y<<' '<<z<<' '<<mol<<endl;
       ans += z ;
       z+=2;
       x = (x+1) % n ;
       y = (y+1)%n;
       s.insert({z,{x,y}});
       mol--;
   }
   cout<<ans;

}


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

int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    if((a*b*c) % 2 == 0){
        cout << 0;
    } else {
        cout << min(a*b,min(a*c,b*c));
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[][] array=new int[4][13];
		for(int i=1; i<=n; i++){
			String s=sc.next();
			int a=sc.nextInt();
			if(s.equals("S")){
				array[0][a-1]=1;
			}else if(s.equals("H")){
				array[1][a-1]=1;
			}else if(s.equals("C")){
				array[2][a-1]=1;
			}else if(s.equals("D")){
				array[3][a-1]=1;
			}
		}
		for(int i=0; i<array.length; i++){
			for(int j=0; j<array[0].length; j++){
				if(array[i][j]==0 && i==0){
					System.out.println("S "+(j+1));
				}else if(array[i][j]==0 && i==1){
					System.out.println("H "+(j+1));
				}else if(array[i][j]==0 && i==2){
					System.out.println("C "+(j+1));
				}else if(array[i][j]==0 && i==3){
					System.out.println("D "+(j+1));
				}
			}
		}

	}




}


Measured memory_bytes: 26248
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for c := 1; c <= 3; c++ {
		if (a*b*c)%2 == 1 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 1768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

char firld[8][8];

int main(){
  int k; cin >> k;
  vector<pii> x(k);
  rep(i,k) cin >> x[i].first >> x[i].second;
  vector<int> v={0,1,2,3,4,5,6,7};
  //vector<int> v={6,0,2,7,5,3,1,4};
  do{
    bool f=1;
    rep(i,k){
      if(v[x[i].first]!=x[i].second) f=0;
    }
    vector<pii> queen(8);
    rep(i,8){
      queen[i]=pii(i,v[i]);
    }
    rep(i,8){
      for(int j=i+1;j<8;j++){
        double dy=queen[i].second-queen[j].second;
        double dx=queen[i].first-queen[j].first;
        if(abs(dy/dx)==1) f=0;
      }
    }
    if(f){
      rep(i,8)rep(j,8) firld[i][j]='.';
      rep(i,8){
        firld[queen[i].first][queen[i].second]='Q';
      }
      rep(i,8){
        rep(j,8){
          cout << firld[i][j];
        }cout << endl;
      }
      //return 0;
    }
  }while(next_permutation(all(v)));
  
}


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

int N;
int M;
vector<int> c(9);

int digit_num(int n, int m) {
    for (int i = 0; i < m - 1; i++) {
        n /= 10;
    }
    return n % 10;
}

int make_num(int n) {
    if (n == 0 || n == 1) {
        return 0;
    }
    else if (n == 2) {
        return 10;
    }
    else return 100;
}

int main() {
    cin >> N >> M;

    vector<int> s(M);

    for (int i = 0; i < M; i++) {
        cin >> s.at(i) >> c.at(i);
    }

    int ans = make_num(N);

    int cnt = 0;

    while (digit_num(ans, N + 1) == 0) {
        for (int i = 0; i < M; i++) {
            if (digit_num(ans, N - s.at(i) + 1) == c.at(i)) {
                cnt++;
            }
        }
        if (cnt == M) {
            cout << ans << endl;
            return 0;
        }
        cnt = 0;
        ans++;
    }

    cout << -1 << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	@SuppressWarnings("unchecked")
	static void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		int h = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		ArrayList<Integer>[] x_ord = new ArrayList[w];
		ArrayList<Integer>[] y_ord = new ArrayList[h];
		for (int i = 0; i < w; i++)
			x_ord[i] = new ArrayList<>();
		for (int i = 0; i < h; i++)
			y_ord[i] = new ArrayList<>();
		int x0 = 0, xw = 0, y0 = 0, yh = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt() - 1;
			y[i] = sc.nextInt() - 1;
			if (x[i] == 0 && x0 == 0)
				x0++;
			else if (x[i] == w - 1 && xw == 0)
				xw++;
			if (y[i] == 0 && y0 == 0)
				y0++;
			else if (y[i] == h - 1 && yh == 0)
				yh++;
			x_ord[x[i]].add(i);
			y_ord[y[i]].add(i);
		}
		int d = Math.max(Math.max(x0, xw), Math.max(y0, yh));

		DJSet ds = new DJSet(n);
		for (int i = 0; i < w; i++) {
			while (!x_ord[i].isEmpty()) {
				for (int j = 0; j < x_ord[i].size(); j++) {
					ds.setUnion(x_ord[i].get(0), x_ord[i].get(j));
				}
				x_ord[i].clear();
			}
		}
		for (int i = 0; i < h; i++) {
			while (!y_ord[i].isEmpty()) {
				for (int j = 0; j < y_ord[i].size(); j++) {
					ds.setUnion(y_ord[i].get(0), y_ord[i].get(j));
				}
				y_ord[i].clear();
			}
		}
		int sum = n - ds.count();
		if (ds.count() == 1) {
			System.out.println(sum);
		} else {
			sum +=2 * ds.count() - 1 - d;
			System.out.println(sum);
		}

	}

	public static class DJSet {
		int n;// the number of vertices
		int[] d;

		DJSet(int n) {
			this.n = n;
			d = new int[n];
			Arrays.fill(d, -1);
		}

		int root(int x) {
			return d[x] < 0 ? x : root(d[x]);
		}

		boolean setUnion(int x, int y) {
			x = root(x);
			y = root(y);
			if (x != y) {
				if (x < y) {
					int d = x;
					x = y;
					y = d;
				}
				// x>y
				d[y] += d[x];
				d[x] = y;
			}
			return x != y;
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		// the number of nodes of which graph contains x
		int size(int x) {
			return d[root(x)] * (-1);
		}

		// the number of connected graphs
		int count() {
			int ct = 0;
			for (int u : d) {
				if (u < 0)
					ct++;
			}
			return ct;
		}
	}
}

Measured memory_bytes: 85296
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
  
    int[][] num = new int[10][10]; // [横][縦]  
    void run(){
	while(sc.hasNext()){
	    String a = sc.next();
	    for(int i=0; i<a.length(); i++){
		String b = a.substring(i, i+1);
		num[0][i] = Integer.parseInt(b);
		//System.out.print(num[0][i]+" ");
	    }
	    //System.out.println();
	    solve();
	}
    }

    void solve(){
	for(int i=1; i<10; i++){ // i=縦
	    for(int j=0; j<10-i; j++){ // j=横
		num[i][j] = (num[i-1][j]+num[i-1][j+1])%10;
		//System.out.print(num[i][j]+" ");
	    }
	    //System.out.println();
	}
	System.out.println(num[9][0]);
    }
}

Measured memory_bytes: 17144
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll r, d, x; cin >> r >> d >> x;

    rep(i,10){
        ll nx = r*x-d;
        dunk(nx);
        x = nx;
    }

}

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

int main() {
  int A, B;
  cin >> A >> B;
  for(int i=0; i<=1250; i++) {
    if(int(i*0.08) == A && int(i*0.1) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

typedef long long ll;

int main(){

    ll n;
    cin >> n;

    vector<long long> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    long long sum;
    unsigned long long ans = 100000000000000000;
    unsigned long long ans_temp;


    // minus first
    sum = 0;
    ans_temp = 0;
    for(int i = 0; i < n; i++){
        sum += v[i];
        if(i % 2 == 1){
            if(sum <= 0){
                ans_temp += 1 - sum;
                sum = 1;
            }
        }
        else{
            if(sum >= 0){
                ans_temp += 1 + sum;
                sum = -1;
            }
        }
    }
    ans = min(ans, ans_temp);

    // plus first
    sum = 0;
    ans_temp = 0;
    for(int i = 0; i < n; i++){
        sum += v[i];
        if(i % 2 == 0){
            if(sum <= 0){
                ans_temp += 1 - sum;
                sum = 1;
            }
        }
        else{
            if(sum >= 0){
                ans_temp += 1 + sum;
                sum = -1;
            }
        }
    }
    ans = min(ans, ans_temp);



    cout << ans << endl;



}

Measured memory_bytes: 1024
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(i,j,k)
            
print(ans)


Measured memory_bytes: 74872
#include<bits/stdc++.h>
#define endl '\n'
#define INF INT_MAX
#define LINF LLONG_MAX
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  int a, b;
  vector<int>st;
  int gl[200001] = {};
  bool jud = false;
  cin >> n >> m;

  for(int i = 0;i < m;i++){
    cin >> a >> b;

    if(a == 1){
      st.push_back(b);
    }else if(a == n){
      gl[b] = 1;
    }
    
    if(b == 1){
      st.push_back(a);
    }else if(b == n){
      gl[a] = 1;
    }
  }

  for(int i = 0;i < st.size() && !jud;i++){
    if(gl[st[i]] == 1){
      jud = true;
    }
  }

  if(jud) cout << "POSSIBLE" << endl;
  else    cout << "IMPOSSIBLE" << endl;
  return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

#define INF 1000000000000000000
#define MOD 1000000007

int main(){
  LL n,x,y;
  cin >> n >> x >> y;
  LL mincw=INF;
  vector<LL> minw(n,INF);
  vector<list<LL>> ba(n,list<LL>());
  LL c,w;
  int second=INF;
  int mincount=1,mincid=0;
  for(int i=0;i<n;i++){
    cin >> c >> w;
    c--;
    if(mincw>w){
      second=mincw;
      mincw=w;
      mincount=1;
      mincid=c;
    }else if(mincw==w){
      mincount++;
    }
    minw[c]=min(minw[c],w);
    ba[c].push_back(w);
  }
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  list<LL> kosu;
  LL count;
  LL total=0;
  for(int i=0;i<n;i++){
    count=0;
    if(i!=mincid){
      if(minw[i]!=INF&&minw[i]+mincw<=y){
        for(auto itr=ba[i].begin();itr!=ba[i].end();itr++){
            if(minw[i]+(*itr)<=x||mincw+(*itr)<=y) count++;
        }
        kosu.push_back(count);
        total+=count;
      }
    }else{
      if(mincount>1){
        if(minw[i]!=INF&&minw[i]+mincw<=y){
          for(auto itr=ba[i].begin();itr!=ba[i].end();itr++){
              if(minw[i]+(*itr)<=x||mincw+(*itr)<=y) count++;
          }
          kosu.push_back(count);
          total+=count;
        }
      }else{
        for(auto itr=ba[i].begin();itr!=ba[i].end();itr++){
            if(second+(*itr)<=y||minw[i]+(*itr)<=x) count++;
        }
        kosu.push_back(count);
        total+=count;
      }
    }
  }
  vector<LL> f(n+1),rf(n+1,1);
  f[0]=1;
  for(int i=1;i<=n;i++){
    f[i]=i*f[i-1]%MOD;
  }
  LL now,k;
  for(int i=1;i<=n;i++){
    now=f[i];
    k=MOD-2;
    while(k){
      if(k&1) rf[i]=(rf[i]*now)%MOD;
      now=(now*now)%MOD;
      k/=2;
    }
  }
  LL ans=1;
  for(auto itr=kosu.begin();itr!=kosu.end();itr++){
    // cout << (*itr) << endl;
    ans=ans*f[total]%MOD*rf[total-(*itr)]%MOD*rf[*itr]%MOD;
    total-=(*itr);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 200005
#define inf 2e9
#define nitro ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
bool flag = true ;
int main()
{
    nitro ;
    int a[4][4] , vis[4][4]={0} ;
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++)
            cin>>a[i][j];
    }
    int n;
    cin>>n;
    vector<int >b;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        b.pb(x);
    }
    sort(b.begin(),b.end()) ;
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            if( find(b.begin(),b.end(),a[i][j]) != b.end()){
                vis[i][j] = 1;
            }
        }
    }
    bool f1 = false ;
    for(int i=1;i<=3;i++){
        int sum = 0;
        for(int j = 1;j<=3;j++){
            sum += vis[i][j];
        }
        if(sum == 3){
            f1 = true ;
            break;
        }
    }
    if(f1 == true){
        cout<<"Yes"<<endl;
        return 0;
    }

    f1 =false ;
    for(int i=1;i<=3;i++){
        int sum = 0;
        for(int j = 1;j<=3;j++){
            sum += vis[j][i];
        }
        if(sum == 3){
            f1 = true ;
            break;
        }
    }
    if(f1 == true){
        cout<<"Yes"<<endl;
        return 0;
    }
    f1 = false ;
    int sum = 0;
    for(int i=1;i<=3;i++){
      for(int j=1;j<=3;j++){
         if(i == j){
            sum += vis[i][j];
         }
      }
      if(sum == 3){
        f1 = true ;
        break;
      }
    }
    if(f1 == true){
        cout<<"Yes"<<endl;
        return 0;
    }
    f1 = false ;
    sum = 0;
    for(int i=1;i<=3;i++){
      for(int j=1;j<=3;j++){
         if(i+j == 4) {
            sum += vis[i][j];
         }
      }
      if(sum == 3){
        f1 = true ;
        break;
      }
    }
    if(f1 == true){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;
size_t i = 0;
int32_t func();
int32_t getvalue()
{
	bool minus = false;
	if (S[i] == '-') {
		minus = true;
		++i;
	}
	int32_t nowv = 0;
	if (S[i] == '(') {
		++i;
		nowv = func();
	}
	else {
		while ('0' <= S[i] && S[i] <= '9') { nowv *= 10; nowv += S[i] - '0'; ++i; }
	}
	return nowv*(minus?-1:1);
}
int32_t func()
{
	int32_t tmpv = 0;
	int32_t tmpmulv = getvalue();
	while (S[i] != ')')
	{
		char ope = S[i];
		++i;
		int32_t nowv = getvalue();
		if (ope == '+') {
			tmpv += tmpmulv;
			tmpmulv = nowv;
		}
		else if (ope == '-') {
			tmpv += tmpmulv;
			tmpmulv = -nowv;
		}
		else if (ope == '*') {
			tmpmulv *= nowv;
		}
		else if (ope == '/') {
			tmpmulv /= nowv;
		}
	}
	++i;
	tmpv += tmpmulv;
	tmpmulv = 1;
	return tmpv;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	int32_t Q;
	in >> Q;
	while (Q--)
	{
		in >> S;
		S.pop_back();
		S.push_back(')');
		i = 0;
		out << func() << endl;
	}

	return 0;
}
#endif



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MOD = 1e9+7;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if(n==0) return 1;
  mint x = f(n/2);
  x *= x;
  if(n%2==1) x *=2;
  return x;
}
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x/y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);//使うか使わないか2択
  ans -= 1;//全て使わない時を除く
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}

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

int main(void) {
	int m, n, a[50], b[50], ans[50] = {};

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		ans[a[i] - 1]++;
		ans[b[i] - 1]++;
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  map<string, int> amap;
  string S;
  for(int i=0;i<N;++i){
    cin>>S;
    amap[S]++;
  }
  cout<<"AC x "<<amap["AC"]<<endl;
  cout<<"WA x "<<amap["WA"]<<endl;
  cout<<"TLE x "<<amap["TLE"]<<endl;
  cout<<"RE x "<<amap["RE"]<<endl;
}



Measured memory_bytes: 3632
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split())))
answer = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        r = bisect_left(l, lij)
        answer += max(0, r - j - 1)
        
print(answer)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x,y;
    cin>>x>>y;
    puts((2*x<=y) and (y<=4*x) and y%2==0?"Yes":"No");
}

Measured memory_bytes: 3652
//
// Created by Huang,Zhiqiang on 2018/6/24.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

int n, m;
int c[705];
int v[705];

int dfs(vector<vector<int>>& tree, int node, int& s, int& t) {
    v[node] = 1;
    vector<int>& ne = tree[node];
    vector<int>::iterator iter = ne.begin();
    while (iter != ne.end()) {
        if (v[*iter]) {
            if (c[*iter] == c[node]) return -1;
            iter++;
        } else {
            c[*iter] = 1 - c[node];
            if (c[*iter] == 0) s++;
            else t++;
            if (dfs(tree, *iter, s, t) == -1) return -1;
        }
    }
    return 0;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < 705; i++) {
        c[i] = -1;
        v[i] = 0;
    }
    vector<vector<int>> tree(n + 1, vector<int>());
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    vector<vector<int>> com_tree(n + 1, vector<int>());
    for (int i = 1; i <= n; i++) {
        vector<int>& ne = tree[i];
        for (int j = 1; j <= n; j++) {
            if (j != i && find(ne.begin(), ne.end(), j) == ne.end()) {
                com_tree[i].push_back(j);
            }
        }
    }
    vector<int> nums;
    for (int i = 1; i <= n; i++) {
        if (!v[i]) {
            int s = 0, t = 0;
            c[i] = 0;
            s++;
            int ans = dfs(com_tree, i, s, t);
            if (ans == -1) {
                cout << -1 << endl;
                return 0;
            }
            nums.push_back(s - t);
        }
    }
    int size = nums.size();
    vector<set<int>> dp(size, set<int>());
    dp[0].insert(nums[0]); dp[0].insert(-nums[0]);
    for (int i = 1; i < size; i++) {
        set<int>& ts = dp[i - 1];
        if (ts.size() == 0) {
            dp[i].insert(nums[i]);
            dp[i].insert(-nums[i]);
        } else {
            set<int>::iterator iter = ts.begin();
            while (iter != ts.end()) {
                int first = (*iter) + nums[i];
                int second = (*iter) - nums[i];
                dp[i].insert(first);
                dp[i].insert(second);
                iter++;
            }
        }
    }
    vector<int> ts(dp[size - 1].begin(), dp[size - 1].end());
    int abs_x = abs(ts[0]);
    for (int i = 0; i < ts.size(); i++) {
        if (abs(ts[i]) < abs_x) abs_x = abs(ts[i]);
    }
    int a = (n + abs_x) / 2;
    int b = n - a;
    int ans = a * (a - 1) / 2 + b * (b - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
vector<pair<int, int>> ta;

void input(){
    cin >> n;
    ta.resize(n);
    for(int i=0;i<n;i++){
        int x, y;
        cin >> x >> y;
        ta[i] = make_pair(x, y);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll t = 1;
    ll a = 1;
    for(int i=0;i<n;i++){
        // cout << t << ' ' << a << endl;
        ll n = max((t - 1) / ta[i].first + 1, (a - 1) / ta[i].second + 1);
        t = n * ta[i].first;
        a = n * ta[i].second;
    }
    cout << t + a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{	
	int n;
	cin >> n;
	int a[n];
	map<int, int> x;
	
	int res = 0;
	rep(i, n) {
		cin >> a[i];
		x[a[i]]++;
		x[a[i] - 1]++;
		x[a[i] + 1]++;
		res = max({res, x[a[i]], x[a[i] + 1], x[a[i] - 1]});
	}
	cout << res;
}


 
 
int main()
{
 //	freopen("sparse.in", "r", stdin);
	//freopen("sparse.out", "w", stdout);
	   Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set> 
using namespace std;

struct UnionFind{
    vector<int> branch;
    UnionFind(int N=0):branch(N,-1){}
    int find(int x){
        if(branch[x]<0){
            return x;
        }
        else{
            return branch[x]=find(branch[x]);//メモ化、要素を入れて根が返ってくる    
        }
    }
    bool unite(int x, int y){
        int rx,ry;
        rx=find(x);
        ry=find(y);
        if(rx==ry){
            return false;//連結できたかどうかが大事なこともあるらしい
        }
        if(-branch[rx]<-branch[ry]){//bramch[rx]を常に大きい方にする
            swap(rx,ry);    
        }
        branch[rx]+=branch[ry];//木のサイズを負の値で管理
        branch[ry]=rx;
        return true;
    }
    bool same(int x, int y){
        if(find(x)==find(y)){
            return true;
        }
        else{
            return false;
        }
    }
    int size(int x){
        return -branch[find(x)];
    }
};

    
int main(){
    int n,m;
    cin >> n >> m;
    UnionFind tree(n);
    set<int> st;
    for(int i = 0; i < m; i++){
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        tree.unite(x,y);
    }
    for(int i = 0; i < n; i++){
        st.insert(tree.find(i));
    }
    cout << st.size() << endl; 
}

Measured memory_bytes: 5376
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    lsort(a);

    int tmp = (a.back() + 1) / 2;
    int t1 = *lower_bound(a.begin(), prev(a.end()), tmp);
    int t2 = *prev(lower_bound(a.begin(), prev(a.end()), tmp));
    if(t1 == a.back() || abs(tmp - t2) < abs(tmp - t1)) swap(t1, t2);
    cout << a.back() << " " << t1 << "\n";

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/


int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        int k,x;
        cin>>k>>x;
        (k*500>=x?cout<<"Yes\n":cout<<"No\n");
    }
}















Measured memory_bytes: 3612
n = gets.to_i
a = gets.split().map(&:to_i)

left = Array.new(n)
right = Array.new(n)

left[0] = a[0]
right[-1] = a[-1]

(n-1).times do |i|
  left[i+1] = left[i].gcd(a[i+1])
end

(n-1).times do |i|
  right[n-2-i] = right[n-1-i].gcd(a[n-2-i])
end

ans = []

n.times do |i|
  if i == 0
    ans << right[i+1]
  elsif i == n-1
    ans << left[i-1]
  else
    ans << left[i-1].gcd(right[i+1])
  end
end

puts ans.max

Measured memory_bytes: 12156
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.back() == 's') s = s + "es";
    else s = s + "s";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h,w;
  cin>>h>>w;
  int si,sj;
  cin>>si>>sj;
  int ti,tj;
  cin>>ti>>tj;
  si--; sj--; ti--; tj--;
  vector<string> s(h);
  rep(i,h) cin>>s[i];
  vector<vector<int>> dist(h,vector<int>(w,INF));
  deque<P> q;
  dist[si][sj]=0;
  q.emplace_back(si,sj);
  while (!q.empty()){
    int i=q.front().first;
    int j=q.front().second;
    int d=dist[i][j];
    q.pop_front();
    rep(v,4){
      int ni=i+di[v], nj=j+dj[v];
      if(ni<0||ni>=h||nj<0||nj>=w) continue;
      if(s[ni][nj]=='#') continue;
      if(dist[ni][nj]<=d) continue;
      dist[ni][nj]=d;
      q.emplace_front(ni,nj);
    }
    for(int ei=-2;ei<=2;ei++){
      for(int ej=-2;ej<=2;ej++){
        int ni=i+ei,nj=j+ej;
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(s[ni][nj]=='#') continue;
        if(dist[ni][nj]<=d+1) continue;
        dist[ni][nj]=d+1;
        q.emplace_back(ni,nj);
      }
    }
  }
  int ans=dist[ti][tj];
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 9468
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

signed main(){
    //const int INF = 1e9;
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n,k,r,s,p; cin >> n >> k >> r  >> s >> p;
    string t; cin >> t;
    vector<bool> win(n,0);
    rep(i,n){
        if(i<k) win[i]=1;
        else{
            if(t[i]==t[i-k]&&win[i-k]==1) win[i]=0;
            else win[i]=1;
        }
    }
    int ans=0;
    rep(i,n){
        if(win[i]){
            if(t[i]=='r') ans+=p;
            if(t[i]=='s') ans+=r;
            if(t[i]=='p') ans+=s;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main() {
	int n, ma, mb, a[44], b[44], c[44], i, j,k, dp[41][401][401];
	cin >> n >> ma >> mb;
	for (i = 1; i <= n; i++)
		cin >> a[i] >> b[i] >> c[i];
	for (i = 0; i <= n; i++)
		for (j = 0; j <= n * 10; j++)
			for (k = 0; k <= n * 10; k++)
				dp[i][j][k] = 100000;
	dp[0][0][0] = 0;
	for (i = 1; i <= n; i++) {
		for (j = 0; j <= i * 10; j++) {
			for (k = 0; k <= i * 10; k++) {
				if (j >= a[i] && k >= b[i])
					dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i]][k - b[i]] + c[i]);
				else
					dp[i][j][k] = dp[i - 1][j][k];
			}
		}
	}
	int ans = 100000;
	for (j = 1; j <= n * 10; j++)
		for (k = 1; k <= n * 10; k++)
			if (dp[n][j][k] < ans&&j*mb == k * ma)
				ans = dp[n][j][k];
	if (ans == 100000)
		cout << "-1" << endl;
	else
		cout << ans << endl;
}

Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
const int mod = 1e9 + 7;
int main()
{

  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  ll n;cin>>n;
  set<string>ans;
  string s;
  rep(i,1,n+1){
      cin>>s;
      ans.insert(s);
  }
  cout<<ans.size();
 //for(auto it=ans.begin();it!=ans.end();it++)cout<<*it<<" ";
  

} 

Measured memory_bytes: 19276
N = int(input())
L = list(map(int, input().split()))

max_L = max(L)
max_i = L.index(max(L))

sum_without_max = sum([*L[:max_i], *L[max_i+1:]])

if sum_without_max > max_L:
    print("Yes")
else:
    print("No")

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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...)
#endif

/**
 * @title Fenwick tree
 * @docs fenwick_tree.md
 */
template <typename AbelianGroup>
class FenwickTree{
  using value_type = typename AbelianGroup::value_type;
  AbelianGroup G;
  
  int size;
  std::vector<value_type> data;
  
public:
  FenwickTree(){}
  FenwickTree(int size):
    size(size), data(size + 1, G.id())
  {}
  
  void update(int i, const value_type &val){
    i += 1; // 1-index
    
    while(i <= size){
      data[i] = G.op(data[i], val);
      i += i & (-i);
    }
  }
  
  value_type get(int i) const { // [0, i)
    value_type ret = G.id();
    i += 1; // 1-index

    while(i > 0){
      ret = G.op(ret, data[i]);
      i -= i & (-i);
    }

    return ret;
  }

  value_type get(int l, int r) const { // [l, r)
    return G.op(get(r-1), G.inv(get(l-1)));
  }
  
  value_type at(int x) const {
    return get(x, x+1);
  }
};

/**
 * @docs sum.md
 */
template <typename T>
struct SumGroup{
  using value_type = T;

  value_type id() const {return 0;}
  value_type op(const value_type &a, const value_type &b) const {return a + b;}
  value_type inv(const value_type &a) const {return -a;}
};



int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int N, Q;

  while(std::cin >> N >> Q){
    std::vector<int> c(N);
    for(int i = 0; i < N; ++i){
      std::cin >> c[i];
      c[i] -= 1;
    }

    std::vector<std::pair<int, int>> query(Q);
    std::map<std::pair<int, int>, std::vector<int>> index;
    std::vector<int> ans(Q);
    
    for(int i = 0; i < Q; ++i){
      int l, r; std::cin >> l >> r;
      --l;
      query[i] = std::make_pair(r, l);
      index[{l, r}].push_back(i);
    }

    FenwickTree<SumGroup<int>> b(N);
    std::vector<int> last_index(N, -1);

    std::sort(query.begin(), query.end());

    dump(query);

    int cur = 0;
    for(auto [r, l] : query){
      while(cur < r){
        if(last_index[c[cur]] != -1){
          b.update(last_index[c[cur]], -1);
        }
        
        last_index[c[cur]] = cur;
        b.update(last_index[c[cur]], 1);
        
        ++cur;
      }

      for(auto i : index[{l, r}]){
        ans[i] = b.get(l, r);
      }
    }

    for(auto x : ans){
      std::cout << x << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 70296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int paircount = 0;
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		Integer i = Integer.parseInt(s);
		String s2 = scan.nextLine();
		scan.close();
		String[] stringArray = s2.split(" ");
		for (int x = 1; x < i; x++) {
			String xlikes = stringArray[x-1];
			if (Integer.parseInt(stringArray[Integer.parseInt(xlikes)-1]) == x && Integer.parseInt(xlikes) != x) {
				paircount++;
			}
		}
		System.out.println((paircount+1)/2);
	}
}



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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define deb(x)     cout << #x << " = "<<x<<endl

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)

int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;


ll gcd(ll  a , ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
ll powmod(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return powmod(n, MOD - 2, MOD);
}
void max_self(ll &a, ll b) {
	a = max(a, b);
}
bool is_ap(vl v, int n) {
	ll d = v[1] - v[0];
	F0R(i, n) {
		if (v[i] != v[0] + i * d)
			return false;
	}
	return true;
}


int main(int argc, char const *argv[])
{
	// two magical lines to speed up IO
	cin.tie(0);
	ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int a, b, c;
	cin >> a >> b >> c;
	cout << c <<" "<< a<<" " << b << endl;


}




Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int a[4], b[2];
	int ans;

	for (int i = 0; i < 4; i++){
		cin >> a[i];
	}
	cin >> b[0] >> b[1];

	sort(a, a + 4);
	sort(b, b + 2);

	ans = a[1] + a[2] + a[3] + b[1];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3136