akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  string s;
  cin >> s;
  rep(i, s.size()){
    if(s[i] == 'h' && s[i + 1] == 'i'){
      i ++;
    } else {
      cout << "No\n";
      return 0;
    }
    
  }
  cout << "Yes\n";
  
  return 0;
}


Measured memory_bytes: 256
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n = int(input())
    a = [x for x in map(int,input().split())]
    b = [x for x in map(int,input().split())]
    c = [x for x in map(int,input().split())]
    eat = n+1
    ans = 0
    for i in range(n):
        ans += b[a[i]-1]
        if a[i]==eat+1:
            ans += c[a[i]-2]
        eat = a[i]
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

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

const int MAXN = 2e5 + 10;

int n, qq;

struct thing {
	int s, t;
	int x;
} tg[MAXN];

class Compare{
	public:
	bool operator() (int a, int b){
		return tg[a].x > tg[b].x;
	}
};

bool ison[MAXN];
vector<pii> beg, endi;

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> qq;
	for(int i=0; i<n; i++){
		cin >> tg[i].s >> tg[i].t >> tg[i].x;
		beg.pb({tg[i].s - tg[i].x, i});
		endi.pb({tg[i].t - tg[i].x, i});
	}

	sort(beg.begin(), beg.end());
	sort(endi.begin(), endi.end());
	
	priority_queue<int, vector<int>, Compare> q;

	auto it1 = beg.begin();
	auto it2 = endi.begin();
	for(int i=0; i<qq; i++){
		ll cd; cin >> cd;		
		while(it1 != beg.end() && it1 -> x <= cd){
			ison[it1 -> y] = 1;
			q.push(it1 -> y);
			it1++;
		}

		while(it2 != endi.end() && it2 -> x <= cd){
			ison[it2 -> y] = 0;
			it2++;
		}

		while(!q.empty() && !ison[q.top()]) q.pop();
		
		if(q.empty()) cout << "-1\n";
		else cout << tg[q.top()].x << endl;
	}
}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define foreach(e, v) for (auto e : v)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

//void print_warm(int l,int r){
//    rep(i,r){
//        if(l<=i && i<r){
//            cout << '-';
//        }else{
//            cout << ' ';
//        }
//    }
//    cout << endl;
//}

int paint_max_area(string &s, int k){
    int left = 0, right = 0, mx = 1;
    char I = '1', O = '0';
    rep(i,k+1){
        do{
            if(right>=s.length()) break;
            right++;
        }while(!((i==0 && s[0]==O)||(s[right-1]==I && s[right]==O)) && right<s.length());
    }
    mx = max(mx, right - left);
//    print_warm(left, right);
    while(right<s.length()){
        do{
            left++;
        }while(!(s[left]==I && s[left-1]==O) && left<right);
//        print_warm(left, right);
        do{
            if(right>=s.length()) break;
            right++;
        }while(!(s[right]==O && s[right-1]==I) && right<s.length());
        mx = max(mx, right - left);
//        print_warm(left, right);
    }
    return mx;
}

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    cout << paint_max_area(s,k) << endl;
    return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c&&c<=b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        int num = r * 100 + g * 10 + b;

        if (num % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21460
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        s: chars
    }
    let mut l = 0;
    for c in s.iter().rev() {
        if *c == ')' { l+=1 } else { l = std::cmp::max(l-1,0) }
    }
    let mut r = 0;
    for c in s.iter() {
        if *c == '(' { r+=1 } else { r = std::cmp::max(r-1,0) }
    }
    for _ in 0..l { print!("("); }
    for c in s { print!("{}", c); }
    for _ in 0..r { print!(")"); }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define sf sacnf
#define pf printf
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define ii pair <int,int>
#define iii pair <int,ii>
#define pll pair <ll,ll>
#define plll pair <ll,pll>
#define Ziru 0
using namespace std;

int main(){
    int a,b;
    char c;

    while(cin>>a>>c>>b){
        if(c=='?') break;
        if(c=='+') cout<<a+b<<endl;
        if(c=='-') cout<<a-b<<endl;
        if(c=='*') cout<<a*b<<endl;
        if(c=='/') cout<<a/b<<endl;
    }
    return Ziru;
}



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

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

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int a, b, t;

signed main()
{
    cin >> a >> b >> t;

    cout << (t/a) * b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int n,h,a[N],b[N],c[N],d[N];
//是否存在可行流
struct edge{int f,t,g;}w[N];
int s,t,S,T,head[N],nxt[N],cnt=1,I[N],O[N];
void add(int f,int t,int g){
	//printf("%d->%d g=%d\n",f,t,g);
	w[++cnt]=(edge){f,t,g};
	nxt[cnt]=head[f];
	head[f]=cnt;
	w[++cnt]=(edge){t,f,0};
	nxt[cnt]=head[t];
	head[t]=cnt;
}
struct st{
	int x,i,df;
	st(int X=0,int DF=0){x=X;i=head[x];df=DF;}
}z[N];
int top,flow,l[N];
#define V z[top].x
#define E z[top].i
#define F z[top].df
void change(){
	int df=F;flow+=df;
	for (int i=top-1;i;i--){
		w[z[i].i].g-=df;
		w[z[i].i^1].g+=df;
		z[i].df-=df;
		if (!z[i].df) top=i;
	}
}
queue<int> Q;
void bfs(){
	for (int i=s;i<=t;i++) l[i]=0;
	l[s]=1;Q.push(s);
	while (!Q.empty()){
		int v=Q.front();Q.pop();
		for (int i=head[v];i;i=nxt[i])
		if (w[i].g&&!l[w[i].t]) l[w[i].t]=l[v]+1,Q.push(w[i].t);
	}
}
bool dinic(){
	bfs();
	if (!l[t]) return 0;
	z[top=1]=st(s,1e9);
	while (top){
		if (V==t) change(),top--,E=nxt[E];else
		if (!E) l[V]=0,top--,E=nxt[E];else
		if (w[E].g&&l[w[E].t]==l[V]+1)
			z[top+1]=st(w[E].t,min(F,w[E].g)),top++;
		else E=nxt[E];
	}
	return 1;
}
vector<int> e[N];
bool cir[N],vis[N];
void bfs(int S,bool *vis){
	Q.push(S);vis[S]=1;
	while (!Q.empty()){
		int v=Q.front();Q.pop();
		for (int i=0;i<e[v].size();i++){
			int u=e[v][i];
			if (!vis[u]) vis[u]=1,Q.push(u);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&h);
	for (int i=1;i<=n;i++){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
		int f=(c[i]?c[i]+h:a[i]),t=(d[i]?d[i]:b[i]+h);
		e[f].push_back(t);
		I[t]++;O[f]++;
		if (f==t) cir[f]=1;
	}
	s=0;S=h*2+1;T=S+1;t=T+1;
	add(T,S,1e9);
	for (int i=1;i<=2*h;i++){
		if (I[i]) add(s,i,I[i]);
		if (O[i]) add(i,t,O[i]);
		if (i>h) add(i,T,1e9);else add(S,i,1e9);
	}
	while (dinic());
	if (flow!=n) return puts("NO"),0;
	for (int i=2;i<=cnt;i+=2)
		if (w[i^1].g) e[w[i].f].push_back(w[i].t);
	bfs(S,vis);
	for (int i=1;i<=2*h;i++)
		if ((I[i]||O[i])&&!vis[i]) return puts("NO"),0;
	puts("YES");
	return 0;
}

Measured memory_bytes: 56320
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <bitset>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

bool used[55][35];

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

		memset(used, 0, sizeof(used));
		rep(i, n) {
			int x;
			cin >> x;
			rep(j, x) {
				int y;
				cin >> y;

				used[i][y] = true;
			}
		}

		ll S[55];
		memset(S, 0, sizeof(S));

		bool flag = true;
		rep(i, 35) {
			rep(j, n) {
				rep(k, n) {
					if(used[j][i] && used[k][i]) {
						ll sum = (S[j] | S[k]);
						sum |= (1LL << j);
						sum |= (1LL << k);

						S[j] = S[k] = sum;
					}
				}
			}

			rep(j, n) {
				if(__builtin_popcountll(S[j]) == n) {
					cout << i << endl;
					flag = false;
					break;
				}
			}

			if(!flag) break;
		}

		if(flag) cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1000*1000*1000;
const ll LINF = (ll)1e18;
int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};

vector<vector<int>> mp(501, vector<int>(501,0));

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    string S;
    cin >> S;
    int balance = 0;
    
    REP(i, S.size()){
        if(S[i] == '('){
            balance++;
        }else{
            balance--;
        }
        if(balance < 0){
            S = '(' + S;
            balance++;
            i++;
        }
    }
    cout << S;
    REP(i, balance){
        cout << ')';
    }
    cout << endl;
    return 0;
}


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

int main() {
	int n,m,a,b,c,sum=0;
	cin>>a>>b>>c>>n;
	if(a>b){
	    sum+=b;
	}
	else{
	    sum+=a;
	}
	if(c>n){
	    sum+=n;
	}
	else{
	    sum+=c;
	}
	cout<<sum<<'\n';
	return 0;
}

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

tmp = sorted(map(int, input().split()), key=lambda x: -x)[:X] \
      + sorted(map(int, input().split()), key=lambda x: -x)[:Y] \
      + sorted(map(int, input().split()), key=lambda x: -x)

print(sum(sorted(tmp, key=lambda x: -x)[:X + Y]))


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

int main()
{
	int n, k, b;
	int stock[100];
	bool judge;

	while(cin >> n >> k, (n||k))
	{
		if(!(n||k))goto YAMADA;

		judge = 0;

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

		for( int i = 0; i < n; i++)
			for( int j = 0; j < k; j++)
			{
				cin >> b;
				stock[j] -= b;

				if(stock[j] < 0)
					judge = 1;

			}

		if(judge == 1)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;

	}
	
	YAMADA:
	return 0;
}

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

int main()
{
	int H, W, i, j;
	
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0){
			break;
		}
		for(i = 0; i < H; i++){
			for ( j = 0; j < W; j++){
				if (j == 0 || j == W - 1 || i == 0 || i == H - 1){
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3028
N, M = map(int, input().split())
ab = [[int(i) for i in input().split()] for i in range(N)]
cd = []
for i in range(M):
    c, d = map(int, input().split())
    cd.append([c, d, i])

ans = []
for a, b in ab:
    dis = float('inf')
    num = 0
    for c, d, i in cd:
        if (abs(c-a) + abs(b-d)) < dis:
            dis = (abs(c-a) + abs(b-d))
            num = i + 1
    ans.append(num)

for i in ans:
    print(i)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int m,f,b;
	cin>>m>>f>>b;
	
	int x=b-m;
	if(m>=b){
		cout<<"0"<<endl;
	}
	else{
		if(x>f){
			cout<<"NA"<<endl;
		}
		else{
			cout<<x<<endl;
		}
	}		
	return 0;
}


Measured memory_bytes: 3136
N = int(input())
S = []
status = -1
for _ in range(N):
  S.append(int(input()))

tmp = 0
for i in range(N):
  if i ==0:
    tmp = S[0]
  elif tmp == 2:
    status = i
    break
  else:
    tmp = S[tmp - 1]
print(status)

Measured memory_bytes: 7084
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <string.h>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef pair<double,int> Pdi;
#define N 10000
struct fence{
  int to;
  double cost;
};

//2点間の距離を求める
double distance(int x1,int y1,int x2,int y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main(){
  int n,m;
  P piles[N];
  vector<fence> fences[N];
  double costsum = 0;

  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    piles[i] = P(x,y);
  }
  for(int i=0;i<m;i++){
    int p,q;
    scanf("%d%d",&p,&q);
    p--;q--;
    double c = distance(piles[p].first,piles[p].second,piles[q].first,piles[q].second);
    fences[p].push_back((fence){q,c});
    fences[q].push_back((fence){p,c});
    costsum += c;
  }

  double sum = 0;
  bool used[N];
  fill(used,used+n,false);

  priority_queue<Pdi> que;
  for(int i=0;i<n;i++){
    if(!used[i]){
      que.push(Pdi(0,i));
      while(que.size()){
        Pdi p = que.top(); que.pop();
        int pos = p.second;
        if(used[pos]) continue;
        used[pos] = true;
        sum += p.first;
        for(int j=0;j<fences[pos].size();j++){
          que.push(Pdi(fences[pos][j].cost,fences[pos][j].to));
        }
      }
    }
  }

  printf("%.3f\n",costsum-sum);


  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h + 2);
  for (int i = 0; i < h + 2; i++) {
    string s(w + 2, '#');
    a.at(i) = s;
  }
  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j < w + 1; j++) {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = 0; i < h + 2; i++) {
    cout << a.at(i) << 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;
using P = pair <int, int>;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(1){
    C = C - B;
    if(C < 1){
      cout << "Yes" << endl;
      break;
    }
    A = A - D;
    if(A < 1){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3624
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  ll N, A, B, W, H, C, D;
  cin >> N;
  int a[N+2];
  a[0] = 0; a[N+1] = 0;
  ll total = 0;
  rep_s(i,1,N+1) {
    cin >> a[i];
    total+= abs(a[i]-a[i-1]);
  }
  total += abs(a[N+1]-a[N]);
  ll ans;
  rep_s(i, 1,N+1) {
    ans = total;
    ans -= abs(a[i]-a[i-1])+abs(a[i]-a[i+1]) -abs(a[i-1]-a[i+1]);
    cout << ans << endl;                 
  }
}


Measured memory_bytes: 1664
import java.util.*;

public class Main
{
  static int n;
  static Integer[] memo;
  static ArrayList<Integer>[] G;
  public static void main(String[] args)
  {
	Scanner in = new Scanner(System.in);
    n = in.nextInt();
    int m = in.nextInt();
    G = new ArrayList[n];
    for (int i = 0; i < n; i++)
      G[i] = new ArrayList<>();
    for (int i = 0; i < m; i++)
      G[in.nextInt()-1].add(in.nextInt()-1);
    
    int max = 0;
    memo = new Integer[n];
    for (int i = 0; i < n; i++)
      if (memo[i] == null)
        max = Math.max(max, dp(i));
    System.out.println(max);
    in.close();
  }
  
  public static int dp(int at)
  {
    if (memo[at] != null)
      return memo[at];
    int ans = 0;
    for (int i : G[at])
      ans = Math.max(ans, 1+dp(i));
    return memo[at] = ans;
  }
}


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

int main() {
	
 int n, a, b,len(0),tmp(0),ans(0);
  string s;
  cin >> n >> a >> b;
  
  for(int i = 1;i <= n;i++){
 	s = to_string(i);
    len = s.length();
    //cout << s << endl << len << "  ";
    for(int j = 0;j < len;j++){
      tmp += (int)s[j]-48;
      //cout << (int)s[j]-48 << endl;
    }
    if(tmp >= a && tmp <= b){
      ans += i;
    }
    tmp = 0;
    len = 0;
    s = " ";
  }
  
    cout << ans;
}


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


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

    ll n;cin>>n;
    ll a[3],b[3];
    rep(i,3) cin>>a[i];
    rep(i,3) cin>>b[i];

    //個数制限なしナップサック

    //A->B
    {
        ll dp[n+1]={};
        rep(i,3){
            rep(j,n+1){
                if(j!=0&&dp[j]==0) continue;
                if(j+a[i]<=n){
                    chmax(dp[j+a[i]],dp[j]+b[i]);
                }
            }
        }
        ll n_new=n;
        rep(i,n+1){
            chmax(n_new,dp[i]+n-i);
        }
        n=n_new;
    }
    //B->A
    {
        ll dp[n+1]={};
        rep(i,3){
            rep(j,n+1){
                if(j!=0&&dp[j]==0) continue;
                if(j+b[i]<=n){
                    chmax(dp[j+b[i]],dp[j]+a[i]);
                }
            }
        }
        ll n_new=n;
        rep(i,n+1){
            chmax(n_new,dp[i]+n-i);
        }
        n=n_new;
    }
    cout<<n<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string s, t; cin >> s >> t;
  int ls = s.length(), lt = t.length();
  int dp[ls+1][lt+1] = {};
  rep(i,ls) rep(j,lt) {
    if (s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
    else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
  }
  // rep(i,ls+1) debug(dp[i],dp[i]+(lt+1));

  string result = "";
  int pos = lt;
  per(i,ls) {
    while (pos!=0&&dp[i+1][pos]==dp[i+1][pos-1]) pos--;
    if (dp[i][pos]!=dp[i+1][pos]) {
      result += s[i];
      pos--;
    }
  }
  reverse(all(result));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 35456
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long LL;
const int mod = 1000000009;
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    LL a, b, c;
    while (cin >> a >> b >> c)
    {
        if (((a == b && b == c)) || ((a != b) && (b != c) && (a != c)))
            cout << "No\n";
        else cout << "Yes\n";
    }
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int N;
const int Size = 2e5;
ll A[Size + 5], DP[Size + 5][2][2];

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];

  DP[1][1][1] = A[1];
  for (int i = 2; i <= N; i++){
    if (i % 2 == 0){
      DP[i][0][0] = max(DP[i-1][0][0], DP[i-1][0][1]);
      DP[i][1][0] = DP[i-1][1][1];
      DP[i][1][1] = DP[i-1][0][0] + A[i];
    }else{
      DP[i][0][0] = max(DP[i-1][1][0], DP[i-1][1][1]);
      DP[i][0][1] = DP[i-1][0][0] + A[i];
      DP[i][1][1] = DP[i-1][1][0] + A[i];
    }
  }

  if (N % 2 == 0){
    cout << max(DP[N][1][0], DP[N][1][1]) << endl;
  }else{
    cout << max(DP[N][0][0], DP[N][0][1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 11444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
#define endl "\n"
/*ll gcd(ll a,ll b)
{
    if(a==0){return b;}
    return gcd(b%a,a);
}
ll modexp(ll x,ll y,ll p)
{
    ll res=1;x%=p;
    while(y>0)
    {   if(y%2==1){res=(res*x)%p;}
        y=y>>1;x=(x*x)%p;
    }return res;
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,d;cin>>n>>d;
    vector<int>x[n];
    rep(i,0,n-1)
    {
        rep(j,1,d)
        {
            int y;cin>>y;
            x[i].pb(y);
        }

    }
    ll ans=0;
    rep(i,0,n-1)
    {
        rep(j,i+1,n-1)
        {
            ll t=0;
            rep(k,0,d-1)
            {
                t+=(x[j][k]-x[i][k])*(x[j][k]-x[i][k]);
            }
            double u=sqrt(t);
            if(floor(u)==ceil(u))
            {
                ans++;
            }
        }
    }
    cout<<ans<<"\n";



    return 0;

    /*check for long long or int*/
}


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

#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

const int MAX_W = 10, MAX_H = 60;
const int INF = 0xfffffff;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};

vector<int>& operator+=(vector<int>& l, const vector<int>& r) {
	for(int i = 0; i < (int)l.size(); ++i)
		l[i] += r[i];

	return l;
}

bool ok;
bool used[MAX_H][MAX_W];
int w, h;
int label[MAX_H][MAX_W];
string brd[MAX_H];

struct node {
	int xl, xr;
	vector<int> cnt, children;

	node():xl(INF), xr(-1), cnt(w, 0){}
};

vector<node> nodes;

inline bool valid(int x, int y) {
	return 0 <= x && x < w && 0 <= y && y < h;
}

void label_dfs(int x, int y, int idx) {
	label[y][x] = idx;
	for(int i = 0; i < 4; ++i) {
		const int nx = x + dx[i], ny = y + dy[i];
		if(valid(nx, ny) && label[ny][nx] == -1 && brd[y][x] == brd[ny][nx])
			label_dfs(nx, ny, idx);
	}
}

int labeling() {
	int idx = 0;
	memset(label, -1, sizeof(label));
	for(int i = h - 1; i >= 0; --i)
		for(int j = 0; j < w; ++j)
			if(label[i][j] == -1 && brd[i][j] != '.')
				label_dfs(j, i, idx++);

	return idx;
}

void create(int x, int y) {
	const int id = label[y][x];
	if(y == h - 1 || (label[y + 1][x] != -1 && label[y + 1][x] != id)) {
		chmax(nodes[id].xr, x);
		chmin(nodes[id].xl, x);
	}
	++nodes[id].cnt[x];
	used[y][x] = true;
 
	for(int i = 0; i < 4; ++i) {
		const int nx = x + dx[i], ny = y + dy[i];
		if(!valid(nx, ny) || used[ny][nx])
			continue;

		if(id == label[ny][nx])
			create(nx, ny);
	}

	if(y > 0 && label[y - 1][x] != -1 && label[y - 1][x] != id)
		if(!exist(nodes[id].children, label[y - 1][x]))
			nodes[id].children.push_back(label[y - 1][x]);
}

vector<int> check(int id) {
	const node& cur = nodes[id];
	vector<int> tmp(cur.cnt);
	for(int i = 0; i < (int)cur.children.size(); ++i)
		tmp += check(cur.children[i]);

	const int sum = accumulate(tmp.begin(), tmp.end(), 0);
	int nume = 0;
	for(int i = 0; i < w; ++i)
		nume += i * tmp[i];

	const double m = (double)nume / sum;
	if(!(cur.xl - 0.5 < m && m < cur.xr + 0.5))
		ok = false;

	return tmp;
}

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

	while(cin >> w >> h, w) {
		for(int i = 0; i < h; ++i)
			cin >> brd[i];

		const int numBlock = labeling();

		nodes.clear();
		nodes.resize(numBlock);
		memset(used, false, sizeof(used));
		for(int i = h - 1; i >= 0; --i)
			for(int j = 0; j < w; ++j)
				if(label[i][j] != -1 && !used[i][j])
					create(j, i);

		ok = true;
		check(0);
		cout << (ok ? "STABLE" : "UNSTABLE") << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1256
n,k,q = map(int,input().split())
check = [0]*(n+1)
for i in range(q):
    a = int(input())
    check[a] += 1

for i in range(1,n+1):
    if k - (q-check[i]) >0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4680
#include <stdio.h>
int main(){
  int num,i,array[251];
  scanf("%d",&num);
  for(i=1;i<=num;i++) scanf("%d",&array[i]);
  for(i=1;i<=num;i++){
    printf("node %d: key = %d, ",i,array[i]);
    if(i/2 >= 1) printf("parent key = %d, ",array[i/2]);
    if(2*i <= num) printf("left key = %d, ",array[2*i]);
    if(2*i+1 <=num) printf("right key = %d, ",array[2*i+1]);
    printf("\n");
  }
  return 0;
}
			    



Measured memory_bytes: 2108
#include<stdio.h>
#include<string.h>

typedef long long ll;

const int I_LENGTH = 5;
ll I[I_LENGTH];

int main() {
  int N;
  char S[11];

  for (int i = 0; i < I_LENGTH; i++) I[i] = 0;

  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    scanf("%s", S);
    if (S[0] == 'M') I[0] += 1;
    else if (S[0] == 'A') I[1] += 1;
    else if (S[0] == 'R') I[2] += 1;
    else if (S[0] == 'C') I[3] += 1;
    else if (S[0] == 'H') I[4] += 1;
  }

  int cnt = 0;

  for (int i = 0; i < I_LENGTH; i++) {
    if (I[i] > 0) cnt += 1;
  }
  
  if (cnt < 3) {
    printf("0\n");
    return 0;
  }

  if (I[0] == 0 && I[1] == 0 && I[2] == 0 && I[3] == 0 && I[4] == 0) {
    printf("0\n");
    return 0;
  }

  ll sum = 0;

  sum += I[0] * I[1] * I[2];
  sum += I[0] * I[1] * I[3];
  sum += I[0] * I[1] * I[4];
  sum += I[0] * I[2] * I[3];
  sum += I[0] * I[2] * I[4];
  sum += I[0] * I[3] * I[4];
  sum += I[1] * I[2] * I[3];
  sum += I[1] * I[2] * I[4];
  sum += I[1] * I[3] * I[4];
  sum += I[2] * I[3] * I[4];
  
  printf("%lld\n", sum);

  return 0;
}


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

typedef long long ll;
typedef tuple<ll, ll, ll> mytuple;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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

int main() {
  int64_t A, B, C, K; cin >> A >> B >> C >> K;

  int64_t sum = 0;
  if(A >= K) {
    sum +=  K;
    cout << sum << endl;
    return 0;
  } else if(B >= K-A) {
    sum +=  A;
    cout << sum << endl;
    return 0;
  } else {
    sum +=  A;
    sum += -1*(K-A-B);
    cout << sum << endl;
    return 0;
  }


  cout << sum << endl;
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x, y;
  cin >> x >> y;
  
  if (x == y) cout << "0\n";
  else if (x < y) cout << min(y - x, abs(y + x) + 1) << '\n';
  else cout << min(abs(x + y) + 1, x - y + 2) << '\n';
}

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

int main(int argc, char const* argv[])
{
  while (true) {
    int n, p;
    std::cin >> n >> p;
    if (n == 0 && p == 0) {
      break;
    }
    int pebbles = p;
    std::vector<int> mayor(n);
    int turn = 0;
    while (true) {
      if (pebbles == 0) {
        pebbles = mayor[turn];
        mayor[turn] = 0;
      } else {
        ++mayor[turn];
        --pebbles;
        if (mayor[turn] == p) {
          std::cout << turn << std::endl;
          break;
        }
      }
      turn = (turn + 1) % n;
    }
  }
  return 0;
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

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

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N, K, S;
    cin >> N >> K >> S;
    if (S == 1e9) {
        rep(i, K) cout << S << " ";
        rep(i, N - K) cout << 3 << " ";
    }
    else {
        rep(i, K) cout << S << " ";
        rep(i, N - K) cout << S + 1 << " ";
    }
    
    


}

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

class Point
{
public:
    int y, x;
    Point(){
        y = x = 0;
    }
    bool operator<(const Point& p) const{
        return make_pair(y, x) < make_pair(p.y, p.x);
    }
    bool operator==(const Point& p) const{
        return y == p.y && x == p.x;
    }
};

int n;
set<Point> rock;
set<vector<Point> > history;
queue<vector<Point> > q;

void moveSnake(vector<Point>& p, int pos)
{
    if(pos >= n){
        if(history.find(p) == history.end()){
            for(int i=0; i<n; ++i){
                for(int j=i+2; j<n; ++j){
                    if(p[i] == p[j])
                        return;
                    for(int k=0; k<6; ++k){
                        if(p[i].y == p[j].y + dy[k] && p[i].x == p[j].x + dx[k])
                            return;
                    }
                }
            }
            history.insert(p);
            q.push(p);
        }
        return;
    }

    moveSnake(p, pos+1);

    for(int i=0; i<6; ++i){
        p[pos].y += dy[i];
        p[pos].x += dx[i];

        if(rock.find(p[pos]) == rock.end()){
            bool isAlive = true;
            for(int j=pos-1; j<=pos+1; j+=2){
                if(j < 0 || j >= n)
                    continue;

                bool isNeighbor = false;
                for(int k=0; k<6; ++k){
                    if(p[j].y == p[pos].y + dy[k] && p[j].x == p[pos].x + dx[k])
                        isNeighbor = true;
                }
                if(!isNeighbor)
                    isAlive = false;
            }
            if(isAlive)
                moveSnake(p, pos+2);
        }

        p[pos].y -= dy[i];
        p[pos].x -= dx[i];
    }
}

int main()
{
    for(;;){
        cin >> n;
        if(n == 0)
            return 0;

        vector<Point> init(n);
        for(int i=0; i<n; ++i)
            cin >> init[i].x >> init[i].y;

        int k;
        cin >> k;
        rock.clear();
        for(int i=0; i<k; ++i){
            Point p;
            cin >> p.x >> p.y;
            rock.insert(p);
        }

        Point goal;
        cin >> goal.x >> goal.y;

        history.clear();
        history.insert(init);
        q = queue<vector<Point> >();
        q.push(init);

        int ret = 0;
        for(;;){
            ++ ret;
            int m = q.size();
            while(--m >= 0){
                vector<Point> p = q.front();
                q.pop();
                moveSnake(p, 0);
            }

            set<vector<Point> >::iterator it = history.lower_bound(vector<Point>(1, goal));
            if(it != history.end() && (*it)[0] == goal)
                break;
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 32548
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    char s; cin >> s;
    if(islower(s)) cout << 'a' << endl;
    else cout << 'A' << endl;
}

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



int main()
{
    long N,M,V,P;
    std::cin >> N >> M >> V >> P;
    std::vector<long> A;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        A.push_back(temp);
    }
    std::sort(A.begin(),A.end(),std::greater<long>());
    long count=P;
    long boader = A[P-1];
    for(long i=P; i<N; i++){
        if(M+A[i]<boader){
            break;
        }else{
            long ateuma=(P-1)+(N-i);
            if(V<=ateuma){
                count++;
            }else{
                long myscore=A[i]+M;
                long boarderpeople=i-(P-1);
                long deadline=0;
                for(long j=P-1; j<i;j++){
                    deadline+=A[j];
                }
                deadline+=M*(V-ateuma);
                if(deadline <=myscore*boarderpeople){
                    count++;
                }
            }
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " " << x << endl;
#define f(i, n) for(i=0; i<n; i++)
#define F(i, k, n) for(i=k; i<n; i++)

void FAST() {	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

template<typename... T>
void read(T&... args) {
	FAST();
	((cin >> args), ...);
}

template<typename... T>
void write(T&&... args) { 
	FAST();
	((cout << args << " "), ...);
}

int main() {
	FAST();
    int n,x,t;
    read(n,x,t);
    if(n%x==0){
        cout << n/x*t<<endl;
    }else cout << (n/x+1)*t<<endl;
}
	

Measured memory_bytes: 3652
#include<stdio.h>

static int n, A[50] ;

static int solve( int i, int m )
{
    if( m == 0 )
        return 1 ;
    if( i >= n )
        return 0 ;

    int res = (solve( i+1, m ) || solve( i+1, m-A[i] )) ;
    return res ;
}

int main(void)
{
    int q, M, i ;
    scanf("%d", &n) ;
    for( i = 0 ; i < n ; i++ )
    {
        scanf("%d", &A[i] ) ;
    }
    scanf("%d", &q) ;
    for( i = 0 ; i < q ; i++ )
    {
        scanf("%d", &M) ;
        if( solve(0, M) )
            printf("yes\n") ;
        else
            printf("no\n") ;
    }
    return 0 ;
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int Tc; cin >> Tc;
  
  while(Tc--) {
    string s, t; cin >> s >> t;
    
    int dp[1001][1001] = {{}};
    
    int const N = s.size(), M = t.size();
    
    for(int i=0; i<N; i++) {
      for(int j=0; j<M; j++) {
        if(s[i] == t[j]) {
          dp[i+1][j+1] = dp[i][j] + 1;
        }
        else {
          dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
      }
    }
    
    cout << dp[N][M] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
 
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                StringBuilder ans = new StringBuilder();
 
                for(int row = 0; row < H; row++){
                    for(int col = 0; col < W; col++){
                        if((row+col)%2 == 0){
                            ans.append("#");
                        }else{
                            ans.append(".");
                        }
                    }
                    ans.append("\n");
                }
 
                System.out.println(ans.toString());
 
 
            } catch (IOException e) {
 
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 25560
using System;

namespace Atcoder_0128_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int a = int.Parse(input);
            input = Console.ReadLine();
            int b = int.Parse(input);
            input = Console.ReadLine();
            int c = int.Parse(input);
            input = Console.ReadLine();
            int x = int.Parse(input);

            int cnt = 0;

            for (int i = 0; i <= a; i++)
            {
                for (int k = 0; k <= b; k++)
                {
                    for (int l = 0; l <= c; l++)
                    {
                        if (i * 500 + k * 100 + l * 50 == x) {
                            cnt++;
                        }
                    }
                }
            }

            Console.WriteLine(cnt);
        }
    }
}


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

int main() {
  char S;
  cin >> S;
  string vowel = "vowel";
  string consonant = "consonant";
  string vowelStr = "aeiou";
  for (int i = 0; i < vowelStr.size() ; i++) {
    if (S == vowelStr.at(i)){
      cout << vowel << endl;
      return 0;
    }
  }
  cout << consonant << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int a[111][111];
int cnt[111][111];
int n,m;

int if_swap(int i, int x, int y){
    int p = a[i][x]/m, q = a[i][y]/m;
    if(p==q)return 0;
    int diff = 0;
    diff += -cnt[x][p];
    diff += cnt[x][q];
    diff += -cnt[y][q];
    diff += cnt[y][p];
    return diff+2;
}

int do_swap(int i, int x, int y){
    int p = a[i][x]/m, q = a[i][y]/m;
    if(p==q)return 0;
    --cnt[x][p];++cnt[x][q];
    --cnt[y][q];++cnt[y][p];
    swap(a[i][x], a[i][y]);
    return 0;
}
struct Xor128{
    unsigned x,y,z,w;

    Xor128(unsigned w_=88675123):x(123456789),y(362436069),z(521288629),w(w_){};

    inline unsigned xor128(){
        unsigned t;
        t = x^(x<<11);
        x = y;
        y = z;
        z = w;
        return w = (w^(w>>19))^(t^(t>>8));
    }

    int nextInt(int x,int y){
        if(x>y)swap(x,y);
        return xor128()%(y-x)+x;
    }

    double nextDouble(double a,double b){
        return (double)(xor128()&0xffff)/0xffff*(b-a)+a;
    }

};

void make_test(int n, int m){
    vector<int> x(n*m);
    iota(x.begin(),x.end(),1);
    random_shuffle(x.begin(), x.end());
    cout<<n<<" "<<m<<endl;
    rep(i,n*m)cout<<x[i]<<" ";
    cout<<endl;
    exit(0);
}
int main(){
    cin>>n>>m;
    //make_test(n,m);
    rep(i,n)rep(j,m)cin>>a[i][j];
    rep(i,n)rep(j,m)--a[i][j];
    rep(i,m)rep(j,n)cnt[i][j]=-1;
    rep(i,n)rep(j,m)cnt[j][a[i][j]/m]++;
    int score = 0;
    rep(i,m)rep(j,n)score += cnt[i][j]*cnt[i][j];
    score/=2;
    auto rnd = Xor128(1333);
    while(score){
        int i = rnd.nextInt(0, n), x = rnd.nextInt(0, m), y = rnd.nextInt(0, m);
        if(x==y)continue;
        int ret = if_swap(i,x,y);
        if(ret<=0)score += ret, do_swap(i,x,y);
        if(score==0)break;
    }
    rep(i,n){
        rep(j,m)cout<<a[i][j]+1<<" ";
        cout<<endl;
    }
    vector<int> b[m];
    rep(i,n)rep(j,m)b[j].push_back(a[i][j]);
    rep(i,m)sort(b[i].begin(),b[i].end());
    rep(i,n){
        rep(j,m)cout<<b[j][i]+1<<" ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int arr[100];

int main(void){
    int N, t, sum = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &t);
        arr[i] = t;
        sum += t;
    }
    if (sum % 10 != 0) printf("%d\n", sum);
    else {
        sort(arr, arr+N);
        for (int i = 0; i < N; i++) {
            if (arr[i] % 10 != 0) {
                sum -= arr[i];
                break;
            }
        }
        (sum % 10 == 0) ? printf("%d\n", 0) : printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 3796
using System;

class _0058 {
    static bool IsZero(float n) {
        return (0 <= n && n <= float.Epsilon * 1e38);
    }
    public static void Main() {
        string str;
        float[] p;
        while((str = Console.ReadLine()) != null) {
            p = Array.ConvertAll(str.Split(), s => float.Parse(s));
            Console.WriteLine((IsZero((p[2] - p[0]) * (p[6] - p[4]) + (p[3] - p[1]) * (p[7] - p[5]))) ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 9152
n,m=map(int,input().split())
c=[[] for i in range(n)]
for i in range(m):
	a,b=map(int,input().split())
	c[a-1].append(b-1)
	c[b-1].append(a-1)
cnt=[0]
def dfs(z,s):
	z[s]=1
	if sum(z)==n:
		cnt[0]+=1
	else:
		for i in c[s]:
			if z[i]==0:
				dfs(z[:i]+[1]+z[i+1:],i)
dfs([0]*n,0)
print(cnt[0])

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;
long long n,m,a,ab,abc,z=1;
char s[100005];
int main()
{ cin>>s;
  for(int i=0;i<strlen(s);i++)
  { if(s[i]=='A')
       a+=z;
	if(s[i]=='B')
       ab+=a;
	if(s[i]=='C')
       abc+=ab;
	if(s[i]=='?')
    { abc*=3;
      abc+=ab;
      ab*=3;
      ab+=a;
      a*=3;
      a+=z;
      z*=3;
    }
	a%=1000000007;
	ab%=1000000007;
	abc%=1000000007;
	z%=1000000007;
  }
  cout<<abc;
  return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int n = r*100 + g*10 + b;
  if (n%4 == 0){
  cout << "YES" << endl;
  }
  else {
  cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 256