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

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

  map<string, int> s;
  for(int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    s[str]++;
  }

  int max_count = 0;
  set<string> s_s;
  for(map<string, int>::iterator it = s.begin(); it != s.end(); ++it) {
    if(it->second > max_count) {
      s_s = set<string>();
      s_s.insert(it->first);
      max_count = it->second;
    } else if(it->second == max_count) {
      s_s.insert(it->first);
    }
  }

  for(set<string>::iterator it = s_s.begin(); it != s_s.end(); ++it) cout << *it << endl;

  return 0;
}

Measured memory_bytes: 34560
/**
 *    author:  morato
 *    created: 19.09.2020 17:39:05
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  int ans = 0;
  for (int a = 1; a < n; a++) {
    int menor = 1;
    int maior = min((n - 1) / a, n - 1);
    ans += maior - menor + 1;
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
	int H, W;

	while (1) {

		cin >> H >> W;
	
		if (H == 0 && W == 0)break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}

		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();

			if (n == 0) {
				out.println(0);
				return;
			}

			StringBuilder sb = new StringBuilder();
			while (n != 0) {
				if (n % 2 == 0) {
					sb.append(0);
					n /= (-2);
				} else {
					sb.append(1);
					if (n < 0) {
						n = (n-1) / (-2);
					} else {
						n /= (-2);
					}
				}
			}

			out.println(sb.reverse().toString());

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

int main(){
	string s;
	cin >> s;
  	int n = s.length();
  	vector<long> x(n);
	
  	bool rnow = true, nowisodd = true;
  	int lnowhere;
 	int oddn=0, evenn=0;
  	for(int i = 0; i < n; i++) {
		if(rnow && s[i] == 'L') {
          	x[i]++;
          	x[i-1] += nowisodd ? evenn : oddn;
        	x[i]   += nowisodd ? oddn : evenn;
        	rnow = false;
          	nowisodd = true;
          	lnowhere = i;
          	oddn = evenn = 0;
        } else if(!rnow && s[i] == 'R' || i == n-1) {
          	x[lnowhere-1] += oddn;
        	x[lnowhere] += evenn;
          	if(i == n-1) {
            	if(!nowisodd)
                  	x[lnowhere]++;
              	else
                	x[lnowhere-1]++;
            }
          	rnow = true;
          	nowisodd = false;
          
          	oddn = 1, evenn = 0;
        } else {
      		if(nowisodd)
              	oddn++;
            else
              	evenn++;
          	nowisodd = !nowisodd;
        }
    }
  	for(int i = 0; i < n-1; i++)
      	cout << x[i] << " ";
  	cout << x[n-1] << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=110;
char s[maxn];
int a[maxn],b[maxn];
int n;
int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%d%s",&n,s)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for (int i=0;i<n;i++) b[s[i]-'a']++;
        int ans=0;
        for (int i=0;i<n;i++)
        {
            a[s[i]-'a']++;
            b[s[i]-'a']--;
            int t=0;
            for (int j=0;j<='z'-'a';j++)
                if (a[j] && b[j])
                    t++;

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


Measured memory_bytes: 888
import sys

s = int(input())
a = []
a.append(s)
i = 1
while True:
    n = 0
    if a[i-1] %2 ==0:
        n = a[i-1]/2
    else:
        n = a[i-1]*3 +1
    i +=1
    if n in a:
        print(i)
        sys.exit()
    a.append(n)


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

int main(void){
    string s,t;
    cin >> s >> t;
    for(int i = 0;i < s.size();i++){
        if(s.at(i) != t.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3132
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        int st = int.MaxValue;
        int ed = -1;
        for(int i=0; i<s.Length; i++) {
            if(s[i] == 'A') st = Math.Min(st, i);
            if(s[i] == 'Z') ed = Math.Max(ed, i);
        }

        return ed - st + 1;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define S(v) sort(v.begin(),v.end());
const ll mod = 1E9+7;
int main()
{
   ll n;
   cin>>n;
   ll ans = 0;
   loop(i,0,n){
      ll x;
      cin>>x;
      if(i%2 == 0 && x%2 == 1)ans++;
   }
   cout<<ans<<endl;
   
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  map<string, int> mp;
  int N; cin >> N;
  REP(i, N){
    string S; cin >> S;
    mp[S]++;
  }
  int M; cin >> M;
  REP(i, M){
    string S; cin >> S;
    mp[S]--;
  }
  int ans = 0;
  for(auto i : mp){
    ans = max(ans, i.second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, ans = 0;
  cin >> N;
  for (int i=1; i<=N; i++){
    if(i%3 == 0 && i%5 == 0)
      continue;
    else if(i%3 == 0 || i%5 == 0)
      continue;
    else
      ans += i;
  }
  cout << ans << endl;
}

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

int main(){
	int n,m;
	cin>>n;
	m=n;
	int x=0;
	for(int i=0;i<9;i++){
		x+=n%10;
		n/=10;
	}
	if(m%x==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll f[501100][3],ans;
int n;
char s[501100];
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	if(n<3){
		cout<<0<<endl;
		return 0;
	}
	s[0]='0';s[n+1]='0';s[n+2]='0';
	int last,now;
	last=0;now=1;
	while(now<=n+2){
		while(s[now]!='0')now++;
		if(now==last+1){
			ans+=max(f[last][0],max(f[last][1],f[last][2]));
			last=now;
			now++;
			continue;
		}
		f[now][0]=max(f[last][0],max(f[last][1],f[last][2]));                   //原地不动 
		if(s[now+1]=='1'){
			if(now==last+2)
				f[now][1]=f[last][0]+now-last-1;
			else
				f[now][1]=max(f[last][1]+now-last-2,f[last][0]+now-last-1);
		}                  //向左走 
		if(s[now-1]=='1'){
			int i=now;
			while(i+1<=n&&s[i+1]=='1')i++;
			if(now==last+2)
				f[now][2]=f[last][0]+i-now;
			else
				f[now][2]=max(max(f[last][0],f[last][1]),f[last][2]-1)+i-now;
		}
		last=now;
		now++;
	}
	printf("%lld\n",ans);
} 

Measured memory_bytes: 12416
#include<iostream>
#include<vector>
#include<cassert>
#include<algorithm>

using namespace std;
struct Piece{
  int w,h;
  Piece(){}
  Piece(int w, int h):w(w),h(h){}
  int getArea(){return w*h;}
  bool operator < (const Piece& p) const{return w*h < p.w*p.h;}
  bool operator > (const Piece& p) const{return w*h > p.w*p.h;}
};
typedef vector<Piece>::iterator ITE;

int n,w,d;
vector<Piece> V;


void init(){
  V.clear();
  V.push_back(Piece(w,d));
}

void cut(int p, int s){

  Piece now = V[p-1];
  V.erase((ITE)&V[p-1]);
  
  int dx[] = {1,0,-1,0};
  int dy[] = {0,1,0,-1};
  int d = 0;
  int cx = 0,cy = 0;
  while(1){
    if(d%2){
      // y-axis
      if(s > now.h){
	s -= now.h;
	cy = now.h;
      }else{
	cy = s;
	s = 0;
	break;
      }
    }else{
      // x-axis
      if(s > now.w){
	s -= now.w;
	cx = now.w;
      }else{
	cx = s;
	s = 0;
	break;
      }
    }
    d = (d+1)%4;
  }
  
  Piece a,b;
  if(d%2){
    // cut horizonal
    a = Piece(now.w,cy);
    b = Piece(now.w,now.h-cy);
  }else{
    // cut vertical
    a = Piece(cx,now.h);
    b = Piece(now.w-cx,now.h);    
  }
  
  if(a > b) swap(a,b);
  
  V.push_back(a);
  V.push_back(b);

}

void solve(){
  
  for(int i = 0; i < n; i++){
    int p,s;
    cin >> p >> s;
    cut(p,s);
  }
  sort(V.begin(),V.end());
  for(int i = 0; i < V.size(); i++){
    if(i) cout << " ";
    cout << V[i].getArea();
  }
  cout << endl;
}

int main(){

  while(cin >> n >> w >> d && n+w+d){
    init();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef tuple<int, int, int> P;

vector<vector<int>> G;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
int main() {
  int N, M; cin >> N >> M;
  G.resize(N);
  for (int i = 0; i < M; ++i) {
    int A, B; cin >> A >> B; --A, --B;
    G[A].push_back(B);
    G[B].push_back(A);
  }

  vector<int> no(N, -1);
  no[0] = 0;

  priority_queue<P, vector<P>, greater<P>> que;
  for (int v : G[0]) {
    que.push({0, v, 1});
  }

  while (!que.empty()) {
    auto [d, v, p] = que.top(); que.pop();
    if (no[v] >= 0) continue;
    no[v] = p;
    for (int u : G[v]) {
      que.push({d + 1, u, v + 1});
    }
  }

  for (int i = 1; i < N; ++i) {
    if (no[i] < 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < N; ++i) {
    cout << no[i] << endl;
  }
}


Measured memory_bytes: 16152
h, w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))

color = []
for i in range(n):
    color += [i+1]*a[i]
    
#print(color)

ans = [[0]*w for _ in range(h)]

now = 0
for row in range(h):
    for col in range(w):
        if row%2 == 0:
            ans[row][col] = color[now]
        else:
            ans[row][-(col+1)] = color[now]
        now += 1
        
for r in ans:
    print(*r)

Measured memory_bytes: 9484
#include <iostream>

using namespace std;

int GCD(int a, int b)
{
    if (b == 0)
        return a;

    return GCD(b, a % b);
}

int LCM(int a, int b)
{
    return a  / GCD(a, b) * b;
}

int main()
{
	int n;

	cin >> n;

	int v1, v2, lcm;
	cin >> v1;
	cin >> v2;
	lcm = LCM(v1, v2);

	for (int i = 2; i < n; i++) {
		cin >> v1;
		lcm = LCM(lcm, v1);
	}
	cout << lcm << endl;
	return 0;
}



Measured memory_bytes: 3116
n,a,b,c = map(int, input().split())
s = [input() for _ in range(n)]

d = {'A':a,'B':b,'C':c}

ans = ['Yes']

for i in range(n):
    if d[s[i][0]] == 0 and d[s[i][1]] == 0:
        print('No')
        exit()
    if d[s[i][0]] == 1 and d[s[i][1]] == 1 and n-i > 1:
        d[s[i][0]] = 2
        d[s[i][1]] = 0
        if d[s[i+1][0]] == 0 and d[s[i+1][1]] ==0:
            d[s[i][0]] = 0
            d[s[i][1]] = 2
            ans.append(s[i][1])
        else:
            ans.append(s[i][0])
    elif d[s[i][0]] >= d[s[i][1]]:
        d[s[i][0]] = d[s[i][0]] - 1
        d[s[i][1]] = d[s[i][1]] + 1
        ans.append(s[i][1])
    else:
        d[s[i][0]] = d[s[i][0]] + 1
        d[s[i][1]] = d[s[i][1]] - 1
        ans.append(s[i][0])

for i in range(n+1):
    print(ans[i])

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

using namespace std;


void pln()
{
	cout << endl;
	return;
}

void print(int x)
{
	cout << x << endl;
	return;
}

void print(string str) {
	cout << str << endl;
	return;
}

int ri() {
	int x;
	cin >> x;
	return x;
}

string rs() {
	string str;
	cin >> str;
	return str;
}

int main(void)
{
	int N = ri();
	int A = ri();

	int ret = N % 500;

	if (A>=ret)
	{
		print("Yes");
	}
	else {
		print("No");
	}

}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (B == 1) {
            out.println(0);
            return;
        }

        if (B <= A) {
            out.println(1);
            return;
        }

        int num = 1;
        int output = A;
        while (true) {
            output += A - 1;
            num += 1;
            if (B <= output) {
                break;
            }
        }
        out.println(num);
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long
#define PI 3.14159265358979323846264

int A, B, H, M;

int main()
{
	cin >> A >> B >> H >> M;
	int a = H*60+M; // [0, 12*60)
	double at = a*2.0*PI/720;
	int b = M*12;
	double bt = b*2.0*PI/720;

	double ay = A, ax = 0;
	double by = B, bx = 0;

	double nay, nax, nby, nbx;
	nax = cos(at)*ax - sin(at)*ay;
	nay = sin(at)*ax + cos(at)*ay;

	nbx = cos(bt)*bx - sin(bt)*by;
	nby = sin(bt)*bx + cos(bt)*by;
	printf("%.12f", sqrt((nax-nbx)*(nax-nbx)+(nay-nby)*(nay-nby)));
	return 0;
}

Measured memory_bytes: 4072
import numpy as np
H, W, K = (int(i) for i in input().split())
C = np.zeros((H, W))
for h in range(H):
    C[h,:] = [int(i=='#') for i in list(input())]
res = 0
for i in range(2 ** H):
    for j in range(2 ** W):
        hv = np.array(list(format(i, '0{}b'.format(H))), dtype='int')
        wv = np.array(list(format(j, '0{}b'.format(W))), dtype='int')
        if C[hv==1,:][:, wv==1].sum() == K:
            res = res + 1
print(res)

Measured memory_bytes: 27172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
int n, m;
vector< vector<int> > path;
bool visited[100005] = {};
int dp[100005];

void dfs(int u) {
  if (visited[u]) {
    return;
  }
  visited[u] = 1;
  for (int i=0; i<(int)path[u].size(); ++i) {
    int v = path[u][i];
    if (!visited[v]) {
      dfs(v);
    }
    chmax(dp[u], 1+dp[v]);
    
  }
}

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

  path.resize(n);
  int x, y;
  for (int i=0; i<m; i++) {
    cin >> x >> y;
    x--; y--;
    path[x].push_back(y);
  }

  for (int i=0; i<n; i++) {
    if (!visited[i]) {
      dfs(i);
    }
  }
  
  int ans = 0;
  for (int i=0; i<n; i++) {
    chmax(ans, dp[i]);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    cin>>s;
    ll dp[s.size()+1][13];
    vector<ll>mod = {1,10,9,12,3,4};
    for(int i=0;i<s.size()+1;i++){
        for(int j=0;j<13;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    // cout<<"AAA"<<endl;

    for(int i=1;i<s.size()+1;i++){
        // cout<<"AAA"<<endl;
        if(s.at(s.size()-i)=='?'){
            int x = mod.at((i-1)%6);
            for(int j=0;j<=12;j++){
                for(int k=0;k<=9;k++){//?が幾つなのか。
                    dp[i][(j+x*k)%13] = (dp[i-1][j]+dp[i][(j+x*k)%13])%1000000007;
                    // for(int q=0;q<=s.size();q++){
                    //     for(int w=0;w<=12;w++){
                    //         cout<<dp[q][w]<<" ";
                    //     }
                    //     cout<<endl;
                    // }
                    // cout<<"---------------------"<<endl;
                }
            }
            // cout<<"BBB"<<endl;
        }
        else{
            int x = mod.at((i-1)%6);
            for(int j=0;j<=12;j++){
                dp[i][(j+x*(s.at(s.size()-i)-'0'))%13] = dp[i-1][j];
            }
            // cout<<"AAA"<<endl;
        }
    }
    cout<<dp[s.size()][5]<<endl;
    // for(int q=0;q<=s.size();q++){
    //     for(int w=0;w<=12;w++){
    //         cout<<dp[q][w]<<" ";
    //     }
    //     cout<<endl;
    // }





    return 0;
}


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

typedef long long ll;

int n,k,a[100];
ll d[100][100001],p=1e9+7;

int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(k==0){
        cout<<1<<endl;
        return 0;
    }
    for(int i=0;i<=k;i++){
        if(i<=a[0])d[0][i]=i+1;
        else d[0][i]=a[0]+1;
    }
    for(int i=1;i<n;i++){
        d[i][0]=d[i-1][0];
        for(int j=1;j<=k;j++){
            d[i][j]=d[i][j-1];
            if(j<=a[i])d[i][j]+=d[i-1][j];
            else d[i][j]+=d[i-1][j]-d[i-1][j-a[i]-1]+p;
            d[i][j]%=p;
        }
    }
    cout<<(d[n-1][k]-d[n-1][k-1]+p)%p<<endl;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

const int N = 200005;
int dir[4]{-1, 1, 0, 0};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, k, sx, sy, gx, gy;
    cin >> h >> w >> k;
    cin >> sx >> sy >> gx >> gy;
    sx--, sy--, gx--, gy--;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];

    ll dist[h][w];
    rep(i, h) rep(j, w) dist[i][j] = 1e9;
    dist[sx][sy] = 0;
    queue<vl> q;
    q.push({0ll, sx, sy});
    while (!q.empty()) {
        auto state = q.front();
        q.pop();
        ll cost = state[0];
        ll cx = state[1];
        ll cy = state[2];
        rep(i, 4) {
            for (int hop = 1; hop <= k; hop++) {
                ll nx = cx + dir[i] * hop;
                ll ny = cy + dir[3 - i] * hop;
                if (nx >= h || ny >= w || nx < 0 || ny < 0 || grid[nx][ny] == '@')
                    break;
                if (dist[nx][ny] > cost + 1) {
                    dist[nx][ny] = cost + 1;
                    q.push({cost + 1, nx, ny});
                } else if (dist[nx][ny] == cost + 1)
                    continue;
                else
                    break;
            }
        }
    }
    cout << (dist[gx][gy] == 1e9 ? -1ll : dist[gx][gy]) << endl;
}

Measured memory_bytes: 18844
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    rep(i, 0, n + 1){
        rep(j, 0, m + 1){
            if(i * m + j * n - 2 * i * j == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

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

int main(){
    int x;
    cin >> x;
    vector<bool> flg(1001, false);
    flg[1] = true;
    for ( int i = 2; i <= 1000; ++i ) {
        int tmp_num = i * i;
        while(1) {
            if ( tmp_num > 1000 ) break;
            flg[tmp_num] = true;
            tmp_num *= i;
        }
    }
    for ( int i = x; i >= 0; --i ) {
        if ( flg[i] ) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

set<vector<int> > s;
map<vector<int>, int> mp;

vector<int> digits(string s) {
	vector<int> res;
  	for (int i = 0; i < 26; i++)
    	res.push_back(0);
  	for (int i = 0; i < s.size(); i++)
      	res[s[i] - 'a']++;
  	return res;
}

int main() {
	int n;
  	cin >> n;
  	string t;
  	for (int i = 0; i < n; i++) {
    	cin >> t;
      	vector<int> v = digits(t);
      	s.insert(v);
      	mp[v]++;
    }
  	long long ans = 0;
  	while(s.size()) {
    	vector<int> v = *s.begin();
      	s.erase(s.begin());
      	ans += (long long)mp[v] * (long long)mp[v] - (long long)mp[v];
    }
  	ans /= 2;
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 36224
n,k = map(int,input().split())
human = [0]*n
for i in range(k*2):
  if i % 2 == 0:
    num = map(int,input())
  else:
    list1=list(map(int, input().split()))
    for i in list1:
      human[i - 1] = 1

cnt = 0
for i in human:
  if i == 0:
    cnt +=1
print(cnt)

Measured memory_bytes: 8964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll wt[100+10], v[100+10], memo[100+10][100000+10];
ll dp[100000+10];
ll n,W;
// ll go(int i, int w) {
//     if (i==n) return 0;
//     if (memo[i][w] != -1) return memo[i][w];
//     ll best = go(i+1,w);
//     if (w+wt[i] <= W) best = max(best, go(i+1,w+wt[i])+v[i]);
//     return memo[i][w] = best;
// }
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n >> W;
    // for (int i = 0; i < n; i++) cin >> wt[i] >> v[i];
    // memset(memo, -1, sizeof memo);
    // cout << go(0, 0) << endl;
    for (int i = 1; i <= n; i++) cin >> wt[i] >> v[i];
    for (int i = 1; i <= n; i++) {
        for (ll j = W; j >= wt[i]; j--) {
            dp[j] = max(dp[j], dp[j-wt[i]]+v[i]);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= W; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4448
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

namespace IO {
    template <typename _T>
    inline bool read (_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return false;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input () {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};
using namespace IO;

namespace modular {
    const int MOD = 1000000007;

    inline int add (int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }

    inline void inc (int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }

    inline int mul (int x, int y) { return 1LL * x * y % MOD; }

    inline int qpow (int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x)) if (y & 1) ans = mul(ans, x);
        return ans;
    }
};

#define reg register
#define MAX_N 200007
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define lep(i, l, r) for(int i = l; i < r; ++i)
#define irep(i, r, l) for(int i = r; i >= l; --i)
#define ilep(i, r, l) for(int i = r; i > l; --i)
typedef long long ll;

int N, res;
int head[MAX_N], to[MAX_N << 1], nxt[MAX_N << 1], cap;
int ban[MAX_N];

inline void addE (int u, int v) {
    nxt[++cap] = head[u];
    head[u] = cap;
    to[cap] = v;
}

void dfs (int x, int las) {
    int t = 0, y = 0, z = 0;
    for (int i = head[x]; i; i = nxt[i]) if (to[i] != las) {
        dfs(to[i], x);
        z |= (t & ban[to[i]]);
        t |= ban[to[i]];
        ban[x] |= ban[to[i]];
    }
    int lb = 0, pos = 0;
    rep (i, 0, 30) if (z >> i & 1) pos = i + 1;
    rep (i, pos, 30) if (!(ban[x] >> i & 1)) { lb = i; break; }
    rep (i, 0, lb - 1) if (ban[x] >> i & 1) ban[x] ^= (1 << i);
    ban[x] |= (1 << lb);
    // printf("%d %d %d %d\n", x, lb, ban[x], pos);
    res = std::max(res, lb);
}

int main () {
#ifdef LOCAL
    FIN("in");
#endif
    read(N);
    int u, v;
    rep (i, 2, N) {
        read(u), read(v);
        addE(u, v);
        addE(v, u);
    }
    dfs(1, 0);
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int H,W,A,B;cin >> H >> W >> A >> B;
  vector<vector<int> > v(W,vector<int> (H));
  int add = 0;
  rep(y,H){
    rep(x,W){
      if(x==A) add^=1;
      v[x][y] = add;
    }
    if(y/2 >= B) add^=1;
  }
  rep(y,H){
    rep(x,W){
      cout << v[x][y];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 5248
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, S;
ll A[3010];
mint dp[3010][3010];

int main()
{
  std::cin >> N >> S;

  rep( i, N )
    std::cin >> A[i];

  dp[0][0] = 1;

  rep( i, N ) rep( j, S+1 )
  {
    dp[i+1][j] += dp[i][j]*2;

    if( j+A[i] <= S )
      dp[i+1][j+A[i]] += dp[i][j];
  }

  std::cout << dp[N][S].x << std::endl;

  return 0;
}

Measured memory_bytes: 73760
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {
    long long int a, b, d=0;
    cin >> a >> b;
    long long int c[a];
    for(int i=0;i<a;i++) cin >> c[i];
    if(a > b) {
        sort(c, c+a, greater<int>());
        for(int i=b;i<a;i++) d+=c[i];
    }
    cout << d << endl;
}

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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s,t;
	int mn=2e18;
	cin>>s>>t;
	forn(i,0,s.size()-t.size()+1){
		int cnt=0;
		forn(j,0,t.size()){
			if (t[j]!=s[i+j])
				cnt++;
		}
		mn=min(mn,cnt);
	}
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 3660
n = int(input())
a = list(map(int,input().split()))
print(' '.join(map(str,a)))
for i in range(1,n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(' '.join(map(str,a)))


Measured memory_bytes: 5600
dic = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(int(input())):
    dic[input()] += 1
print(f"AC x {dic['AC']}")
print(f"WA x {dic['WA']}")
print(f"TLE x {dic['TLE']}")
print(f"RE x {dic['RE']}")


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <stdio.h>
# define M_PI  3.14159265358979323846
using namespace std;

typedef long long ll;
const int N = 1e5 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;
const int mod = 1000000000+7;

int x, a;


int main(){
	//freopen ("i.in","r",stdin);
	//freopen ("no.out","w",stdout);

	scanf("%d%d", &x, &a);
	if(x < a) puts("0");
	else puts("10");
	
	
	return 0;
}


Measured memory_bytes: 256
[n, m] = [int(s) for s in input().split()]
h = [int(s) for s in input().split()]
r = [[] for _ in range(n)]

for _ in range(m):
    [a, b] = [int(s)-1 for s in input().split()]
    r[a].append(b)
    r[b].append(a)

print(len([0 for i, hi in enumerate(h) if len([0 for j in r[i] if h[j] >= hi]) == 0]))

Measured memory_bytes: 29980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int count = 0;
		for(int i = 0; i < N; i++) {
			if(A[i] >= K) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}

}


Measured memory_bytes: 50364
#include <iostream>

using namespace std;

int n, k;

int able_to_load(int loadMax, int weight[])
{
  int v = 0, i, j = 0, track[100000];
  
  for(i = 0;i < k;i++){
    track[i] = loadMax;
  }
  
  for(i = 0;i < n;){
    if(j == k){
      break;
    }
    if(track[j] - weight[i] >= 0){
      track[j] -= weight[i];
      v++;
      i++;
    }
    else{
      j++;
    }
  }
  return v;
}

int main(void)
{
  int i, P = 0, weight[100000],WeightMAX = 0;
  
  cin >> n >> k;
  
  for(i = 0;i < n;i++){
    cin >> weight[i];
    WeightMAX += weight[i];
  }
  
  int mid, left, right,flag = 0;

  mid = WeightMAX / 2;
  left = 0;
  right = WeightMAX;
  
  while(right - left > 0){    
    int load = able_to_load(mid, weight);

    if(load >= n){
      right = mid;
      mid = (right + left) / 2;
    }
    else{
      left = mid + 1;
      mid = (right + left) / 2;
    }
  }
  
  cout << right << endl;
  
  return 0;
}



Measured memory_bytes: 3876
x, y = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
if (x in g1 and y in g1) or (x in g2 and y in g2):
    print("Yes")
else:
    print("No")

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) cin >> a.at(i) >> b.at(i);

    vector<set<int>> to1(n + 1);
    rep(i, m)
    {
        to1.at(a.at(i)).insert(b.at(i));
        to1.at(b.at(i)).insert(a.at(i));
    }

    string answer = "IMPOSSIBLE";
    for (int x : to1.at(1))
    {
        if (to1.at(x).count(n) != 0)
        {
            answer = "POSSIBLE";
            break;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 29952
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static ArrayList<Integer>[] vertice;
    static int ans = 0;
    static int total = 0;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        long cur = 1;
        int mod = (int)(1e9+7);
        for(int i=1;i<=n;i++){
            cur*=i;
            cur%=mod;
        }
        System.out.println(cur);
    }
}


Measured memory_bytes: 22612
#include<stdio.h>
int main(void)
{
	char s[3];
	scanf("%s", s);
	if(s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2])
	printf("Yes\n");
	else
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {

	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	if (x - r >= 0&&x+r<=w&&y-r>=0&&y+r<=h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
using namespace std;
int dp[1001][1001]={0};
int main()
{
    int c=0;
    while(1)
    {
        int W;
        cin>>W;if(!W)return 0;
        int n;
        cin>>n;
        int a[1001],w[1001];
        for(int i=1;i<=n;++i){
            cin>>a[i];
            cin.ignore();
            cin>>w[i];
        }
        for(int j=1;j<=n;++j){
            for(int i=0;i<=W;++i){
                if(i<w[j]){
                    dp[i][j]=dp[i][j-1];
                }else{
                    dp[i][j]=max(dp[i][j-1],dp[i-w[j]][j-1]+a[j]);
                }
            }
        }
        c++;
        cout<<"Case"<<" "<<c<<":"<<endl;
        cout<<dp[W][n]<<endl;
        for(int i=0;i<=W;++i){
            if(dp[i][n]==dp[W][n]){
                    cout<<i<<endl;
                    break;
            }
        }
    }
}

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main()
{
  int N;
  ll C, K;
  cin >> N >> C >> K;
  vector<ll> A(N);
  REP(i, N)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  ll ans = 1,cnt=0,l=A.at(0)+K;
  REP(i,N){
    cnt++;
    if(C<cnt||l<A[i]){
      ans++;
      l = A[i] + K;
      cnt = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, m, k;
	cin >> n >> m >> k;
	
	if(k == 0 || k == n*m){
		cout << "Yes" << endl;
		return 0;
	}

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
			int a = i*j;
			int b = (n-i)*j;
			int c = i*(m-j);
			int d = (n-i)*(m-j);

			if(a+b == k || b+d == k ||c+d == k ||a+c == k ||a+d == k ||b+c == k){
				cout << "Yes" << endl;
				return 0;
			}

    }
  }

  cout << "No" << endl;

  return 0;
}

/*
NSNNSNSN

NNEW

W


*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int num = 0;
	int mountains[10];
	for (int i = 0; i < 10; i++){
		cin >> mountains[i];
	}
	sort(mountains,mountains+10);
	cout << mountains[9] << endl;
	cout << mountains[8] << endl;
	cout << mountains[7] << endl;
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <cmath>

int main(void) {
	// input
	long long n;
	std::vector<long long> c(5);
	std::cin >> n;
	for(int i = 0; i < 5; ++i) {
		std::cin >> c[i];
	}

	// capacity
	long long capacity = c[0];
	for(int i = 0; i < 5; ++i) {
		capacity = (capacity > c[i] ? c[i] : capacity);
	}

	long long t_end = 4 + std::ceil((long double)n / capacity);

	std::cout << t_end << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,m;
        cin>>n>>m;
        vvl V(n,vl(0));
        rep(i,m){
            ll a,b;
            cin>>a>>b;
            a--;b--;
            V[a].pb(b);
            V[b].pb(a);
        }
        queue<ll> Q;
        umap<ll,ll> ma;
        ma[0]++;
        vl ans(n-1,0);
        Q.push(0);
        while(!Q.empty()){
            ll a=Q.front();
            Q.pop();
            for(ll p:V[a]){
                if(ma[p]!=0)continue;
                ma[p]++;
                Q.push(p);
                ans[p-1]=a+1;
            }
        }
        cout<<"Yes"<<endl;
        rep(i,n-1)cout<<ans[i]<<endl;
    }

Measured memory_bytes: 16536
#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
int main()
{
    cin >> n >> m;
    if ( n * 2 >= m ) cout << min( n, m>>1);
    else cout << (n + ( ( m - 2 * n ) >> 2 ) );
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, M = LI()

def primes(n): #試し割り法で各素因数とその指数を求める
    cnt=collections.defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            while n%i==0:
                cnt[i]+=1
                n//=i
    if n!=1:
        cnt[n]+=1
    return cnt


"""
O(N ** 0.5)で計算できる約数列挙

N = 20
make_divisors(20) = [1,2,4,5,10,20]
"""


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

divs = make_divisors(M)

ans = -1
for i, divisior in enumerate(divs):
    if divisior > M // N:
        break
    else:
        ans = divisior

print(ans)
    

Measured memory_bytes: 10848
# -*- coding: utf-8 -*-
N, T = map(int, input().split())
best_c = 1001
for i in range(N):
    c, t = map(int, input().split())
    if (t <= T) and (c < best_c):
        best_c = c
if best_c < 1001:
    print(best_c)
else:
    print('TLE')

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N+1);
  vector<long long> B(N+1);
  for(int i=0; i<=N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  long long killed = 0;

  for(int i=N; i>0; i--){
    if(B[i-1] >= A[i]){
      killed += A[i];
      B[i-1] -= A[i];
      if(A[i-1] >= B[i-1]){
        killed += B[i-1];
        A[i-1] -= B[i-1];
      }else{
        killed += A[i-1];
        A[i-1] = 0;
      }
    }else{
      killed += B[i-1];
      B[i-1] = 0;
    }
  }
  cout << killed << endl;
  return 0;
}




Measured memory_bytes: 1792