akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static boolean debug =  true;
	
	public static void print_arr(int [] arr) {
		int i = 0;
		while(i < arr.length) {
			System.out.print(arr[i]);
			if(i < arr.length-1) {
				System.out.print(" ");
			}else {
				System.out.print("\n");
			}
			i++;
		}
	}
	
	public static void insertion_sort(int [] arr) {
		for(int i = 1; i < arr.length;  i++) {
			if(debug) {
				print_arr(arr);
			}
			int j = i - 1;
			int key = arr[i];
			while(j >= 0 && arr[j] > key) {
				arr[j+1] = arr[j];
				j--;
			}
			arr[j+1] = key;

		}
		
		if(debug) {
			print_arr(arr);
			
		}
	
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = 0;
		
		n = cin.nextInt();
		
		int [] arr = new int[n];
		
		int x_i = 0;
		
		for(int i = 0; i < n; i++) {
			x_i = cin.nextInt();
			arr[i] = x_i;
		}
		
		insertion_sort(arr);
		
	
	}
}

Measured memory_bytes: 33832
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;


int main()
{

    ll N,X,Y;

    cin >> N >> X >> Y;
    vector<ll> kasu(N-1,0);

   for(ll k = 1; k<N ; k++){

       for(ll i =k+1; i<=N; i++){



               ll onu = min(i-k, abs(k-X)+1 +abs(i-Y));



               kasu[onu-1] = 1+kasu[onu-1];





           }
   
       

   }

   for(ll x=0;x<kasu.size();x++){

       cout << kasu[x] << endl;
   }
   return 0;
}



Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <sstream>
# include <set>
# include <cmath>
# include <algorithm>
# pragma  comment(linker,"/STACK:102400000,102400000")
using namespace std;
# define LL          long long
# define pr          pair
# define mkp         make_pair
# define lowbit(x)   ((x)&(-x))
# define PI          acos(-1.0)
# define INF         0x3f3f3f3f3f3f3f3f
# define eps         1e-8
# define MOD         1000000007

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
# define MX 10005
/**************************/

int main()
{
    map<int,int> mp;
    int n =scan();
    for(int i=1;i<=n;i++)
    {
        int x = scan();
        mp[x]++;
    }
    int all=0;
    for (map<int,int>::iterator it = mp.begin();it!=mp.end();it++)
    {
        int p = it->second;
        if (p%2==1) all++;
    }

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


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

using namespace std;
typedef long long ll;
ll Q,H,S,D;
ll memo[5];

ll dp(int val) {
    if(val < 0) return 1000000000000LL;
    if(!val) return 0LL;
    if(~memo[val]) return memo[val];
    ll a = Q + dp(val - 1), b = H + dp(val - 2), c = S + dp(val - 4);
    return memo[val] = min(a,min(b,c));
}

int main() {
    ios::sync_with_stdio(false);cin.tie(NULL);
    ll N;
    cin >> Q >> H >> S >> D >> N;
    ll c1 = Q * 8LL, c2 = H * 4LL, c3 = S * 2LL;
    ll best = min(c1, min(c2, min(c3, D))), ans = (N >> 1) * best;
    memset(memo, -1, sizeof memo);
    if(N % 2 != 0)
        ans += dp(4);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int64_t N, K;
vector<int64_t> A;

bool isOK(double mid) {
  int cut = 0;
  rep(i, N) { cut += ceil((double)A[i] / mid) - 1; }
  return (cut <= K);
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> K;
  A.resize(N);
  int64_t max_A = 0;
  rep(i, N) {
    cin >> A[i];
    max_A = max(max_A, A[i]);
  }

  double left = 0.0;
  double right = max_A;
  int loop = 100;
  while (loop--) {
    double mid = (left + right) / 2.0;
    if (isOK(mid)) {
      right = mid;
    } else {
      left = mid;
    }
  }
  cout << (int)ceil(left) << endl;
  return 0;
}


Measured memory_bytes: 4788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INF=LLONG_MAX;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	long double t=2.0;
	long double ans=w*h/t;

	if(w%2==0 && h%2==0){
		if(x==w/2 && y==h/2){
			cout<<ans<<" "<<1<<endl;
		}else{
			cout<<ans<<" "<<0<<endl;
		}
	}else{
		cout<<ans<<" "<<0<<endl;
	}
	return 0;
}


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

using namespace std;

#define ll long long

int main(){
    int x=0, N, max = 0;
    string S;
    cin >> N;
    cin >> S;

    for(int i=0; i < N; ++i){
        if(S[i] == 'I')
            ++x;
        else if(S[i] == 'D')
            --x;
        if(max < x)
            max = x;
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
    // 文字列の入力
    String s = sc.next();
		// 出力
    String ans = s.matches("[A-Z]") ? "A":"a";
    System.out.println(ans);
	}
}

Measured memory_bytes: 35596
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d,e,f,g;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b){
		d=a;
		a=b;
		b=d;
	}
	if(b<c){
		d=b;
		b=c;
		c=d;
	}
	if(a<b){
		d=a;
		a=b;
		b=d;
	}	
	e=abs(a-b);
	f=abs(b-c);
	g=e+f;
	printf("%d",g);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
using namespace std;
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=10009;
int a[]={2,5,5,4,5,6,3,7,6};
vector< pair<int,int> > v;
bool mark[N];
vector<int> ans;
int mem[N];
int solve(int rem){
    if(rem==0){
        return 0;
    }
    int &ret=mem[rem];
    if(ret!=-1) return ret;
    int ans=-100000;
    for(int i=1;i<=9;i++){
        if(mark[i]==0||a[i-1]>rem)
         continue;
        ans=max(ans,1+solve(rem-a[i-1]));
    }
    return ret=ans;
}
void print(int rem){

   int mx=0,d=0;
   for(int i=1;i<=9;i++){
        if(mark[i]==0||a[i-1]>rem)
          continue;
        int ret=1+solve(rem-a[i-1]);
        if(ret>mx){
            mx=ret;
            d=i;
        }
        else if(ret==mx){
            mx=ret;
            d=max(d,i);
        }
    }
    if(d!=0)
    ans.pb(d);
    if(d!=0)
    print(rem-a[d-1]);

}
int main(){
    GO();
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int no;
        cin>>no;
        mark[no]=1;
    }
    clr(mem,-1);
    int mx=solve(n);
    if(mx<=0){
        cout<<"0"<<endl;
        return 0;
    }
    print(n);

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



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
typedef pair<int, int> PII;
typedef long long ll;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, ans;
int d[51];

int main() {

	cin >> n;
	rep(i, n)cin >> d[i];

	rep(i, n) {
		REP(j, i + 1, n) {
			if (i != j) {
				ans += d[i] * d[j];
			}
		}
	}

	cout << ans << endl;

	return 0;
}



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

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

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

// ref. YouTube ABC 152 E
class EratosthenesSieve {
    public:
        const int N;

        EratosthenesSieve(const int N): N(N) {
            numbers.resize(N + 1, 0);
            init();
        }

        // assume that n > 0 && n <= N
        map<int, int> factors(int n) {
            // assert(n > 0 && n <= N); 
            map<int, int> res;
            while (n > 1) {
                res[numbers[n]]++;
                n /= numbers[n];
            }
            return res;
        }

        void primes(vector<int> &p) {
            for (int i = 2; i <= N; i++) {
                if (is_prime(i)) {
                    p.push_back(i);
                }
            }
        }

        // assume that n > 0 && n <= N
        bool is_prime(const int n) {
            // assert(n > 0 && n <= N);
            return numbers[n] == n;
        }

    private:
        vector<int> numbers; // numbers[i] means minimum prime factor for i (e.g. numbers[12] = 2)

        void init() {
            // O(N * log(logN)) ???
            int i = 2;
            for (; i * i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                    for (int j = i * i; j <= N; j += i) {
                        if (numbers[j] == 0) {
                            numbers[j] = i;
                        }
                    }
                }
            }
            for (; i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                }
            }
        }
};

const int MAX_N = 999999;

// ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
int main(void) {
    EratosthenesSieve *sieve = new EratosthenesSieve(MAX_N);
    vector<int> ps;
    sieve->primes(ps);

    char buf[1024];
    while (fgets(buf, 1024, stdin) != NULL) {
        int x = atoi(buf);
        auto y = upper_bound(ps.begin(), ps.end(), x);
        cout << y - ps.begin() << endl;
    }

    delete sieve;
    return 0;
}



Measured memory_bytes: 7156
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o C.exe C.cpp 
Execute: ./C
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, m, k; 
	long a[200000], b[200000]; 
	vector<long long> a_cum (200001, 0), b_cum (200001, 0); 
	int result = 0; 
	
	// Input 
	cin >> n >> m >> k; 
	for(int i = 0; i < n; i++) {
		cin >> a[i]; 
	}
	for(int i = 0; i < m; i++) {
		cin >> b[i]; 
	}
	// Set up cumulative arrays
	a_cum[0] = 0; 
	for(int i = 1; i <= n; i++) {
		a_cum[i] = a_cum[i-1] + a[i-1]; 
	}
	b_cum[0] = 0; 
	for(int i = 1; i <= m; i++) {
		b_cum[i] = b_cum[i-1] + b[i-1]; 
	}
	
	// Solve problem 
	result = 0;
	int j_start; 
	for(int i = 0; i <= n && a_cum[i] <= k; i++) {
		j_start = max(0,min(m, result-i)); 
		for(int j = j_start; j <= m && a_cum[i] + b_cum[j] <= k; j++) {
			if(a_cum[i] + b_cum[j] <= k) {
				if(i + j > result) {
					result = i + j; 
				}
			}
		}
	}
	
	cout << result << endl; 
	
	return 0; 
} 


Measured memory_bytes: 9524
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    s.push_back('.');
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            cnt++;
        }
        else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans;

    return 0;
}


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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            const long MOD = (long)1e9 + 7;
            var N = cin.ReadInt;
            var M = cin.ReadInt;
            if (Abs(N - M) >= 2) { WriteLine(0); return; }
            var x = FactMod(N, MOD);
            var y = FactMod(M, MOD);
            var ans = (x * y) % MOD;
            if (Abs(N - M) == 1) WriteLine(ans);
            else WriteLine((ans * 2) % MOD);
        }

        public static long FactMod(int n, long mod)
        {
            long ans = 1;
            for (int i = n; i >= 2; i--) ans = (ans * i) % mod;
            return ans;
        }
    }

    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;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


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

int main() 
{
    int num = 1,max = 1;
    int max_pri = 0;
    int i,j,k;
    int n=0,m,l;
    std::vector<int> res;
    while(1){
        cin >> num >> max;
        if(num==0&&max==0){
            break;
        }
        std::vector<int> vec(num);
        for(i=0;i<num;i++){
            cin >> vec[i]; 
        }
        for(i=0;i<num;i++){
            for(j=i+1;j<num;j++){
                if(max_pri<vec[i]+vec[j] && vec[i]+vec[j]<= max){
                    max_pri =  vec[i]+vec[j];
                }
            }
        }
        if(max_pri==0){
            res.push_back(-100);
        }else{
            res.push_back(max_pri);
        }
        max_pri = 0;
        n++;
    }
    for(i=0;i<n;i++){
        if(res[i]==-100){
            cout << "NONE" << endl;
        }else{
            cout << res[i] << endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3080
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		System.out.println(
				a.substring(0, 1).toUpperCase() + b.substring(0, 1).toUpperCase() + c.substring(0, 1).toUpperCase());

	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;

int main() {
    std::string N;
    cin >> N;
    size_t size = N.length();
    int sum=0;
    for (int i = 0; i < size; i++) {
        sum += N[i] - '0';
    }
        if (sum % 9 == 0) {
            cout << "Yes";

        }
        else {
            cout << "No";

        }
}

Measured memory_bytes: 3372
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum;
string s;
double ans,a;
LL alp[100000][125];
int main() {
	cin >> N;
	vector<double> v(N);
	ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		ans+=1/a;
	}

	cout << setprecision(16)<<1/ans << endl;
	return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll N, K;
    cin >> N >> K;
    
    if(N % K == 0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl; 
    }
}

Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d %d",$n, $m);

$cards = trim(fgets(STDIN));
$card = explode(" ",$cards);
$mod = [];
while($m--){
    fscanf(STDIN,"%d %d",$B, $C);
    @$mod[$C] += $B;
}

krsort($mod);
sort($card);
$card[$n]= 0;
$j=0;
foreach($mod as $value => $times){
    for($k=0;$k<$times; $k++) {
        if ($card[$j] < $value && $j < $n) {
            $card[$n+1] += $value;
            unset($card[$j]);
            $j++;
        } else {
            break;
        }
    }
}
echo array_sum($card);

Measured memory_bytes: 19188
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
#include <cassert>
#include <tuple>
#include <utility>
using namespace std;

int dist[100001];
vector<int> G[100001];
vector<int> val[100001];

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

  for(int i=0; i<n-1; ++i){
    int a,b;
    scanf("%d%d", &a,&b);
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int k;
  scanf("%d", &k);

  fill(dist, dist+n, 1e8);

  int mn = 1e6, mx=0;
  while(k--){
    int v,p;
    scanf("%d%d", &v, &p);
    v--;

    dist[v] = p;

    mn = min(mn, p);
    mx = max(mx, p);
  }

  if(mx-mn >= n){
    puts("No");
    return 0;
  }

  for(int i=0; i<n; i++){
    if( dist[i] != 1e8 ){
      dist[i] -= mn;
      val[ dist[i] ].push_back( i );
    }
  }

  for(int i=0; i<n; ++i){
    for(int k=0; k<val[i].size(); ++k){
      int p = val[i][k];
      for(int j=0; j<G[p].size(); ++j){
        int nx = G[p][j];
        if( dist[nx] == 1e8 ){
          dist[nx] = dist[p] + 1;
          val[i+1].push_back( nx );
        }
        if( abs(dist[p] - dist[nx]) != 1 ){
          puts("No");
          return 0;
        }
      }
    }
  }

  // for(int i=0; i<n; ++i ){
  //   for(auto j=0; j<G[i].size(); ++j){
  //     if( abs(dist[i]-dist[ G[i][j] ]) != 1 ){
  //       puts("No");
  //       return 0;
  //     }
  //   }
  // }

  puts("Yes");
  for(int i=0; i<n; ++i){
    printf("%d\n", dist[i]+mn);
  }


  return 0;
}


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

int main()
{
   int x,a,b;
   cin >> x >> a >> b;
   int cake = x - a;
   int ans = cake % b;
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    string s;
    cin >> s;
    LL s_size=s.size();
    LL ans=0;
    LL sum=0;
    vector<LL> s_sum(s_size);
    for(LL i=0; i<s_size; i++){
        if(s[i]=='g'){
            sum++;
        }else{
            sum--;
        }
        s_sum[i]=sum;
    }

    LL min_sum=s_sum[s_size-1];
    for(LL i=s_size-1; i>=0; i--){
        min_sum=min(min_sum, s_sum[i]);
        if(s[i]=='g' && min_sum>=2){
            min_sum=min_sum-2;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  string s;
  long long k;
  cin>>s;
  cin>>k;
  bool flag = true;
  //const long long days = 5*1e15;
  if(s[0]=='1'){
    REP(i,k){
      if(s[i]=='1'){
        continue;
      }else{
        flag = false;
        cout<<s[i]<<endl;
        break;
      }
    }
    if(flag){
      cout<<s[0]<<endl;
    }
  }else{
    cout<<s[0]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >>t;
  string ans;
  for(int i =0;i<s.size();i++){
    ans.push_back('z');
  }
  bool flag =false;
  for(int i =0;i<s.size()-t.size()+1;i++){
    bool che =false;
    string kari=s;
    for(int j=0;j<t.size();j++){
      che =true;
      if(kari.at(i+j)=='?'||kari.at(i+j)==t.at(j)){
                kari.at(i+j) =t.at(j);
        continue;
      }
      else{
        che =false;
        break;
      }
    }
    if( che){
      for(int i=0;i<s.size();i++){
        if(kari.at(i) =='?'){
          kari.at(i) ='a';
        }
      }
      if( kari<ans){
        ans =kari;
        flag =true;
      }
    }
  }
  
  cout << (flag ? ans:"UNRESTORABLE");

      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
    int n;
    cin>>n;
    int k=0;
    for(int i=1;i<=10;i++){
        if(i*1000>=n){
            cout<<i*1000-n<<endl;
            return 0;
        }
    }


     }


 


 






    





      

        


Measured memory_bytes: 3596
def solve():
    n_max = 10 ** 5
    is_prime = sieve(n_max)
    is_like_2017 = [False] * (n_max+1)

    for i in range(n_max+1):
        if is_prime[i] and is_prime[(i+1)//2]:
            is_like_2017[i] = True

    l = [0] * (n_max+1)
    r = [0] * (n_max+1)
    for i in range(1,n_max+1):
        if is_like_2017[i]:
            l[i] = l[i-1] + 1
        else:
            l[i] = l[i-1]

    for i in range(n_max-1,-1,-1):
        if is_like_2017[i]:
            r[i] = r[i+1] + 1
        else:
            r[i] = r[i+1]
    
    r.append(r[-1])

    Q = int(input())
    ans = []
    for i in range(Q):
        mn, mx = map(int,input().split())
        ans.append(l[-1] - l[mn-1] - r[mx+1])
    
    print(*ans, sep='\n')

# エラトステネスの篩
# n以下の素数を全列挙
# O(nloglogn)
def sieve(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False

    p = 0
    for i in range(2,n+1):
        if is_prime[i]:
            p = i
            for j in range(p+p, n+1, p):
                is_prime[j] = False
        
        if p * p > n:
            break

    return is_prime

if __name__ == '__main__':
    solve()

Measured memory_bytes: 63064
while True:
    n = int(raw_input())
    if n == 0:
        break
    m,x,d = int(raw_input()),int(raw_input()),int(raw_input())
    amida = ["" for i in range(d)]
    for i in range(d):
        amida[i] = "0" + raw_input() + "0"
    rroot = []
    for i in range(d-1,-1,-1):
        if amida[i][x-1] == "1": x -= 1
        elif amida[i][x] == "1" : x += 1
        rroot.append(x)

    if m == x: print 0
    else:
        root = []
        for i in range(d):
            if amida[i][m-1] == "1": m -= 1
            elif amida[i][m] == "1" : m += 1
            root.append(m)
        rroot.reverse()
        for i in range(d):
            if abs(root[i]-rroot[i]) == 1:
                p = min(root[i],rroot[i])
                if int(amida[i][p-1]) + int(amida[i][p+1]) == 0:
                    print i+1, p
                    break
            if i == d-1: print 1

Measured memory_bytes: 4288
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef signed long long ll;

using namespace std;

ll A[200010];
ll B[200010];

int main(){
	ll N,x,K,T,cnt,k,a,b,lo,hi,ans,T1,T2,T3;
	
	scanf("%ld", &N);
	rep(i,N) scanf("%ld", &A[i]);
	rep(i,N) scanf("%ld", &B[i]);
	
	K=30;
	ans=0;
	
	
	for(int k=K ; k>-1 ; --k){
		T=pow(2,k);

		cnt=0;
		int AM[200010];
		int BM[200010];
		
		rep(i, N) AM[i]= A[i]%(2*T);
		rep(i, N) BM[i]=B[i]%(2*T);
		sort(BM,BM+N);
						
		 for(int i=0 ; i < N; ++i){
			a=AM[i];
			T1=lower_bound(BM,BM+N, T-a )-BM;
			T2=lower_bound(BM,BM+N, 2*T-a )-BM;
			T3=lower_bound(BM,BM+N, 3*T-a ) -BM;
			cnt += (T2-T1)+(N-T3);
		}
		if (cnt%2!=0) ans+=T;
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 4992
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}Node;

int rec(int,int);

Node T[MAX];
int n,D[MAX];

int main(){

  int n,i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    
    for(j=0;j<d;j++){
      scanf("%d",&c);

      if(j==0) T[v].l=c;
      else T[l].r=c;
      
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }

  rec(r,0);
  
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("depth = %d, ",D[i]);
    
    if(T[i].p==NIL) printf("root, ");
    else if(T[i].l==NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(j=0,c=T[i].l;c!=NIL;j++,c=T[c].r){
      if(j) printf(", ");
      printf("%d",c);
    }
    
    printf("]\n");
  }
  
    return 0;
}

int rec(int u,int p){

  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}



/*
#include<stdio.h>
#define MAX 100005
#define NIL -1
  
typedef struct{
  int p;
  int l;
  int r;
}Node;
  
int rec(int,int);
  
Node T[MAX];
int n,D[MAX];
  
int main(){
  
  int n,i,j,d,v,c,l,r;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
      
    for(j=0;j<d;j++){
      scanf("%d",&c);
  
      if(j==0) T[v].l=c;
      else T[l].r=c;
        
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }
  
  rec(r,0);
    
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("depth = %d, ",D[i]);
      
    if(T[i].p==NIL) printf("root, ");
    else if(T[i].l==NIL)printf("leaf, ");
    else printf("internal node, ");
  
    printf("[");
    for(j=0,c=T[i].l;c!=NIL;j++,c=T[c].r){
      if(j!=0) printf(", ");
      printf("%d",c);
    }
      
    printf("]\n");
  }
    
    return 0;
}
  
int rec(int u,int p){
  
  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}
*/



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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

template <typename T> T gcd(T a, T b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

template <typename T> T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

void solve() {
    int n;
    cin >> n;

    n = n % 10;

    switch (n) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
  int w,price;
  
  for(;;){
    scanf("%d",&w);
    if(w==-1)
      break;

    price=1150;
    if(w>10){
      if(w<20)
	price+=125*(w-10);
      else
	price+=1250;
    }
    if(w>20){
      if(w<30)
	price+=140*(w-20);
      else
	price+=1400;
    }
    if(w>30)
      price+=160*(w-30);
    
    printf("%d\n",4280-price);
  }
  return 0;
}

Measured memory_bytes: 0
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    sunuke = 0
    arai = sum(a)
    ans = float("inf")
    for i in range(n-1):
        sunuke += a[i]
        arai -= a[i]
        ans = min(ans,abs(sunuke-arai))

    print(ans)
main()            


Measured memory_bytes: 101536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7, A = 1e5+5;
ll fp(ll x, ll y)
{
	if (!y)
		return 1;
	ll acc = fp(x, y / 2) % mod;
	acc = (acc * acc) % mod;
	if (y & 1)
		return ((acc % mod) * (x % mod)) % mod;
	return acc;
}
ll divmod(ll x, ll y)
{
	return ((x % mod) * fp(y, mod-2) % mod) % mod;
}
ll gcd(ll x, ll y)
{
	return (!y) ? x : gcd(y, x % y);
}
ll lcm(ll x, ll y)
{
	return divmod(((x % mod) * (y % mod)) % mod, gcd(x, y));
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	ll a[n], lc = 1, ans = 0;
	unordered_map <ll, ll> mop, tmp;
	for (int i = 0, x; i < n; i++)
	{
		cin >> a[i], x = a[i];
		for (int j = 2; j <= sqrt(x); j++)
		{
			while (x % j == 0)
				x /= j, tmp[j]++;
		}
		if (x > 1)
			tmp[x]++;
		for (auto j : tmp)
			mop[j.F] = max(mop[j.F], j.S);
		tmp.clear();
	}
	for (auto i : mop)
		lc = ((lc % mod) * (fp(i.F, i.S) % mod)) % mod;
	for (int i = 0; i < n; i++)
		ans += divmod(lc, a[i]), ans %= mod;
	cout << ans;
	return 0;
}


Measured memory_bytes: 768
class UnionFind(object):
    def __init__(self, size):
        self.size = size
        self.parents = list(range(size))
        self.counts = [1] * size

    def find(self, x):
        history = []
        while self.parents[x] != x:
            history.append(x)
            x = self.parents[x]
        
        for i in history: 
            self.parents[i] = x
        return x
    
    def union(self, x1, x2):
        y1 = self.find(x1)
        y2 = self.find(x2)
        if y1 != y2:
            self.parents[y2] = y1
            self.counts[y1] += self.counts[y2]

    def count(self, x):
        return self.counts[self.find(x)]
    
if __name__ == '__main__':
    n, m = map(int, input().split())
    alist = []
    blist = []
    for _ in range(m):
        a, b = map(int, input().split())
        alist.append(a - 1)
        blist.append(b - 1)

    answers = [n * (n - 1) // 2]
    uf = UnionFind(n)

    for a, b in zip(reversed(alist), reversed(blist)):
        answers.append(answers[-1])
        c = uf.find(a)
        d = uf.find(b)
        if c == d: 
            continue
  
        answers[-1] -= uf.count(a) * uf.count(b)
        uf.union(a, b)

    for i in reversed(range(m)):
        print(answers[i])

Measured memory_bytes: 19556
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

  for(int i=0;i<s.size();i++){
    if(s[i]!=s[s.size()-1-i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<tuple<string, int, int>> P(N);
  rep(i, N)
  {
    string a;
    int b;
    cin >> a >> b;
    P.at(i) = make_tuple(a, b * -1, i);
  }

  sort(P.begin(), P.end());
  //reverse(P.begin(), P.end());
  vector<int> d(N);
  rep(i, N)
  {
    string a;
    int b, c;
    tie(a, b, c) = P.at(i);
    //d.at(i) = c;
    cout << c + 1 << endl;
  }
}


Measured memory_bytes: 3616
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
    }
    let mut hm = HashMap::new();
    for _ in 0..n {
        input! {
            s: String,
        }
        let entry = hm.entry(s).or_insert(0);
        *entry += 1;
    }

    input! {
        m: usize,
    }
    for _ in 0.. m {
        input! {
            s: String,
        }
        let entry = hm.entry(s).or_insert(0);
        *entry -= 1;
    }

    let mut ans = 0;
    for (_, v) in &hm {
        ans = ans.max(*v);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define sz size()
#define vec vector<int>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, int now) {
	/*if (depth == n)return !now;
	for (int i = 0; i < k; i++) {
		if (dfs(depth + 1, now ^ t[depth][i]))return true;
	}
	/**/
	return false;
}



int main() {
	int k, x; cin >> k >> x;
	if (k * 500 >= x)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!(str = br.readLine()).equals("0")){
			int num = Integer.parseInt(str);
			ArrayList<String> read_str = new ArrayList<String>();
			int max_length = 0;
			for(int i = 0; i<num; i++){
				String read = br.readLine();
				if(read.length()>max_length){
					max_length = read.length();
				}
				read_str.add(read);
			}
			System.out.println(check_state(max_length, read_str));
		}
	}

	public static int check_state(int length, ArrayList<String> read_list){
		char boin[] = {'a','i','u','e','o'};
		String str;
		int max_k = 1;
		ArrayList<String> list = new ArrayList<String>();
		for(int i= 0; i<read_list.size(); i++){
			StringBuilder build = new StringBuilder();
			char array[] = read_list.get(i).toCharArray();
			boin_add(array, boin , build,length);
			str = new String(build);
			if(str.length()>max_k){
				max_k = str.length()+1;
			}
			list.add(str);
		}

		for(int i = 1; i<51; i++){
			ArrayList<String> check_list = new ArrayList<String>();
			for(int j = 0; j<list.size(); j++){
				if(i > list.get(j).length()){
					str = list.get(j).substring(0, list.get(j).length());
				}else{
					str = list.get(j).substring(0, i);
				}
				if(check_list.indexOf(str) != -1){
					break;
				}
				check_list.add(str);
			}
			if(check_list.size()==list.size()){
				return i;
			}
		}
		return -1;
	}

	public static void  boin_add(char array[], char boin[], StringBuilder build,int length){
		build.append(array[0]);
		for(int s = 0; s<length; s++){
			for(int j = 0; j<boin.length; j++){
				if(s>=array.length-1){
					return;
				}
				if(array[s] == boin[j]){
					build.append(array[s+1]);
				}
			}
		}
	}
}

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

typedef long long ll;

int main()
{
	ll n, k, x, ans;
	cin >> n >> k;
	x = n / k;
	if(k& 1) ans = x * x * x;
	else
	{
		ll y = x;
		if(n % k >= k / 2) ++y;
		ans = x * x * x + y * y * y;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			String packageName = new Main().getClass().getPackage().getName();
			System.setIn(new FileInputStream("src/" + packageName + "/input.txt"));
			// System.setOut(new PrintStream(new FileOutputStream("src/" + packageName + "/result.txt")));
		} catch (FileNotFoundException e) {
		} catch (NullPointerException e) {
		}
		new Main().run();
	}

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		int T = sc.nextInt();
		while (T -- > 0) solve();
	}
	void solve() {
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int P = sc.nextInt();
		boolean[][][][] cannot = new boolean[X+2][Y+2][X+2][Y+2];
		for (int p = 0; p < P; p++) {
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			cannot[x1][y1][x2][y2] = true;
			cannot[x2][y2][x1][y1] = true;
		}
		long[][] dp = new long[X+2][Y+2];
		dp[0][0] = 1;
		for (int x = 0; x <= X; x++)
			for (int y = 0; y <= Y; y++) {
				if (!cannot[x+1][y][x][y]) dp[x+1][y] += dp[x][y];
				if (!cannot[x][y+1][x][y]) dp[x][y+1] += dp[x][y];
			}
		if (dp[X][Y] == 0)
			System.out.println("Miserable Hokusai!");
		else
			System.out.println(dp[X][Y]);
	}

}

Measured memory_bytes: 13000
#include<iostream>
#include<string.h>
using namespace std;

int main(){ 
  int n, k;
  cin >> n >> k;
  int nums[10]{};
  
  while(k--){
    int index;
    cin >> index;
    nums[index]++;
  }

  bool found = false;
  int pay = n;
    
  while(!found){
	string money =  to_string(pay);
    bool have = true;
    for(int i=0;i<money.length();++i){
    	char c = money[i];
      	int digit = c -'0';
      	if(nums[digit]==1){
        	have = false;
          	break;
        }
    }
    if(have) found = true;
    else pay++;
  }
  cout << pay << endl;
  
  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
const int N = 100010;//10^5+10

int main() {

	int n, m, x, y; cin >> n >> m >> x >> y;

	vector<int> a(n);
	vector<int> b(m);

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

	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int z = a[n - 1]+1;
	int bmin = b[0];

	if (z > x && z <= y && z<=bmin) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n,ans=1;
    cin>>n;
    map<ll,ll> m;
    for(ll ind=2;ind<=n;ind++){
        ll k=ind;bool flag;
        while(k>1)
    {
        ll s=sqrt(k)+1;flag=false;ll i=2;
        while(k%i!=0){
            if(i>=s){
                flag=1;break;
            }
            i++;
        }
        if(flag){
           m[k]++;  k=1;
        }
        else{
            k/=i;  m[i]++;
        }
    }
    }
    for(auto x:m){
        if(x.first==1) continue;
        ans=(ans*(x.second+1))%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if ( x-r >= 0 && y-r >= 0 ){
        if ( x+r <= W && y+r <= H ){
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    } else {
        printf("No\n");
    }
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int A, B;
	cin >> A >> B;
	ce(A*B)
    return 0;
}



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

int main(){
  int N;
  int red=0;
  int blue=0;
  cin>>N;
  char S[N+1]; 
  
  for(int i=1; i<=N; ++i){
    cin>>S[i];
    if(S[i]=='R') red += 1;
    else blue += 1;
  }
  
  if(red>blue) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
while (--$n) {
	fscanf(STDIN, "%d %d %d", $a, $b, $c);
	$g[$a][$b] = $g[$b][$a] = $c;
}
fscanf(STDIN, "%d %d", $q, $k);
$d[$k] = 0;
$tmp[] = $k;
while ($tmp) {
	$a = array_pop($tmp);
	foreach ($g[$a] as $b => $c) {
		if (!isset($d[$b])) {
			$d[$b] = $d[$a] + $c;
			$tmp[] = $b;
		}
	}
}
while ($q--) {
	fscanf(STDIN, "%d %d", $x, $y);
	$ans[] = $d[$x] + $d[$y];
}
echo implode("\n", $ans);

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

int main() {
  int n;
  cin >> n;
  vector<string> S(n);
  for (int i = 0; i < n; ++i)
    cin >> S[i];

  vector<vector<int>> alpha(n, vector<int>(26));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < S[i].size(); ++j)
      ++alpha[i][S[i][j] - 'a'];

  string ans;
  for (int i = 0; i < 26; ++i) {
    int alpha_n = 1000000001;
    for (int j = 0; j < n; ++j)
      alpha_n = min(alpha[j][i], alpha_n);
    for (int k = 0; k < alpha_n; ++k)
      ans += 'a' + i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256