akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll facto(ll n,ll k)
{
	if(n<=k)
	return 1;
	if(k==1)
	{
		return n;
	}
	if(k==2)
	{
		return ((n)*(n-1))/2;
	}
	return ((n)*(n-1)*(n-2))/6;
}
bool my(pair<double,ll> p1, pair<double,ll> p2)
{
	if(p1.f<p2.f)
	return true;
	if(p1.f==p2.f && p2.s>p1.s)
	return true;
	return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    ll maxm=0;
    cin>>n;
    map<string,ll> m;
    string s;
    REP(i,0,n)
    {
        cin>>s;
        m[s]++;
        assmax(maxm,m[s]);
    }
    for(auto itr=m.begin();itr!=m.end();++itr)
    {
        if(itr->second==maxm)
        {
            cout<<itr->first<<"\n";
        }
    }
	return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m) cin >> p[i].first >> p[i].second;
    rep(x, 1000) {
        int keta = 1;
        int nx = x / 10;
        vector<int> d(1, x % 10);
        while(nx) {
            keta++;
            d.push_back(nx % 10);
            nx /= 10;
        }
        if(keta != n) continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        rep(i, m) {
            if(d[p[i].first - 1] != p[i].second) ok = false;
        }
        if(ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N, We;
  cin>>N>>We;
  vector<ll> W(N), V(N);
  rep(i, N){
    cin>>W[i]>>V[i];
  }
  vector<vector<ll>> dp(N, vector<ll>(100100, INF));
  dp[0][V[0]]=W[0];
  rep(i, N){
    dp[i][0]=0;
  }
  rep(i, N-1){
    rep(j, 100100){
      if(j-V[i+1]>=0){
        dp[i+1][j]=min(dp[i][j], dp[i][j-V[i+1]]+W[i+1]);
      }else{
        dp[i+1][j]=dp[i][j];
      }
    }
  }
  ll Ans=0;
  rep(i, 100100){
    if(dp[N-1][i]<=We)Ans=i;
  }
  cout<<Ans<<endl;
} 

Measured memory_bytes: 82460
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N,A,B;
    cin >> N >> A >> B;
    ll a = N / (A+B);
    ll ans = A*a;
    ans += (N%(A+B)) > A ? A : (N%(A+B));
    pr(ans);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ju = 0
for i in range(n): 
  if(a[i]%4==0):
      ju +=1
  elif(a[i]%2!=0):
    ju -= 1
if(n%2==1):
  ju += 1
if(ju>=0):
  print("Yes")
else:
  print("No")


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

int main(){
	int a, b, h=100, w=100, i, j;
	char s[110][110];
	cin>>a>>b;
	a--;
	b--;
	cout<<h<<' '<<w<<endl;
	for(i=0; i<50; i++){
		for(j=0; j<100; j++){
			s[i][j]='#';
		}
	}
	for(i=50; i<100; i++){
		for(j=0; j<100; j++){
			s[i][j]='.';
		}
	}
	for(i=0; i<50 && a; i+=2){
		for(j=0; j<100 && a; j+=2){
			s[i][j]='.';
			a--;
		}
	}
	for(i=99; i>50 && b; i-=2){
		for(j=0; j<100 && b; j+=2){
			s[i][j]='#';
			b--;
		}
	}
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			cout<<s[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

#define rep(i,n) for(i=0;i<n;i++)
#define rep_r(i,n) for(i=n-1;i>=0;i--)
#define debug_i(x) printf("x:%d\n",x)
#define debug_s(str) printf("str:%s\n",str)
#define debug_c(c) printf("c:%c\n",c) 

int main()
{
	int i,j,k;
	int n,s,kep,count=0,ans=0,a_c=0;
	int num[11]={0,1,2,3,4,5,6,7,8,9};
	int bit[11]={};
	int sum=0;
	while(1)
	{
		scanf("%d %d",&n,&s);
		if(n==0 && s==0)break;
		rep(i,1023)
		{
			sum++;
			kep=sum;
			for(j=0;;j++)
			{
				if(kep>0)
				{
					bit[j]=kep%2;
					kep/=2;
				}
				else break;
			}
			rep(j,10)if(bit[j]==1)count++;
			if(count==n)
			{
				rep(k,10)ans+=bit[k]*k;
				if(ans==s)a_c++;
			}
			count=0;
			ans=0;
		}
		printf("%d\n",a_c);
		rep(i,10)bit[i]=0;
		sum=0;
		a_c=0;
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fir first
#define sec second
#define MOD 1000000007
#define vvi vector<vector<int> >
#define vvs vector<vector<string> >
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define pb push_back
#define vi vector<int>
#define test(t) int t; cin>>t; while(t--)
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vvl vector<vl>
#define loopin(i, n) for(int i = 0; i < (n); i++)
#define loopdec(i, n) for(int i = n-1; i >= 0; i--)
const int mod=1e9+7;
void solve(){
     int n;
     cin>>n;
     if(n==0){
       cout<<"1"<<endl;
     }
     else{
        cout<<"0"<<endl;
      }               
}           

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



Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int a[500001];
		int flag,flag1,flag2;
		flag=flag1=flag2=0;
		for(int i=0;i<n;++i)
		{
			scanf("%d",&a[i]);
			if(a[i]%4 == 0)
				flag++;
			else if(a[i]%2 == 0)
				flag1++;
			else
				flag2++;
		}
		if(flag1)
			flag2++;
		if(flag2<=flag+1)
			printf("Yes\n");
		else
			printf("No\n");
	}
}

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

using namespace std;
char board[105][105];
bool deleted[105][105];
int n,m;
bool allWhiteRow(int curRow)
{
    for(int i = 1;i <= m;i++)
    {
        if(board[curRow][i] == '#')
            return false;
    }
    for(int i = 1;i <= m;i++)
        deleted[curRow][i] = true;
    return true;
}
bool allWhiteCol(int Col)
{
    for(int i = 1;i <= n;i++)
    {
        if(board[i][Col] == '#')
            return false;
    }
    for(int i = 1;i <= n;i++)
        deleted[i][Col] = true;
    return true;
}
int main()
{

    cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        string s;
        cin >> s;
        for(int j = 0;j < s.length();j++)
            board[i][j+1] = s[j];
    }
    for(int i = 1;i <= n;i++)
        allWhiteRow(i);
    for(int i = 1;i <= m;i++)
        allWhiteCol(i);
    for(int i = 1;i <= n;i++)
    {
        bool f = false;
        for(int j = 1;j <= m;j++)
        {
            if(deleted[i][j])
                continue;
            f = true;
            cout << board[i][j];
        }
        if(f)
        cout << endl;
    }
	return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	int res = 1;
	int ma = 0;
	for (int i = 1; i <= n; i++) {
		int num = i;
		int cnt = 0;
		while (num % 2 == 0) {
			num /= 2;
			cnt++;
		}

		if (ma < cnt) {
			ma = cnt;
			res = i;
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x.end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
signed main()
{
    int n,r;
    cin >> n >> r;
   if(n>=10){
       cout << r;
   }else{
       cout << r+100*(10-n);
   }
    }

Measured memory_bytes: 256
"""
x = 10
y = input("y?>")

print("{} {}".format(x, y))
"""

s = input()

a_and_b = s.split(" ")
# print(a_and_b)
# print(a_and_b)
a = int(a_and_b[0])
b = int(a_and_b[1])
"""
print(a)
print(type(a))
"""
square = a*b
long = (a+b)*2

print("{} {}".format(square, long))

Measured memory_bytes: 7556
n=int(input())
s=input()
ans=""
alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lists=list(alpha)

listss=[0 for i in range(26)]
for i in range(26):
    j=i+n
    if j>=26:
        j-=26
    listss[i]=lists[j]
for i in range(len(s)):
    for j in range(26):
      if lists[j]==s[i]:
        
      	ans+=listss[j]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          998244353
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}

#define PI 3.14159
  
void solve()
{
 
 int r;
 cin >> r;
 double cir = 2*PI*(double)r;
 cout<<cir<<endl;

}

int32_t main()
{
  pr_init();
  fastio;
  solve();

 }
      

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

int main()
{
	int n;
	int count;
	
	while (cin >> n) {
		count = 0;
		for(int i = 0; i < 10; i++)
			for(int j = 0; j < 10; j++)
				for(int k = 0; k < 10; k++)
					for(int l = 0; l < 10; l++)
						if(i + j + k + l == n)
							count++;
		cout << count << "\n";
	}
	return 0;
}

Measured memory_bytes: 1160
import math

A,B,H,M = map(int, input().split())

H_angle  = (H*30)+ (M/60)*30 #0時方向を0度としたときの角度
M_angle  = (M/60)*360
ab_angle = abs(M_angle-H_angle)
C_2 = A**2 + B**2 -2*A*B*math.cos(math.radians(ab_angle))
print(math.sqrt(C_2))

Measured memory_bytes: 9364
H, W, M = map(int, input().split())
target = [tuple(map(lambda x:int(x) - 1, input().split())) for _ in range(M)]

X = [0 for _ in range(H)]
Y = [0 for _ in range(W)]

for i in range(M):
    h, w = target[i]
    X[h] += 1
    Y[w] += 1

xmax = max(X)
ymax = max(Y)

xlist = set()
ylist = set()

for i in range(H):
    if X[i] == xmax:
        xlist.add(i)

for i in range(W):
    if Y[i] == ymax:
        ylist.add(i)

tmp = 0

for h, w in target:
    if h in xlist and w in ylist:
        tmp += 1

if len(xlist) * len(ylist) == tmp:
    print(xmax + ymax - 1)
else:
    print(xmax + ymax)

Measured memory_bytes: 167836
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

ll lcm(ll aaa, ll bbb) {
  ll g = __gcd(aaa, bbb);
  return aaa / g * bbb;
}

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

  cin >> a >> b;
  Cout(lcm(a, b));
  return 0;
}

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



int main() {
	string s;
	cin >> s;
	vector<char> a(s.size());
	for(int i = 0; i < s.size(); i++){
		a.at(i) = s[i];
	}
	string ans = "";
	for(int i = 0; i < s.size(); i++){
		if(a.at(i) == '0'){
			ans += '0';
		}
		else if(a.at(i) == '1'){
			ans += '1';
		}
		else{
			if(ans == ""){
				continue;
			}
			else{
				ans = ans.substr(0, ans.size() - 1);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	P := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &P[i])
	}
	mismatch := 0
	for i := 0; i < N; i++ {
		if P[i] != i+1 {
			mismatch++
		}
	}
	if mismatch == 0 || mismatch == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
A, B = map(int, input().split())

count = 0
digit_half = 2

for i in range(A, B + 1):
    digit_list = [int(s) for s in str(i)]
    #digit_half = int(len(digit_list) / 2)
    for j in range(digit_half):
        if digit_list[j] != digit_list[-1 * (j + 1)]:
            break
        if j == digit_half - 1:
            count += 1

print(count)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 3e5 + 7;
int n, sz;
int a[4][N], inv[2], flip[2];
int tr[N];
int lowbit(int x) { return x & -x;}
void modify(int x, int y) { for(int i = x; i <= sz; i += lowbit(i)) tr[i] += y;}
int query(int x){ 
	int res = 0;
	for(int i = x; i; i -= lowbit(i)) res += tr[i];
	return res;
}
int main() {
#ifdef fwat
#endif
	n = gi(), sz = n * 3;
	rep(i, 1, 3)
	rep(j, 1, n) a[i][j] = gi();
	
	rep(j, 1, n) {
		int mi = a[1][j], mx = a[1][j];
		rep(i, 2, 3) Min(mi, a[i][j]), Max(mx, a[i][j]);
		flip[j & 1] ^= a[3][j] == mi;
		if(mx - mi + 1 != 3 || a[2][j] != mi + 1) return puts("No"), 0;
		if(j % 2 == 1 && mi % 6 != 1) return puts("No"), 0;
		if(j % 2 == 0 && mi % 3 != 1) return puts("No"), 0;
	}
	for(int j = 1; j <= n; j += 2) {
		inv[1] ^= query(sz) - query(a[2][j]) & 1;
		modify(a[2][j], 1);
	}
	re(tr);
	for(int j = 2; j <= n; j += 2) {
		inv[0] ^= query(sz) - query(a[2][j]) & 1;
		modify(a[2][j], 1);
	}
	puts(flip[0] == inv[1] && flip[1] == inv[0] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ok=false;
  for(int i=0;i<s.size();i++){
    for(int j=i;j<s.size();j++){
      string t=s.substr(0,i)+s.substr(j);
      if(t=="keyence")ok=true;
    }
  }
  if(ok){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
typedef unsigned int ui;
typedef unsigned long long ul;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef pair<bool, bool> pbb;
#define fi first
#define se second
#define pb push_back
#define ls (i << 1)
#define rs (i << 1 | 1)
#define mid ((l + r) >> 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++) // loop structure abbreviations are here
#define open(i, j, k) for(int i = j; i < k; i ++)
#define dec(i, j, k) for(int i = j; i >= k; i --)
#define mega(i, j, k) for(int i = j; i > k; i --)
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
#include "ext/pb_ds/priority_queue.hpp"
#define priority_queue __gnu_pbds::priority_queue
bool chkmax(int &x, int y) { return y > x ? x = y, true : false; }
bool chkmin(int &x, int y) { return y < x ? x = y, true : false; }
int _()
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
void _(int x)
{
	if(x < 10) { putchar(x + '0'); return; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Will_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
	srand(time(0) ^ ui(ul(new char)));
}
/* Default Code Ends Here. */

#define maxn 500
int a[maxn][maxn];



int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Will_you_save_us();
	
	int k;
	cin >> k;
	if(k == 1)
		return cout << "1\n1\n", 0;
	int n = (k + 1) / 2;
	if(n % 2)
		n ++;
	open(i, 0, n)
		open(j, 0, n)
			a[i][j] = (i + j) % n + (i % 2 ? n : 0);
	cout << n << endl;
	open(i, 0, n)
	{
		open(j, 0, n)
			cout << (a[i][j] < k ? a[i][j] + 1 : a[i][j] - n + 1) << ' ';
		cout << endl;
	}
	return 0;
}





























Measured memory_bytes: 2176
from collections import Counter
N,P =map(int,input().split(' '))
if N==1:
    print(P)
    exit()
prime = []
f = 2
while f**2 <=P:
    if P%f==0:
        prime.append(f)
        P//=f
    else:
        f += 1
if P != 1:
    prime.append(f)

ans = 1
for k,v in Counter(prime).items():
    if v//N:
        ans *= k**(v//N)
print(ans)

Measured memory_bytes: 3316
/*input
200
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld k;
	cin >> k;
	lld res=0;
	rep(i,1,k+1){
		rep(j,1,k+1){
			rep(l,1,k+1){
				res+=__gcd(l,__gcd(i,j));
			}
		}
	} 
	cout << res << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>

using namespace std;

int main() {
	int n,x;
	int min = 1000000, max = -1000000;
	long long sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (min > x)min = x;
		if (max < x)max = x;
		sum += x;
	}
	cout << min << " " << max << " " << sum << endl;
}

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

#define int long long 

const int N = 1e5+10;
const int mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin >> a >> b;
	if((a+b)/2 == (a+b-1)/2+1)
	{
		cout << (a+b)/2;
	}
	else
	{
		cout << "IMPOSSIBLE";
	}
}



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

ans = A*X + B*Y

i = 1
while True:
    cost = A*max(X-i, 0) + B*max(Y-i, 0) + 2*C*i
    if cost > ans:
        break
    ans = min(cost, ans)
    i += 1

print(ans)

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

  using P = pair<Int, Int>;
  vector<vector<P> > vp(s);
  for(Int i=0;i<s;i++) vp[i].emplace_back(a[i],i);
  
  for(Int b=0;b<s;b++){
    for(Int i=0;i<n;i++){
      if((~b>>i)&1) continue;
      auto &v=vp[b];
      for(auto p:vp[b^(1<<i)])
	v.emplace_back(p);
      sort(v.rbegin(),v.rend());
      v.erase(unique(v.begin(),v.end()),v.end());
      if(v.size()>2u) v.resize(2);
    }
  }

  Int ans=0;
  for(Int i=1;i<s;i++){
    chmax(ans,vp[i][0].first+vp[i][1].first);
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 32896
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;

const int N = 262144;  
  
int n; 
  
long long tree[2 * N]; 


long long max(long long a, long long b){
	if(a > b) return a;
	return b;
}  

  
void updateTreeNode(int p, long long value)  
{  
    tree[p+n] = value; 
    p = p+n; 
      
    for (int i=p; i > 1; i >>= 1) 
        tree[i>>1] = max(tree[i] , tree[i^1]); 
} 
  
long long query(int l, int r)  
{  
    long long res = 0; 
      
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) 
    { 
        if (l&1)  
            res = max (res, tree[l++]); 
      
        if (r&1)  
            res = max (res, tree[--r]); 
    } 
      
    return res; 
} 


int main(){
	
	cin>>n;
	
	vector<int> h;
	vector<long long> p;
	
	for(int i = 0; i < n; i++){
		int a; cin>>a;
		h.push_back(a);
	}
	
	for(int i = 0; i < n; i++){
		int a; cin>>a;
		p.push_back(a);
	}
	
	for(int i = 0; i < n; i++){
		long long sf = query(1, h[i]);
//		cout<<"sf:  "<<sf<<endl;
		updateTreeNode(h[i], sf + p[i]);
	}
	
	cout<<query(1, n+1);
	
	return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
int n;
vector<lli> a;
lli res;
const lli maxv = 1000000000000000000LL;

int main(void){
    cin >> n;
    while(n--){
        lli ai;
        cin >> ai;
        a.push_back(ai);
    }
    for(auto ai : a) if(ai == 0){cout << 0 << endl; return 0;}
    res = 1;
    for(auto ai: a){
        if((maxv+1)/res < ai || res*ai > maxv){
            cout << -1 << endl;
            return 0;
        }
        res *= ai;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4292
#include <bits/stdc++.h>
using namespace std;
  int main() {

int a, c;
char b;    
    
    cin >> a >> b >> c;
    
    
  
    if(b==('+')){
    
    cout << a+c <<endl;
      
    }
    else {

      
      cout << a-c <<endl;
      
      
    }


  }


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

#define equals(a, b) (fabs((a)-(b)) < EPS)
const double EPS = (1e-10);

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (double a) {
        return Point(x*a, y*a);
    }
    Point operator / (double a) {
        return Point(x/a, y/a);
    }

    double abs() {
        return sqrt(norm());
    }
    double norm() {
        return x*x + y*y;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;
// ??????
double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}
// ??????
double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

class Circle {
public:
    Point c;                    // ??????
    double r;                   // ??????
    Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};


int intersect(Circle c1, Circle c2) {
    double d = (c2.c - c1.c).abs();

    // ????????£???????????´???
    if (d - (c1.r+c2.r) > EPS) {
        return 0;
    }

    if (c1.r > c2.r && c1.r-c2.r > d) {
        return 2;
    }
    if (c2.r > c1.r && c2.r-c1.r > d) {
        return -2;
    }

    return 1;
}

int main(void) {

    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        Circle ca, cb;
        cin >> ca.c.x >> ca.c.y >> ca.r
            >> cb.c.x >> cb.c.y >> cb.r;

        cout << intersect(ca, cb) << endl;
    }

    return 0;
}

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

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

  int ans = -1;
  for (int i = 0; i + t.size() <= s.size(); i++) {
    string tmp = s.substr(i, t.size());

    int cnt = 0;
    for (int j = 0; j < t.size(); j++) {
      if (tmp.at(j) != t.at(j)) cnt++;
    }

    if (ans == -1) ans = cnt;
    else ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
N_A_B = list(map(int, input().split()))
N = N_A_B[0]
A = N_A_B[1]
B = N_A_B[2]

"""
count = 0
retu = []
while count < 10 ** 100 and count < N:
    count += 1
    for index in range(A):
        retu.append(1)
    for index in range(B):
        retu.append(0)
retu = retu[0:N]
print(sum(retu))
"""

if N % (A + B) == 0:
    print(N // (A + B) * A)
elif N % (A + B) > A:
    print(N // (A + B) * A + A)
else:
    print(N // (A + B) * A + N % (A + B))


Measured memory_bytes: 3064
H, W = map(int, input().split())
S = [input() for _ in range(H)]
ans = [[''] * W for _ in range(H)]
N = [(1, 1), (1, 0), (1, -1), (0, 1), (0, -1), (-1, 1), (-1, 0), (-1, -1)]
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            ans[h][w] = '#'
        else:
            ans[h][w] = str(sum([S[h + nh][w + nw] == "#" for nh, nw in N if 0 <= h + nh < H and 0 <= w + nw < W]))

for h in range(H):
    print(''.join(ans[h]))


Measured memory_bytes: 3188
declare function require(x: string): any;

var input = require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split("\n");

const n = +input[0];
const k = +input[1];
const x = input[2].split(" ").map((x:string)=>+x);


let result = 0;
for(const a of x){
	result += Math.min(a, Math.abs(a-k))*2;
}

console.log(result);


Measured memory_bytes: 7372
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, A[100004];
int DP[100004];

ll dfs(int idx, int r, int b, int g) {
  if (idx==N) return 1;
  if (DP[idx]>=0) return DP[idx];
  ll ret=0ll;
  if (r==A[idx]) {
    ret += dfs(idx+1, r+1, b, g);
  }
  if (b==A[idx]) {
    ret += dfs(idx+1, r, b+1, g);
  }
  if (g==A[idx]) {
    ret += dfs(idx+1, r, b, g+1);
  }
  ret%=MOD;
  DP[idx] = ret;
  return ret;
}

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) DP[i] = -1;
  cout << dfs(0, 0, 0, 0) << "\n";
  return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#include<vector>
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define mod 1000000007
using namespace std;

ll ipow(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    } 
    return result; 
} 

int main(){
	fio
	string s;
	cin>>s;
	if(s=="ARC")
	cout<<"ABC"<<endl;
	else
	cout<<"ARC"<<endl;
	return 0;
}

Measured memory_bytes: 3584
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int n = ReadLineParseInt();
        string[] s = ReadLine().Split(' ');
        int[] even = new int[100001];
        int[] odd = new int[100001];
        for(int i = 0; i < n; i += 2)
            even[int.Parse(s[i])]++;

        for (int i = 1; i < n; i += 2)
            odd[int.Parse(s[i])]++;

        int e1 = 0;
        int e2 = 0;
        for(int i = 0; i < even.Length; i++)
        {
            if(even[i] > even[e1])
            {
                e2 = e1;
                e1 = i;
            }
            else if( even[i] > even[e2])
            {
                e2 = i;
            }
        }
        int o1 = 0;
        int o2 = 0;
        for (int i = 0; i < odd.Length; i++)
        {   
            if(odd[i] > odd[o1])
            {
                o2 = o1;
                o1 = i;
            }
            else if(odd[i] > odd[o2])
            {
                o2 = i;
            }
        }
        if (o1 == e1)
            WriteLine(n - Max(odd[o1] + even[e2], odd[o2] + even[e1]));
        else
            WriteLine(n - even[e1] - odd[o1]);
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
}

Measured memory_bytes: 19296
n = input()
w = input().split()

# もしl_sumの方が小さければl_sumに次の配列を足す
# もしr_sumの方が小さければr_sumに前の配列を足す
# l_sumとr_sumの合計がwの合計になるまで繰り返す
r_sum = 0
l_sum = 0
w_sum = 0
for i in range(len(w)):
    w_sum += int(w[i])
lcounter = 0
rcounter = 1

for i in range(len(w)):
    if l_sum <= r_sum:
        l_sum += int(w[lcounter])
        lcounter += 1
    else:
        while l_sum > r_sum:
            r_sum += int(w[-rcounter])
            rcounter += 1
            if l_sum + r_sum == w_sum:
                break
    if l_sum + r_sum == w_sum:
        break

print(abs(r_sum - l_sum))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, m;
    cin >> n >> m;
    cout << abs((n-2)*(m-2)) << endl;
    return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	if c > a - b {
		fmt.Println(c - a + b)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
if __name__ == '__main__':
    s = list(input())
    l = [int(s[i]) for i in range(len(s))] 
    ans = 999
    n=753
    for i in range(len(l)-2):
        num = int(l[i]*100 + l[i+1]*10 + l[i+2])
        res = abs(n-num)
        if ans > res:
            ans = res
    print(int(ans))

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll MinimumSpanningTree(const V<V<pair<ll, int>>> &g, int n) { // 最小全域木
    using pi = pair<ll,int>; // pair = (cost, to);
    ll res = 0;

    vector<int> v;
    v.push_back(0);
    priority_queue<pi, vector<pi>, greater<pi>> pq; 
    vector<bool> seen(n);
    seen[0] = true;
    for(pi nv : g[0]) {
        pq.push(nv);
    }

    while(sz(v) != n) {
        pi p = pq.top(); pq.pop();
        if(seen[p.se]) continue;
        v.push_back(p.se);
        seen[p.se] = true;
        res += p.fi;
        for(pi nv : g[p.se]) {
            if(!seen[nv.se])
                pq.push(nv);
        }
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    V<V<pair<ll,int>>> g(n);
    rep(i,n)rep(j,n) {
        ll a;
        cin >> a;
        if(a == -1) continue;
        g[i].emplace_back(a,j);
    }
    ll ans = MinimumSpanningTree(g,n);
    cout << ans << endl;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char s;
	cin >> s;
	map<char, char> m;
	m['A'] = 'T';
	m['T'] = 'A';
	m['C'] = 'G';
	m['G'] = 'C';
	cout << m[s];
}

Measured memory_bytes: 256
input_data = input().split(" ")
items = [int(cont) for cont in input_data]
keys = ['T', 'S', 'E', 'W', 'N', 'B']
dice = dict(zip(keys, items))

def q1():
    def rot_func_list(rot, dice):
        if rot == "N":
            keys = ['T', 'S', 'B', 'N']
            items = dice['S'], dice['B'], dice['N'], dice['T']
            new_dice = dict(zip(keys, items))
            dice.update(new_dice)

        if rot == "S":
            keys = ['T', 'S', 'B', 'N']
            items = dice['N'], dice['T'], dice['S'], dice['B']
            new_dice = dict(zip(keys, items))
            dice.update(new_dice)

        if rot == "E":
            keys = ['T', 'E', 'B', 'W']
            items = dice['W'], dice['T'], dice['E'], dice['B']
            new_dice = dict(zip(keys, items))
            dice.update(new_dice)

        if rot == "W":
            keys = ['T', 'E', 'B', 'W']
            items = dice['E'], dice['B'], dice['W'], dice['T']
            new_dice = dict(zip(keys, items))
            dice.update(new_dice)

    controls = list(input())
    for i in controls:
        rot_func_list(i, dice)
    print(dice["T"])

def q2():

    def search_surf(conds, dice):
        a,b=conds
        a_key = [k for k, v in dice.items() if v == a ]
        b_key = [k for k, v in dice.items() if v == b ]
        key_list = a_key + b_key

        part_st = ''.join(key_list)

        def search(part_st):
            if part_st in "TNBST":
                return "W"

            if part_st in "TSBNT":
                return "E"

            if part_st in "TEBWT":
                return "N"

            if part_st in "TWBET":
                return "S"

            if part_st in "NESWN":
                return "B"

            if part_st in "NWSEN":
                return "T"


        target_key = search(part_st)
        print(dice[target_key])

    a = input()
    repeater = int(a)

    for neee in range(repeater):
        control_input = input().split(" ")
        conds = [int(i) for i in control_input]
        search_surf(conds, dice)

q2()



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 1000000007;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

void Main(){

	ll N;
	cin >> N;
	vl v(0);
	rep(i, N){
		ll in1, in2;
		cin >> in1 >> in2;
		v.push_back(in1);
		v.push_back(in2);
	}
	rep2(i, 5, v.size()){
		if(v[i - 5] == v[i - 4] && v[i - 3] == v[i - 2] && v[i - 1] == v[i]){
			print("Yes");
			return;
		}
	}
	print("No");
		

}

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





Measured memory_bytes: 3656
s = input()
n = len(s)
sums = 0
for i in range(2 ** (n - 1)):
    plus = []
    for j in range(n - 1):
        if i & (1 << j):
            plus.append(j)
    numbers = []
    prev = -1
    if len(plus) == 0:
        numbers.append(int(s))
    else:
        for p in plus:
            if prev == -1:
                numbers.append(int(s[:p + 1]))
            else:
                numbers.append(int(s[prev + 1: p + 1]))
            prev = p
        numbers.append(int(s[prev+1:]))
    sums += sum(numbers)
print(sums)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
  int n,a[6000],i,b[6000];
  for(;;)
    {
      scanf("%d",&n);
      if(n==0)
	break;
      for(i=0;i<n;i++)
	scanf("%d",&a[i]);
      b[n]=0;
      for(i=n-1;i>=0;i--)
	{
	  b[i]=a[i];
	  if(a[i]+b[i+1]>b[i])
	    b[i]=a[i]+b[i+1];
	}
      for(i=0;i<n;i++)
	if(b[0]<b[i])
	  b[0]=b[i];
      printf("%d\n",b[0]);
    } 
  return 0;
 }

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

ll modpow(ll a , ll n , ll m){
    if(!n)  return 1;
    if(n % 2)   return (a % m * modpow(a , n - 1 , m) % m) % m;
    return ((a * a) % m * modpow(a , n / 2 , m) % m) % m;
}

ll n , m;
ll a[MAXX];
bool used[MAXX];
ll dp[MAXX];

int main()
{
    _FastIO;
    cin >> n >> m;
    for(ll i = 1; i <= m; i++){
        cin >> a[i];
        used[a[i]] = true;
    }
    for(ll i = 1; i <= n; i++){
        if(used[i] && used[i - 1]){
            cout << "0" << endl;
            return 0;
        }
    }
    dp[0] = 1;
    if(a[1] != 1)
        dp[1] = 1;
    for(ll i = 2; i <= n; i++){
        if(!used[i]){
            if(!used[i - 2])
                dp[i] += dp[i - 2];
            if(!used[i - 1])
                dp[i] += dp[i - 1];
        }
        dp[i] %= 1000000007;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<P> xy;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		xy.push_back({x,y});
	}
	sort(all(xy));
	vector<P> A;
	rep(i,N)rep(j,N)if(i<j){
		int x1 = xy[i].first;
		int y1 = xy[i].second;
		int x2 = xy[j].first;
		int y2 = xy[j].second;
		A.push_back({x2-x1, y2-y1});
	}
	sort(all(A));
	/*printpair(xy);
	printpair(A);*/
	int M = A.size();
	int ans = INF;
	rep(i,M){
		int cnt = 0;
		rep(j,M){
			if(A[i] == A[j])cnt++;
		}
		ans = min(ans,N-cnt);
	}
	if(N==1)ans = 1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

map <ll,ll>a;
int main() {
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		if(x==1){
			a[y]++;
		}
		if(y==n){
			a[x]++;
		}
	}
	for(auto itr=a.begin();itr!=a.end();itr++){
		ll val=itr->second;
		if(val==2){
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	// your code goes here
	return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	int N;
	scanf("%d", &N);
	int A[20];
	int B[20];
	int C[20];
	int sum = 0;
	int a = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &B[i]);
	}
	for (int i = 0; i < N - 1; i++) {
		scanf("%d", &C[i]);
	}
	for (int i = 0; i < N; i++) {
		if (A[i]+1 == A[i+1]) {
			a = A[i];
			sum += C[a-1];
		}

		sum += B[i];
	}



	printf("%d", sum);




	return 0;

}

Measured memory_bytes: 128