akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

vvll f(100, vll(10, 0));
vvll p(100, vll(11, 0));
ll n;

ll calc(ll r, vll c) {
  if (!r) return -HIGHINF;  // 営業時間が0はダメ
  ll ans=0;
  REP(i, n) {
    ans += p.at(i).at(c.at(i));
  }
  return ans;
}

ll dps(ll i, ll r, vll c) {
  if (i == 10) return calc(r, c);
  vll tmpc = c;
  // 各店について営業時間が被っていたら+1する
  REP(j, n) if (f.at(j).at(i)) tmpc.at(j)++;
  return max(dps(i+1, r+1, tmpc), dps(i+1, r, c));
}

int main() {
  cin >> n;
  REP(i, n) REP(j, 10) cin >> f.at(i).at(j);
  REP(i, n) REP(j, 11) cin >> p.at(i).at(j);
  vll c(n, 0);  // 営業時間が何個被っているかを格納する変数
  ll ans = dps(0, 0, c);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	string a;
	cin >> a;
	ll best = 0;
	ll count = 0;
	for (int z=0;z<a.size();z++){
		if (z%2 == 0){
			if (a[z] == '0'){
				count ++;
			}
		} else {
			if (a[z] == '1'){
				count ++;
			}
		}
	}
	best = count;
	count = 0;
	for (int z=0;z<a.size();z++){
		if (z%2 == 1){
			if (a[z] == '0'){
				count ++;
			}
		} else {
			if (a[z] == '1'){
				count ++;
			}
		}
	}
	cout << min(best,count) << endl;
	cin >> a;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
char c[55][55]; int h, w, cnt;
int main() 
{
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) 
			cin >> c[i][j];
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') 
				cnt++;
		}
	}
	if (cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<P> job(n);
    rep(i,n) cin >> job[i].second >> job[i].first;
    sort(all(job));
    int now = 0;
    rep(i,n) {
        int nf = job[i].first;
        int ns = job[i].second;
        if(now+ns > nf) {
            cout << "No" << endl;
            return 0;
        }
        now += ns;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


int main(){

  long long int N;
  scanf("%lld",&N);

/*
  char A[];
  scanf("%s",A);
  */

  /*
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }
  */
  int i;
  long long int A;
  A =0;
for (i=1;i<=N;i++){
  if (i%3 != 0 && i%5 != 0){
  A+=i;
  }
  else{}
}
  printf("%lld",A);







 return(0);
 }


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define FASTIO std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef long long ll;
const int N = 2e5 + 5, mod = 998244353;

int main () {

  int x, y, z;
  cin >> x >> y;
  z = y - 2 * x;
  if (z >= 0 && z % 2 == 0 && z / 2 <= x) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3640
#include <stdio.h>

int is_palindrome(char s[100],int start,int end){
    int i,ans=1;
    for(i=start;i<end/2;i++){
        if(s[i] != s[end-i-1]){
            ans = 0;
            break;
        }
    }
    return ans;
}

int main(void){
    char s[100],ans=0;
    int cnt=0;
    scanf("%s",s);
    while(s[cnt] != '\0') cnt++;

    if(is_palindrome(s,0,cnt)){
        if(is_palindrome(s,0,(cnt-1)/2)){
            if(is_palindrome(s,(cnt+3)/2,cnt)){
                ans = 1;
            }
        }
    }

    if(ans == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

int ans,ans2;
int n,K;
int x[111],y[111];

signed main(){

	cin>>n>>K;
	rep(i,n)cin>>x[i]>>y[i];
	int min=LINF;
	rep(i,n){//x点決める
		rep(j,n){//x点決める
			if(i==j)continue;
			int minx=std::min(x[i],x[j]),maxx=std::max(x[i],x[j]);
			rep(k,n){//y点
				rep(l,n){
					if(k==l)continue;
					int miny=std::min(y[k],y[l]),maxy=std::max(y[k],y[l]);
					int co=0;
					rep(k,n){//4点による長方形に含まれる点数え上げ
						if(minx<=x[k] && x[k]<=maxx && miny<=y[k] && y[k]<=maxy)co++;
					}
					if(K<=co){
						min=std::min(min,(maxx-minx)*(maxy-miny));
					}
				}
			}
			
			//cout<<minx<<" "<<maxx<<" "<<miny<<" "<<maxy<<endl;
			
		}
	}
	cout<<min<<endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long A, B, K;
	long long i;
	cin >> A >> B >> K;
	if (K <= A)
	{
		cout << A - K << " " << B << endl;
	}
	else if (K <= A + B)
	{
		cout << 0 << " " << A + B - K << endl;
	}
	else
	{
		cout << 0 << " " << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int data[10] = {0}, data2[100] = {0}, i = 0, j = 0;
void push(int n){
        data[i] = n;
}
void pop(int n){
        data2[j] = data[i];
        j++;
        data[i+1] = 0;
}
int main(){
        int n, k;
        while(scanf("%d", &n) != EOF){
                if(n == 0){
                        i--;
                        pop(n);
                }else{
                        push(n);
                        i++;
                }
        }
        for(k = 0; k < j; k++){
                printf("%d\n",data2[k]);
        }

}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i] / 2;
    }
    ll least = 1;
    for (ll i = 0; i < n;i++){
        least = lcm(least, b[i]);
    }
    map<ll, ll> mp;
    for (ll i = 0; i < n;i++){
        ll cnt = 0;
        while (b[i] % 2 == 0) {
            cnt++;
            b[i] /= 2;
        }
        mp[cnt]++;
    }
    if (mp.size() != 1)
        cout << 0 << endl;
    else{
        cout << ((m/least)+1)/2 << endl;
    }
}

Measured memory_bytes: 4832
N = int(input())

lis = [0] * 4
for _ in range(N):
  S = input()
  if S == 'AC':
    lis[0] += 1
  elif S == 'WA':
    lis[1] += 1
  elif S == 'TLE':
    lis[2] += 1
  elif S == 'RE':
    lis[3] += 1
    
print('AC x {}'.format(lis[0]))
print('WA x {}'.format(lis[1]))
print('TLE x {}'.format(lis[2]))
print('RE x {}'.format(lis[3]))
  
  

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    
    vector<int> inputN(n);
    vector<char> inputC(n);
    
    bool restTrump[4][13] = {};
    
    for(int i = 0; i < n; i++){
        cin >> inputC[i] >> inputN[i];
        
        switch(inputC[i]){
            case 'S' :{
                restTrump[0][inputN[i]-1] = true;
                break;
            }
            case 'H' :{
                restTrump[1][inputN[i]-1] = true;
                break;
            }
            case 'C' :{
                restTrump[2][inputN[i]-1] = true;
                break;
            }
            case 'D' :{
                restTrump[3][inputN[i]-1] = true;
                break;
            }
            default:{
                break;
            }
        }
    }

    for(int i = 0; i < 4; i++){
        for(int j =0; j < 13; j++){
                if(!restTrump[i][j]){
                    switch(i){
                        case 0 :{
                            cout << "S " << j+1 << endl;
                            break;
                        }
                        case 1 :{
                            cout << "H " << j+1 << endl;
                            break;
                        }
                        case 2 :{
                            cout << "C " << j+1 << endl;
                            break;
                        }
                        case 3 :{
                            cout << "D " << j+1 << endl;
                            break;
                        }
                        default:{
                            break;
                        }
                }
            }
        }
    }
    
    return 0;
    
}



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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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(){
	int N;
	cin >> N;
	ll ini = 0;
	vector<ll> A(N+2);
	FORq(i,1,N){
		cin >> A[i];
		if (i % 2 == 1){
			ini += A[i];
		}else{
			ini -= A[i];
		}
	}

	vector<ll>ans(N+2);
	ans[1] = ini;
	FORq(i,2,N){
		ans[i] = 2 * A[i-1] - ans[i-1];
	}

	FORq(i,1,N){
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
   ll n,a,b;
   cin>>n>>a>>b;
   if(a>b)
    cout << 0<<endl;
   else if(n==1&&a!=b)
     cout << 0<<endl;
   else if(n==1&&a==b)
    cout << 1 << endl;
  else
  {
    ll mn=a*(n-1)+b;
    ll mx=b*(n-1)+a;
    cout<<mx-mn+1 << endl;
  }

}
return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int nen,getu,gomi;
	scanf("%d/%d/%d",&nen,&getu,&gomi);
	if(nen<2019) prin("Heisei");
	else if(nen==2019&&getu<=4) prin("Heisei");
	else prin("TBD");
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int l[205];
int main()
{
	int num=0;
	scanf("%d",&n);
	n*=2;
	for(int i=1;i<=n;i++)
		scanf("%d",&l[i]);
	sort(l+1,l+1+n);
	for(int i=n-1;i>=1;i-=2)
	{
		num+=l[i];
	}
	printf("%d\n",num);
}

Measured memory_bytes: 128
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int H,W,c[11],to,from,cc;
  ll d[11][11],res=0;
  cin >> H >> W;
  REP(i,11)REP(j,11)d[i][j] = INF_INT;
  REP(i,10)REP(j,10){
    cin >> cc;
    d[i][j] = cc;
  }
  REP(i,10)c[i] = 0;
  REP(i,H)REP(j,W){
    cin >> cc;
    if(cc == -1)
      continue;
    else
      c[cc]++;
  }
  REP(i,10)REP(j,10)REP(k,10){
    d[j][k] = min(d[j][k],d[j][i] + d[i][k]);
  }
  REP(i,10){
    res += c[i]*d[i][1];
  }
  cout << res << endl;
  
  
  
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int N, M;
	while (cin >> N >> M) {
		if (N == 0) break;
		long long res = 0;
		vector<pair<long long, long long> > a(N);
		for (int i = 0; i < N; ++i) cin >> a[i].second >> a[i].first;
		sort(a.begin(), a.end(), greater<pair<long long, long long> >());
		for (int i = 0; i < N; ++i) {
			if (M >= a[i].second) {
				M -= a[i].second;
			}
			else {
				res += a[i].first * (a[i].second - M);
				M = 0;
			}
		}
		cout << res << endl;
	}
}



Measured memory_bytes: 3280
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[m][2];
        for (int i = 0; i < m; i++) {
            a[i][0] = sc.nextInt()-1;
            a[i][1] = sc.nextInt()-1;
        }
        Arrays.sort(a, (x,y)->y[0]-x[0]);
        int[] b = new int[n];
        Arrays.fill(b, -1);
        for (int i = 0; i < m; i++) {
            if(b[a[i][1]] < 0) b[a[i][1]] = a[i][0];
        }
        int ans = 0;
        int idx = 0;
        for (int i = 1; i < n; i++) {
            if(idx <= b[i]){
                ans++;
                idx = i;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 91168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a1 = -1, a2 = -1, a3 = -1;
		int c1 = 0, c2 = 0, c3 = 0;
		int a;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			if (a1 == a) {
				c1++;
				continue;
			} else if (a2 == a) {
				c2++;
				continue;
			} else if (a3 == a) {
				c3++;
				continue;
			}
			if (-1 == a1) {
				a1 = a;
				c1++;
				continue;
			} else if (-1 == a2) {
				a2 = a;
				c2++;
				continue;
			} else if (-1 == a3) {
				a3 = a;
				if ((a1 ^ a2) != a3) {
					System.out.println("No");
					return;
				}
				c3++;
				continue;
			}
			System.out.println("No");
			return;
		}
		if (0 == a1 && -1 == a2) {
			System.out.println("Yes");
			return;
		} else if ((0 == a1 || 0 == a2) && -1 == a3) {
			if ((0 == a1 && c1 * 2 == c2) || (0 == a2 && c2 * 2 == c1)) {
				System.out.println("Yes");
				return;
			}
			System.out.println("No");
			return;
		} else if (c1 == c2 && c1 == c3) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 46280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int n; cin >> n;
    int ans = 0;
    vi vs(n),cs(n);
    rep(i,n) cin >> vs.at(i);
    rep(i,n) cin >> cs.at(i);
    rep(i,n) {
        int v = vs.at(i); int c = cs.at(i);
        if(v > c) ans += v-c;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S[5] == '0'){
        if(S[6] <= '4'){
            cout << "Heisei" << endl;
        }else{
            cout << "TBD" << endl;
        }
    }else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
P, Q, R = map(int, input().split())
L =[]
l1 = P+Q
l2 = P+R
l3 = Q+R
l4 = Q+P
l5 = R+P
l6 = R+Q
L.extend([l1, l2, l3, l4, l5, l6])
print(min(L))

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

int main(){
    int n,R[200000],min;
    int answer = -999999999;
    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];
    min = R[0];
    for ( int i = 1; i < n; i++ ){
        if(min>R[i]){
            if(answer < R[i] - min)answer = R[i] - min;
            min = R[i];
        }else if(min<=R[i]){
            if(answer < R[i] - min)answer = R[i] - min;
        }
    }
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 1940
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;
                                                          
template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int INF32 = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, W;
    cin >> n >> W;
    vector<int> w(n + 1), c(n + 1);
    for (int i = 1; i <= n; i++)     
        cin >> w[i] >> c[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1));
    for (int i = 1; i <= n; i++) 
        for (int s = 0; s <= W; s++) {
            dp[i][s] = dp[i - 1][s];
            if (s >= w[i])
                dp[i][s] = max(dp[i][s], dp[i - 1][s - w[i]] + c[i]);
        }                
    cout << dp[n][W];
    return false;                                                       
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();

  string ss=s+s+s;
  vector<vector<ll>> p(26);
  rep(i,3*n){
    p[ss[i]-'a'].pb(i);
  }

  vector<vector<ll>> q(26,vector<ll>(3*n));
  rep(i,26){
    if(p[i].empty()){
      rep(j,3*n){
        q[i][j]=-1;
      }
    }
    else {
      ll cnt=0;
      ll now=p[i].size()-1;
      for(int j=3*n-1;j>=0;j--){
        if(j==p[i][now]) {
          q[i][j]=cnt;
          cnt=0;
          now--;
          if(now<0) now=p[i].size()-1;
        }
        else q[i][j]=cnt;
        cnt++;
      }
    }
  }

  ll ans=0;
  ll now=n-1;
  rep(i,m){
    if(q[t[i]-'a'][now]==-1){
      cout << -1 << endl;
      return 0;
    }
    ans+=q[t[i]-'a'][now];
    now+=q[t[i]-'a'][now];
    if(now>=n) now%=n;
  }

  cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1; i<N; i++){
        int j = N-i;
        if(i < j) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

int f(int x) {
	string s = to_string(x);
	int ma = -1;
	rep(i, 1, s.size()) {
		string a = s.substr(0, i);
		string b = s.substr(i);
		ma = max(ma, stoi(a)*stoi(b));
	}
	return ma;
}

signed main() {
	int Q; cin >> Q;
	rep(i, 0, Q) {
		int N; cin >> N;
		int cnt = 0;
		int a = N;
		while (true) {
			a = f(a);
			if (a == -1)break;
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3276
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        Integer last = null;
        int lastIndex = 0;

        for (int i=0; i<5; i++) {
            int input = sc.nextInt();
            if (input % 10 == 0) list.add(input);
            else {
                if (last == null || input % 10 < last % 10) {
                    last = input;
                    lastIndex = i;
                }

                int next10 = input + 10 - (input % 10);
                list.add(next10);
            }
        }

        int sum = 0;
        if (last == null) {
            for (int each: list) {
                sum += each;
            }
        } else {
            for (int i=0; i<5; i++) {
                if (i != lastIndex) {
                    sum += list.get(i);
                }
            }

            sum += last;
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int i,n;
    long num,max=-1000000,min=1000000,sum=0;
    cin>> n;
    // vector<long> data(n);
    // for(i=0;i<n;i++){
    //     cin>> data[i];
    // }
    // max=min=data[0];
    // for(i=0;i<n;i++){
    //     if(max<data[i]) max= data[i];
    //     if(min>data[i]) min= data[i];
    //     sum+=data[i];
    // }
    for(i=0;i<n;i++){
        cin>> num;
        if(max<num) max=num;
        if(min>num) min=num;
        sum+=num;
    }
    cout<< min<< " "<< max<< " "<< sum<< endl;

    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int a,b,s=0;
int main(){
ios_base::sync_with_stdio(0);
cin>>a>>b;
if(a==3)s+=100000;
if(a==2)s+=200000;
if(a==1)s+=300000;
if(b==3)s+=100000;
if(b==2)s+=200000;
if(b==1)s+=300000;
if(a==1&&b==1)cout<<s+400000<<'\n';
else cout<<s<<'\n';
}



Measured memory_bytes: 256
n, m = map(int, input().split())

if n >= 2 and m >= 2:
    print((n - 2) * (m - 2))
if n >= 2 and m == 1:
    print(n - 2)
if n == 1 and m >= 2:
    print(m - 2)
if n == 1 and m == 1:
    print(1)

Measured memory_bytes: 9080
//
// Created by rect0r on 16-02-2020.
//
#include <bits/stdc++.h>
#define ll long long
#define mod1 (pow(10,9)+9)
#define mod2 (pow(10,7)+7)
#define lim pow(10,9)
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    ll T;
    //cin >> T;
    T = 1;
    while (T--) {
        ll n;
        cin>>n;
        ll a,b;
        cin>>a>>b;
        ll A=a,B=b;
        for(ll i=1;i<n;i++){
            cin>>a>>b;
            ll p=(A+a-1)/a;
            ll q=(B+b-1)/b;
            ll m=max(p,q);
            A=a*m;
            B=b*m;
        }
        cout<<A+B;
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
n,x,y=map(int,input().split())
x-=1
y-=1
k=[0]*n
for i in range(n-1):
  for j in range(i+1,n):
    m=min(j-i,abs(i-x)+1+abs(y-j),abs(j-x)+1+abs(y-i))
    k[m]+=1
for i in range(1,n):print(k[i])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;

int main(){
	int n;
	cin>>n;
	
	map<int,int>mp;
	for(int i=0;i<n-1;i++){
	   int x;
	   cin>>x;
	   
	mp[x]++;
}
for(int i=1;i<=n;i++){
	if(mp.find(i)!=mp.end()){
	   cout<<mp[i]<<"\n";
	}
	else{
		cout<<"0\n";
	}
}	
	
	
	
	
	
	
	
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, q;
  cin >> n >> q;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  for (i64 _ = 0; _ < q; _++)
  {
    i64 l, r;
    cin >> l >> r;
    i64 ri = upper_bound(a.begin(), a.end(), r) - a.begin();
    i64 li = lower_bound(a.begin(), a.end(), l) - a.begin();
    cout << ri - li << endl;
  }
  return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        ++mp[a];
    }
    bool ok = true;
    ll ans = 1;
    for ( auto tmp_mp : mp ) {
        if ( !(n&1) && !(tmp_mp.first&1) ) {
            ok = false;
            break; 
        }
        if ( (n&1) && (tmp_mp.first&1) ) {
            ok = false;
            break;
        }
        if ( (n&1) && (tmp_mp.first == 0 ) ) {
            if ( tmp_mp.second != 1 ) {
                ok = false;
                break;
            }
            else {
                continue;
            }
        }
        if ( tmp_mp.second != 2 ) {
            ok = false;
            break;
        }
        else {
            ans = ( ans * 2LL ) % mod;
        }
    }
    if ( ok ) cout << ans << endl;
    else      cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<assert.h>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
vector<pair<int,int>> ans;
int main(){
	int i,n,m,index=1;
	scanf("%d%d",&n,&m);
	if(n&1){
		int len=n;
		for(i=1;i<=m;i++){
			printf("%d %d\n",index,index+len-1);
			index++;
			len-=2;
		}		
	}
	else{
		for(i=1;i<=n/4;i++)
			ans.emplace_back(i,n-i+1);
		for(;i<n-i;i++)
			ans.emplace_back(i,n-i);
		for(i=0;i<m;i++)
			printf("%d %d\n",ans[i].first,ans[i].second);
	}
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
using namespace std;
typedef long long ll;


int main(void) {
	int n; cin >> n;
	int m = INT_MAX;
	vint x(n);
	rep(i, n) {
		cin >> x[i];
	}
	
	for (int i = 1; i <= 100; i++) {
		int sum = 0;
		rep(j, n) {
			sum += (x[j] - i)*(x[j] - i);
		}
		m = min(m, sum);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    map<ll, ll> m;
    loop(i,0,n){
        cin>>a[i];
    }
    ll ans = 0;
    for(ll i=0; i<n; i++){
        ll val = i-a[i];
        ans += m[val];
        m[i+a[i]]++;
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


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

int main() {
	char c;
	while(1){
		scanf("%c", &c);
		if(isalpha(c)){
			if(islower(c)) printf("%c", toupper(c));
			else printf("%c", tolower(c));
		}
		else printf("%c",c);
		if(c == '\n') break;
	}
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main(){
    string s; cin >> s;
    
    bool ans = true;
    
    if (s[2] != s[3]) {
        ans = false;
    }
    if (s[4] != s[5]) {
        ans = false;
    }
    
    if(ans){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}


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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 184467440737095516;

ll dp[100100], arr[100100], n, k, mini;

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

	cin >> n >> k;
	for (ll i = 1; i <= n; i++){
		cin >> arr[i];
	}
	dp[1] = 0;
	dp[2] = abs(arr[2] - arr[1]);
	for (ll i = 3; i <= n; i++){
		mini = inf;
		for (ll j = 1; j <= k; j++){
			if (i - j >= 1){
				mini = min(mini, dp[i -j] + abs(arr[i] - arr[i-j])); 
			}
		}
		dp[i] = mini;
	}
	cout << dp[n] << '\n';
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N; 
  
  int sum = 0;

  for (int i = 0; i < N; i++) {
	int l, r;
    cin >> l >> r;
    
    sum += (r - l) + 1;
  }
  
  cout << sum << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define fi             first
#define ub             upper_bound
#define se              second
#define mp             make_pair
#define vll            vector<ll>
#define mod            1000003
#define endl            "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define sz               size()
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)       for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)       {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}
int main()
{
   ll i,j,k,l,m,n,c=0;
     string str;
    cin>>n;
    ll a,b;
    vll v(n),v1;
    for(i=0;i<n;i++)
    { cin>>a>>b;
      if(a==b)
      {c++;
      }
       else
        {v1.pb(c);
       c=0;
       }


    } v1.pb(c);ll flag=0;
    for(i=0;i<v1.size();i++)
    {

     if(v1[i]>=3)
        flag=1;
    }
    if(flag==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


return 0;
}


Measured memory_bytes: 3628
import sys, os, re
from pprint import pprint
from math import sin, cos, sqrt, radians

(a, b, h, m) = map(int, sys.stdin.readline().strip().split())

a_t = radians(30*h + 0.5*m)
b_t = radians(6*m)

(a_x, a_y) = (a*cos(a_t), a*sin(a_t))
(b_x, b_y) = (b*cos(b_t), b*sin(b_t))

print(sqrt((a_x-b_x)**2+(a_y-b_y)**2))


Measured memory_bytes: 68876
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		sc.close();
		
		if(N < M) {
			int cap = N;
			N = M;
			M = cap;
			String cap2 = S;
			S = T;
			T = cap2;
		}
		
		if(S.equals(T)) {
			System.out.println(N);
		} else if(S.charAt(0) != T.charAt(0)){
			System.out.println("-1");
		} else if(M == 1) {
			System.out.println(N);
		} else if(N % M == 0){
			boolean flag = true;
			for(int i = 0;i < M;++i) {
				if(S.charAt(i*(N/M)) != T.charAt(i)) {
					flag = false;
					break;
				}
			}
			if(flag) {
				System.out.println(N);
			} else {
				System.out.println("-1");
			}
		} else {
			boolean flag = true;
			int gcd = 0;
			int n = N;
			int m = M;
			while(true) {
				if(n < m) {
					int cap = n;
					n = m;
					m = cap;
				}
				if(n == m) {
					gcd = n;
					break;
				}else if(n % m == 0){
					gcd = m;
					break;
				}else {
					n -= (n/m) * m;
				}
			}
			long ans = (((long)N*(long)M)/(long)gcd);
			
			int swidth = (int)(ans/N);
			int twidth = (int)(ans/M);
			for(int sidx = 0, tidx = 0;sidx < N || tidx < M;) {
				if(sidx * swidth == tidx * twidth) {
					if(S.charAt(sidx) != T.charAt(tidx)) {
						flag = false;
						break;
					}
					sidx++;
					tidx++;
					continue;
				}
				if(sidx * swidth > tidx * twidth) {
					int cap = (sidx * swidth - tidx * twidth) / twidth;
					if(cap > 0)
						tidx += cap;
					else
						tidx++;
				}else {
					int cap = (tidx * twidth - sidx * swidth) / swidth;;
					if(cap > 0)
						sidx += cap;
					else
						sidx++;
				}
			}
			if(flag) {
				System.out.println(ans);
			}else {
				System.out.println("-1");
			}
		}
	}
}


Measured memory_bytes: 28188
<?php
  $N = trim(fgets(STDIN));
$judge = 0;
for($i=0;$i<$N;$i++){
  
  $a = explode(" ",trim(fgets(STDIN)));
  if($a[0] == $a[1]){
  $judge++;
    if($judge == 3){
    echo "Yes";
    exit;
    }
    
    
  }else{
  $judge = 0;
  }
  
}
echo "No";

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

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	vector<char> sa, sb, sc;
	for (int i = 0; i < a.size(); i++) {
		sa.push_back(a[i]);
	}
	for (int i = 0; i < b.size(); i++) {
		sb.push_back(b[i]);
	}
	for (int i = 0; i < c.size(); i++) {
		sc.push_back(c[i]);
	}
	reverse(sa.begin(), sa.end());
	reverse(sb.begin(), sb.end());
	reverse(sc.begin(), sc.end());
	char next = sa[sa.size() - 1];
	sa.pop_back();
	while (1) {
		if (next == 'a') {
			if (sa.size() == 0) {
				cout << 'A' << endl;
				break;
			}
			next = sa[sa.size() - 1];
			sa.pop_back();
		}
		else if (next == 'b') {
			if (sb.size() == 0) {
				cout << 'B' << endl;
				break;
			}
			next = sb[sb.size() - 1];
			sb.pop_back();
		}
		else if (next == 'c') {
			if (sc.size() == 0) {
				cout << 'C' << endl;
				break;
			}
			next = sc[sc.size() - 1];
			sc.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;

int an[5005] = { 0 }, bn[5005] = { 0 };
int dp[5005][5005] = { 0 };
int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < a; i++) cin >> an[i];
	for (int i = 0; i < b; i++) cin >> bn[i];
	for (int i = 0; i < a; i++) {
		if (an[i] == bn[0]) dp[0][i] = 1;
		if (i > 0) dp[0][i] = max(dp[0][i], dp[0][i - 1]);
	}
	for (int i = 0; i < b; i++) {
		if (bn[i] == an[0]) dp[i][0] = 1;
	}
	for (int i = 1; i < b; i++) {
		for (int j = 1; j < a; j++) {
			if (bn[i] == an[j]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
			else {
				dp[i][j] = max(dp[i][j], dp[i][j - 1]);
			}
		}
	}
	int res = 0;
	for (int i = 0; i < b; i++) {
		res = max(res, dp[i][a - 1]);
	}
	out(res);
	return 0;
}


Measured memory_bytes: 100924
//AtCoder ABC056 A - HonestOrDishonest
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    char a,b;
    cin>>a>>b;
    if (a=='H') cout<<(char)b<<endl;
    else cout<<(b=='H'?"D":"H")<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(x+1,y+1):
    if i>max(a) and i<=min(b):
        print("No War")
        exit()
else:
    print("War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,m;
queue<string>lane[15];
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x;
        string s;
        cin>>x;
        if(x==0){
            cin>>x;
            cout<<lane[x-1].front()<<endl;
            lane[x-1].pop();
        }else{
            cin>>s;
            int p=0;
            for(int j=0;j<n;j++)if(lane[p].size()>lane[j].size())p=j;
            lane[p].push(s);
        }
    }
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	if(x>y){
		for(int i=1;i<=x;i++) cout<<y;
		return 0;
	}else{
		for(int i=1;i<=y;i++) cout<<x;
		return 0;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void) {
	int a, b, c, i;
	for (i = 0; i < 7; i++) {
		scanf("%d %d", &a, &b);
		c = a + -1 * b;
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define md(a, b)		((a) % b + b) % b
#define mod(a)			md(a, MOD)
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define forn(i, n)			for(int i = 0; i < n; i++)
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
//int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef long long 		ll;
typedef long double ld;	
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1); 
int rem[2][200020];
int f(int n)
{
	//cout<<n<<' '<<n / __builtin_popcount(n)<<'\n';
	if(n == 0) return 0;
	return 1 + f(n % __builtin_popcount(n));
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("qwe.txt", "w", stdout);
	int n;
	int rum, ram;
	cin>>n;
	string s;
	cin>>s;
	int can = 0;
	fore(i, 0, n)
		can += s[i] == '1';
	rem[0][0] = 1;
	rem[1][0] = 1;
	rum = s[0] == '1';
	ram = s[0] == '1';
	fore(i, 1, n)
	{
		//cout<<i<<'\n';
		if(can > 1)
			rem[0][i] = rem[0][i - 1] * 2 % (can - 1);
		rem[1][i] = rem[1][i - 1] * 2 % (can + 1);
		if(can > 1)
		{
			ram = (ram * 2 + (s[i] == '1')) % (can - 1);
		}
		rum = (rum * 2 + (s[i] == '1')) % (can + 1);
	}
	reverse(all(s));
	//cout<<1;
	//cout<<can<<' '<<ram<<' '<<rum<<'\n';
	for(int i = n - 1; i > -1; i--)
	{
		//cout<<i<<'\n';
		if(can == 0)
			cout<<1<<'\n';
		else if(can == 1)
		{
			if(s[i] == '1')
				cout<<"0\n";
			else
			{
				cout<<1 + f((rum + rem[1][i]) % (can + 1))<<'\n';
			}
		}
		else if(can == 2)
		{
			if(s[i] == '1')
				cout<<"1\n";
			else
				cout<<1 + f((rum + rem[1][i]) % (can + 1))<<'\n';
		}
		else
		{
			//cout<<rem[0][i]<<' '<<rem[1][i]<<'\n';
			if(s[i] == '1')
				cout<<1 + f((ram - rem[0][i] + can - 1) % (can - 1))<<'\n';
			else
				cout<<1 + f((rum + rem[1][i]) % (can + 1))<<'\n';
		}
	}
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2	

Measured memory_bytes: 5272