akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

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

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll fact[200010];

ll powI(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = powI(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll choose(ll A, ll B) {
    ll ans = fact[A];
    ans = fact[A] * powI(fact[B], MOD-2); ans = ans % MOD;
    ans = ans * powI((fact[A-B] + MOD) % MOD, MOD-2); ans = ans % MOD;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    fact[0] = 1;
    FOR(i, 1, 200010) {
        fact[i] = fact[i-1] * i; fact[i] = fact[i] % MOD;
    }

    ll N, M, K; cin >> N >> M >> K;

    ll ans = choose(N*M, K); ans = ans * choose(K, 2); ans = ans % MOD;
    ans = ans * (N+M);
    ans = ans % MOD; ans = ans * powI(3, MOD-2); ans = ans % MOD;
    cout << ans << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	vector<pair<char, int>> cnt;
	char pre = '\0';
	int combo = 1;
	for (auto& i : s) {
		if (i == pre) combo++;
		else {
			if (pre) cnt.emplace_back(pre, combo);
			combo = 1;
			pre = i;
		}
	}
	cnt.emplace_back(s.back(), combo);
	int res = 0;
	for (auto i = 1; i < cnt.size()-1; i++) {
		if (cnt[i-1].first != 'J' || cnt[i].first != 'O' || cnt[i+1].first != 'I') continue;
		if (cnt[i-1].second < cnt[i].second || cnt[i].second > cnt[i+1].second) continue;
		res = max(res, cnt[i].second);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 11976
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cmath>
#define il inline
#define vd void
#define rg register
#define ll long long
#define int long long
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
ll s,x,y;
signed main(){
	s=rd(),x=sqrt(s);
	if(x*x>s) --x;
	y=x;
	while(x*y<s) ++y;
	if(y>1e9||x*y-s>1e9){
		++x;
		printf("0 0 %lld 1 %lld %lld",x,x*x-s,x);
		return flush(),0;
	}
	printf("0 0 %lld 1 %lld %lld",x,x*y-s,y);
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
vector<int> P;
void primes(int x) {
    if (x >= 2) {
        P.push_back(2);
        if (x == 2) {
            return;
        }
    }
    for (int i = 3; ; i += 2) {
        bool prime = true;
        for (auto p : P) {
            if (i%p == 0) {
                prime = false;
                break;
            }
        }
        if (prime) {
            P.push_back(i);
            if (i >= x) {
                break;
            }
        }
    }
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    primes(X);
    printf("%d\n", *prev(P.end()));
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  vector<vector<int>> G(n);
  vector<pair<int,int>> edge;
  rep(i,n-1){
    int a,b; cin >> a >> b;
    a--;b--;
    G[a].push_back(b); G[b].push_back(a);
    edge.push_back(make_pair(a,b));
  }
  int k = 0;
  queue<int> q;
  q.push(0);
  vector<int> with_parent(n), used(n,0);
  used[0] = 1;
  map<pair<int,int>,int> f; // edge to color
  while(!q.empty()){
    int now = q.front(); q.pop();
    k = max(k,int(G[now].size()));
    int candidate = 1;
    for(auto i:G[now]){
      if(used[i]) continue;
      q.push(i); 
      if(candidate == with_parent[now]) candidate++;
      with_parent[i] = candidate;
      f[make_pair(now,i)] = candidate; f[make_pair(i,now)] = candidate;
      candidate++;
      used[i] = 1;
    }
  }
  
  cout << k << endl;
  for(auto p:edge) cout << f[p] << endl;
  
  return 0;
}

Measured memory_bytes: 20088
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(void){
int a,b;
cin >> a >> b;
if (a*2<=b&&a*4>=b){
 if (b%2 ==0){
  cout << "Yes" << endl;
 }
 else{
 cout << "No" <<endl;
 }
}
else{cout << "No"<<endl;}
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#define N 10000
#define Y 1000000000

int search(int *,int,int);

int main()
{
  int i,n,q,S[N],T,cnt=0;

  scanf("%d",&n);
  if(n>10000) exit(1);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i] > Y) exit(2);
  }
  scanf("%d",&q);
  if(q>500) exit(1);
  for(i=0;i<q;i++){
    scanf("%d",&T);
    if(T > Y) exit(2);
    if(search(&S[0],n,T)) cnt++; //１が返って来たらカウントする
  }

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

int search(int *S,int n,int T)
{
  int i;

  for(i=0;i<n;i++)
    if(S[i] == T) return 1; 
  return 0;
}



Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll number(State &);
ll factor(State &);
ll term(State &);
ll expr(State &);

ll number(State &begin) {
	ll ret = 0;
	while (isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}
ll factor(State &begin) {
	if (*begin == '(') {
		begin++;
		ll ret = expr(begin);
		begin++;
		return ret;
	} else {
		return number(begin);
	}
}
ll term(State &begin) {
	ll ret = factor(begin);
	while (1) {
		if (*begin == '*') {
			begin++;
			ret *= factor(begin);
		} else if (*begin == '/') {
			begin++;
			ret /= factor(begin);
		} else {
			break;
		}
	}
	return ret;
}
ll expr(State &begin) {
	ll ret = term(begin);
	while (1) {
		if (*begin == '+') {
			begin++;
			ret += term(begin);
		} else if (*begin == '-') {
			begin++;
			ret -= term(begin);
		} else {
			break;
		}
	}
	return ret;
}

int main() {
	ll n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		string s;
		getline(cin, s);

		State begin = s.begin();
		dump(expr(begin));
	}
	return 0;
}


Measured memory_bytes: 3100
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  set<string> st;
  st.insert("a");
  for(int i=1;i<n;i++){
    set<string> tmp;
    for(auto s:st){
      char mc= 'a';
      for(auto c:s){
        mc = max(mc,c);
      }
      if(mc!='z') mc = mc+1;
      for(char c='a';c<=mc;c++){
        string x = s;
        x += c;
        tmp.insert(x);
      }
    }
    st = tmp;
  }
  for(auto s:st){
    cout << s << endl;
  }
}


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

void outPut(int Arry[], char mark){
  for(int i = 1; i<= 13; i++){
    if(Arry[i] == 0) cout << mark << " " << i << endl;
  }
}

int main(){
  char mark[2];
  int tmp;
  int S[14], H[14], C[14], D[14];
  rep(i,14) S[i] = H[i] = C[i] = D[i] = 0;
  int n; cin >> n;

  rep(i,n){
    cin >> mark[0] >> tmp;
    switch(mark[0]){
      case 'S':
          S[tmp] = 1;
          break;
      case 'H':
          H[tmp] = 1;
          break;
      case 'C':
          C[tmp] = 1;
          break;
      case 'D':
          D[tmp] = 1;
          break;
    }
  }
  outPut(S,'S');
  outPut(H,'H');
  outPut(C,'C');
  outPut(D,'D');

  return 0;
}


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

typedef long long int ll;

int main()
{
    ll a, b;
    string ans;
    cin >> a >> b;
    if(a <= 0 && b >= 0){
        ans = "Zero";
    }
    else if(a < 0 && b < 0){
        if((b - a) % 2 != 0) ans = "Positive";
        else ans = "Negative";
    }
    else{
        ans = "Positive";
    }

    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=3e5+5;
int ans[N];

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
rep(i,2,n)
{
	int x;
	cin>>x;
	ans[x]++;
}
rep(i,1,n)
{
	ol(ans[i]);on;
}
return 0;
}



Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    for(int i=0; i<n; i++){
        cout << s.at(i);
        cout << t.at(i);
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
edge = [[] for i in range(N)]
for i in range(N-1):
  u,v,w = map(int, input().split())
  edge[u-1] += [[u-1,v-1, w%2]]
  edge[v-1] += [[v-1,u-1, w%2]]
  
group = [0]+ [-1]* (N-1)
cnt = N-1#未訪問数
path = edge[0]
while path:
  uv = path.pop()
  if group[uv[1]] == -1:#未訪問
    group[uv[1]] = (group[uv[0]] + uv[2])%2
    for e in edge[uv[1]]:
      path.append(e)

for i in range(N):
  print(group[i])

Measured memory_bytes: 48224
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int[] m = new int[6];
		for (int i = 0; i < 6; i++) {
			m[i] = in.nextInt();
		}
		Dice d = new Dice(m);
		for (int i = 0; i < 6; i++) {
			m[i] = in.nextInt();
		}
		Dice dd = new Dice(m);

		boolean	match = false;
		for (int l = 0; l < 4; l++) {
			d.moveE();
			for (int j = 0; j < 4; j++) {
				d.moveN();
				for (int k = 0; k < 4; k++) {
					d.moveE();
					if (d.equals(dd)) {
						match = true;
						break;
					}
				}
				if (match) break;
			}
			if (match) break;
		}
		out.println(match ? "Yes" : "No");
	}

	private static class Dice {
		private int[] no;
		Dice(int[] no) {
			if (no.length != 6) throw new RuntimeException();
			this.no = Arrays.copyOf(no, no.length);
		}
		public boolean equals(Object o) {
			if (o == null || !(o instanceof Dice)) {
				return false;
			}
			int[] n = ((Dice)o).getNo();
			for (int i = 0; i < 6; i++) {
				if (this.no[i] != n[i]) {
					return false;
				}
			}
			return true;
		}
		private void moveX(boolean rev) {
			int temp = no[0];
			if (rev) {
				no[0] = no[4];
				no[4] = no[5];
				no[5] = no[1];
				no[1] = temp;
			} else {
				no[0] = no[1];
				no[1] = no[5];
				no[5] = no[4];
				no[4] = temp;
			}
		}
		void moveN(){moveX(false);}
		void moveS(){moveX(true);}

		private void moveY(boolean rev) {
			int temp = no[0];
			if (rev) {
				no[0] = no[3];
				no[3] = no[5];
				no[5] = no[2];
				no[2] = temp;
			} else {
				no[0] = no[2];
				no[2] = no[5];
				no[5] = no[3];
				no[3] = temp;
			}
		}
		void moveW(){moveY(false);}
		void moveE(){moveY(true);}

		int[] getNo(){return Arrays.copyOf(no, no.length);};
	}
}

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

int main() {
    int x,t; cin >> x >> t;
    if (x > t) {
        cout << x-t << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

bool check(int S)
{
  int x = 1;
  while(2*(x*x+x)<=S)
    {
      if((S-x)%(2*x+1) == 0)return false;
      x++;
    }
  return true;
}

int main()
{

  int N;
  cin >> N;
  int found = 0;
  for(int i=1;i<=N;i++)
    {
      int S;
      cin >> S;
      if(check(S))
	found++;  
    }
  cout << found << endl;
  return 0;
}

Measured memory_bytes: 1160
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    mod = 10 ** 9 + 7
    N, K = map(int, input().split())


    from operator import mul
    from functools import reduce


    # 未読
    def comb(n, r):
        if n < r:
            return 0
        else:
            r = min(n - r, r)
            if r == 0:
                return 1
            over = reduce(mul, range(n, n - r, -1))
            under = reduce(mul, range(1, r + 1))
            return over // under

    for i in range(1, K + 1):
        print((comb(K - 1, i - 1) * comb(N - K + 1, i)) % mod)


resolve()

Measured memory_bytes: 47580
class Node
  @@time = 1
  @@nodes = []
  def initialize(id)
    @id = id
    @discover = false
    @discover_time = nil
    @end_time = nil
    @edge = nil
    @@nodes[id - 1] = self
  end

  def <<(edges)
    @edge = edges
  end

  def search
    if !@discover
      @discover = true
      @discover_time = @@time
      @@time += 1
      @edge.each{|item|
        @@nodes[item - 1].search
      }
      @end_time = @@time
      @@time += 1
    end
  end

  def to_s
    return [@id, @discover_time, @end_time].join(" ")
  end

  def discover?
    return @discover
  end
  
end

def main
  n = gets.to_i
  arr = Array.new(n){|i|Node.new(i + 1)}
  n.times do |i|
    arg =  gets.split(" ").map(&:to_i)
    arr[i] << arg[arg.length - arg[1]..-1]
  end
  arr.each do |item|
    item.search if !item.discover?
    puts item
  end
end
main

Measured memory_bytes: 6244
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define int long long
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;



int  dp[105][100005];
signed main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,W;
  int v[100005],w[100005];
  cin >>n>>W;
  FOR(i,n)
    cin >>w[i] >> v[i] ;
  FOR(i,n){
    FOR(j,W+1){
      if(j < w[i]){
        dp[i + 1][j] = dp[i][j];
      }else{
        dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      }
    }
  }
  cout <<dp[n][W] fin;

  return 0;
}



Measured memory_bytes: 79360
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m];
        int b[] = new int[m];
        UFtree uft = new UFtree(n);
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        int cnt = 0;
        for (int i = 0; i < m; i++) {
            // 繰り返す階数
            uft = new UFtree(n);
            for (int j = 0; j < m; j++) {
                if (i == j) {
                    continue;
                } else {
                    uft.unit(a[j], b[j]);
                }
            }
            if (uft.count() != 1) {
                cnt++;
            }

        }
        System.out.println(cnt);
        sc.close();
    }
}

/**
 * UFtree;
 */
class UFtree {
    // 親の番号
    int parent[];

    int size;

    UFtree(int n) {
        parent = new int[n];
        init();
        size = n;
    }

    void init() {
        for (int i = 0; i < parent.length; i++) {
            parent[i] = i;
        }
    }

    // 数値xの親を調べる
    int root(int x) {
        if (parent[x] == x) {
            return x;
        } else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyをグルーピング
    void unit(int x, int y) {
        int rootX = root(x);
        int rootY = root(y);
        if (rootX == rootY) {
            return;
        }
        parent[rootX] = rootY;
    }

    // xとyが同じグループかどうか
    boolean same(int x, int y) {
        return root(x) == root(y);
    }

    // グループの数
    int count() {
        boolean[] check = new boolean[size];
        for (int i = 0; i < size; i++) {
            check[root(i)] = true;
        }
        int count = 0;
        for (int i = 0; i < size; i++) {
            if (check[i])
                count++;
        }
        return count;
    }
}


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

#define nax 100009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef vector<ll> vi;

int main(){
	ll dp[nax];

	ll weight,n; cin>>n>>weight;
	memset(dp,0,sizeof dp);
	vi w(n),v(n);

	REP(i,n) cin>>w[i]>>v[i];

	ll m = 0;
	REP(j,n){
		for(ll i=weight;i>=0;i--){
			if(i-w[j]>=0){
				dp[i] = max(dp[i],dp[i-w[j]] + v[j]);
				m = max(m,dp[i]);
			}
		}
	}

	cout<<m<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

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 (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
using Arr = array<ll, 4>;

int main() {
    init();
    ll H, W, K, h1, w1, h2, w2;
    cin >> H >> W >> K >> h1 >> w1 >> h2 >> w2;
    h1--, w1--, h2--, w2--;
    vc<string> S(H);
    rep(i, H) cin >> S[i];

    vvc<Arr> D(H, vc<Arr>(W, {INF, INF, INF, INF}));
    rep(i,4) D[h1][w1][i] = 0;

    vvc<bool> used(H, vc<bool>(W));
    vl dh = {0, 0, 1, -1}, dw = {1, -1, 0, 0};

    auto comp = [](Arr a1, Arr a2) { return a1[2] > a2[2]; };
    priority_queue<Arr, vc<Arr>, decltype(comp)> pq{comp};
    pq.emplace(Arr({h1, w1, 0, -1}));

    while(!pq.empty()){
        auto [h, w, d, m] = pq.top();
        pq.pop();

        rep(i,4){
            ll th = h + dh[i], tw = w + dw[i];
            if (th < 0 or th >= H or tw < 0 or tw >= W or S[th][tw]=='@') continue;

            ll td = (i==m ? d : (d + K - 1) / K * K);

            if (!chmin(D[th][tw][i], td + 1)) continue;
            pq.emplace(Arr({th, tw, td + 1, i}));
        }
    }

    
    cout << (*min_element(all(D[h2][w2])) == INF ? -1 : (*min_element(all(D[h2][w2]))+K-1) / K) << endl;
}

Measured memory_bytes: 66836
import java.util.*;

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

    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[2000];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    int cost = 999999999;
    for (int i = -100; i <= 100; i++) {
      int k = 0;
      for (int j = 0; j < n; j++) {
        if (a[j] != i) k += (int)Math.pow(a[j] - i, 2);
      }
      cost = Math.min(cost, k);
    }

    System.out.println(cost);
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repbit(n) for(ll bit=0,bit<(1<<n),bit++)
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
inline constexpr int modpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
int main(){
    ll n,t;
    cin>>n;
    vector<ll> h(5);
    rep(i,0,5) cin>>h[i];
    sort(h.begin(),h.end());
    t=(n-1)/h[0];
    cout<<t+5;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;

int main(void){
    string tmp;
    cin >> tmp;
    if(tmp == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;

}

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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

typedef long long ll;
string s;
ll ans=0;

ll calc(string t){
    int n=t.size(), i=0;
    ll sum=0;
    while(i < n){
        ll tmp=0;
        while(t[i] != '+' && i < n){
            if(t[i] == '#'){
                i++;
                tmp *= 10; 
                continue;
            }
            tmp += t[i++]-'0';
        }
        sum += tmp;
        i++;
    }
    return sum;
}

int main(){
    cin >> s;
    int n=s.size();
    for(int bit=0; bit<(1<<n-1); bit++){
        string tmp = s;
        rep(i, n-1){
            if(bit&(1<<i)) tmp.insert(i*2+1, "+");
            else tmp.insert(i*2+1, "#");
        }
        ans += calc(tmp);
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if(a == b) printf("%d\n", a + b);
    else if(a > b) {
        printf("%d\n", a + a - 1);
    }
    else if(a < b) {
        printf("%d\n", b + b - 1);
    }

}

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



int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(b-a == c-b){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n,m;
	string a[100] ,b[100] ;
	cin >> n >> m;
	for( int i=0 ; i<n ; i++ )
			cin >> a[i] ;
	for( int i=0 ; i<m ; i++ )
		cin >> b[i];

	int counter=0,count=0;
	for( int i=0 ; i<n ; i++ ){
		string str=a[counter];
		string st=b[counter];
		if( str.find(st) <= n ){
			counter++;
		}
		if( counter==m )
			count++;
	}
	if( count == 1 )
		cout <<"Yes"<<endl;
	else
		cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 1000001
bool p[N] = {1,1};
vl v;

int main(){
	REP(i, N){
		if(p[i]) continue;
		for(int j = i*2; j < N; j+=i) p[j]=true;
		for(ll j = i; j <= 1'000'000'000'000LL; j *= i) v.EB(j);
	}
	sort(ALL(v));
	// for(auto i : v) printf("%lld\n", i);

	ll n; scanf("%lld", &n);
	ll ans = 0;
	for(ll i : v){
		if(n % i == 0){
			n /= i;
			ans++;
		}
	}
	REP(i, N) if(!p[i]) while(n%i==0) n/=i;
	if(n>1) ans++;
	// if(ans == 0 && n > 1) ans = 1;
	printf("%lld\n", ans);
}


Measured memory_bytes: 6204
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
    int A, B, C;
	cin >> A >> B >> C;
	cout << max(0, C - A + B) << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a;
 cin >> a;
 vector<int> b(a);
 rep(i,a){
   cin >> b[i];
 }
 int count = 0;
 rep(i,a){
   if(b[i]!=i+1) count++;
 }
 if(count<=2){
   cout << "YES" << endl;
 }else{
   cout << "NO" << endl;
 }

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n;
    cin >> n;
    map<ll,int> mp;
    rep(i, n){
        ll a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto e:mp){
        if(e.second%2!=0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9664
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

const int N = 9e6;

int n;
struct {
    int v;
    int tag;
} t[N];

void build(int p, int v, int d) {
    if (d > n) return;
    t[p].v = v;
    for (int i = 0; i < 3; i++) {
        build(p * 3 + i, i, d + 1);
    }
}

void pushdown(int p) {
    
    for (int i = 0; i < 3; i++) {
        t[p * 3 + i].tag += t[p].tag;
    }
    if (t[p].tag & 1 && t[p].v) {
        t[p].v ^= 3;
    }
    t[p].tag = 0;
}

void update(int p, int d) {
    if (d >= n) return;
    for (int i = 0; i < 3; i++) {
        int x = p * 3 + i;
        pushdown(x);

        t[x].v++;
        if (t[x].v == 3) {
            t[x].v = 0;
            update(x, d + 1);
        }
    }
}

int query(int p, int x, int d) {
    if (d > n) return 0;
    pushdown(p);
    int res = t[p].v;
    return query(p * 3 + x % 3, x / 3, d + 1) * 3 + res;
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n;
    string s;
    cin >> s;
    build(1, 0, 0);

    for (auto c : s) {
        if (c == 'S') {
            t[1].tag++;
        }
        else {
            pushdown(1);
            update(1, 0);
        }
    }
    int t = 1;
    for (int i = 1; i <= n; i++) t *= 3;
    for (int i = 0; i < t; i++) cout << query(1, i, 0) / 3 << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 23168
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int x;cin >> x;
    LL l = 0,r = LINF;
    while(r - l > 1){
        LL m = (r - l) / 2 + l;
        LL t = m;
        LL cnt = 0;
        while(t > 2){
            cnt++;
            t = (t - 1) / 2;
        }
        if(cnt > x) r = m;
        else l = m;
    }
    cout << l << endl;
    return 0;
}


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

#define WHITE 0
#define GRAY -1
#define BLACK 1

int **G;
int *u, *k, **v, *color, *d, *f;
int n, time;

void init() {
	int i, j;

	u = (int *)malloc(sizeof(int) * (n + 1));
	k = (int *)malloc(sizeof(int) * (n + 1));
	color = (int *)malloc(sizeof(int) * (n + 1));
	d = (int *)malloc(sizeof(int) * (n + 1));
	f = (int *)malloc(sizeof(int) * (n + 1));
	G = (int **)malloc(sizeof(int *) * (n + 1));
	v = (int **)malloc(sizeof(int *) * (n + 1));

	for (i = 1; i <= n; i++) {
		G[i] = (int *)malloc(sizeof(int) * (n + 1));	
		for (j = 1; j <= n; j++) {
			G[i][j] = WHITE;
		}
	}
}

void createAdjacencyMatrix(int a, int b) {
	int i, j;
	for (j = 1; j <= n; j++) {
		if (u[j] == v[a][b])
			G[a][u[j]] = BLACK;
	}
}

void input() {
	int i, j;

	scanf("%d", &n);
	init();

	for (i = 1; i <= n; i++) {
		scanf("%d%d", &u[i], &k[i]);
		v[i] = (int *)malloc(sizeof(int) * (k[i] + 1));
		for (j = 1; j <= k[i]; j++) {
			scanf("%d", &v[i][j]);
			createAdjacencyMatrix(i,j);
		}
	}
}

void DFSVisit(int u) {
	int i;

	color[u] = GRAY;
	d[u] = ++time;

	for (i = 1; i <= k[u]; i++) {
		if (color[v[u][i]] == WHITE) DFSVisit(v[u][i]);
	}
	color[u] = BLACK;
	f[u] = ++time;
}

void DFS() {
	int i;

	for (i = 1; i <= n; i++) {
		color[u[i]] = WHITE;
	}

	for (i = 1; i <= n; i++) {
		if (color[u[i]] == WHITE) DFSVisit(i);
	}
}

void output() {
	int i;

	for (i = 1; i <= n; i++) {
		printf("%d %d %d\n", u[i], d[i], f[i]);
		free(G[i]);
		free(v[i]);
	}
	free(G);
	free(u);
	free(k);
	free(v);
	free(color);
}

main () {
	input();
	DFS();
	output();
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100
int main(){
  int n,i,j;
  int Adj[N][N];
  int a[N][N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&Adj[i][0],&Adj[i][1]);
    for(j=2;j<Adj[i][1]+2;j++){
      scanf("%d",&Adj[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    for(j=2;j<Adj[i][1]+2;j++){
      a[i][Adj[i][j]-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j!=n-1)printf(" ");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 680
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i]
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,h,w;
    cin>>n>>h>>w;
    int a,b;
    int ans=0;
    rep(i,n){
        cin>>a>>b;
        if(h<=a&&w<=b)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#include <chrono>
#include <array>
#include <random>
#include <fstream>
#include <list>



int main() {
    std::cin.tie(0); std::ios::sync_with_stdio(false);
    int n;
    std::cin >> n ;
    std::priority_queue<int> a;
    for (int i = 0; i < n; ++i) {
        int tmp;
        std::cin >> tmp;
        a.push(tmp);
    }
    int take = 0;
    bool atu = true;
    for (int j = 0; j < n; ++j) {
        int tmp =a.top(); a.pop();
        tmp *= atu ? 1 : -1;
        take += tmp;
        atu = !atu;
    }
    std::cout << take << std::endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("unroll-loops, no-stack-protector")
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// hj cho minh bulli bai nay
ll dp[200005], a[200005];
int st[800005][2]; 
void update(ll root, ll l, ll r, ll i, ll val, ll id){
	if (i < l || r < i) return;
	if (l == r){
		st[root][id] = val; return;
	}
	int mid = (l + r) / 2;
	update(root * 2 + 1, l, mid, i, val, id);
	update(root * 2 + 2, mid + 1, r, i, val, id);
	st[root][id] = min(st[root * 2 + 1][id], st[root * 2 + 2][id]);
}
ll query(ll root, ll l, ll r, ll u, ll v, ll id){
	if (u > v) return 1e18;
	if (v < l || r < u) return 1e18;
	if (u <= l && r <= v) return st[root][id];
	ll mid = (l + r) / 2;
	return min(query(root * 2 + 1, l, mid, u, v, id), query(root * 2 + 2, mid + 1, r, u, v, id));
}
int main(){
	fastio;
	ll n, e, t; cin >> n >> e >> t;
	for (ll i = 1; i <= n; i++) cin >> a[i];
	// dp[i]: shortest time to clear first i candies.
	dp[0] = 0;
	// 2 segtrees: one record dp[j] - 2 * a[j + 1] - a[j], one record dp[j] - a[j].
	update(0, 0, n - 1, 0, dp[0] - 2 * a[1], 0);
	for (ll i = 1; i <= n; i++){
		dp[i] = 1e18;
		ll lw; // lw: (a[i] - a[lw]) * 2 <= t, (a[i] - a[lw - 1]) * 2 > t. (lw - 1 -> 0)
		// manual binsearch? lw >= l, <= r
		ll l = 0, r = i - 1;
		while (l < r){
			ll mid = (l + r) / 2;
			if ((a[i] - a[mid + 1]) * 2 <= t) r = mid;
			else l = mid + 1;
		}
		lw = l;
		// so (dp[j] - 2 * a[j + 1] - a[j]) + 3 * a[i] with a from 0 to lw - 1, (dp[j] - a[j]) + a[i] + t to lw to i - 1
		dp[i] = min(query(0, 0, n - 1, 0, lw - 1, 0) + 3 * a[i], query(0, 0, n - 1, lw, i - 1, 1) + a[i] + t);
		update(0, 0, n - 1, i, dp[i] - 2 * a[i + 1] - a[i], 0); update(0, 0, n - 1, i, dp[i] - a[i], 1);
		// for (ll j = 0; j < i; j++) dp[i] = min(dp[i], dp[j] + max(2 * (a[i] - a[j + 1]), t) + a[i] - a[j]);
	}
	// hj, optimize nao
	cout << dp[n] + (e - a[n]) << endl;
}

Measured memory_bytes: 7244
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[][] = new int[2][N];
		for (int i = 0; i < N; i++) {
			A[0][i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			A[1][i] = sc.nextInt();
		}
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int temp = 0;
			for (int j = 0; j < N; j++) {
				if (j < i) temp += A[0][j];
				else if (j == i) temp += A[0][j] + A[1][j];
				else temp += A[1][j];
			}
			ans = Math.max(ans, temp);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import java.util.*;
import java.io.*;

public class Main extends Template{
	public void solve() throws IOException{
		Random rand = new Random();
		int n = nextInt();
		char[][] judge = new char[n+1][n+1];
		for(int i = 0; i < n; i++){
			String str = nextToken();
			for(int j = 0; j < str.length(); j++){
				judge[i+1][j+1] = str.charAt(j);
			}
		}
		int hand = 1;
		int count = 1000-n*n;
		int[] trend = new int[n*n];
		for(int i = 0; i < n*n; i++){
			System.out.println(hand);
			trend[i] = nextInt();
		}
		for(int i = 0 ;i < count ; i++){
			System.out.println(trend[i%(n*n)]);
			int ai_hand = nextInt();
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
}

abstract class Template implements Runnable{
	public abstract void solve() throws IOException;
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run(){
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	
	public double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	public long nextLong() throws IOException{
		return Long.parseLong(nextToken());
	}
	
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}
		

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int make_query(ll v) {
	printf("? %lld\n", v);
	fflush(stdout);
	char c[10];
	scanf("%s", &c[0]);
	return c[0] == 'Y';
}

void make_ans(ll v) {
	printf("! %lld\n", v);
	fflush(stdout);
	exit(0);
}

void solve(){
	if (make_query(1e9)) {
		ll v = 1e9;
		while(v > 1) {
			if (!make_query(v - 1)) {
				make_ans(v);
			}
			v /= 10;
		}
		make_ans(v);
	} else {
		ll v = 1e9;
		while(1) {
			v /= 10;
			if (make_query(v)) {
				break;
			}
		}
		ll l = v, r = 10 * v - 1;
		for(; l + 1 < r; ) {
			ll mid = (l + r) / 2;
			if (make_query(10 * mid)) {
				r = mid;
			} else {
				l = mid;
			}
		}
		make_ans(r);
	}
}   

int main(){
/*#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif*/
    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 596
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = n/100;
		int b = n%100;
		int c = b%10;
		if(a==c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
	//memoization
	
	
	long long knap_sack(long long W, long long n, const vector<long long>& is, const vector<long long>& value, vector<vector<long long>> &dp) {
		//base condition
        if (n < 0)
            return 0;
        if (dp[n][W] != -1)
            return dp[n][W];
		if(is[n] > W) {
            dp[n][W] = knap_sack(W, n - 1, is, value, dp);
            return dp[n][W];
		}
		else {
			dp[n][W] = max(knap_sack(W - is[n], n - 1, is, value, dp) + value[n], knap_sack(W, n - 1, is, value, dp));
            return dp[n][W];
		}
	}

    void solve(std::istream& in, std::ostream& out) {
        long long n, W;
        in >> n >> W;
        vector<long long> w(n), value(n);
    	for (int i=0;i<n;i++) {
            in >> w[i] >> value[i];
    	}
        vector<vector<long long>> dp(n + 1, vector<long long>(W + 1, -1));
        long long ans = knap_sack(W, n-1, w, value,dp);
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 80256
#include <iostream>
using namespace std;
int main(void){
    int n,i,cnt=0;
    cin >> n;
    int a[n],b[n],c[n-1];
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<n;i++) cin >> b[i];
    for(i=0;i<n-1;i++) cin >> c[i];
    for(i=0;i<n;i++){
        cnt+=b[a[i]-1];
        if(i!=0){
            if(a[i]-a[i-1]==1) cnt+=c[a[i]-2];
        }
    }
    cout << cnt << endl;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()){
            long num = in.nextLong();
            long sqr = (long) Math.ceil(Math.sqrt(num)) + 1;
            ArrayList<Long> arr = new ArrayList<>();
            arr.add(num - 1);
            for (long i = 1; i < sqr; i++){
                if (num%i == 0){
                    arr.add((num/i) + i - 2);
                }
            }
            System.out.println(Collections.min(arr));
        }
    }
}


Measured memory_bytes: 23636
#include <stdio.h>

int a[100000];

void Do(int N, int K, int Q){
  int i, A;
  for(i = 0;i < N;i++) a[i] = 0;
  for(i = 0;i < Q;i++){
    scanf("%d", &A);
    a[A-1]++;
  }
  for(i = 0;i < N;i++){
    if(K - Q + a[i] > 0) printf("Yes\n");
    else printf("No\n");
  }
}

int main(void){
  int N, K, Q;
  scanf("%d %d %d", &N, &K, &Q);
  Do(N, K, Q);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a;
  long long b;
  cin >> a;
  b=0;
  for(int i=1;i<=a;i++){
   if(i%3>0 && i%5>0){
     b=b+i;
  }
  }
  cout << b << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() 
{
 int n;
 cin>>n;
 long long int arr[n];
 long long int ans =0;
 for(int i=0;i<n;i++)
 {
     cin>>arr[i];
 }
 long long int my=arr[0];
 for(int i=1;i<n;i++)
 {
if(arr[i]<arr[i-1])
{
    ans=ans+arr[i-1]-arr[i];
    arr[i]=arr[i-1];
}

 }
 cout<<ans<<endl;
}


Measured memory_bytes: 5148
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <climits>
using namespace std;
int main(void){
    
    int N;
    int bingo[3][3];
    bool visit[3][3] = {{false, false, false} , {false, false, false}, {false, false, false}};
                
    
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> bingo[i][j];
        }
    }
    cin >> N;
    
    for(int i = 0; i < N; i++){
        int b;
        cin >> b;
        
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(bingo[j][k] == b) visit[j][k] = true;
            }
        }
        
    }
    
    if(visit[0][0] && visit[0][1] && visit[0][2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(visit[1][0] && visit[1][1] && visit[1][2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(visit[2][0] && visit[2][1] && visit[2][2]){
        cout << "Yes" << endl;
        return 0;
    }
    
    if(visit[0][0] && visit[1][0] && visit[2][0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(visit[0][1] && visit[1][1] && visit[2][1])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(visit[0][2] && visit[1][2] && visit[2][2])
    {
        cout << "Yes" << endl;
        return 0;
    }

    if(visit[0][0] && visit[1][1] && visit[2][2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(visit[0][2] && visit[1][1] && visit[2][0]){
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
    
    
}


Measured memory_bytes: 256