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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    while(cin >> n, n) {
        vector<P> rw(n);
        int allRead = 0, allWrite = 0;
        rep(i, n) {
            cin >> rw[i].fi >> rw[i].se;
            allRead += rw[i].fi;
            allWrite += rw[i].se;
        }

        sort(all(rw), greater<P>());
        if (allRead >= 2 * rw[0].fi) {
            cout << allRead + allWrite << endl;
        } else {
            int rest = 2 * rw[0].fi - allRead + 1;
            bool dp[rest] = {true};
            int maxi = 0;
            repl(i, 1, rest) dp[i] = false;
            repl(i, 1, n) {
                repr(j, rest) {
                    if (dp[j] && j + rw[i].se < rest) {
                        dp[j + rw[i].se] = true;
                        maxch(maxi, j + rw[i].se);
                    }
                }
            }
            cout << 2 * rw[0].fi + allWrite - maxi << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3116
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

struct Dscc {
public:

	//fst:belongs , scd:newedges
	pair<vector<vector<int>>, vector<vector<int>>>get(const vector<vector<int>>&edges) {
		nums.resize(edges.size());
		fill(nums.begin(), nums.end(), -1);
		vector<vector<int>>revedges(edges.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				revedges[j].push_back(i);
			}
		}
		int num = 0;
		for (int i = 0; i < edges.size(); ++i) {
			dfs(i, num, edges);
		}
		vector<int>big(nums.size());
		for (int i = 0; i < nums.size(); ++i) {
			big[nums[i]] = i;
		}
		reverse(big.begin(), big.end());
		unis.resize(edges.size());
		fill(unis.begin(), unis.end(), -1);
		num = 0;
		for (int i = 0; i < big.size(); ++i) {

			dfs2(big[i], num, revedges);
			num++;
		}
		vector<int>nums;
		for (int i = 0; i < unis.size(); ++i) {
			nums.push_back(unis[i]);
		}
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());


		map<int, int>mp;
		for (int i = 0; i < nums.size(); ++i) {
			mp[nums[i]] = i;
		}
		for (int i = 0; i < unis.size(); ++i) {
			unis[i] = mp[unis[i]];
		}

		vector<vector<int>>belongs(nums.size());
		for (int i = 0; i < unis.size(); ++i) {
			belongs[unis[i]].push_back(i);
		}
		vector<vector<int>>newedges(nums.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				if (unis[i] != unis[j]) {
					newedges[unis[i]].push_back(unis[j]);
				}
			}
		}
		return make_pair(belongs, newedges);
	}
private:
	vector<int>nums;
	vector<int>unis;


	void dfs(const int id, int &num, const vector<vector<int>>&edges) {
		if (nums[id] != -1)return;
		else {
			nums[id] = -2;
			for (auto i : edges[id]) {
				dfs(i, num, edges);
			}
		}
		nums[id] = num++;
		return;
	}
	void dfs2(const int id, const int &num, const vector<vector<int>>&edges) {
		if (unis[id] != -1)return;
		else {
			unis[id] = -2;
			for (auto i : edges[id])
				dfs2(i, num, edges);
		}
		unis[id] = num;
		return;
	}

}dscc;

int main() {	
	vector<vector<int>>real_edges;
	{
		int N, M; cin >> N >> M;
		vector<vector<int>>edges(N);
		for (int i = 0; i < M; ++i) {
			int a, b; cin >> a >> b;
			edges[a].push_back(b);
		}
		auto p = dscc.get(edges);
		real_edges = (p.second);
	}

	vector<int>comes(real_edges.size());

	int num1=0,num2=0;
	for (int i = 0; i < real_edges.size(); ++i) {
		for (auto e : real_edges[i]) {
			comes[e]++;
		}
		if(real_edges[i].empty())num1++;
	}
	num2=count(comes.begin(),comes.end(),0);

	int ans=real_edges.size()==1?0:max(num1,num2);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 8060
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62



def solve(N: int):
    pre  = str(N)[-1]

    if int(pre) in [2
,
4
,
5
,
7
,
9
    ]:
        print('hon')
    elif int(pre) in [0,1,6,8]:
        print("pon")
    else:
        print("bon")
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9512
import java.util.Arrays;
import java.util.Scanner;

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

        int[] ls = new int[n];
        for (int i = 0; i < n; i++) {
            ls[i] = std.nextInt();
        }

        long ans = 0;
        Integer[] sortedLs = Arrays.stream(ls).sorted().boxed().toArray(Integer[]::new);
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int ab = sortedLs[i] + sortedLs[j];
                int nn = ~Arrays.binarySearch(sortedLs, ab, (l, r) -> (l.compareTo(r) >= 0) ? 1:-1);
                int diffIndex = nn - (j + 1);

                ans += Math.max(0, diffIndex);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 47576
#include <stdio.h>
#include <string.h>
int main(void) {
	char h[100],n[100];
	int lh,ln,i=0,j=0;
	scanf("%s",h);
	lh=strlen(h);
	scanf("%s",n);
	ln=strlen(n);
	for(;i<lh;i++){
		if(h[i]!=n[0]){continue;}
		for(j=1;j<ln;j++){
			if(h[(i+j)%lh]!=n[j]){j=ln*2;}
		}
		if(j==ln){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

int main(){
	int n, hen[3];

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> hen[0] >> hen[1] >> hen[2];
		sort(hen, hen+3);
		if(((hen[0]*hen[0]) + (hen[1]*hen[1])) == (hen[2]*hen[2])){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" <<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll k;
ll ct[100005];
int main(){
    scanf("%d%lld",&n,&k);
    for (int i = 0; i < n; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        ct[a] += b;
    }
    ll sum = 0;
    for (int i = 1; i <= 100000; i++){
        sum += ct[i];
        if (sum >= k){
            printf("%d",i);
            return 0;
        }
    }
}


Measured memory_bytes: 1024
#include <math.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>


using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for (int i = 0; i < N; i++)
  {
    cin >> m[i];
  }
  int res_X = X - accumulate(m.begin(), m.end(), 0);
  int m_min = *min_element(m.begin(), m.end());
  int num_m_min = res_X / m_min;
  cout << N + num_m_min << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  ll x, y; cin >> x >> y;
  if(y==100)
    cout << (ll)pow(100, x) * 101 << endl;
  else
    cout << (ll)pow(100, x) * y << endl;

  return 0;
}




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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

void solve();

int main(void){
    string S;
    string T;
    cin >> S >> T;
    int cnt = 0;
    rep(i, 3){
        if(S[i] == T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

void solve(){}

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

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

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

	int n;
	cin >> n;

	ll sum = 0;

	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MAXN 100000
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    int a[MAXN]={0};
    for (int i=0;i<N;i++){
	int x;
	cin >> x;
	a[x]++;
    }

    int res=a[0];
    for (int i=1;i<MAXN-1;i++){
	res=max(res,a[i-1]+a[i]+a[i+1]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, m, b[202][5003];
ll a[5003], d[5003][5003], z;

void sol(int i, int l, int r) {
    int c = 0;
    for (int j = l + 1; j < r; j++) if (b[i][j] > b[i][c]) c = j;
    for (int j = l + 1; j <= c; j++) d[j][c] += b[i][c], d[j][r] -= b[i][c];
    if (l + 1 < c) sol(i, l, c);
    if (c + 1 < r) sol(i, c, r);
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 2; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> b[j][i];
    for (int i = 1; i <= m; i++) sol(i, 0, n + 1);
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) d[i][j] += d[i][j - 1];
    for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) z = max(z, d[i][j] - a[j] + a[i]);
    cout << z;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(j,n) {
      if(j != n-1) {
        cout << a[j] << ' ';
      }else{
        cout << a[j] << endl;
      }
    }
  for(int i = 1; i < n; i++) {
    int v = a[i];
    int j = i - 1;
    while(j >= 0 && a[j] > v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    rep(j,n) {
      if(j != n-1) {
        cout << a[j] << ' ';
      }else{
        cout << a[j] << endl;
      }
    }
  }
  return 0;
}



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

using namespace std;

int main(){
  const int dirx[4] = {  1,  0, -1,  0 };
  const int diry[4] = {  0,  1,  0, -1 };
  int h,w,wall=0;
  cin >> h >> w;
  char map[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> map[i][j];
      if(map[i][j] == '#') wall++;
    }
  }

  vector<vector<int> > dist( h, vector<int>(w,0) );
  dist[0][0] = 1;
  for(int d = 1; d < h*w; d++ ){
    for(int y = 0; y < h; y++){
      for(int x = 0; x < w; x++){
        if ( dist[y][x] == d ){
          for ( int r=0; r<4; r++ ){
            int tx = x + dirx[r];
            int ty = y + diry[r];

            if ( 0 <= tx  &&  tx < w  &&
                       0 <= ty  &&  ty < h  &&
                      map[ty][tx] != '#'  &&
                      dist[ty][tx] == 0 ){
                    dist[ty][tx] = d + 1;
            }
          }
        }
      }
    }
  }
  if(dist[h-1][w-1] == 0) cout << -1 << endl;
  else cout << (h*w - wall - dist[h-1][w-1]) << endl;
  return 0;
}


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

int main() {
  ll n,m,x,ans=0;
  cin>>n>>m>>x;
  vector<ll> c(n);
  vector<vector<ll>> a(n,vector<ll>(m));
  for(ll i=0;i<n;i++){
    cin>>c[i];
    for(ll j=0;j<m;j++) cin>>a[i][j];
  }
  for(ll i=0;i<(1<<n);i++){
    vector<ll>u(m);
    ll ii=i,jj=0,anst=0; bool ok=1;
     while(ii){
      if(ii%2){
        anst+=c[jj];
        for(ll j=0; j<m; j++) u[j]+=a[jj][j];
      }
      ii/=2; jj++;
    }
    for(ll j=0; j<m; j++) if(u[j]<x){ok=0; break;}
    if(ok){
      if(ans) ans=min(ans,anst);
      else ans=anst;
    }

  }
  cout <<(ans==0?-1:ans);

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define N 200005
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
multiset<int>st;
multiset<int>::iterator it;
int n,m;
bool res;
int A[N];
int ans;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++){scanf("%d",&A[i]);}
	for(int i=n;i;i--){
		it=st.upper_bound(A[i]);
		if(it==st.end())ans++,st.insert(A[i]);
		else st.erase(it),st.insert(A[i]);
	}
	printf("%d",ans);
	return 0;
}


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

int main(){

  int n, a;
  vector<int>v;

  cin >> n;

  for(int i = 1; i <= n; i++){
    cin >> a;
    a--;
    v.push_back(a);
  }
  int cur = 0, cnt = 0;
  while(true){
    if(cur == 1){
      cout << cnt << endl;
      return 0;
    }
    if(cnt >= n){
      cout << "-1" << endl;
      return 0;
    }
    cnt++;
    cur = v[cur];
  }
}


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

using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
        for (int j = i + 1; j < s.length(); j++) {
            if (s[i] == s[j]) {
                cnt++;
            }
        }
    }

    cout << (cnt == 2 ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll H,W;
    cin>>H>>W;
    ll ans = 10e10;

    // horizontal
    ans=min(ans, (H%3==0)?0:W);

    // vertial
    ans=min(ans,(W%3==0)?0:H);

    for (ll x=0; x<=W; x++){
        set<ll> s;
        s.insert((H/2)*x);
        s.insert(H*x - (H/2)*x);
        s.insert(H*(W-x));
        auto mi = s.begin();
        auto ma = s.end(); ma--;
        ans=min(ans, *ma-*mi);
    }

    for (ll y=0; y<=H; y++){
        set<ll> s;
        s.insert((W/2)*y);
        s.insert(W*y - (W/2)*y);
        s.insert(W*(H-y));
        auto mi = s.begin();
        auto ma = s.end(); ma--;
        ans=min(ans, *ma-*mi);
    }

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


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

int a[500000];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n) {
        if (s[i] == '<') {
            a[i+1] = max(a[i+1], a[i]+1);
        }
    }
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == '>') {
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    Int ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2820
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        int b;
        int f;
        int r;
        int v;
        n = sc.nextInt();
        int house[][][];
        house = new int[4][3][10];//[building],[floor],[room]
        int i,j,k;
        for(i=0;i<4;i++){
            for(j=0;j<3;j++){
                for(k=0;k<10;k++){
                    house[i][j][k] = 0;
                }
            }
        }
        int count;
        for(count=0;count<n;count++){
            b = sc.nextInt();            
            f = sc.nextInt();            
            r = sc.nextInt();            
            v = sc.nextInt();
            house[b-1][f-1][r-1] += v;
            //System.out.println("ok");
        }

        for(i=0;i<4;i++){
            for(j=0;j<3;j++){
                for(k=0;k<10;k++){
                    System.out.print(" " + house[i][j][k]);
                }
                System.out.println("");
            }
            if(i<3){
                System.out.println("####################");
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 29776
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
ll A[10000];
int main() {
	ll N, M, X; cin >> N >> M >> X;
	rep(i, 0, M)
	{
		cin >> A[i];
		//(X > A[i]) ? b++ : a++;
	}
	auto t = upper_bound(A, A + M, X);
	ll a = t - A;
	ll b = M - a;

	cout << max((ll)0, min(a, b)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	bitset<100010>v;

	int n,m,aux,p=0,a=0;
	string s;

	cin >> n >> m;
	vector<int>pe(n+10);
	while(m--){
		cin >> aux >> s;
		if(s=="AC" and v[aux]==false){
			a++;
			v[aux]=true;
			p+=pe[aux];
		}
		if(s=="WA" and v[aux]==false){
			pe[aux]++;
		}
	}
	cout << a << " " << p << endl;
	return 0;
}

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

int main(){
    int a, b;
    while(cin >> a >> b){
        if(a + b == 0)  break;

        int dp[b][a];
        bool cons[b][a];
        for(int i = 0; i < b; i++){
            for(int j = 0; j < a; j++){
                dp[i][j] = 0;
                cons[i][j] = false;
            }
        }
        dp[0][0] = 1;

        int n;
        cin >> n;

        int x, y;
        for(int i = 0; i < n; i++){
            cin >> x >> y;
            x--; y--;
            cons[y][x] = true;
        }

        for(int i = 1; i < b; i++){
            if(!cons[i][0]) dp[i][0] = dp[i-1][0];
        }
        for(int i = 1; i < a; i++){
            if(!cons[0][i]) dp[0][i] = dp[0][i-1];
        }

        for(int i = 1; i < b; i++){
            for(int j = 1; j < a; j++){
                if(!cons[i][j]) dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
        }
        cout << dp[b-1][a-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
N = int(input())
a = list(map(int, input().split()))
d2 = 0
d4 = 0
for i in a:
    if i % 4 == 0:
        d4 += 1
    elif i % 2 == 0:
        d2 += 1
if d4 >= N // 2:
    print("Yes")
elif d2 >= N - d4 * 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int64_t& f(int *i) {
    return *(int64_t *)i;
}

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

    char s[3][2001] = {};
    int k = 1;
    vector<int[2001]> v(n + 1);
    vector<int[2001][2]> e(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> s[k];
        int t = 0;
        for (int j = 0; j < m; j++) {
            v[i + 1][j + 1] = v[i][j + 1] + (t += (s[k][j] -= '0'));
            f(e[i + 1][j + 1]) = f(e[i][j + 1]) + f(e[i + 1][j]) - f(e[i][j]) + (s[k][j] & s[k][j - 1]) + ((int64_t)(s[k][j] & s[k ^ 3][j]) << 32);
        }
        k ^= 3;
    }

    for (int i = 0; i < q; i++) {
        int x0, y0, x1, y1;
        scanf("%d%d%d%d", &y0, &x0, &y1, &x1);
        int x2 = x0 - 1, y2 = y0 - 1;

        cout << (v[y1][x1] - v[y1][x2] - v[y2][x1] + v[y2][x2]) - (e[y1][x1][0] - e[y1][x0][0] - e[y2][x1][0] + e[y2][x0][0]) - (e[y1][x1][1] - e[y1][x2][1] - e[y0][x1][1] + e[y0][x2][1]) << '\n';
    }

    return 0;
}

Measured memory_bytes: 48768
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	printf("%d\n", n/2 + n%2);
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = input()
a1 = n[0]
a2 = n[0]
count1 = 1
count2 = 0
for nc in range(1,4):
    if(n[nc] == a1):
        count1 += 1
    elif(a1 == a2):
        a2 = n[nc]
        count2 += 1
    elif(n[nc] == a2):
        count2 += 1
    else:
        count1 = 5
if(count1 == count2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int a[101][101], b[101], c[101];
    int i, j;
    int n, m;
 
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    }
    for (j = 0; j < m; j++) scanf("%d", &b[j]);
 
    for (i = 0; i < n; i++) {
        c[i] = 0;
        for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
    }
 
    for (i = 0; i < n; i++) {
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2056
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		
		String str;
		
		char c = 'a';

		int id; //read??§?????????????????????????????????????´?
		
		int sum[] = new int[26];
		
		try {
			while((id = isr.read()) != -1) {
				id = Character.toLowerCase(id);
				
				int num = id - 'a'; //id ??? a ???????????????????????????????´?
				
				if(0 <= num && num < 26) {
					sum[num]++;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		for(int i = 0; i < 26; i++){
			System.out.println(c + " : " +sum[i]);
			c++;
		}
	}
}

Measured memory_bytes: 24408
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

k = iinp()
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])

Measured memory_bytes: 3064
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<ll> a(n); rep(i, n)cin >> a[i];
	ll res = 1e18;
	rep(i, pow(2, n - 1))
	{
		ll tmp = 0;
		ll now = a[0];
		int cnt = 1;
		rep(j, n - 1)
		{
			if (i&(1 << j))
			{
				++cnt;
				if (now < a[j + 1])now = a[j + 1];
				else
				{
					tmp += now - a[j + 1] + 1;
					++now;
				}
			}
			else
			{
				now = max(now, a[j + 1]);
			}
		}
		if (cnt >= k)res = min(res, tmp);
	}
	cout << res << endl;
}

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

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int ans = 0;
    REP(i,4){
        char c; cin >> c;
        if(c == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long

int main(){
    ll N, K,sum=0,l=0,r=0, tmp =1000000000000000000LL;;
    cin >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        sum += a[i];
    }
    r = sum;
    for(int i = 0; i < N-1; i++){
        l += a[i];
        r -= a[i];
        tmp = min(tmp, abs(l-r));  
    }
    cout << tmp << endl;
}

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

	int main(){
    int a;
    int b;
    double x;
    double y;  
    double z;  
    cin>>a>>b;
    x=(a+b)/2;
    y=(a+b)/2.0;
    z=(y-x)*2;  
    cout<<x+z<<endl;  
    }

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

int main() {
    int A,B;cin>>A>>B;
    int big=max(A,B);
    for(int i=0;i<=big;i++){
        if(abs(A-i)==abs(B-i)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
n=int(input())
dic={}
l=list(input())
for i in range(n):
    dic.setdefault(l[i],0)
    dic[l[i]]+=1
s=list(dic.values())
ans=1
mod=10**9+7
for i in s:
    ans*=(i+1)%mod
print((ans-1)%mod)

Measured memory_bytes: 3956
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int H,W;

  cin>>H>>W;

  string str;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>str;

      if(str=="snuke"){
	printf("%c%d\n",'A'+j,i+1);
	return 0;
      }
    }
  }

  return 0;
  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  if(N>=64){
    cout<<64;
  }else if(N>=32){
    cout<<32;
  }else if(N>=16){
    cout<<16;
  }else if(N>=8){
    cout<<8;
  }else if(N>=4){
    cout<<4;
  }else if(N>=2){
    cout<<2;
  }else if(N>=1){
    cout<<1;
  }
}

Measured memory_bytes: 3564
num = map(int, raw_input().split())
for i in range(0,2):
 for j in range(0,2):
  if num[j] > num[j+1]:
   tmp_box = num[j]
   num[j] = num[j+1]
   num[j+1] = tmp_box
sort = map(str, num)
print sort[0] + " " + sort[1] + " " + sort[2]

Measured memory_bytes: 6376
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    map<string, ll>cnt;
    string s, t;
    cin >> s >> t;
    cin >> cnt[s] >> cnt[t];
    string u;
    cin >> u;
    cnt[u]--;
    cout << cnt[s] << " " << cnt[t] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a && c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;  
}


Measured memory_bytes: 3612
def is_prime(t):
  i=2
  while i**2<=t:
    if t%i==0:
      return 0
    i+=1
  return 1
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
n=10**5
p=[0]*(n+1)
d=set()
for i in range(2,n):
  if is_prime(i):
    d.add(i)
  if i in d and (i+1)//2 in d:
    p[i]=p[i-1]+1
  else:
    p[i]=p[i-1]
for l,r in lr:
  print(p[r]-p[l-1])



Measured memory_bytes: 29860
#include<stdio.h>
#include<math.h>

int main(){
  int N; 
  scanf("%d",&N);
  int i,j;
  int a[N][2];

  for(i = 0;i < N;i++){
  	scanf("%d %d",&a[i][0],&a[i][1]);
  }

  double num = 0.0;
  for(i = 0; i < N;i++){
  	for(j = i;j < N;j++){
        num += sqrt( (a[i][0] - a[j][0])*(a[i][0] - a[j][0]) + (a[i][1] - a[j][1])*(a[i][1] - a[j][1]));
    }
  }

  printf("%f",num*2/N);
  return 0;
}

Measured memory_bytes: 128
l = [0] * 5
for i in range(5):
  l[i] = int(input())
k = int(input())

#print(l, k)

for i in range(5):
  for j in range(5):
    if abs(l[i] - l[j]) > k:
      print(':(')
      exit()

print('Yay!')

Measured memory_bytes: 3060
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline

N, C = map(int, readline().split())
xv = np.array(read().split(), np.int64).reshape(N, 2)
v = xv[:, 1]
x = xv[:, 0]

ax = C - x[::-1]
cx = x.copy()
cx[1:] = cx[1:] - cx[:-1]
acx = C - x
acx[:-1] = acx[:-1] - acx[1:]

clockwise = v - cx
np.cumsum(clockwise, out=clockwise)
anticlockwise = v - acx
anticlockwise = np.cumsum(anticlockwise[::-1])

con_max = np.maximum.accumulate(clockwise)
anti_max = np.maximum.accumulate(anticlockwise)

answer = [0, con_max[-1], anti_max[-1]]

for i in range(N - 1):
    answer.append(clockwise[i] - x[i] + anti_max[N - i - 2])
    answer.append(anticlockwise[i] - ax[i] + con_max[N - i - 2])

print(max(answer))

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e8
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 100005

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);

    REP(i, n) cin >> a[i];

    int left = 0, right = 0;
    ll ans = 0;
    ll now_xor = 0;
    ll now_sum = 0;
    int i, j = 0;

    REP(i, n) {
        while(1) {
            if(j == n) break;
            if((now_xor^a[j]) != (now_sum + a[j])) break;
            now_xor ^= a[j];
            now_sum += a[j];
            //cout << now_xor << " " << now_sum << endl;
            j++;
        }

        ans += j - i;
        //cout << j << " " << i << " " << j-i << endl;

        now_sum -= a[i];
        now_xor ^= a[i];
    }

    cout << ans << endl;
}
 

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

int main(void){
  int n, temp;
  cin >> n;
  map<int, int> m;
  for(int i = 0; i < n; i++){
    cin >> temp;
    m[temp]++;
  }
  int ans = 0;
  for(auto i = m.begin(); i != m.end(); i++){
    if(i->first != i->second){
      if(i->second > i->first) ans += i->second - i->first;
      else ans += i->second;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4736
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = in.next();
        StringBuilder new_s = new StringBuilder(s.length()/2);
        for (int i = 0; i < s.length(); i += 2){
            if (i % 2 == 0){
                new_s = new_s.append(s.charAt(i));
            }
        }
        System.out.println(new_s);
    }
}

Measured memory_bytes: 24916
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main () {
    int n;
    string s; cin >> n >> s;
    char now_c;
    int count = 1; 

    for (int i = 0; i < n; i++) {
        char c = s[i];
        if (i == 0) {
            now_c = c;
        } else {
            if (now_c == c) {
                continue;
            } else {
                count++;
                now_c = c;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 512
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val in = List.fill(n, 2)(sc.next())
  val groupedBySuit = in.groupBy(e => e(0))

  // ???????????????'S'???????????????'H'???????????????'C'???????????????'D'
  // ????????????????????????????????????????????????????????????????????§???????????????????????????
  val suit = List("S", "H", "C", "D")
  for (s <- suit) {
    if (groupedBySuit.get(s).get.size == 13) {}
    else {
      val numList = groupedBySuit.get(s).get.map(e => e(1).toInt)
      val shortage = (1 to 13).diff(numList).toList.sorted
      shortage.foreach(e => println(s"${s} ${e}"))
    }
  }
}

Measured memory_bytes: 45212
A,B,C,X,Y = map(int, (input().split()))

if C*2 >= A+B:
    print(A*X+B*Y)
else:
    if X > Y:
        ans=Y*2*C+(X-Y)*A
        ans=min(ans, X*2*C)
    else:
        ans=X*2*C+(Y-X)*B
        ans=min(ans, C*2*Y)
    print(ans)

Measured memory_bytes: 9180
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m=sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        Map<Long,Long> map = new HashMap<>();
        for(int i = 0;i<n;i++){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
            if(map.containsKey(a[i])){
                map.put(a[i],map.get(a[i])+b[i]);
            }else {
                map.put(a[i],b[i]);
            }
        }
        Arrays.sort(a);
        long ans = 0;
        long count = 0;
        for(int i = 0;i<n;i++){
            if (i!=0 && a[i] == a[i-1]) continue;
            if(count+map.get(a[i])>m){
                ans+=a[i]*(m-count);
                count=m;
            }else {
                ans+=a[i]*map.get(a[i]);
                count+=map.get(a[i]);
            }
            if(count>=m)break;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 69408
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int, Y: int):
    for i in range(X+1):
        if 2 * i + 4 * (X - i) == Y:
            return YES
    return NO


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    print(solve(X, Y))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll H,W;scanf("%lld %lld",&H,&W);
    vvl info(H,vl(W));
    rep(i,H)rep(j,W)scanf("%lld",&info[i][j]);
    vector<pair<pl,pl>> ans;
    rep(i,H)rep(j,W){
        if(i<H-1){
            if(info[i][j]%2){
                ans.push_back({{i+1,j+1},{i+2,j+1}});
                info[i][j]--,info[i+1][j]++;
            }
        }
        else{
            if(j<W-1){
                if(info[i][j]%2){
                    ans.push_back({{i+1,j+1},{i+1,j+2}});
                    info[i][j]--,info[i][j+1]++;
                }
            }
        }
    }
    printf("%lld%s",ans.size(),"\n");
    for(auto p:ans)printf("%lld %lld %lld %lld%s",p.fi.fi,p.fi.se,p.se.fi,p.se.se,"\n");
    return 0;
}

Measured memory_bytes: 8176
from collections import deque

n = int(input())
vdata = [list(map(int,input().split())) for _ in range(n)]
d = [-1]*n
q = deque()
q.append(vdata[0])
d[0] = 0

while len(q) > 0:
  node = q.popleft()
  c = d[node[0]-1]
  a = node[1]
  for i in range(a):
    b = node[i+2]-1
    if d[b] == -1:
      d[b] = c+1
      q.append(vdata[b])
      
for i in range(n):
  print(i+1, d[i])


Measured memory_bytes: 6036
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    ull a;
    float b;
    cin >> a >> b;
    ull ans = (a * (ll)(b*100+0.5))/100;
    cout << ans << endl;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
//const int mod = 1e18 + 7;
int main()
{
	SPEED
	int n, k, count = 0, temp;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> temp;
		if (temp>=k)
		{
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <climits>
#include <algorithm>
using namespace std;

#define MAX 1000000
using ll = long long;

int main(){
    vector<ll> v;
    vector<ll> odd_v;

    for(ll i = 1; i < MAX; ++i){
        ll num = i * (i + 1) * (i + 2) / 6;
        v.push_back(num);
        if(num & 1) odd_v.push_back(num);
    }

    int dp[MAX];
    int odd_dp[MAX];
    fill(dp, dp+MAX, INT_MAX);
    fill(odd_dp, odd_dp+MAX, INT_MAX);
    dp[0] = 0;
    odd_dp[0] = 0;

    for(int i = 0; i < MAX; ++i){
        for(int j = 0; j < v.size(); ++j){
            if(i - v[j] >= 0) dp[i] = min(dp[i - v[j]] + 1, dp[i]);
            else break;
        }

        for(int j = 0; j < odd_v.size(); ++j){
            if(i - odd_v[j] >= 0) odd_dp[i] = min(odd_dp[i - odd_v[j]] + 1, odd_dp[i]);
            else break;
        }
    }

    while(true){
        int n; cin >> n;
        if(!n) break;

        cout << dp[n] << ' ' << odd_dp[n] << endl;
    }

    return EXIT_SUCCESS;
}



Measured memory_bytes: 22316
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n; cin >> n;
    cout << (n - 1)/ 2 << endl;
    return 0;
}

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

int main() {
	int n, m, l;
	int a[100][100] = {}, b[100][100] = {};
	long long  c[100][100] = {};

	cin >> n >> m >> l;

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			cout << c[i][j];

			if (j != l - 1)cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
const int INF = 1e8;
int N, Q; string S; set<int> s[26];
int main() {
  cin >> N >> S >> Q;
  for(int i = 0; i < 26; ++i) s[i].insert(INF);
  for(int i = 0; i < N; ++i) s[S[i]-'a'].insert(i+1);
  for(int i = 0; i < Q; ++i) {
    int type, iq, lq, rq; char cq;
    cin >> type;
    if(type == 1) {
      cin >> iq >> cq;
      s[S[iq-1]-'a'].erase(iq);
      s[cq-'a'].insert(iq);
      S[iq-1] = cq;
    } else {
      cin >> lq >> rq;
      int cnt = 0;
      for(int j = 0; j < 26; ++j) {
        auto itrL = s[j].lower_bound(lq);
        auto itrR = s[j].upper_bound(rq);       
        if(*itrR > *itrL) ++cnt;
      }
      cout << cnt << endl;
    }
  }
}

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

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

    int a, b;

    for(int i=0; i<s.size(); ++i){
        if(s.at(i) == 'A'){
            a = i;
            break;
        }
    }

    for(int i=s.size()-1; i>=0; --i){
        if(s.at(i) == 'Z'){
            b = i;
            break;
        }
    }
    cout << b-a+1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long a[105];
long long b2,b4,b14,b24,b74;
int main(void){
    int n; cin>>n;
    for(int i=1;i<=n;i++){
        int k=i;
        for(int j=2;j*j<=k;j++){
            while(k%j==0){
                a[j]++;
                k/=j;
            }
        }
        if(k!=1){
            a[k]++;
        }
    }
    for(int i=1;i<=n;i++){
        if(a[i]>=74){
            b74++; b24++; b14++; b4++; b2++;
        }else if(a[i]>=24){
            b24++; b14++; b4++; b2++;
        }else if(a[i]>=14){
            b14++; b4++; b2++;
        }else if(a[i]>=4){
            b4++; b2++;
        }else if(a[i]>=2){
            b2++;
        }
    }
    cout<<b74+b24*(b2-1)+b14*(b4-1)+b4*(b4-1)*(b2-2)/2<<endl;
    
}


Measured memory_bytes: 256
using System;

namespace DPL_1E_1 {
    public class Program {
        public static void Main(string[] args) {
            var s1 = " " + Console.ReadLine();
            var s2 = " " + Console.ReadLine();
            var dp = new int[s1.Length, s2.Length];

            for(var i = 0; i < s1.Length; i++) dp[i, 0] = i;
            for(var j = 0; j < s2.Length; j++) dp[0, j] = j;

            for(var i = 1; i < s1.Length; i++) {
                for(var j = 1; j < s2.Length; j++) {
                    var min = Math.Min(dp[i - 1, j] + 1, dp[i, j - 1] + 1);
                    dp[i, j] = s1[i] == s2[j] ? Math.Min(min, dp[i - 1, j - 1]) : Math.Min(min, dp[i - 1, j - 1] + 1);
                }
            }

            Console.WriteLine(dp[s1.Length - 1, s2.Length - 1]);
        }
    }
}

Measured memory_bytes: 13024
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string str;
int main(){
	string left("qwertasdfgzxcvb");
	string right("yuiophjklnm");
	while(cin>>str){
		if(str[0]=='#')
			break;
		int l = str.length();
		int step = 0;
		bool flag;
		if(left.find(str[0],0)!=string::npos){
			flag =true;
		}else{
			flag =false;
		}
		for(int i = 1;i < l;i++){
			int L =left.find(str[i],0);
			if(L!=string::npos){//左で見つかった場合
				if(flag)
					continue;
				else{
					step++;
					flag = true;
				}
			}else{//右で見つかった場合
				if(!flag){//前の手が右手
					continue;
				}else{//前の手が左
					step++;
					flag = false;
				}
			}
		}
		cout <<step<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int prim[N/5],prime_n,midiv[N+5]; 
void prime(){
    for(int i=2;i<=N;i++){
        if(!midiv[i])prim[prime_n++]=i,midiv[i]=i;//没有筛掉的为素数
        for(int j=0;j<prime_n&&i*prim[j]<=N;j++){
            midiv[prim[j]*i]=prim[j];//筛掉
            if(i%prim[j]==0)break;//后面的数最小因数一定小于等于prim[j]
        }
    }
}
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int num[N+5];
int main(){
	int n,x;scanf("%d",&n);
	prime();
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		while(x>1){num[midiv[x]]++;int w=midiv[x];while(x%w==0)x/=w;}
	}
	int ma=0;
	for(int i=1;i<=N;i++)ma=max(ma,num[i]);
	if(ma==n)puts("not coprime");
	else if(ma>1)puts("setwise coprime");
	else puts("pairwise coprime");
	return 0;
}

Measured memory_bytes: 11796
#include <stdio.h>

int main(void){
    int n, i, j, p, s[247000];
    n=1;
    s[0]=0; s[1]=0;
    for (i=2; i<=246999; i++) {
        p=1; j=2;
        while (j*j<=i) {
            if (i%j==0) {
                p=0;
                break;
            }
            j++;
        }
        s[i]=s[i-1]+p;
    }
    while (1) {
        scanf("%d", &n);
        if (n==0) break;
        printf("%d\n", s[2*n]-s[n]);
    }
    return 0;
}


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




int n;




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

    cin >> n;
    int d[n+1];
    for ( int i = 1; i <= n; ++i)
        cin >> d[i];


    sort(d + 1, d + (n+1));

        cout << d[n/2 +1] - d[n/2];






    return 0;
}


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

using namespace std;

int main() {
	int num[5];
	for (int i = 0; i < 5; ++i) {
		cin >> num[i];
	}

	sort(num, num + 5);

	cout << num[4] << " " << num[3] << " " << num[2] << " " << num[1] << " " << num[0] << endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    int ans=0;
    rep(i,n) cin >> d[i];
    rep(i,n){
        for (int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,t,sum;
    while(cin>>n)
    {
    	sum=0;
    	t=n;
    	while(n)
    	{
	    	sum=sum*10+n%10; 
        	n/=10;
	    }
	    if(t==sum) 
        cout<<"Yes"<<endl;
    	else
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256