akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#define N 10000
int main(){

  int num[N],n,i,j=3,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&num[i]);

  for(i=0;i<n;i++){
    if(num[i]==2)count+=1;
    else if(num[i]>2&&num[i]%2!=0){
      while(j<=sqrt(num[i])){
	if(num[i]%j==0){
	  count-=1;
	  break;
	}
	else j+=2;
      }
      count+=1;
      j=3;
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2064
#include<stdio.h>
#include<string.h>
main(){
  char s[1000001];
  int n;
  int i,j,l=0;
  int jf=0;
  char JOI[4]="JOI";
  int joi[3]={0};
  int ans=0;
  scanf("%s",s);
  n=strlen(s);
  for(i=0;i<n;i++){

    for(j=1;j<3;j++){
      if(joi[j]>0 && s[i]=='J'){ jf=1; l=0;}
    }

    if(jf==1){
      if(joi[0]>=joi[1] && joi[1]<=joi[2]){
	if(ans<joi[1]){
	  ans=joi[1];
	  // printf("OK\n");
	}
      }
      memset(joi,0,sizeof(joi));
      jf=0;

      //printf("JF!\n");
    }

    if(s[i]=='J' && l==0) joi[0]++;
    else if(s[i]=='O' && l<=1){ joi[1]++; l=1;}
    else if(s[i]=='I' && l<=2){ joi[2]++; l=2;}

 
    //    for(j=0;j<3;j++)  printf("%c...%d\n",JOI[j],joi[j]);

  }

  if(joi[0]>=joi[1] && joi[1]<=joi[2]){
    if(ans<joi[1]) ans=joi[1];
  }

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    int i,a[26]={0};
    char  ch;
    while(scanf("%c",&ch)!=EOF){
        if(ch>='A'&&ch<='Z'){
            ch+=32;
        }
        a[ch-'a']++;
    };
    for(i=0;i<26;i++){
        printf("%c : %d\n",i+'a',a[i]);
    };
    
    
}



Measured memory_bytes: 2056
N=int(input())
S=input()
now_max=0



separater=1
while separater<N:
    former_list = []
    latter_list = []
    former_set = {}
    latter_set = {}
    former_string=S[:separater]
    latter_string=S[separater:N]
    former_set=set(list(former_string))
    latter_set=set(list(latter_string))
    intersection=former_set & latter_set
    if now_max<len(intersection):
        now_max=len(intersection)

    #print(former_string)
    #print(latter_string)
    #print(intersection)

    separater+=1
print(now_max)

Measured memory_bytes: 3064
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int arr[] = new int[N];
		for(int n=0;n<N;n++){
			arr[n] = sc.nextInt();

		}
		Arrays.sort(arr);
		int sum=0;
		for(int n=0;n<N;n++){
			if(n==N-1){
				sum += (int)arr[n]/2;
			}
			else{
				sum += arr[n];
			}
		}

		System.out.println(sum);

	}
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll h,w;
    cin >> h >> w;
    char c[h][w] = {};
    rep(i,0,h) rep(j,0,w) cin >> c[i][j];

    ll dp[h+1][w+1] = {};
    rep(i,0,h+1) rep(j,0,w+1) dp[i][j] = LINF;
    dp[0][0] = 0;

    rep(i,0,h){
        rep(j,0,w){
            if(i < h-1 && c[i][j] == '#' && c[i+1][j] == '.') dp[i+1][j] = min(dp[i+1][j],dp[i][j]+1);
            else dp[i+1][j] = min(dp[i+1][j],dp[i][j]);

            if(j < w-1 && c[i][j] == '#'&& c[i][j+1] == '.') dp[i][j+1] = min(dp[i][j+1],dp[i][j]+1);
            else dp[i][j+1] = min(dp[i][j+1],dp[i][j]);
        }
    }

    if(c[h-1][w-1] != '#') cout << dp[h-1][w-1] << endl;
    else cout << dp[h-1][w-1] + 1 << endl;

    return 0;
}


Measured memory_bytes: 3684
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


struct UnionFind {
	vector<int> d;
	UnionFind(int n = 0) : d(n, -1) {}
	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};


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

	UnionFind uf(N);

	REP(i, M)
	{
		int a, b;
		cin >> a >> b;
		a--;b--;
		uf.unite(a, b);
	}

	int ans = 0;
	REP(i, N)
	{
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
}



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

int main() {
  string s;
  cin >> s;
  string ans;
  if (s=="Sunny"){
    ans = "Cloudy";
  } else if (s=="Cloudy") {
    ans = "Rainy";
  } else {
    ans = "Sunny";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
Idea:

*/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (2e9)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 711

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int adj[maxn][maxn], col[maxn];
vector<pii> comp;

int n, m, nn, cnt;

bool used[maxn], ok;
bool dp[maxn][maxn];

void DFS(int x, int c){
	col[x] = c;
	used[x] = 1;
	nn++;
	cnt += col[x];

	for(int i = 1; i <= n; i++){
		if(adj[x][i] && used[i] && col[x] == col[i])
			ok = 0;

		if(adj[x][i] == 1 && !used[i])
			DFS(i, 1 - c);
	}
}

void fun(int x, int diff){
	diff = abs(diff);

	if(dp[x][diff] == 1)
		return;

	dp[x][diff] = 1;

	if(x == comp.size())
		return;
	
	int cur = abs(comp[x].fi - comp[x].se);
	fun(x + 1, diff - cur);
	fun(x + 1, diff + cur);
}

int cost(int x){
	return x * (x - 1) / 2;
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a][b] = 1;
		adj[b][a] = 1;
	}

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i == j)
				continue;

			adj[i][j] = 1 - adj[i][j];
		}
	}

	ok = 1;
	for(int i = 1; i <= n; i++){
		if(!used[i]){
			nn = cnt = 0;
			DFS(i, 0);
			comp.pb(mp(nn - cnt, cnt));
		}
	}

	if(!ok){
		printf("-1\n");
		return 0;
	}

	fun(0, 0);

	int ans = INF;
	for(int i = 0; i <= n; i++){
		if(dp[comp.size()][i]){
			int x = (n - i) / 2;
			int y = n - x;
			ans = min(ans, cost(x) + cost(y));
		}
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		int n = Integer.parseInt(s);
		s = scanner.nextLine();
		int count = 0;
		char last_char = '\0';
		for(int i = 0; i < n; i++){
			char c = s.charAt(i);
			if(last_char != c) {
				count++;
				last_char = c;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 28228
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int& x : a) { cin >> x; -- x; }
	int r = 0;
	for (int i = 0; i < N; ++ i) {
		int j = a[i];
		if (i < j && a[j] == i) ++ r;
	}
	cout << r << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using std::string;
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define FORR(i,l,r) for(int (i)=l;(i)<(r);++(i))
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define EPSILON 1e-9
#define MAX 100002
#define PI 3.1415926535897932384626433832795028841971693993751
typedef long long  ll;
typedef unsigned long long llu;
typedef long double  ldb;
typedef double  db ;
int dp[MAX][3],a[100002],b[MAX],c[MAX],inf=1000000002;
int main()
{
    // freopen("in.txt","r",stdin);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1; i<n; i++)
    {
        for(int j=0; j<=2; j++)
        {
            if(j==0)
                dp[i][j]=a[i]+max(dp[i-1][1],dp[i-1][2]);
            else if(j==1)
                dp[i][j]=b[i]+max(dp[i-1][0],dp[i-1][2]);
            else if(j==2)
                dp[i][j]=c[i]+max(dp[i-1][0],dp[i-1][1]);
        }
    }
    int ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
int area1,area2;
area1=a*b;
area2=c*d;
if(area1>area2)
printf("%d",area1);	
else if(area2>area1)
printf("%d",area2);
else
printf("%d",area1);	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;cin>>a>>b;
string str;cin>>str;
bool flag=true;
for(int i=0;i<a;i++)
if(str[i]=='-'){
flag=false;
break;
}
if(str[a]!='-')flag=false;
for(int i=a+1;i<str.size();i++){
if(str[i]=='-'){flag=false;break;}
}
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int main(){
    int n, k; cin >> n >> k;
    int count = 1;
    while(n>=k){
        n /= k;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
     int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)
     {
      cin>>a[i];
     }
     int j=1;
     sort(a,a+n,greater<int>());
     ll sum=0;
     sum+=a[0];
     for(int i=2;i<n;i++)
     {
        sum+=a[j];
        i++;
        if(i<n)
        {
          sum+=a[j];
        }
        j++;
     }
     cout<<sum<<endl;
}

 

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int main(){

  ll n,k;
  scanf("%lld %lld",&n,&k);

  ll array[500001] = {0};

  for(ll i = 0; i < n; ++i){
    ll a,b;
    scanf("%lld %lld",&a,&b);
    array[a] += b;
  }

  int i = 0;
  while(1){
    k -= array[i];
    if(k <= 0){
      printf("%d",i);
      return 0;
    }
    ++i;
  }

  return 0;

}


Measured memory_bytes: 4096
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;


int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

   int n;
   cin >> n;
   int a[n];
   for(int i = 0 ; i< n ; i++){
      cin >> a[i];
   }  
   vector<int>suff(n,0);
   suff[n-1] = a[n-1];
   for(int i = n-2 ; i>=0 ; i--){
     suff[i] = a[i]+suff[i+1];
   }

   int ans = 0;
   for(int i = 0 ; i < n-1 ; i++){

     int curr = a[i];
     ans = ((ans%mod) + ( (curr%mod) * 1LL * (suff[i+1]%mod))%mod)%mod;
   }
   cout << ans;

}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	

	string S;
	cin>>S;
	int ans = 0;
	for(int i=1;i<S.size();i++){
		if(S[i]!=S[i-1])ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int m;
  cin>>n;
  if(n % 2 == 0){
    m = n/2;
  }
  else{
    m = n/2+1;
  }
  cout<<(double)m/n<<'\n';
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 2e5 + 41;

ll const INF = 1e18;

ll x[MAX];
ll s[MAX];
ll ans;

int n;

void solve() {
	fi(1, n) {
		ans = max(ans, s[i]);
	}

	ll b = -INF;
	ll sum = 0;

	fi(1, n) {
		ll prefr = sum + s[i];
		ll pans = prefr - x[i] + b;
		ans = max(ans, pans);
		b = max(b, x[i] - sum);
		sum += s[i];	
	}

	printf("%lld\n", ans);

}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  fi(1, n) {
  	scanf("%lld %lld", &x[i], &s[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 3328
gets.to_i.times do
  n = gets.to_i
  hash = {}
  res = 0
  while true do
    s = n.to_s
    break if s.size == 1
    if hash[n]
      res = -1
      break
    else
      res += 1
      hash[n] = 1
    end
    n = s.size.times.map{|i|
      a = s[0..i]
      b = s[i.succ...s.size]
      a.to_i * b.to_i
    }.max
  end
  p res
end

Measured memory_bytes: 8924
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    //データ定義
    string input_str; //入力される文字列
    int order_cnt; //命令の数
    int i;
    string order; //入力される命令
    string replace_str; //置き換える文字
    int start; //何文字目から処理を始めるか
    int end; //何文字目まで処理を行うか
    
    //データ入力
    cin >> input_str;

    //命令の数を入力
    cin >> order_cnt;

    //主処理
    for(i = 0; i < order_cnt; i++){
        //命令を受け取る
        cin >> order >> start >> end;

        //命令を実行する
        if(order == "print"){
            cout << input_str.substr(start, end - start + 1) << endl;
        }else if(order == "reverse"){
            reverse(input_str.begin() + start, input_str.begin() + end + 1);
        }else if(order == "replace"){
            //置き換える文字を受け取る
            cin >> replace_str;
            input_str.replace(start, end - start + 1, replace_str);
        }else{
            ;
        }
    }
    return 0;
}


Measured memory_bytes: 3212
from copy import deepcopy
n = int(input())
A = list(map(int,input().split()))
AA = deepcopy(A)
f = [0]*n
m = 0
b = []
for i in range(n-1,0,-1):
    if A[i]%2==0:
        continue
    b.append(i+1)
    m += 1
    for k in range(1,int((i+1)**0.5)+1):
        if (i+1)%k == 0:
            if(k-1!=(i+1)//k-1):
                A[k-1] -= 1
                A[(i+1)//k-1] -= 1
                f[k-1] += 1
                f[(i+1)//k-1] += 1
            else:
                A[k-1] -= 1
                f[k-1] += 1

if f[0]%2 !=AA[0]%2:
    b.append(1)
    m += 1
for i in range(1,n):
    if f[i]%2 != AA[i]:
        print(-1)
        exit()
print(m)
if m==0:
    exit()
print(*b)

Measured memory_bytes: 73552
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() { 
  int N, X; cin >> N >> X;
  int m[N]; rep(i, N) cin >> m[i]; sort(m,m+N);

  rep(i, N) X -= m[i];
  int result = N + X/m[0];

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    l=int(input())
    n=1
    while (1<<n)<=l:
        n+=1
    ans=[]
    for i in range(n-1):
        ans.append([i,i+1,0])
        ans.append([i,i+1,1<<i])
    l-=1<<(n-1)
    val=1<<(n-1)
    for p in range(n-2,-1,-1):
        if l>=(1<<p):
            ans.append([p,n-1,val])
            val+=1<<p
            l-=1<<p
    print(n,len(ans))
    for a,b,c in ans:
        print(a+1,b+1,c)
main()

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

int main(){
  int N;
  cin >>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice=0,bob=0;
  for(int i=0;i<N;i++){
    if(i%2==0)
      alice+=a.at(i);
    else
      bob+=a.at(i);
  }
  cout << alice-bob<<endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            string S = cin.ReadLine;
            var words = new string[] {"dream","eraser","erase"};
            var checkWords = new string[] {"eraser","erase","er"};
            bool flgForCheck = false;

            for(int i=0; i<S.Length;){
              	flgForCheck = false;
                foreach (string word in words)
                {
                  	if((i + word.Length) > S.Length) continue;
                    if(S.Substring(i,word.Length) == word){
                        i += word.Length;
                        flgForCheck = true;
                        if(word == "dream"){
                            foreach(string checkWord in checkWords){
                  				if((i + checkWord.Length) > S.Length) continue;
                                if(S.Substring(i,checkWord.Length) == checkWord){
                                    i += checkWord.Length;
                                  	break;
                                }
                            }
                        }
                        break;
                    }
                }
                if(!flgForCheck)break;
            }

            if(flgForCheck) WriteLine("YES");
            else WriteLine("NO");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

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

int N;
int A[int(1.1e5)];

int freq[int(1.1e5)];

int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    freq[A[i]] += 1;
  }

  int ans = 0;
  int cnt2 = 0;
  for(int x = 1; x <= int(1e5); x++) {
    if(freq[x] >= 3) {
      int how_much = (freq[x] - 1) / 2;
      freq[x] -= how_much * 2;
      ans += how_much * 2;
    }

    if(freq[x] == 2) {
      cnt2 += 1;
    }
  }

  ans += (cnt2 + 1) / 2 * 2;
  printf("%d\n", N - ans);
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int i,j;
    int A[100];
    int B[100];
    int C[100];
    int count=0;
    for(int i=0;i<n;i++){
        scanf("%d",&j);
        A[i]=j;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&j);
        B[i]=j;
    }
    for(int i=0;i<n-1;i++){
        scanf("%d",&j);
        C[i]=j;
    }
    j=1000000;
    for(int i=0;i<n;i++){
        count+=B[i];
        if(A[i]==j+1){
            count+=C[j-1];
        }
        j=A[i];
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x, k, d;
    long double y;
    cin >> x >> k >> d;
    y = (long double) abs(x) / (long double) d;
    if(y > k){
        cout << abs(abs(x) - k * d);
    }
    else if(y == k || ((long long)y == y && (k - (long long)y) % 2 == 0)){
        cout << 0;
    }
    else{
        if((k - (long long)y) % 2 == 0){
            cout << abs(abs(x) - (long long)y * d);
        }
        else{
            cout << abs(abs(x) - ((long long)y + 1) * d);
        }
    }
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
int x[100000],d[100000],c[100000];

int lis(int n){
	int i,j,I;
/*
	for(i=-1;I=0,++i<n;d[i]=I+1)
		for(j=i-1;~j;j--)
			if(x[j]<x[i]&&I<d[j])I=d[j];
*/
	int sz = 1;
	c[1] = x[0];
	d[0] = 1;
	for(i=0;++i<n;){
		if(x[i] < c[1]){
			c[1] = x[i];
			d[i] = 1;
		}else if(x[i] > c[sz]){
			c[sz+1] = x[i];
			d[i] = sz+1;
			sz++;
		}else{
			int k = std::lower_bound(c,c+sz,x[i])-c;
			c[k] = x[i];
			d[i] = k;
		}
	}
	for(i=j=0;i<n;i++)
		if(d[i]>d[j])j=i;
	return d[j];
}

int n,i;
int main(){
	for(scanf("%d\n",&n);i<n;i++)scanf("%d",x+i);
	printf("%d\n",lis(n));
}

Measured memory_bytes: 2192
n=int(input())
n-=1
a='abcdefghijklmnopqrstuvwxyz'
a=list(a)
ans=''
for i in range(1,20):
    if n<26**i:
        for j in range(i):
            ans+=a[n%26]
            n//=26
        break
    else:
        n-=26**i
print(ans[::-1])
    



Measured memory_bytes: 9108
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long a = sc.nextLong();
		// スペース区切りの整数の入力
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		// 文字列の入力
		long e = a * c;
		long f = b * c;
		long g = b * d;
		long h = a * d;
		
		if( e >= f &&  e >= g &&  e >= h){
			System.out.println(e);
		}else if( f >= e &&  f >= g &&  f >= f){
			System.out.println(f);
		}else if( g >= e &&  g >= f &&  g >= h){
			System.out.println(g);
		}else if( h >= e &&  h >= f &&  h >= g){
			System.out.println(h);
		}
		
	}
}

Measured memory_bytes: 35768
#include<iostream>
#include <climits>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

void BubbleSort(vector<string> &C, int N) {
	for (int i = 0;i < N - 1;i++) {
		for (int j = N - 1;j > i;j--) {
			if ((int)C[j-1][1] > (int)C[j][1]) {
				string tmp = C[j];
				C[j] = C[j - 1];
				C[j - 1] = tmp;
			}
		}
	}
}

void SelectionSort(vector<string> &C, int N) {
	for (int i = 0;i < N - 1;i++) {
		int minj = i;
		for (int j = i + 1;j < N;j++) {
			if ((int)C[minj][1] > (int)C[j][1]) minj = j;
		}
		if (minj != i) {
			string tmp = C[minj];
			C[minj] = C[i];
			C[i] = tmp;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<string> C(N), D(N);
	REP(i, N) {
		cin >> C[i];
		D[i] = C[i];
	}
	BubbleSort(C, N);
	SelectionSort(D, N);
	REP(i, N) {
		if (i < N - 1) cout << C[i] << " ";
		else cout << C[i] << "\n";
	}
	cout << "Stable\n";
	bool sta = true;
	REP(i, N) {
		if (C[i] != D[i]) sta = false;
		if (i < N - 1) cout << D[i] << " ";
		else cout << D[i] << "\n";
	}
	if (sta) cout << "Stable\n";
	else cout << "Not stable\n";
	

	
	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
 string S;
 cin >> S;
 
 if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
 	cout << "Yes" << endl;
 }else{
 	cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,d,t;
    cin>>n;
    std::map<long long int, long long int> map;
    for (int i=0;i<n;i++) {
        cin>>d;
        map[d]++;
    }
    cin>>m;
    for (int i=0;i<m;i++) {
        cin>>t;
        if (map[t]>0) {
            map[t]--;
        } else {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

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

struct UF {
    int n;
    vector<int> par;
    UF(int _n) : n(_n) {
        for(int i = 0; i < n; i++) par.push_back(i);
    }
    int find(int a){
        if(a != par[a]) par[a] = find(par[a]);
        return par[a];
    }
    void join(int a, int b){
        par[find(a)] = find(b);
    }
};

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int m;
	cin >> m;
	vector<int> aa(m);
	for(int i = 0; i < m; i++) cin >> aa[i];
	int best = 0;
	for(int x : aa){
		best += (x / 2);
	}
	best += (n / 2);
	if(best < n-1){
		cout << "Impossible" << '\n';
		return 0;
	}
	vector<int> odds, evens;
	for(int i = 0; i < m; i++){
		if(aa[i] & 1){
			odds.push_back(aa[i]);
		} else {
			evens.push_back(aa[i]);
		}
	}
	vector<int> b;
	if(!odds.empty()){
		b.push_back(odds.back());
		odds.pop_back();
	}
	for(int e : evens) b.push_back(e);
	if(!odds.empty()){
		b.push_back(odds.back());
		odds.pop_back();
	}
	vector<int> a = b;
	if(b.size() == 1){
		if(n > 1){
			b.front()--;
			b.push_back(1);
		}
	} else {
		b.front()++;
		b.back()--;
		if(b.back() == 0) b.pop_back();
	}
	UF uf(n);
	{
		int r = 0;
		for(int x : a){
			for(int j = 0; j < x; j++) uf.join(r+j, r + x-1-j);
			r += x;
		}
	}
	{
		int r = 0;
		for(int x : b){
			for(int j = 0; j < x; j++) uf.join(r+j, r + x-1-j);
			r += x;
		}
	}
	for(int i = 0; i < n; i++){
		assert(uf.find(0) == uf.find(i));
	}

	for(int x : a) cout << x << ' ';
	cout << '\n';
	cout << b.size() << '\n';
	for(int x : b) cout << x << ' ';
	cout << '\n';
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >>H >>x >>y >>r;
    if(y>=r && y<=H-r && x>=r && x<=W-r )cout << "Yes" <<endl;
    else cout<<"No" << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

int main() {
  int N; std::cin >> N;
  std::vector<long long> A(N);
  for (int i = 0; i < N; ++i) std::cin >> A[i];

  sort(A.begin(), A.end());

  std::vector<long long> out1, out2;
  int start = 0;
  int end = N - 1;
  bool push_small = true;

  while (start != end) {
    if (push_small) {
      out1.push_back(A[start]);
      ++start;
    } else { // large one
      out1.push_back(A[end]);
      --end;
    }
    push_small = !push_small;
  }
  out1.insert(out1.begin(), A[start]);

  start = 0;
  end = N - 1;
  push_small = false;

  while (start != end) {
    if (push_small) {
      out2.push_back(A[start]);
      ++start;
    } else { // large one
      out2.push_back(A[end]);
      --end;
    }
    push_small = !push_small;
  }
  out2.insert(out2.begin(), A[start]);

  long long sum1 = 0;
  long long sum2 = 0;
  for (int i = 0; i < N-1; ++i) {
    sum1 += std::abs(out1[i]-out1[i+1]);
    sum2 += std::abs(out2[i]-out2[i+1]);
  }
  std::cout << std::max(sum1, sum2) << std::endl;
}


Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
  int A,B,X,i;
  X=0;
  scanf("%d %d",&A,&B);
  for(i=1;i<=2;i++){
    if(A>=B){
      X=X+A,A=A-1;}
    else{
      X=X+B,B=B-1;}
  }
  printf("%d",X);
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define sll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll tt;cin>>tt; while(tt--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v
#define scan(x,n)  for(ll i=0;i<n;i++) cin>>x[i]
#define scan1(x,n) for(ll i=1;i<=n;i++) cin>>x[i]
#define all(x) x.begin(),x.end()
ll mod = 1e9+7;
#define N 300005

int main() 
{
	fast_io;
	// Test
    ll n,i,k,j;
    cin>>n;
    ll arr[n][3],dp[n][3];
    for(i=0;i<n;i++)
     for(j=0;j<3;j++)
         cin>>arr[i][j];
   
    for(i=0;i<n;i++)
    {
     for(j=0;j<3;j++){
      if(i==0)dp[i][j]=arr[i][j];
      else dp[i][j]=arr[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
    //   cout<<dp[i][j]<<" ";
     }
    // cout<<"\n";
    }
      
      
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

int main() {
  std::vector<int> a(4);
  for (auto & x : a) std::cin >> x;
  std::sort(a.begin(), a.end());
  if (a[0] == 1 and a[1] == 4 and a[2] == 7 and a[3] == 9) std::cout << "YES";
  else std::cout << "NO";
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=262144;
int a[N];
inline void sol(int n,int d){
	if(n==2){a[1]=1;return;}
	int m=n>>1,i;
	if(d&1){
		sol(m,1  );
		REP(i,0,m)a[i|n]= a[i  ]<<1;
		sol(m,(d>>1)^1);
		REP(i,0,m)a[i|m]=(a[i  ]^1)<<1|1;
		REP(i,0,m)a[i  ]= a[i|n];
	}else{
		sol(m,d>>1);
		per(i,m-1,0){
			if(i&1){a[i<<1|1]=a[i]<<1  ;a[i<<1]=a[i]<<1|1;}
			else   {a[i<<1|1]=a[i]<<1|1;a[i<<1]=a[i]<<1  ;}
		}
	}
	//REP(i,0,n)printf("%d ",a[i]);printf("SOL n=%d d=%d\n",n,d);
}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,s,b,c=1,i;
    scanf("%d%d%d",&n,&s,&b);
    for(i=(b^=s);i;i&=(i-1))c^=1;
	if(c){puts("NO");return 0;}
	else{
		puts("YES");
		sol(1<<n,b);
		REP(i,0,1<<n)printf("%d ",a[i]^s);
	}
    return 0;
}

Measured memory_bytes: 1792
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Measured memory_bytes: 9132
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
using namespace std;


int main() {
  int N, W;
  cin >> N >> W;

  vector<long long> w(N), v(N);
  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

  // dp[i][j]: max value when we consider upto i'th item and the total weight <= j.
  vector<vector<long long>> dp(N, vector<long long> (W + 1, -1));
  for (int j = 0; j <= W; j++) {
    if (w[0] <= j) dp[0][j] = v[0];
    else dp[0][j] = 0;
  }

  for (int i = 1; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j >= w[i]) dp[i][j] = max(dp[i-1][j - w[i]] + v[i], dp[i-1][j]);
      else dp[i][j] = dp[i-1][j];
    }
  }

  cout << dp[N-1][W] << endl;


  return 0;
}


Measured memory_bytes: 82376
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b;
	if ((a*b * 1) % 2 == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if ((a*b * 2) % 2 == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if ((a*b * 3) % 2 == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<long>A(N),S(N+1);S[0]=0;
  for(int i=0;i<N;i++){cin>>A[i];S[i+1]=S[i]+A[i];}
  sort(S.begin(),S.end());
  long ans=0;
  long c=0;
  for(int i=0;i<N+1;i++){
    c++;
    if(i==N||S[i]!=S[i+1]){
      ans+=c*(c-1)/2;
      c=0;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <map>
using namespace std;
string z(int i){string s="";if(i>25){s+='a'+i/25;i%=25;}s+='a'+i;return s;}
string c(char c){string s="";s+=c;return s;}
int main(){
	string s;
	map<string,int>m;
	int i;
	cout<<"?shiritori"<<endl;
	for(i=0;i<100;i++){
		cin>>s;
		if(s[0]!='i'||m[s]){cout<<"!OUT"<<endl;return 0;}
		m[s]=1;
		cout<<string("?")+s[s.size()-1]+z(i)+"i"<<endl;
	}
	return 1; //RE
}

Measured memory_bytes: 0
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL A, B, C;
	cin >> A >> B >> C;

	O(max((LL)0, C - (A - B)));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const int M = 1e7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main(){
  int n;
  ll m;
  cin >> n >> m;

  ll d = m / n;
  for (ll i = d;;d--){
    if ((d + (m - d * n)) % d == 0){
      cout << d << endl;
      return 0;
    }
  }  
  return 0;
}


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

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

using namespace std;

const int MAXN = 1001 * 1001 ;



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

    string s ;
    cin >> s ;
    int n = s.size() ;

    int ans = n ;

    for(char c = 'a' ; c <= 'z' ; c ++ )
    {
        int prv = -1 ;
        int x = 0 ;
        for(int i = 0 ; i < n ; i ++ ) if(s[i]==c) x = max(x,i-prv-1) , prv = i ;
        x = max(x,n-prv-1) ;
      //  if(c=='a') cout << n - prv << endl ;
        if(prv!=-1) ans = min(ans,x);
    }
    cout << ans << endl ;


    return 0;
}


Measured memory_bytes: 256
S=input()
N=len(S)

if N%2==0:
  S1="10"*(N//2)
  count=0
  for i in range(N):
    if S[i]==S1[i]:
      count+=1
  if count >= N//2:
    print(N-count)
  else:
    print(count)
else:
  S2="10"*((N-1)//2)+"1"
  count=0
  for i in range(N):
    if S[i]==S2[i]:
      count+=1
  if count >= (N+1)//2:
    print(N-count)
  else:
    print(count)

Measured memory_bytes: 9256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	long long k;
	scanf("%d %lld",&n,&k);
	vector<int> v(n+1);
	vector<int> f(n+1);
	for(int i = 0; i < n;i++)
	 scanf("%d",&v[i+1]);
	int sig = 1;
	int d1,d2,ini = 0;
	int t = 1;
	do{
		f[sig]++;
		sig = v[sig];
	}while(f[sig] <= 1);
	ini = sig;
	sig = 1;
	while(sig!=ini && k){
		sig = v[sig];
		k--;
	}
	if(!k)
		printf("%d\n", sig);
	else{
		d2 = 1;
		t = ini;
		while(v[t] != ini){
			d2++;
			t = v[t];
		}
		k = k%d2;
		t = ini;
		while(k--)
			t = v[t];
		printf("%d\n", t);
	}
	return 0;
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    int flag = 0;
    for(int i=0;i<=n;i++)
    {
        int j = n - i;
        int sum = i*2 + j*4;
        if(sum == k)
        {
            flag = 1;
            break;
        }
    }
    if(flag == 1)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 3592
import java.util.*;

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

        int[] c = new int[S.length()];
        for(int i = 0; i < S.length(); i++){
            c[i] = S.charAt(i);
        }
        for(int i = 0; i < S.length(); i++){
            if(c[i] + N > 90) c[i] = c[i] + N - 90 + 64;
            else c[i] += N;
        }
        char[] a = new char[S.length()];
        for(int i = 0; i < S.length(); i++){
            a[i] = (char)c[i];
            System.out.print(a[i]);
        }
    }
}

Measured memory_bytes: 26324
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	cout << (a - 1)*(b - 1) << endl;
}

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

int main() {
 int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int> (m));
  rep(i,n){
    cin>>c[i];
     rep(j,m) cin>>a[i][j];
  }
  ////////////bit全探索 n
  ll mn=100000412;
  bool ok;
  vector<int> q(m);
  for(int bit=0;bit<(1<<n);bit++){
    ll count=0;
    ok=true;
    q.assign(m,0);
    rep(i,n){//i番目の本
    	if(bit&(1<<i)){//1なら買う
              count+=c[i];
              rep(j,m){ //能力アップ
                 q[j]+=a[i][j];
              }
    	}
    }
    
    rep(i,m){ //okか判断
      if(q[i]<x){
        ok=false;
      }
    }
    
    
    
    
    if(ok){
        mn=min(mn,count);
    }
  }
  if(mn==100000412) cout<<-1<<endl;
  else cout<<mn<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
    int m, f, r;
    
   for(;;) {
       scanf("%d %d %d",&m, &f, &r);
       if(m == -1 && f == -1 && r == -1){
           break;
       }
       else if(m == -1 || f == -1){
           printf("F\n");
       }
       else if(m+f >= 80){
           printf("A\n");
       }
       else if(m+f >= 65 && m+f < 80){
           printf("B\n");
       }
       else if(m+f >= 50 && m+f < 65){
           printf("C\n");
       }
       else if(m+f >= 30 && m+f < 50){
           if(r >= 50){
               printf("C\n");
           }
           else{
               printf("D\n");
           }
       }
       else /* if(s < 30) */{
           printf("F\n");
       }
   }
   return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
int memo[87];
 
int luca(int n) {
    if(memo[n]!=0) return memo[n];
    if(n==0) return 2;
    if(n==1) return 1;
    return memo[n] = luca(n-1) + luca(n-2);
}
 
signed main() {
    int n;
    cin >> n;
    cout << luca(n) << endl;
    return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF=2e18;
const ll MOD=1e9+7;
ll N,C;
ll A[500],B[500];
ll dp[500][500];
ll powSum[500][500];
ll ModPow(ll x,ll n){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%MOD;
        }
        x=x*x%MOD;
        n>>=1;
    }
    return ret;
}
int main(){
    cin>>N>>C;
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    for(ll i=0;i<N;i++){
        cin>>B[i];
    }
    for(ll j=0;j<=C;j++){
        powSum[0][j]=0;
        for(ll i=1;i<=410;i++){
            powSum[i][j]=(powSum[i-1][j]+ModPow(i,j) )%MOD;
        }
    }
    dp[0][0]=1;
    for(ll i=0;i<N;i++){
        for(ll j=0;j<=C;j++){
            for(ll k=0;k<=C-j;k++){
                ll tmp=powSum[B[i]][k]-powSum[A[i]-1][k];
                if(tmp<0)tmp=MOD+tmp;
                dp[i+1][j+k]+=dp[i][j]*tmp%MOD;
                dp[i+1][j+k]%=MOD;
            }
        }
    }
    cout<<dp[N][C]<<endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum,cnt;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll m=0,odd=0,even=0;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
		if(a[i]%4==0) m++;
		else if(a[i]%2!=0) odd++;
		else even++;
	}
	if(m>=odd && even >1) cout<<"Yes";
	else if(m+1>=odd && even==0) cout<<"Yes";
	else if(n==1 && a[0]%4==0) cout<<"Yes";
	else if(m>=1 && n<=3) cout<<"Yes";
	else if(even == n) cout<< "Yes";
	else cout<<"No";
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct data{
	int v,n;
}b[410001];
int i,j,k,n,m,a[410001];
bool cmp1(data x,data y){
	return x.n<y.n;
}
bool cmp2(data x,data y){
	return x.n>y.n;
}
int main(){
	scanf("%d",&n);
	for (i=1,j=k=0;i<=n;i++){
		scanf("%d",&a[i]);b[i].v=a[i];
		if (i&1) b[i].n=++k;else b[i].n=--j;
	}
	//sort(b+1,b+1+n);
	if (n%2==0) sort(b+1,b+1+n,cmp1);else sort(b+1,b+1+n,cmp2);
	for (i=1;i<=n;i++) printf("%d ",b[i].v);
	puts("");
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	s = "??" + s;
	int ans = 0;
	for (int i = 2; i < s.size(); i++) {
		if (s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C') {
			ans++;
		}
	}

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


Measured memory_bytes: 256
l = input()
m = input()
z = l.split(" ")
M = int(z[1])
F = m.split(" ")
X = []
for item in F:
  votes = int(item)
  X.append(votes)

X.sort(reverse=True)
S = sum(X)
C = (S/(4*M))
if X[M-1]<C:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
N=int(input())
A=map(int,input().split())
m=10**9+7
r=1
C=[0,0,0]
for a in A:
    try:
        i=C.index(a)
        r=r*sum([1 if c==a else 0 for c in C])%m
        C[i]+=1
    except:
        print(0)
        exit()
print(r)


Measured memory_bytes: 10644