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

int main() {
    int n;
    cin >> n;
    n *= 2;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int x = 0;
    for (int i = 0; i < n; i+=2) {
        x += a[i];
    }
    cout << x << endl; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

#define size_t int


int main(int argc, char const *argv[]) {
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);
  int P[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &P[i]);
  }
  int a = 0;
  int b = 0;
  int c = 0;
  for (size_t i = 0; i < N; i++) {
    if (P[i] <= A) {
      a++;
    } else if (P[i] <= B) {
      b++;
    } else {
      c++;
    }
  }
  int min = a < b ? a : b;
  min = min < c ? min : c;
  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

cnt = 0
m_cnt = 0
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        if S[i + j] == T[j]:
            cnt += 1

    if cnt > m_cnt:
        m_cnt = cnt
    cnt = 0

print(len(T) - m_cnt)


Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


class UnionFind {
private:
	vector<int> par, ran;

public:
	UnionFind(int n) {
		par = decltype(par)(n + 4, -1);
		ran = decltype(ran)(n + 4, 0);
	}

public:
	int find(int x) {
		if (par[x] < 0) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

public:
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

		if (ran[x] < ran[y]) {
			par[find(y)] += par[find(x)];
			par[x] = y;
		}
		else {
			par[find(x)] += par[find(y)];
			par[y] = x;
			if (ran[x] == ran[y]) ran[x]++;
		}
	}

	int size(int x) {
		return -par[find(x)];
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

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


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

int main(){
  string s;
  cin >> s;
  int ans =0;
  if(s == "RRR"){ans = 3;}
  if(s == "RRS"){ans = 2;}
  if(s == "RSR"){ans = 1;}
  if(s == "SRR"){ans = 2;}
  if(s == "RSS"){ans = 1;}
  if(s == "SRS"){ans = 1;}
  if(s == "SSR"){ans = 1;}
  if(s == "SSS"){ans = 0;}
  cout << ans << endl;
}

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

bool check[11];

int main() {
    int D, G; cin >> D >> G;
    vector<int> p(D), c(D);
    rep(i, D){
        cin >> p[i] >> c[i];
    }

    int ans = 1001001001;
    for (int i = 0; i < 1<<D; i++){
        int restMin = -1;
        int cnt = 0;
        int now = 0;
        for (int j = 0; j < D; j++){
            if(i>>j&1){
                cnt += p[j];
                now += (j+1)*100 * p[j] + c[j];
            } else {
                restMin = j;
            }
        }

        if(now < G){
            int x = G - now - 1;
            x /= (restMin+1) * 100;
            x++;
            if(x > p[restMin]-1){
                continue;
            }
            cnt += x;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

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

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

const int H = 10;
const int W = 1000;
int arr[H][W];

int compute(int h, int w, int k, int mask){
	int part[h];
	part[0] = 0;
	for(int i = 0; i + 1 < h; i++){
		if(mask&(1<<i))part[i + 1] = part[i] + 1;
		else part[i + 1] = part[i];
	}
	int ret = 0;
	int n = part[h - 1] + 1;
	int tot[n] = {0};
	for(int col = 0; col < w; col++){
		bool flg = true;
		int sum[n] = {0};
		for(int row = 0; row < h; row++){
			sum[part[row]] += arr[row][col];
		}
		for(int i = 0; i < n; i++){
			if(sum[i] > k)return -1;
			if(tot[i] + sum[i] > k){
				flg = false;
				break;
			}
		}
		if(flg){
			for(int i = 0; i < n; i++){
				tot[i] += sum[i];
			}
		}else{
			ret++;
			for(int i = 0; i < n; i++){
				tot[i] = sum[i];
			}
		}
	}
	for(int i = 0; i + 1 < h; i++){
		if(mask&(1<<i))ret++;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int h, w, k;
	cin>>h>>w>>k;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char ch;
			cin>>ch;
			arr[i][j] = ch - '0';
		}
	}
	int ans = h + w - 2;
	for(int mask = 0; mask < (1<<(h-1)); mask++){
		int tmp = compute(h, w, k, mask);
		if(tmp != -1)ans = min(ans, tmp);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <map>

using namespace std;
map<string,int> Map;

int main()
{
    int n;
    string str;
    while(scanf("%d",&n)!=EOF){
        for(int i=0;i<n;i++){
            cin>>str;
            Map[str]++;
        }
        int m;
        scanf("%d",&m);
        for(int i=0;i<m;i++){
            cin>>str;
            Map[str]--;
        }
        int ans=0;
        map<string ,int> ::iterator it;
        for(it=Map.begin();it!=Map.end();it++){
            if(it->second>ans){
                ans=it->second;
            }
        }
        cout<<ans<<endl;
        Map.clear();
    }
    return 0;
}


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

int main() {
  int n, time, c, t, min;
  cin >> n >> time;
  int i;
  min = 10000;
  for (i = 0; i < n ; i++) {
    cin >> c >> t;
    if (t <= time) {
      if (min > c) {
        min = c;
      }
    }
  }
  if (min == 10000) {
    cout << "TLE" << endl;
  } else {
    cout << min << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 10000;

    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        int count = 0;
        for (int j = 0; j < t.size(); j++) {
            // cout << s[i + j] << ", " << t[j] << endl;
            if (s[i + j] != t[j]) {
                count++;
            }
        }

        ans = min(ans, count);
    }

    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i= i; i < n ; i++)cin >> a[i];
  
  int sum1 = 0, sum2 = 0;
  int MIN = 10000000;
  
  for(int t = 1; t < n; t++){
    for(int i = 0; i < t ; i++) sum1 += a[i];
    for(int j = t; j < n ; j++) sum2 += a[j];
    int sa = abs(sum1 - sum2);
    MIN = min(MIN , sa);
    
    sum1 = 0;
    sum2 = 0;
  }
  
  cout << MIN << endl;
}

    
    


Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll n,m;
    scanf("%lld",&n);
    scanf("%lld",&m);
    ll k[15];
    vector<vector<ll>> s(m);
    ll ta;
    rep(i,m){
        scanf("%lld",&k[i]);
        rep(j,k[i]){
            scanf("%lld",&ta);
            s[i].push_back(ta);
        }
    }
    ll p[15];
    rep(i,m) scanf("%lld",&p[i]);
    ll mem_on[11];
    ll res=0;
    bool f;
    rep(i,(int)pow(2,n)){
        f=1;
        rep(j,m) mem_on[j]=0;
        rep(j,m){
            rep(l,k[j]) if(i&(1<<(s[j][l]-1))) mem_on[j]++;
            if(mem_on[j]%2 != p[j]) f=0;
        }
        if(f) res++;
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string A, B;
  cin >> A >> B;
  if (A.size() < B.size()) {
    cout << "LESS" << endl;
  } else if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else {
    for (int i = 0; i < A.size(); i++) {
      if (A[i] < B[i]) {
        cout << "LESS" << endl;
        return 0;
      } else if (A[i] > B[i]) {
        cout << "GREATER" << endl;
        return 0;
      } else {
        continue;
      }
    }
    cout << "EQUAL" << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
h = na()

dp = [inf] * n
dp[0] = 0
for i in range(n):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

print(dp[n - 1])

Measured memory_bytes: 52444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int n = Integer.parseInt(line);
		int sum = 0;
		for(int i = 1; i< n + 1 ;i++){
			sum += i;
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 7636
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		int ans=0;
		Arrays.parallelSort(a);
		boolean[] af = new boolean[n];
//		Arrays.fill(af, true);
		for (i = 1; i < a.length; i++) {
			if(a[i-1]==a[i]) {
				af[i-1]=true;
				af[i]=true;
			}
		}
		for (i = 0; a[i]*2 <= a[n-1]; i++) {
			int k = a[i]*2;
			int ret=0;
			while(k<=a[n-1]&&ret<n) {
				ret = Arrays.binarySearch(a, i+1, n, k);
				if(n>ret && ret>=0) {
					af[ret]=true;
				}
				k+=a[i];
			}
		}
//		if(n>=2&&a[0]<a[1])ans++;
//		for (i = 1; i < a.length; i++) {
//			if(af[i]) continue;
//			boolean f=true;
//			for (j = 0; j < i; j++) {
//				int k = a[j];
//				if(a[i]%a[j]==0) {
//					af[i]=true;
//					f=false;
//					break;
//				}
//			}
//			if(f)ans++;
//		}
		for (i = 0; i < a.length; i++) {
			if(!af[i]) ans++;
		}
		out.println(ans);
	}
}


Measured memory_bytes: 50200
x,y = list(map(int,input().split()))
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
f = False

if x in g1 and y in g1:
  f = True
if x in g2 and y in g2:
  f = True

if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
  int x,flag=0;
  int i[6];
  
  scanf("%d",&x);
  if(x>=2000){
    flag=1;
  } else {
    for(i[0]=0;i[0]<20;i[0]++){
      for(i[1]=0;i[1]<20-i[0];i[1]++){
        for(i[2]=0;i[2]<20-i[0]-i[1];i[2]++){
          for(i[3]=0;i[3]<20-i[0]-i[1]-i[2];i[3]++){
            for(i[4]=0;i[4]<20-i[0]-i[1]-i[2]-i[3];i[4]++){
              for(i[5]=0;i[5]<20-i[0]-i[1]-i[2]-i[3]-i[4];i[5]++){
                if(i[0]*100+i[1]*101+i[2]*102+i[3]*103+i[4]*104+i[5]*105==x){
                  flag=1;
                }
              }
            }
          }
        }
      }
    }
  }
  printf("%d",flag);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  sort(as.begin(),as.end());
  Int p=as.front(),q=as.back();
  if(p==q){
    if(p==n-1) drop("Yes");
    if(p<=(n/2)) drop("Yes");
    drop("No");
  }

  if(p+1!=q) drop("No");

  Int x=count(as.begin(),as.end(),p);
  if(x+1>q) drop("No");
  if(x+(n-x)/2<q) drop("No");
  drop("Yes");
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x;
    int y;
} a[200009];
int cmp(node a,node b)
{
    return a.y<b.y;
}
int main()
{
    int n,flag=1,tmp=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i].x>>a[i].y;
    sort(a,a+n,cmp);
    for(int i=0; i<n; i++)
    {
        if(tmp+a[i].x<=a[i].y)
            tmp+=a[i].x;
        else
        {
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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

int main(){
	int x[5], sum = 0;

	for(int i = 0; i < 5; i++){
		cin >> x[i];
		if(x[i] < 40) x[i] = 40;
	}

	for(int i = 0; i < 5; i++){
		sum += x[i];
	}

	cout << sum / 5 << endl;

}

Measured memory_bytes: 1160
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		long sum=0;
		for(int i=0; i<m; i++){
			sum+=sc.nextInt();
		}
		if(sum>n){
			System.out.println(-1);
		}else{
			System.out.println(n-sum);
		}
	}
}


Measured memory_bytes: 46304
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <array>

using namespace std;

int main(int argc, const char *argv[])
{
  string s, t;
  cin >> s >> t;
  
  array<set<int>, 26> s_positions;
  for (int i = 0; i < s.size(); i++) {
    s_positions[s[i] - 'a'].insert(i);
  }
  
  int s_cur = 0, t_cur = 0;
  long long repeat_cnt = 0;
  while (t_cur < t.size()) {
    char t_ch = t[t_cur];
    auto &ch_positions = s_positions[t_ch - 'a'];
    auto it = ch_positions.lower_bound(s_cur);
    if (it != ch_positions.end()) {
      s_cur = *it + 1;
      t_cur++;
    } else if (s_cur != 0) {
      s_cur = 0;
      repeat_cnt++;
    } else {
      s_cur = -1;
      repeat_cnt = 0;
      break;
    }
  }

  cout << repeat_cnt * static_cast<long long>(s.size()) + s_cur << "\n";
  return 0;
}

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

int main() {
  int D, N;
  cin >> D >> N;
  if (N == 100) {
    N = 101;
  }
  for (int i=0; i<D; i++) {
    N = N * 100;
  }
  cout << N << endl;
}

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	if(n&1)
		cout << "No";
	else {
		for(int i=0; i<n/2; i++) {
			if(s[i] != s[n/2+i]) {
				cout << "No";
				exit(0);
			}
		}
		cout << "Yes";
	}
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n, m, c;
    int b[20];
    int a[20][20];
    int sum = 0;
    int count = 0;
    cin >> n >> m >> c;
    rep(i, m){
        cin >> b[i];
    }
    for(int i = 0; i < n ; i++ ){
        for(int j = 0; j < m; j++){
            cin  >> a[i][j];
        }
    }
    for (int i = 0; i < n ; i++) {
        sum =0;
        for (int j = 0; j < m ; j++) {
            sum += a[i][j]*b[j]; 
        }
        sum += c;
        if(sum>0){
            count ++;
        }
    }
    cout << count << 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 = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  string s;
  cin >> s;
  int n0 = count(rng(s),'0');
  int n1 = count(rng(s),'1');
  int ans = min(n0,n1)*2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
use proconio::input;

fn main() {
    input!(mut a: i32, b: i32, mut c: i32, d: i32);

    let mut turn = 0;

    while a > 0 && c > 0 {
        if turn == 0 {
            c -= b;
        } else {
            a -= d;
        }

        turn = 1 - turn;
    }

    let ans = if c <= 0 { "Yes" } else { "No" };

    println!("{}", ans);
}


Measured memory_bytes: 2096
import java.io.*;

public class Main{
    public static void main(String[]args){
        BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
        try{
            int x = Integer.parseInt( br.readLine());
            int ans = x * x * x;
            System.out.println(ans);
        }catch( IOException e){
            System.out.println("");
        }
    }
}

Measured memory_bytes: 24340
#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#define Max 0x3F3F3F

#define LL long long
#define MODD 1000000007
#define  pii  pair<int,int>

#include<stdio.h>
#include<queue>
//#include<bits/stdc++.h>
using namespace std;
char ch[10000]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<int>v[100500];
int arr[100500]={0};
int brr[100500]={0};
int vis[100500]={0};
int co[100500]={0};
map<pii ,int> mp;

int ans = 0;
void bfs(int x ){
    queue<int>q;q.push(x);
    vis[x]=1;
    int cnt=0;
    while(!q.empty()){
        int fron = q.front() ;q.pop();
        for(int i=0;i<v[fron].size();i++){
            if(!vis[v[fron][i]]){
                vis[v[fron][i]]=1;
                if(cnt==co[fron])cnt++;
                co[v[fron][i]] = cnt;
                mp[make_pair(fron , v[fron][i])] = cnt;
                mp[make_pair(v[fron][i] , fron)] = cnt;
                cnt++;
                q.push(v[fron][i]);
            }
        }
        ans = max(ans , cnt-1);
        cnt=1;
    }
}
int main() {
    int n;cin >>n;
    for(int i=0;i<n-1;i++){
        int a, b;cin>>a>>b;
        arr[i]=a;brr[i]=b;
        v[a].push_back(b);
        v[b].push_back(a);
       // mp[make_pair(a ,b)] =0;
    }
   // memset(co,1,sizeof(co));
    bfs(1);
    cout<<ans<<endl;
    for(int i=0;i<n-1;i++){
        cout<<mp[make_pair(arr[i],brr[i])]<<endl;
    }
    return 0;
}
/*
8
1 2
2 3
2 4
4 7
2 5
5 6
6 8
*/


Measured memory_bytes: 20096
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    cin >> n;
    int h[n];
    //rep(i,n)cin >> h[i];
    rep(i,n){scanf("%d",&h[i]);}

    int now = h[0]-1;

    srep(i,1,n){
        if(h[i]<now){
            cout << "No" << endl;
            return 0;
        }else if(now<h[i]){
            now = h[i]-1;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
 
 


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-b*2)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100;
vector<int> g[maxn+5];
int n,s,t;
int fa[maxn+5],dep[maxn+5],a[maxn+5];
long long ans;
void dfs(int k,int last)
{
    dep[k]=dep[last]+1;
    fa[k]=last;
    int d=0;
    for(auto u:g[k])
    {
        if(u==last) continue;
        dfs(u,k);
        ++d;
    }
    a[dep[k]]=max(a[dep[k]],d);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v),g[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;++i)
        if(dep[i]>dep[s]) s=i;
    dfs(s,0);
    for(int i=1;i<=n;++i)
        if(dep[i]>dep[t]) t=i;
    //printf("%d %d\n",s,t);
    int ans1=(dep[t]+1)/2;
    printf("%d ",ans1);
    for(int i=1;i<=n;++i)
    {
        memset(a,0,sizeof(a));
        a[0]=1;
        dfs(i,0);
        long long res=1;
        for(int j=0;j<=n;++j)
            if(a[j]==0) break;else res=res*a[j];
        if(a[ans1]!=0) continue;
        if(ans==0||res<ans) ans=res;
    }
    for(int u=1;u<=n;++u)
        for(auto v:g[u])
        {
            memset(a,0,sizeof(a));
            a[0]=2;
            dep[u]=0;
            dfs(v,u);
            dep[v]=0;
            dfs(u,v);
            long long res=1;
            for(int j=0;j<=n;++j)
                if(a[j]==0) break;else res=res*a[j];
            if(a[ans1]!=0) continue;
            if(ans==0||res<ans) ans=res;
        }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;

  for(int i = 0;i < k;i++){
	if(i % 2 == 0){
	  if(a % 2 != 0){
		a -= 1;
	  }
	  b += (a / 2);
	  a /= 2;
	}else{
	  if(b % 2 != 0){
		b -= 1;
	  }
	  a += (b / 2);
	  b /= 2;
	}
  }

  cout << a << ' ' <<  b << endl;
  
  return 0;
}


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

#define INF 1000000001

using namespace std;

string n_ary_convert(long n, long ary, long w){
    string ans = "";
    while(n != 0){
        if(n < 0){
            long temp = abs(ary) + n % ary;
            ans += to_string(temp);
            n = n / ary;
            if(temp == 0) continue;
            if(ary < 0) n++;
            else n--; 
        }
        else{
            ans += to_string(n % ary);
            n /= ary;
        }
    }
    while(ans.length() < w) ans += "0";
    reverse(ans.begin(), ans.end());
    return ans;
}

int main(){
    int N, A[3];
    cin >> N >> A[0] >> A[1] >> A[2];
    int l[N];
    int ans = INF;

    for(int i=0; i<N; i++) cin >> l[i];

    for(int i=0; i<int(pow(4, N)); i++){
        int kdmt[4]; fill(kdmt, kdmt + 4, 0);
        int temp = 0;
        string s = n_ary_convert(i, 4, N);
        int mag[4]; fill(mag, mag + 4, 0);
        for(int j=0; j<N; j++){
            kdmt[s[j] - '0'] += l[j];
            mag[s[j] - '0']++;
        }
        for(int j=0; j<3; j++){
            if(mag[j] == 0) {
                temp += INF;
                break;
            }
            else temp += 10 * (mag[j] - 1);
            temp += abs(A[j] - kdmt[j]);
        }
        ans = min(temp, ans);
    }
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
const int P = 998244353;
 
int n,cnt[3],ans=1;
char c;
 
int main(){
	scanf("%d\n",&n);
	rep(i,1,n) ans = 1ll * ans * i % P;
	rep(i,1,3*n){
		scanf("%c",&c);
		int t = (c>'B') + (c>'G'), mn = 1e9;
		rep(j,0,2) if(cnt[j]>cnt[t]) mn = min(mn, cnt[j] - cnt[t]);
		if(mn<1e9) ans = 1ll * ans * mn % P;
		++cnt[t];
	}
	cout<<ans<<endl;
	return 0;
}

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

const int magic = 26 , N = (1<<magic) + 5 ;
const int maxn = 2e5 + 5 ;

int dp[N] , res[N] ;


int main () {

    int n ;
    string s ;
    cin >> s ;
    n = s.size() ;
    s = "#" + s ;
    for (int i = 1 ; i < N ; i++) {
        dp[i] = (1<<26) ;
    }
    dp[0] = 0 ;
    int cur = 0 ;
    for (int i = 1 ; i <= n ; i++) {
        int bit = s[i]-'a' ;
        cur ^= (1<<bit) ;
        res[i] = dp[cur] + 1 ;
        for (int j = 0 ; j < 26 ; j++) {
            int nw = cur^(1<<j) ;
            res[i] = min(res[i],dp[nw] + 1) ;
        }
        dp[cur] = min(dp[cur],res[i]) ;
    }
    cout << res[n] << endl ;
}


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

/**
 * Created on 2017/09/30 21:46.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextLong()) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] A = new int[N];
            int[] B = new int[N];

            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
                B[i] = sc.nextInt();
            }

            long ans = 0;

            while (true) {
                long sum = 0;
                for (int i = 0; i < N; i++) {
                    if ((K & (A[i])) == A[i]) {
                        sum += B[i];
                    }
                }
                ans = Math.max(sum, ans);

                int pos0 = -1;
                for (int i = 0; (1 << i) < K; i++) {
                    if (((1 << i) & K) == 0) {
                        pos0 = i;
                        break;
                    }
                }
                if (K == 0 || pos0 == -1) {
                    break;
                }
                K -= (1 << pos0);
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 87048
// inputに入力データ全体が入る
function Main(input) {

    input = input.split("\n");
  
    let n = parseInt(input[0], 10);
    
    let ary = [[400, 599, 8], [600, 799, 7], [800, 999, 6], [1000, 1199, 5], 
                [1200, 1399, 4], [1400, 1599, 3], [1600, 1799, 2], [1800, 1999, 1]];

    let rslt = 0;

    for (let i=0;i<ary.length;i++) {
        if (ary[i][0] <= n && n <= ary[i][1]) {
            rslt = ary[i][2];
        }
    }

    console.log('%d', rslt);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

static int compare(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return aNum-bNum;
}

int main(void)
{
    int n, m, x[10*10*10*10*10], i, ans=0, diff[10*10*10*10*10];

    scanf("%d%d", &n, &m);
    for(i=0;i<m;i++){
        scanf("%d", &x[i]);
    }
    if(n>=m){
        ans=0;
        printf("%d\n", ans);
        return 0;
    }
    
    qsort(x, m, sizeof(int), compare);
    for(i=0;i<m-1;i++){
        diff[i]=x[i+1]-x[i];
    }
    
    qsort(diff, m-1, sizeof(int), compare);
    for(i=0;i<m-n;i++){
        ans=ans+diff[i];
    }
    if(n==1){
        ans=x[m-1]-x[0];
        printf("%d\n", ans);
        return 0;
    }

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

    return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

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

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

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

   ll b = 0, r = 0;
   REP(i, n) (s[i] == '0') ? b++ : r++;
   cout << n - abs(b - r) << endl;
}


Measured memory_bytes: 512
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N;
    cin >> N;
    vector<int> h(N);

    rep(i, N){
        cin >> h[i];
    }

    vector<int> cost(N, INF);

    cost[0] = 0;

    rep(i, N - 2){
        int plus1 = abs(h[i] - h[i + 1]) + cost[i];
        int plus2 = abs(h[i] - h[i + 2]) + cost[i];
        
        cost[i + 1] = min(plus1, cost[i + 1]);
        cost[i + 2] = min(plus2, cost[i + 2]);
    }

    cost[N - 1] = min(cost[N - 1], abs(h[N - 2] - h[N - 1]) + cost[N - 2]);
    cout << cost[N - 1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int cnt[105];

int main() 
{
    int n;
    while(cin >> n){
        cnt[n]++;
    }
    int c = 0;
    for(int i = 0; i < 105; i++){
        c = max(c,cnt[i]);
    }
    for(int i = 0; i < 105; i++){
        if(cnt[i] == c){
            cout << i << endl;
        }
    }
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n, y;
    cin >> n >> y;

    rep(i, n+1) {
       rep(j, n+1-i) {
           int k = n-(i+j);
           int t = 10000*i+5000*j+1000*k;
           if(t == y) {
               cout << i << " " << j << " " << k << endl;
               return 0;
           }
       }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    
    return 0;
}

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

using namespace std;

int main()
{
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N,vector<int>(M));

    for(int i=0;i<M;i++)
        cin >> B.at(i);
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A.at(i).at(j);
        }
    }
    
    int cnt=0;
    int ans;

    for(int i=0;i<N;i++){
        ans = C;
        for(int j=0; j<M; j++){
            ans += A.at(i).at(j) * B.at(j);
        }
        if(ans > 0)
            cnt++;
    }

    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define SIZE 50
using namespace std;
int res[SIZE],mx[SIZE],zero[SIZE];
void copy(int*a,int*b){
	for(int i = 0; i < SIZE; i++) a[i] = b[i];
}
void converts(int *a, string str){
	int i, len = str.size();
	for(i = 0; i < len; i++)a[i] = str[len-i-1]-'0';
	for(;i<SIZE;i++) a[i] = 0;
}
void add(int*a, int*b, int len = SIZE){
	for(int i = 0; i < len; i++)
		if((a[i]+=b[i])>=10){a[i+1]++; a[i]-=10;}
}
void mul(int *c,int *a,int *b) {
	converts(c,"0");
	for(int i=0;i<SIZE;i++)
		for(int j=0; j<b[i]; j++)
			add(c+i, a, SIZE-i);
}
bool le(int *a, int *b, int len = SIZE){
	int i;
	for(i = len-1; i>=0 && a[i]==b[i]; i--);
	return i<0||a[i]<b[i];
}
void print(int *a){
	int i;
	for(i=SIZE-1;i>0;i--) if(a[i]>0) break;
	for(;i>=0;i--) cout<<a[i]; cout<<endl;
}
int main(){
	int n; cin>>n;
	converts(mx,"1000000000000000000");
	converts(zero,"0");
	converts(res,"1");
	for(int i=1;i<=n;i++){
		string s; cin>>s;
		int a[SIZE]; converts(a,s);
		int tmp[SIZE]; converts(tmp,"0");
		if(s=="0") return puts("0"),0;
		mul(tmp,res,a);
		if(!le(tmp,mx)) converts(res,"0");
		else copy(res,tmp);
	}
	if(le(res,zero)) puts("-1");
	else print(res);
	return 0;
}

Measured memory_bytes: 3628
import bisect
N = int(input())
A = [int(input())for _ in range(N)]
li = [-1]
for i in A[::-1]:
    if(li[-1]<i):
        li.append(i)
    else:
        ind = bisect.bisect_right(li,i)
        if(ind>=len(li)):
            li.append(i)
        elif(li[ind]>i):
            li.pop(ind)
            li.insert(ind,i)
        else:
            li.pop(ind+1)
            li.insert(ind+1)
print(len(li)-1)

Measured memory_bytes: 8604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            if (N % 2 == 0)
            {
                out.print(-1);
                return;
            }
            long k = 7;
            long cnt = 1;
            while (true)
            {
                if (k % N == 0)
                {
                    out.print(cnt);
                    break;
                }
                if (cnt > N)
                {
                    out.print(-1);
                    break;
                }
                k = (k % N) * 10 + 7;
                ++cnt;
            }
        }

    }
}



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

int main(){
while(1){
	int n,m,s;
	static int dp[2][2002][3002];
	for(int i=0;i<2;i++)for(int j=0;j<2002;j++)for(int k=0;k<3002;k++)dp[i][j][k]=0;
	scanf("%d%d%d",&n,&m,&s);
	if(n==0&&m==0&&s==0)break;
	for(int j=0;j<=m;j++)dp[0][j][0]=1;
	for(int i=1;i<=n*n;i++){
		for(int j=1;j<=m;j++){
			for(int k=1;k<=s;k++){
				if(k-j>=0){
					dp[1][j][k]=dp[0][j-1][k-j];
				}
				dp[1][j][k]+=dp[1][j-1][k];
				dp[1][j][k]%=100000;
			}
		}
		for(int j=0;j<=m;j++)for(int k=0;k<=s;k++){dp[0][j][k]=dp[1][j][k]; dp[1][j][k]=0;}
	}
	printf("%d\n",dp[0][m][s]);
}
}

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

int main(){
    int N;
    cin >> N;
    int V[N],C[N];
    for (int i=0; i<N; i++){
        cin >> V[i];
    }
    for (int i=0; i<N; i++){
        cin >> C[i];
    }
    int res = 0;
    for (int i=0; i<N; i++){
        if(V[i] > C[i]) res += V[i]-C[i];
    }
    cout << res << endl;
}


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

int main(){
	int x, y;
	cin >> x;
	cin >> y;

	if(y%2 == 0){
		if(x*4 >= y){
			if(x*2 <= y){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int N, M, Q;
int a[60], b[60], c[60], d[60];
int A[15];
int dfs(){
	int sum=0;
	rep(i,N) sum+=A[i];
	if(sum>M*N) return 0;
	int p=0;
	rep(i,Q){
		if(A[b[i]]-A[a[i]]==c[i]) p+=d[i];
	}
	rep(i,N-1){
		if(A[i]>A[i+1]){
			p=0;
			break;
		}
	}
	for(int n=N-1; n>=0; n--){
		if(A[n]<M){
			A[n]++;
			for(int j=n+1; j<N; j++) A[j]=A[n];
			break;
		}
	}
	return p;
}

int main(){
	cin >> N >> M >> Q;
	rep(i,Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	rep(i,Q){
		a[i]--;
		b[i]--;
	}
	int ans=0;
	rep(i,N) A[i]=1;
	rep(i,4000000) ans=max(ans,dfs());
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
while s = gets
  break if s.strip == ""
  _ = s.match /([0-9X]+)\+([0-9X]+)\=([0-9X]+)/
  a = _[1]
  b = _[2]
  c = _[3]
  answer = nil
  (0..9).each do|i|
    next if i == 0 && (a != 'X' && a[0] == 'X' ||
                       b != 'X' && b[0] == 'X' ||
                       c != 'X' && c[0] == 'X')
    x = a.gsub(/X/, i.to_s).to_i
    y = b.gsub(/X/, i.to_s).to_i
    z = c.gsub(/X/, i.to_s).to_i
    if x + y == z
      answer = i
      break
    end
  end
  puts answer ? answer.to_s : 'NA'
end

Measured memory_bytes: 6244
#include <stdio.h>

int main(){
	while(1){
		int h, w;
		scanf(" %d %d", &h, &w);
		if(h==0 && w==0) break;
		
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				if( (i+j)%2==0 ) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}



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

using namespace std;

int main()
{
    short a, b, c, d;
    cin >> a >> b >> c >> d;
    short turn=0;
    while (a>0 and c>0) {
        if (turn%2==0)
            c=c-b;
        else
            a=a-d;
        turn++;
    }
    if (a>c)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long int
#define pi 3.1415926535897932384626433832795028841971
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int k;
	string s;
	cin>>k;
	cin>>s;
	if(s.size()<=k){
		cout<<s<<endl;
	}
	else{
		cout<<(string)(s.substr(0,k)+"...")<<endl;
	}

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main() {
  ll a,p,q,sum;
  sum = 0;
  
  cin >> a;
  
  for(ll i=1;i<=a;i++){
    for(ll j=1;j<=a;j++){
      for(ll k=1;k<=a;k++){
           p = __gcd(i,j);
           q = __gcd(p,k);
             
           sum += q;
      }
    }
  }
  
  cout << sum <<endl;
  
  
}




Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;
int main() {
    int n;
    cin >> n;

    cout << n + n * n + n * n * n << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
	int i;
	char w,t[101]={};

	for(i=0;scanf("%c",&w)==1;i++)
		t[w-'a']++;
	
	for(i=0;i<26;i++)
		if(t[i]%2!=0){
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]
tmp = 0
ans = "No"
for i in range(N):
    if D[i][0] == D[i][1]:
        tmp += 1
    else:
        tmp = 0
    if tmp == 3:
        ans = "Yes"
print(ans)

Measured memory_bytes: 9204
//   HVARDHANSINGH   //
 
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
 
#define ll      long long
#define F       first
#define S       second
#define endl    "\n"

const ll M =    200006;
const int mod = 1000000007;

void solve()
{
	int n;	cin>>n;
	vector<double> v(n);
	for(int i=0; i<n; i++)
	{
		cin>>v[i];
	}
	
	double ans = 0;
	
	double one = 1;
	
	for(int i=0; i<n; i++)
	{
		ans = ans + (one/v[i]);
	}
	
	ans = one/ans;
	
	printf("%.15f", ans);
	
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}


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

int main(void)
{
    int H, W, N, total_paint=0, ans=0;
    cin >> H >> W >> N;
    int one_paint = max(H, W);
    while (total_paint < N){
        total_paint += one_paint;
        ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;
class BIT{
public:
  ll n,bit[555555];
  BIT(){fill(bit,bit+555555,0);}
  void add(ll i,ll x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  ll sum(ll i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};

BIT b=BIT();
void Main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) R a[i];
  b.n=n+1;
  ll ans=0;
  rep(i,n) {
    if(!b.sum(a[i])) ans++;
    b.add(a[i],1);
  }
  cout << ans << endl;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 6144
#include<stdio.h>
#define MAX 250
int A[MAX],n;
int left(int i){ return 2*i;}
int right(int i){ return 2*i+1;}
int parent(int i){ return i/2;}

void print(int u){
  printf("node %d: key = %d, ",u,A[u]);
  if(u>1) printf("parent key = %d, ",A[parent(u)]);
  if(left(u)<=n) printf("left key = %d, ",A[left(u)]);
  if(right(u)<=n) printf("right key = %d, ",A[right(u)]);
  printf("\n");
}
int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=n;i++) print(i);

  return 0;
}




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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) {
        cnt++;
      }
    }

    if (cnt == 8) {
      ans++;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var s, t, u string
	var sCount, tCount int

	firstArg := nextLine()
	secondArg := nextLine()
	thirdArg := nextLine()

	nSlice := strings.Split(firstArg, " ")
	kSlice := strings.Split(secondArg, " ")
	uSlice := strings.Split(thirdArg, " ")

	s = nSlice[0]
	t = nSlice[1]

	sCount, _ = strconv.Atoi(kSlice[0])
	tCount, _ = strconv.Atoi(kSlice[1])

	u = uSlice[0]

	if s == u {
		sCount--
	} else if t == u {
		tCount--
	}

	fmt.Print(sCount, tCount)
}

Measured memory_bytes: 640