akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int n;
    cin >> n;

    vector<vector<pair<int, bool>>> test(n, vector<pair<int, bool>>());

    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;

        for (int j = 0; j < a; ++j)
        {
            int x, y;
            cin >> x >> y;
            --x;

            test[i].push_back({x, y});
        }
    }

    int res = 0;

    for (int bits = 1; bits < (1 << n); ++bits)
    {
        bool ok = true;

        for (int j = 0; j < n; ++j)
        {
            if (bits & (1 << j))
            {
                for (int t = 0; t < test[j].size(); ++t)
                {
                    if (((bits >> test[j][t].first) & 1) != test[j][t].second)
                    {
                        ok = false;
                        break;
                    }
                }
            }
        }

        if (ok)
            res = std::max(res, static_cast<int>(__builtin_popcount(bits)));
    }

    cout << res << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    cout << a * b << endl;
  } else {
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string.h>

using namespace std;

class C {
	int N;
	int64_t record[100][3];
	int64_t nonZeroPoint[3];
public:
	void solve()
	{
		cout << helper() << endl;
	}

	string helper()
	{
		ostringstream oss;
		int64_t h, tmph;
		bool flag{ true };

		for (int cx{ 0 }; cx <= 100; cx++)
		{
			for (int cy{ 0 }; cy <= 100; cy++)
			{
				h = nonZeroPoint[2] + abs(nonZeroPoint[0] - cx) + abs(nonZeroPoint[1] - cy);
				if (h < 1)
					continue;

				flag = true;
				for (int i{ 0 }; i < N; i++)
				{
					tmph = h - abs(record[i][0] - cx) - abs(record[i][1] - cy);
					tmph = max((int64_t)0, tmph);
					if (record[i][2] != tmph)
					{
						flag = false;
						break;
					}
				}

				if (flag)
				{
					oss << cx << " " << cy << " " << h;
					return oss.str();
				}
			}
		}
	}
	
	C()
	{
		cin >> N;
		memset(record, 0, sizeof record);
		for (int i{ 0 }; i < N; i++)
			cin >> record[i][0] >> record[i][1] >> record[i][2];

		for (int i{ 0 }; i < N; i++)
		{
			if (record[i][2])
			{
				nonZeroPoint[0] = record[i][0];
				nonZeroPoint[1] = record[i][1];
				nonZeroPoint[2] = record[i][2];
				break;
			}
		}
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  vector<int> b(N+1);
  vector<int> c(N+1);
  rep(i,1,N+1)cin>>a[i];
  rep(i,1,N+1)cin>>b[i];
  rep(i,1,N)cin>>c[i];
  int ans=0;
  rep(i,1,N+1){
    ans+=b[a[i]];
    if(i<N)if(a[i+1]==a[i]+1)ans+=c[a[i]];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int tam = 26;
vector< vector< int > > v(tam);
string s, t;
int n;

int bs(int pos, int c) {
    int l = -1, r = v[c].size();
    while( r-l != 1 ) {
        int mid = (l+r)/2;
        if( v[c][mid] >= pos ) {
            r = mid; 
        } else {
            l = mid;
        }
    }
    return r == v[c].size()? v[c][0] : v[c][r];
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> s >> t;
    n = s.size();
    for( int i = 0; i < n; i++ ) {
        v[s[i]-'a'].emplace_back(i);
    }
    for( int i = 0; i < t.size(); i++ ) {
        if(v[ t[i]-'a' ].size() == 0 ) {
            cout << -1 << '\n';
            return 0;
        }
    }
    long long ans = 0;
    int pointer = 0;
    //cout << v['t'-'a'][0] << '\n';
    for( char i: t ) {
        int temp = bs(pointer, i-'a');
        //cout << i << ' ' << pointer << ' ' << temp << '\n';
        if(temp < pointer) {
            ans += n;
        }
        pointer = temp + 1;
    }
    //cout << '\n';
    cout << ans + pointer << '\n';
    return 0;
}

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

double dp[3001][3001];
double sushi(const vector<double>& v,int i,int x) {
    if(x == 0)
        return 1;
    if(i == 0)
        return 0;
    if(dp[i][x] >= -0.9)
        return dp[i][x];

    return dp[i][x] = v[i]*sushi(v,i-1,x-1) + (1-v[i])*sushi(v,i-1,x);
}

int main() {
    int n;
    cin >> n;
    vector<double> v(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
    }

    memset(dp,-1,sizeof dp);

    cout << fixed << setprecision(10) << sushi(v,n,(n+1)/2) << "\n";

    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    string s,t;
    cin >> s;
    cin >> t;

    int ssize = s.size();
    int tsize = t.size();

    vector<vector<pair<int,char>>> dp(ssize + 1, vector<pair<int,char>>(tsize + 1));

    rep(i,ssize){
        dp[i + 1][0] = mpair(0,'U');
    }
    rep(i,tsize){
        dp[0][i + 1] = mpair(0,'L');
    }

    for(int i = 1; i <= ssize; i++){
        for(int j = 1; j <= tsize; j++){

            if(s[i - 1] == t[j - 1]){
                dp[i][j] = mpair(dp[i - 1][j - 1].first + 1, 'S');
            }else{

                if(dp[i - 1][j].first < dp[i][j - 1].first){
                    dp[i][j] = mpair(dp[i][j - 1].first, 'L');
                }else{
                    dp[i][j] = mpair(dp[i - 1][j].first, 'U');
                }
            }
        }
    }

    int tmpi = ssize;
    int tmpj = tsize;
    string ans;

    while(tmpi != 0 && tmpj != 0){
        if(dp[tmpi][tmpj].second == 'S'){
            ans += s[tmpi - 1];
            tmpi--;
            tmpj--;
        }else{
            if(dp[tmpi][tmpj].second == 'L'){
                tmpj--;
            }else{
                tmpi--;
            }
        }
    }

    reverse(ALL(ans));

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

Measured memory_bytes: 70784
#include <cstdio>
#include <algorithm>

int main()
{
  long long n, k;
  scanf("%lld%lld", &n, &k);
  long long x[100000];
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", x + i);
  }
  long long ans = 1e10;
  for (long long i = 0; i <= n - k; ++i)
  {
    long long d;
    if (x[i] <= 0 && 0 <= x[i + k - 1])
    {
      d = x[i + k - 1] - x[i] + std::min(-x[i], x[i + k - 1]);
    }
    else if (x[i + k - 1] < 0)
    {
      d = -x[i];
    }
    else
    {
      d = x[i + k - 1];
    }
    if (ans > d) ans = d;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int n, i=0, ans;
  scanf("%d", &n);
  while(i <= sqrt(n)){
    i++;
  }
  i--;
  ans = i*i;
  
  for(int j=i*i+1;j<=n;j++){
    for(int k=i-1;k>=2;k--){
      for(int m=3;(int)pow(k,m)<=j;m=m+2){
	//printf("%d\n", (int)pow(k,m));
	if((int)pow(k,m) == j){
	  ans = j;
	  break;
	}
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

int main() {
  string s, p;

  cin >> s;
  cin >> p;
  s += s;
  rep(i,s.size()) {
    if (i + p.size() > s.size()) {
      cout << "No" << endl;
      return 0;
    }
    rep(j, p.size()) {
      if (s[i+j] != p[j]) break;
      if (j == p.size() - 1) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3196
inp = list(map(lambda x: int(x), input().split(" ")))
K = inp[0]
N = inp[1]
inp = list(map(lambda x: int(x), input().split(" ")))

diffs = []

for i in range(N-1):
    diffs.append(inp[i+1]-inp[i])
diffs.append(inp[0]+K-inp[-1])

print(sum(diffs)-max(diffs))


Measured memory_bytes: 87388
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = "abcdefghijklmnopqrstuvwxyz";
        String c = sc.next();
        System.out.println(s.charAt(s.indexOf(c)+1));
    }
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int a[10][10];
	int x,y,i,j,size,n,max;


	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			a[i][j]=0;
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		if(x<0)
			break;
		if(size==1){
			if(0<=x&&x<10&&0<=y-1&&y-1<10)
				a[x][y-1]+=1;

			if(0<=x-1&&x-1<10&&0<=y&&y<10)
				a[x-1][y]+=1;
			if(0<=x&&x<10&&0<=y&&y<10)
				a[x][y]+=1;
			if(0<=x+1&&x+1<10&&0<=y&&y<10)
				a[x+1][y]+=1;

			if(0<=x&&x<10&&0<=y+1&&y+1<10)
				a[x][y+1]+=1;
		}else if(size==2){
			if(0<=x-1&&x-1<10&&0<=y-1&&y-1<10)
				a[x-1][y-1]+=1;
			if(0<=x&&x<10&&0<=y-1&&y-1<10)
				a[x][y-1]+=1;
			if(0<=x+1&&x+1<10&&0<=y-1&&y-1<10)
				a[x+1][y-1]+=1;

			if(0<=x-1&&x-1<10&&0<=y&&y<10)
				a[x-1][y]+=1;
			if(0<=x&&x<10&&0<=y&&y<10)
				a[x][y]+=1;
			if(0<=x+1&&x+1<10&&0<=y&&y<10)
				a[x+1][y]+=1;

			if(0<=x-1&&x-1<10&&0<=y+1&&y+1<10)
				a[x-1][y+1]+=1;
			if(0<=x&&x<10&&0<=y+1&&y+1<10)
				a[x][y+1]+=1;
			if(0<=x+1&&x+1<10&&0<=y+1&&y+1<10)
				a[x+1][y+1]+=1;
		}else{
			if(0<=x&&x<10&&0<=y-2&&y-2<10)
				a[x][y-2]+=1;

			if(0<=x-1&&x-1<10&&0<=y-1&&y-1<10)
				a[x-1][y-1]+=1;
			if(0<=x&&x<10&&0<=y-1&&y-1<10)
				a[x][y-1]+=1;
			if(0<=x+1&&x+1<10&&0<=y-1&&y-1<10)
				a[x+1][y-1]+=1;

			if(0<=x-2&&x-2<10&&0<=y&&y<10)
				a[x-2][y]+=1;
			if(0<=x-1&&x-1<10&&0<=y&&y<10)
				a[x-1][y]+=1;
			if(0<=x&&x<10&&0<=y&&y<10)
				a[x][y]+=1;
			if(0<=x+1&&x+1<10&&0<=y&&y<10)
				a[x+1][y]+=1;
			if(0<=x+2&&x+2<10&&0<=y&&y<10)
				a[x+2][y]+=1;

			if(0<=x-1&&x-1<10&&0<=y+1&&y+1<10)
				a[x-1][y+1]+=1;
			if(0<=x&&x<10&&0<=y+1&&y+1<10)
				a[x][y+1]+=1;
			if(0<=x+1&&x+1<10&&0<=y+1&&y+1<10)
				a[x+1][y+1]+=1;

			if(0<=x&&x<10&&0<=y+2&&y+2<10)
				a[x][y+2]+=1;
		}
	}
	n=0;
	max=0;
	for(i=0;i<10;i++)
		for(j=0;j<10;j++){
			if(a[i][j]==0)
				n++;
			if(a[i][j]>max)
				max=a[i][j];
		}
	printf("%d\n%d\n",n,max);
	return 0;
}

Measured memory_bytes: 600
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n = int(input())
if n % 2 == 0:
    print((n//2))
else:
    print((n//2)+1)


Measured memory_bytes: 3960
#include <stdio.h>
#include <string.h>
 
int main(void) {
  char w[11];
  char T[1001];
  int cnt = 0;
  int i;
  scanf("%s", &w);
  for (i = 0; i < strlen(w); i++) {
    w[i] = tolower(w[i]);
  }
  while(1) {
    scanf("%s", &T);
    if (strcmp(T, "END_OF_TEXT") == 0) break;//Tと"END_OF_TEXT"は同じ文字かどうか
    for (i = 0; i < strlen(T); i++) {
      T[i] = tolower(T[i]);//大文字から小文字へ
    }
    if (strcmp(T, w) == 0) cnt++;//T, wは同じ文字かどうか
  }
  printf("%d\n", cnt);
  return 0;
}


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

int main(){
	int N, A, B, ans=0;
	cin >> N >> A >> B;
	for(int i=0; i<=N; i++){
		int k = i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + i%10;
		if(A<=k&&k<=B) ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int x, y;
    int nt=0;
    int nc=0;
    bool flg = false;
    cin >> x >> y;
    for (int i=0; i < x+1; i++){
        nt = i;
        nc = x - i;
        if (nt * 2 + nc * 4 == y){
            flg = true;
            break;
        }
    }
    if (flg){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
a,b,k=map(int,input().split())
X=[]
for i in range(a,a+k):
    if i>b:
        break
    X.append(i)
    
    
for j in range(b-k+1,b+1):
    if j<a:
        break
    X.append(j)
    
X=set(X)
X=list(X)
X.sort()

for i in range(len(X)):
    print(X[i])

Measured memory_bytes: 3064
N = int(input())
H = list(map(int, input().split()))

dp = []
dp.append(0)
dp.append(abs(H[-1] - H[-2]))
for i in range(N-2)[::-1]:
  c1 = abs(H[i] - H[i+1]) + dp[-1]
  c2 = abs(H[i] - H[i+2]) + dp[-2]
  dp.append(c1 if c1 < c2 else c2)

print(dp[-1])

Measured memory_bytes: 13980
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 6)
input=sys.stdin.readline

def main():
    def dfs(i,oi=-1,s=0):
        ans[i]=s+d[i]
        for ki in to[i]:
            if ki==oi:continue
            dfs(ki,i,s+d[i])

    n,q=map(int, input().split())
    to=defaultdict(list)
    d=[0]*n
    ans=[0]*n
    for _ in range(n-1):
        a,b=map(int, input().split())
        a-=1
        b-=1
        to[a].append(b)
        to[b].append(a)
    for _ in range(q):
        p, x = map(int, input().split())
        d[p-1]+=x
    dfs(0)
    print(*ans)

main()

Measured memory_bytes: 294648
/*
  code by RyeCatcher
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cctype> 
#include <utility>
#include <queue>
#include <vector>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iostream>
#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w",stdout);
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define ri register int
#define ll long long
#define ull unsigned long long
#define SIZE 1<<22
using std::min;
using std::max;
using std::priority_queue;
using std::queue;
using std::vector;
using std::pair;
using namespace __gnu_pbds;
inline char gc(){
    static char buf[SIZE],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
template <class T>inline void read(T &x){
    x=0;int ne=0;char c;
    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;
    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;
}
gp_hash_table <int,int> g;
const int maxn=100005;
const int inf=0x7fffffff;
int f[maxn],tot=0;
int a[maxn],b[maxn],c[maxn],d[maxn],n;
int fa[maxn<<1],size[maxn<<1];
bool vis[maxn<<1];
int get(int x){return (fa[x]==x)?fa[x]:(fa[x]=get(fa[x]));}
inline void merge(int x,int y){
	x=get(x),y=get(y);
	if(x==y){
		//size[x]++;
		return ;
	}
	if(size[x]<size[y]){
		size[y]+=size[x];
		fa[x]=y;
	}
	else{
		size[x]+=size[y];
		fa[y]=x;
	}
	return ;
}
ll ans=0;
int main(){
	int x,pre_sum=0;
	read(n);
	for(ri i=1;i<=n;i++){
		read(x);
		pre_sum^=x;
		if(!g[x]){
			g[x]=++tot;
			vis[tot]=0,size[tot]=0,fa[tot]=tot;
			f[tot]=x;
		}
		c[i]=a[i]=g[x];
	}
	if(!g[pre_sum]){
		g[pre_sum]=++tot,f[tot]=g[pre_sum];
		vis[tot]=0,size[tot]=0,fa[tot]=tot;
	}
	//printf("--%d--\n",pre_sum);
	a[n+1]=c[n+1]=g[pre_sum];
	pre_sum=0;
	for(ri i=1;i<=n;i++){
		read(x);
		pre_sum^=x;
		if(!g[x]){
			g[x]=++tot;
			vis[tot]=0,size[tot]=0,fa[tot]=tot;
			f[tot]=x;
		}
		d[i]=b[i]=g[x];
		if(a[i]!=b[i])size[a[i]]++;
	}
	if(!g[pre_sum]){
		g[pre_sum]=++tot,f[tot]=g[pre_sum];
		vis[tot]=0,size[tot]=1,fa[tot]=tot;
	}
	//printf("--%d--\n",pre_sum);
	b[n+1]=d[n+1]=g[pre_sum];
	n++;	
	std::sort(c+1,c+1+n);std::sort(d+1,d+1+n);
	//printf("%d\n",n);
	for(ri i=1;i<=n;i++){
		if(c[i]!=d[i]){puts("-1");exit(0);}
		if(a[i]!=b[i]){
			//printf("%d %d\n",a[i],b[i]);
			merge(a[i],b[i]);
		}
	}
	int cnt=0;
	x=get(a[n]);
	if(size[x]==0){
		//vis[get(a[n])]=1;
		ans=0,cnt=1;
		//puts("sss");
	}
	for(ri i=1;i<n;i++){
		x=get(a[i]);
		//printf("%d %d %d\n",i,a[i],f[a[i]]);
		if(!vis[x]){
			if(size[x]==0)continue;
			cnt++,vis[x]=1;
			ans+=size[x];
			//printf("%d %d %d %d\n",f[i],i,x,size[x]);
		}
	}
	printf("%lld\n",ans+cnt-1);
	return 0;
}

Measured memory_bytes: 7664
#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(){
    int h,a; cin >> h >> a;
    cout << (h + (a-1)) / a << endl;
    


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

int main() {
  vector<vector<int>> n;
  n={{1,3,5,7,8,10,12},{4,6,9,11},{2}};
  int x,y;
  cin>>x>>y;
  bool ans=false;
  rep(i,3){
    if(count(n[i].begin(),n[i].end(),x)==1){
      if(count(n[i].begin(),n[i].end(),y)==1){
        ans=true;
        break;
      }
    }
  }
  
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#define int long long
using namespace std;
const int N=4e5+10;
map<int,int> Map;
int n,k,a[N],t[N],f[N],A[N],B[N],L[N],R[N],cc,ans=1e18,tt,rk[N];
void pushdown(int x) {if(t[x]) t[x<<1]=t[x<<1|1]=t[x],t[x]=0;}
void Cover(int x,int l,int r,int gl,int gr,int w)
{
	if(l>r||gl>gr) return;
	if(l>=gl&&r<=gr) {t[x]=w;return;}
	int mid=(l+r)>>1;pushdown(x);
	if(gl<=mid) Cover(x<<1,l,mid,gl,gr,w);
	if(gr>mid) Cover(x<<1|1,mid+1,r,gl,gr,w);
}
int Query(int x,int l,int r,int p)
{
	if(l==r) return t[x];
	int mid=(l+r)>>1;pushdown(x);
	return p<=mid?Query(x<<1,l,mid,p):Query(x<<1|1,mid+1,r,p);
}
int query(int x)
{
	int d=Query(1,1,tt,x);
	return !d?0:f[d]+((rk[L[d]]-rk[x])%k+k)%k;
}
signed main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>B[i],A[i]=A[i-1]+a[i];
		if(B[i]==1) L[++cc]=(-2*A[i-1]%k+k)%k,R[cc]=(-2*A[i]%k+k)%k;
		else L[++cc]=0,R[cc]=k-1;
		if(B[i]==1&&2*a[i]>k) return puts("-1"),0;
	}
	for(int i=1;i<=cc;i++) B[++tt]=L[i],B[++tt]=R[i];
	sort(B+1,B+tt+1);tt=unique(B+1,B+tt+1)-B-1;
	for(int i=1;i<=tt;i++) rk[i]=B[i],Map[B[i]]=i;
	for(int i=1;i<=cc;i++) L[i]=Map[L[i]],R[i]=Map[R[i]];
	for(int i=cc;i>=1;i--)
	{
		f[i]=query(L[i]);
		if(L[i]>R[i]) Cover(1,1,tt,R[i]+1,L[i]-1,i);
		else Cover(1,1,tt,1,L[i]-1,i),Cover(1,1,tt,R[i]+1,tt,i);
	}
	for(int i=1;i<=tt;i++) ans=min(ans,query(i));
	cout<<ans+2*A[n]<<endl;
}


Measured memory_bytes: 27776
#include<iostream>
#include<string>
using namespace std;
char S[600005];
int fi = 200001;
int la = 200000;
void push(char c) {
  S[fi - 1] = c;
  fi --;
  return;
}
void pu_b(char c) {
  S[la + 1] = c;
  la ++;
  return;
}
int main () {
  string K;
  cin >> K;
  for(int i = 0; i < K.size(); i ++) pu_b(K[i]);
  int Q;
  cin >> Q;
  int re = 1;
  for (int i = 0; i < Q; i ++) {
    int t;
    cin >> t;
    if (t == 1) re *= -1;
    else {
      int f;
      char c;
      cin >> f >> c;
      int ku = ((f == 1) ? 1 : -1);
      if (ku * re == 1) push(c);
      else pu_b(c);
    }
  }
  for (int i = fi; i <= la; i ++) {
    int j = i;
    if (re == -1) j = la + fi - i;
    cout << S[j];
  }
  cout << endl;
}
  
  

Measured memory_bytes: 1024
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
using mint = modint<998244353>;
int main() {
	int N;
	cin >> N;
	vector<int> D(N), C(N);
	for (int i = 0; i < N; ++i) {
		cin >> D[i];
		++C[D[i]];
	}
	if (D[0] != 0 || C[0] != 1) {
		cout << 0 << endl;
	}
	else {
		mint ans = 1;
		for (int i = 1; i < N; ++i) {
			ans *= mint(C[i - 1]).pow(C[i]);
		}
		cout << ans.get() << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
H, W = gets.split(" ").map(&:to_i)

bitmap = []
for i in 0...H do
  line = gets.chomp.split("")
  bitmap[i] = line
end

bitmap.map!{|line|
  unless !!line.find_index("#") then
    line = nil
  end
  line
}

bitmap.compact!

bitmap = bitmap.transpose

bitmap.map!{|line|
  unless !!line.find_index("#") then
    line = nil
  end
  line
}

bitmap.compact!

bitmap = bitmap.transpose

bitmap.each{|line|
  puts line.join
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

void transpose(vector<vector<char>> &b)
{
    if (b.size() == 0)
        return;

    vector<vector<char>> trans_vec(b[0].size(), vector<char>());

    for (int i = 0; i < b.size(); i++)
    {
        for (int j = 0; j < b[i].size(); j++)
        {
            trans_vec[j].push_back(b[i][j]);
        }
    }

    b = trans_vec; // <--- reassign here
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s, ans = "No";

    cin >> n >> s;
    if (n % 2 == 0)
    {
        string substr = s.substr(n / 2);
        if (substr == s.substr(0, n / 2))
        {
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
   int N,K;
   cin>>N>>K;
  int s=1;
  for(int i=0;i<N;i++){
    if(s<=K){
    s*=2;
    }
    else if(s>K){
      s+=K;
    }
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        string[] input = Console.ReadLine ().Split (' ');
        int N = int.Parse (input[0]); //10の5条数子
        long C = Int64.Parse (input[1]); //

        long[] x = new long[N];
        long[] v = new long[N];
        long[] realv = new long[N];
        bool[] isleft = new bool[N];

        long harfline = C / 2;

        for (int i = 0; i < N; i++) {
            string[] input2 = Console.ReadLine ().Split (' ');
            x[i] = long.Parse (input2[0]); //
            v[i] = long.Parse (input2[1]); //
        }

        long plusvalue = 0;
        long[] leftrealv = new long[N];
        long[] rightrealv = new long[N];

        long[] leftrealv2 = new long[N];
        long[] rightrealv2 = new long[N];

        long[] maxright = new long[N];
        long[] maxleft = new long[N];

        for (int i = 0; i < N; i++) { //時計回りに近い順に
            leftrealv[i] = v[i] - x[i] + plusvalue;
            plusvalue += v[i];
        }

        plusvalue = 0;
        for (int i = N - 1; i >= 0; i--) {
            rightrealv[N - 1 - i] = v[i] - (C - x[i]) + plusvalue;
            plusvalue += v[i];
        }

        long maxr2 = 0;
        long maxl2 = 0;

        for (int i = 0; i < N; i++) {
            rightrealv2[i] = rightrealv[i] - (C - x[N - 1 - i]);
            leftrealv2[i] = leftrealv[i] - x[i];
            if (maxr2 < rightrealv2[i]) {
                maxr2 = rightrealv2[i];
            }
            maxright[i] = maxr2;
            if (maxl2 < leftrealv2[i]) {
                maxl2 = leftrealv2[i];
            }
            maxleft[i] = maxl2;
            
        }

        long maxvalue = 0;
        for (int i = 0; i < N; i++) {
            long maxr = 0;
            if (i>0)maxr = maxright[i-1];
            // for (int j = 0; j < i; j++) {
            //     if (rightrealv2[j] > maxr) {
            //         maxr = rightrealv2[j];
            //     }
            // }
            if (leftrealv[N - 1 - i] + maxr > maxvalue) {
                maxvalue = leftrealv[N - 1 - i] + maxr;
            }
        }
        //Console.WriteLine ("");

        for (int i = 0; i < N; i++) {
            long maxr = 0;
            if (i>0)maxr = maxleft[i-1];
            // for (int j = 0; j < i; j++) {
            //     if (leftrealv2[j] > maxr) {
            //         maxr = leftrealv2[j];
            //     }
            // }
            if (rightrealv[N - 1 - i] + maxr > maxvalue) {
                maxvalue = rightrealv[N - 1 - i] + maxr;
            }
            //Console.WriteLine (rightrealv[N-1-i]+","+maxr);
        }

        Console.WriteLine (maxvalue);

        //Console.WriteLine (count);

    }
}

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

typedef long long ll;
const double PI = acos(-1);

bool check(std::vector< ll >& vh, ll A, ll B, ll max_cnt)
{
  ll cnt = 0;
  std::vector< ll >::iterator it;
  for (it = vh.begin(); it != vh.end(); it++) {
    cnt += std::max(0LL, (*it - B * max_cnt + A - B - 1) / (A - B));
  }

  bool judge = false;
  if (cnt <= max_cnt) {
    judge = true;
  }

  //std::cout << max_cnt << " " << judge << std::endl;
  return judge;
}

int main(int argc, char* argv[])
{
  ll N, A, B;
  std::cin >> N >> A >> B;

  ll left  = 0;
  ll right = 1e9+1;

  std::vector< ll > vh(N, 0);
  for (ll i = 0; i < N; i++) {
    std::cin >> vh[i];
  }

  while (right - left > 1) {
    ll mid = (left + right) / 2;
    if (check(vh, A, B, mid)) {
      right = mid;
    } else {
      left = mid;
    }
  }

  std::cout << right << std::endl;
  
  return 0;
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdlib.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define INF 1000000

char S[202][202];
int colors[202];

bool dfs(int v, int color, int N){

    colors[v] = color;

    REP(i,N){
        if(S[v][i] == '1' && colors[i] == color) return false;
        else if(S[v][i] == '1' && colors[i] == 0 && !dfs(i, -color, N)) return false; 
    }

    return true;
}

bool is_bipartite(int N){
    return dfs(0, 1, N);
}

int main(void){
    int N;
    cin >> N;
    REP(i,N)REP(j,N) cin >> S[i][j];
    REP(i,N) colors[i] = 0;

    int d[N][N];
    REP(i,N)REP(j,N){
        if(S[i][j] == '0') d[i][j] = INF;
        else d[i][j] = 1;
    }

    if(!is_bipartite(N)){
        cout << -1 << endl;
        return 0;
    }

    REP(k,N)REP(i,N)REP(j,N) chmin(d[i][j], d[i][k]+d[k][j]);

    int ans=0;
    REP(i,N)FOR(j,i+1,N) if(d[i][j] < INF ) chmax(ans, d[i][j]);
    
    cout << ans+1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>

#define MAX_SET (1000)

using namespace std;

int main()
{   
    int count;
    int size;
    
    int* n = new int[MAX_SET + 1];
    int* x = new int[MAX_SET + 1];

    for (int i = 0; i < MAX_SET + 1; i++) {
         do {
             cin >> n[i] >> x[i];             
         } while ((n[i] < 3 || n[i] > 100) && !(n[i] == 0 && x[i] == 0));
        
         if (n[i] == 0 && x[i] == 0) {
             size = i;
	     break;
         }
    }
   
    for (int i = 0; i < size; i++) {
         count = 0;

         for (int j = 1; j <= n[i] - 2; j++) {
	      for (int k = j + 1; x[i] - j - k > k; k++) {
                   for (int l = k + 1; l <= n[i]; l++) {
		        if (j + k + l == x[i]) {
		            count++;
                            break;
                        }
	 	   }
	      }
         }

         cout << count << endl;
    }

    delete[] n;
    delete[] x;
    
    return (0);
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

bool ok(ll m, ll N, ll K, vector<ll>& as, vector<ll>& fs)
{
    ll ops = 0;

    for (int i = 0; i < N; ++i)
    {
        auto t = m / fs[i];

        ops += (as[i] > t ? as[i] - t : 0);
    }

    return ops <= K;
}

ll solve(ll N, ll K, vector<ll>& as, vector<ll>& fs)
{
    sort(as.begin(), as.end());
    sort(fs.begin(), fs.end(), greater<ll>());
 
    ll a = 0, b = 1000000000010, ans = b;

    while (a <= b)
    {
        auto m = a + (b - a)/2;

        if (ok(m, N, K, as, fs))
        {
            ans = m;
            b = m - 1;
        } else
            a = m + 1;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

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

    vector<ll> as(N), fs(N);

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

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

    auto ans = solve(N, K, as, fs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T = int > T in() {
  T x;
  cin >> x;
  return (x);
}
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a = in< int >();
  string s = in< string >();
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int a1, a2, a3;
    std::cin >> a1 >> a2 >> a3;

    std::string ans = "";
    if(a1 + a2 + a3 < 22){
        ans = "win";
    }else{
        ans = "bust";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut ans = v[0];
    for i in 1..n {
        ans = gcd(ans, v[i]);
    }
    println!("{}", ans);
}

fn gcd(n: usize, m: usize) -> usize {
    use std::cmp::{min,max};

    let mut l = min(n, m);
    let mut r = max(n, m);
    while l > 0 {
        let t = l;
        l = r % l;
        r = t;
    }
    r
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
int main(){
	int n;
	std::cin>>n;
	std::vector<int> v(n);
	for(int i=0;i<n;i++){
		std::cin>>v[i];
	}
	int max=v[0],min=v[0];
        long long int all=0;
	for(int i=0;i<n;i++){
		if(max<v[i]){
			max=v[i];
		}
		if(min>v[i]){
			min=v[i];
		}
		all=all+v[i];
	}
	std::cout<<min<<" "<<max<<" "<<all<<std::endl;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<vector<int>>VC(N,vector<int>(2));
  
  for (int i = 0; i < N; i++) {
    cin >> VC.at(i).at(0);
  }
  for (int i = 0; i < N; i++) {
    cin >> VC.at(i).at(1);
  }
  int A = 0;
  for (int i = 0; i < N; i++) {
    if (VC.at(i).at(0) > VC.at(i).at(1)) {
      A += VC.at(i).at(0) - VC.at(i).at(1);
    }
  }
  cout << A << endl;
  return 0;
}


Measured memory_bytes: 256
function B173(_input) {
    var lines = _input.split("\n");
    var num = lines.shift();
    var result = {
        'AC': 0,
        'WA': 0,
        'TLE': 0,
        'RE': 0,
    };

    for (var i = num - 1; i >= 0; i--) {
        result[lines[i]]++;
    }
    
    console.log('AC x ' + result['AC']);
    console.log('WA x ' + result['WA']);
    console.log('TLE x ' + result['TLE']);
    console.log('RE x ' + result['RE']);
}
B173(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37304
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, count=1;
	
	long long l_ans=-1, s_ans=-1;

	cin>>n;

	vector<long long> a(n);

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

	sort(all(a)); reverse(all(a));

	rep(i, n-1){
		if(a[i]==a[i+1]){
			count++;
		}else{
			count=1;
		}
		if(count==2&&l_ans!=-1&&s_ans==-1){
			s_ans=a[i]; break;
		}else if(count==4&&l_ans==a[i]&&s_ans==-1){
			s_ans=a[i]; break;
		}else if(count==2&&l_ans==-1){
			l_ans=a[i];
		}
	}
	if(count==2&&l_ans!=-1&&s_ans==-1){
		s_ans=a[n-1];
	}
	if(l_ans!=-1&&s_ans!=-1){
		cout<<l_ans*s_ans<<endl;
	}else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

a = list(map(int,input().split()))
cnt = 0
a.sort()
while len(set(a))>1:
    if a[0]!=a[2] and a[1]!=a[2]:
        a[0]+=1
        a[1]+=1
    elif a[2] - a[1] < 1 and a[1]==a[2]:
        a[0]+=2
    else:
        a[1]+=1
        a[2]+=1
    cnt+=1
    a.sort()
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
#define llt long long int
#define modm 1000000007
 
int main(){
	llt n;
	float m;
	string s;
	cin>>n>>m;
	llt ans=n*(llt)round(m*100);
	cout<<ans/100<<endl;
}

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

struct Dinitz {
    int n, s, t;
    struct edge {
        int u, v, c, f;
    };
    vector<vector<int> > graph;
    vector<edge> E;
    Dinitz(int n = 0, int s = 0, int t = 0): n (n), s (s), t (t) {
        E.clear();
        graph.assign(n+1, vector<int> ());
    }
    void addEdge(int u, int v, int c) {
        graph[u].push_back(E.size()); E.push_back({u, v, c, 0});
        graph[v].push_back(E.size()); E.push_back({v, u, 0, 0});
    }
    vector<int> dist, ptr;
    bool bfs() {
        dist.assign(n+1, 1e9 + 7); ptr.assign(n+1, 0);
        dist[s] = 0;
        queue<int> wl; wl.push(s);
        while(not wl.empty()) {
            int u = wl.front(); wl.pop();
            for(int i : graph[u]) {
                if(dist[E[i].v] == 1e9 + 7 && E[i].f < E[i].c) {
                    dist[E[i].v] = dist[u] + 1;
                    wl.push(E[i].v);
                }
            }
        }
        return dist[t] != 1e9 + 7;
    }
    int dfs(int u, int flow) {
        if(u == t || not flow) return flow;
        for(int &j = ptr[u]; j < graph[u].size(); j++) {
            int i = graph[u][j];
            if(E[i].f >= E[i].c || dist[E[i].v] != dist[u] + 1) continue;
            int sendFlow = dfs(E[i].v, min(flow, E[i].c - E[i].f));
            if(sendFlow) {
                E[i].f += sendFlow, E[i^1].f -= sendFlow;
                return sendFlow;
            }
        }
        return 0;
    }
    int maxflow() {
        while(bfs()) {
            while(dfs(s, 1e9 + 7));
        }
        int ans = 0;
        for(int i : graph[s]) ans += E[i].f;
        return ans;
    }
} maxflow;

int h, w, n;
char s[110][110];

int main() {
    scanf("%d%d", &h, &w); n = h + w;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) scanf(" %c", &s[i][j]);
    }
    maxflow = Dinitz(n+2, n+1, n+2);
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if(s[i][j] == 'o') {
                maxflow.addEdge(i, j+h, 1);
                maxflow.addEdge(j+h, i, 1);
            }
            else if(s[i][j] == 'S') {
                maxflow.addEdge(n+1, i, 1e9 + 7);
                maxflow.addEdge(n+1, j+h, 1e9 + 7);
            }
            else if(s[i][j] == 'T') {
                maxflow.addEdge(i, n+2, 1e9 + 7);
                maxflow.addEdge(j+h, n+2, 1e9 + 7);
            }
        }
    }
    int ans = maxflow.maxflow();
    if(ans >= 1e9 + 7) ans = -1;
    printf("%d", ans);
}

Measured memory_bytes: 1452
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int n;
int max_value;

void dfs(int point, int num_color, vector<int> ans){
    char s;
    if(point==n){
        for(int i=0; i<n; i++){
            s = 'a' + ans[i];
            cout << s;
        }
        cout << endl;
        return;
    }

    for(int j=0; j<num_color+1; j++){
        ans[point]=j;
        dfs(point+1, num_color, ans);
    }
    if(num_color+1<n){
        bool hantei=true;
        if(point==0){
            hantei=false;
        }
        int max_value=-1;
        for(int i=0; i<point; i++){
            if(max_value<ans[i]){
                max_value=ans[i];
            }
        }
        if(max_value<num_color){
            hantei=false;
        }
        if(hantei==true){
            ans[point]=num_color+1;
            dfs(point+1, num_color+1, ans);
        }
    }
}

int main() {
    cin >> n;
    vector<int> ans(n);
    ans[0]=0;
    dfs(0, 0, ans);

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D;cin>>N>>D;
  vector<vector<int>>X(N,vector<int>(D));
  for (int i=0;i<N;++i){
    for (int j=0;j<D;++j){
      cin>>X[i][j];
    }
  }
  int ans=0;
  for (int i=0;i<N;++i){
    for (int j=i+1;j<N;++j){
      int norm=0;
      for (int k=0;k<D;++k){
        int diff=abs(X[i][k]-X[j][k]);
        norm += diff*diff;
      }
      bool flag=false;
      for (int k=0;k<=norm;++k){
        if (k*k==norm){
          flag=true;
        }
      }
      if (flag)++ans;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=list(map(lambda x:0 if x=='R' else 1,input()))
c=0
a=s[0]
b=a^1
for i in range(n-1):
    if s[i:i+2]==[b,a]:
        c+=1
        s[i]=a
    elif s[i]==b:
        s[i]=a
    if c==k:
        ans=0
        for i in range(n-1):
            if s[i]==s[i+1]:
                ans+=1
        print(ans)
        break
else:
    print(n-1)

Measured memory_bytes: 4084
#define N 100
 
int G[N][N],way[N],chi[N],n,weigh[N][N];
 
void Fsearch(int x, int y){
	//printf("%d %d \n\n",x,y);
  int i;
  way[x] = y;
  for(i=0;i<chi[x];i++)
    if(y+weigh[x][i]<way[G[x][i]]) Fsearch(G[x][i], y+weigh[x][i]);
}
 
int main(){
  int i,j,m;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    way[i]=10000000;
    scanf("%d",&m);
    scanf("%d",&chi[m]);
    
    for(j=0;j<chi[m];j++){
	 scanf("%d",&G[m][j]);
	 scanf("%d",&weigh[m][j]);
    }
  }
 
  Fsearch(0,0);
 
  for(i=0;i<n;i++)
    if(way[i]==10000000)way[i]=-1;
 
  for(i=0;i<n;i++) printf("%d %d\n",i,way[i]);
 
  return 0;
}

Measured memory_bytes: 676
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

c = max(0, sum(B) - sum(A))
ca = 0
cb = 0

for a, b in zip(A, B):
    if a < b:
        ca += (b - a + 1) // 2
        cb += (b - a) % 2
    if a > b:
        cb += a - b

if c < max(ca, cb):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 4596
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    int ar[21][21],n,ans;

    vector<pii> v[21];

    vector<int> v2,v3;

    int visited[21],visited2[21];

    void func(int i)
    {
        int j,k;
        if(i==n+1)
        {
            for(j=0;j<=n;++j)
                visited[j]=0,visited2[j]=0;
            for(j=0;j<v2.size();++j)
            {
                for(auto it:v[v2[j]])
                {
                    if(it.s==0)
                    {
                        visited2[it.f]=1;
                    }
                    else
                        visited[it.f]=1;
                }
            }
            for(j=0;j<v2.size();++j)
            {
                if(visited2[v2[j]]==1)
                    return;
            }
            for(j=0;j<v3.size();++j)
                if(visited[v3[j]]==1)
                    return;
            ans=max(ans,(int)v2.size());
            return;
        }
        v2.pb(i);
        func(i+1);
        v2.pop_back();
        v3.pb(i);
        func(i+1);
        v3.pop_back();
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int i,j,x,y,z,a,b;
            cin>>n;
            for(i=1;i<=n;++i)
            {
                cin>>x;
                while(x--)
                {
                    cin>>a>>b;
                    v[i].pb({a,b});
                }
            }
            func(1);
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256