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

using namespace std;

int main()
{
  
  map<string,int> mp;
  int t;
  cin>>t;
  while(t--)
  {
    string s;
    cin>>s;
    mp[s]++;
  }
  cout<<"AC x"<<" "<<mp["AC"]<<"\n";
  cout<<"WA x"<<" "<<mp["WA"]<<"\n";
  cout<<"TLE x"<<" "<<mp["TLE"]<<"\n";
  cout<<"RE x"<<" "<<mp["RE"]<<"\n";
  
  return 0;
}
    

Measured memory_bytes: 3632
#include<bits/stdc++.h>
 
using namespace std;
int main()
{
    int n;
    cin >> n;
    int  arr[n];
    int dp[n];
    for(int  i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1]- arr[0]);
    for(int i=2; i<n; i++)
    {
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] +abs(arr[i] - arr[i-2]) );
    }
    cout<< dp[n-1];
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};
ll N, M, Q;
int A[100050], B[100050], C[100050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> Q;
    for(int i = 0; i < Q; i++) cin >> A[i] >> B[i] >> C[i];
    UnionFind uni(N);
    for(int i = 0; i < Q; i++) {
        if(C[i] == 0) {
            uni.merge(A[i], B[i]);
        }
    }
    int num = 0;
    for(int i = 0; i < N; i++) {
        if(uni.root(i) == i) num++;
    }
    ll minM = N - 1;
    ll maxM = (N - num) + num * (ll)(num - 1) / 2;
    for(int i = 0; i < Q; i++) {
        if(C[i] == 1 && num <= 2) {
            cout << "No" << endl;
            return 0;
        }
        if(C[i] == 1 && uni.issame(A[i], B[i])) {
            cout << "No" << endl;
            return 0;
        }
        if(C[i] == 1) minM = N;
    }
    if(minM <= M && M <= maxM) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	ll x,y;
	cin >> x >> y;
	ll ans = 0;
	for(ll i = x; i <= y; i *= 2)ans++;
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=15,M=1<<15;
const ll inf=1e12;
int n,ax[N],ay[N],b[N];
ll dp[M][N+1],cost[M];
int main(){
//	freopen("E.in","r",stdin);
//freopen("E.out","w",stdout);
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d%d%d",&ax[i],&ay[i],&b[i]);
	for(int i=1;i<1<<n;++i){
		ll sum;cost[i]=inf;
		sum=0;
		for(int j=0;j<n;++j)if(i&(1<<j))
			sum+=1ll*b[j]*abs(ax[j]);
		cost[i]=min(cost[i],sum);
		sum=0;
		for(int j=0;j<n;++j)if(i&(1<<j))
			sum+=1ll*b[j]*abs(ay[j]);
		cost[i]=min(cost[i],sum);
	}
	for(int i=1;i<1<<n;++i){
		ll &tmp=dp[i][0];
		tmp=inf;
		for(int t=i;t;t=(t-1)&i)
			tmp=min(tmp,cost[i^t]+cost[t]);
	}
	
	for(int i=0;i<1<<n;++i){
		ll sum=0;
		for(int j=0;j<n;++j){
			sum=0;
			for(int k=0;k<n;++k)if(i&(1<<k))
				sum+=1ll*b[k]*abs(ax[j]-ax[k]);
			cost[i]=min(cost[i],sum);
		}
		for(int j=0;j<n;++j){
			sum=0;
			for(int k=0;k<n;++k)if(i&(1<<k))
				sum+=1ll*b[k]*abs(ay[j]-ay[k]);
			cost[i]=min(cost[i],sum);
		}
	}

	
	for(int i=0;i<1<<n;++i)
	for(int j=1;j<=n;++j){
		ll &tmp=dp[i][j];
		tmp=inf;
		for(int t=i;t;t=(t-1)&i)
			tmp=min(tmp,dp[i^t][j-1]+cost[t]);
	}
	
	for(int i=0;i<=n;++i)cout<<dp[(1<<n)-1][i]<<endl;
	return 0;
}


Measured memory_bytes: 8096
from sys import exit

s = input()
t = input()

l = len(s)
d_s = dict()
d_t = dict()
for i in range(l):
    if s[i] in d_s:
        if d_s[s[i]] != t[i]:
            print('No')
            exit()
    else:
        d_s[s[i]] = t[i]
    
    if t[i] in d_t:
        if d_t[t[i]] != s[i]:
            print('No')
            exit()
    else:
        d_t[t[i]] = s[i]

print('Yes')

Measured memory_bytes: 73928
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
int n, x, l[maxn], r[maxn];
ll ans1, ans2;
struct cmpl { bool operator () (const int & i, const int & j) const { return l[i] > l[j] || (l[i] == l[j] && i < j);}};
struct cmpr { bool operator () (const int & i, const int & j) const { return r[i] < r[j] || (r[i] == r[j] && i < j);}};
set<int, cmpl> sl;
set<int, cmpr> sr;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d%d", &l[i], &r[i]);
		sl.insert(i); sr.insert(i);
	}
	int cur = 0;
	for(int i = 1; i <= n; ++i)
	{
		if(i & 1) x = *sl.begin();
		else x = *sr.begin();
		sl.erase(x); sr.erase(x);
		if(l[x] <= cur && cur <= r[x]) continue;
		else if(cur < l[x]) { ans1 += l[x] - cur; cur = l[x];}
		else { ans1 += cur - r[x]; cur = r[x];}
	}
	ans1 += abs(cur);
	
	for(int i = 1; i <= n; ++i) sl.insert(i), sr.insert(i);
	cur = 0;
	for(int i = 1; i <= n; ++i)
	{
		if(i & 1) x = *sr.begin();
		else x = *sl.begin();
		sl.erase(x); sr.erase(x);
		if(l[x] <= cur && cur <= r[x]) continue;
		else if(cur < l[x]) { ans2 += l[x] - cur; cur = l[x];}
		else { ans2 += cur - r[x]; cur = r[x];}
	}
	ans2 += abs(cur);
	
	cout << max(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 13892
N = gets.to_i
a = gets.split(' ').map(&:to_i)

def sum(arr)
  arr.inject(&:+)
end

ans = 10**10
su = 0
ara = a.inject(&:+)
N.times do |i|
  break if i == N-1
  su += a[i]
  ara -= a[i]

  cal = [su, ara].max - [su, ara].min
  ans = [ans, cal].min

  break if ans == 0
end

p ans

Measured memory_bytes: 19204
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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;
    }
}

int main(void)
{
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a, a + N);
    lli cnt = 0;
    for (int i = 0; i < N - 2; i++)
    {
        for (int j = i + 1; j < N - 1; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                if (a[k] < a[i] + a[j])
                {
                    cnt++;
                }
                /*else
                {
                    break;
                }*/
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String []line = br.readLine().split(" ");

        long curr = Long.parseLong(line[0]), moves = Long.parseLong(line[1]), d = Long.parseLong(line[2]);

        curr=Math.abs(curr);

        long maxMoves = (long)curr/d;

        if(maxMoves > moves){
            curr-= moves*d;
            moves=0;
        }
        else {
            curr-= maxMoves*d;
            moves-= maxMoves;
        }

        if(moves >0){
            if(moves%2 == 0){
                System.out.println(Math.abs(curr));
            }
            else {
                if(Math.abs(curr-d) <= Math.abs(curr+d)){
                    System.out.println(Math.abs(curr-d));
                }
                else {
                    System.out.println(Math.abs(curr+d));
                }
            }
        }
        else {
            System.out.println(Math.abs(curr));
        }
    }
}

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

int main(){
  int n,i,j,k,l;
  char stn[9],ma[9],mi[9];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",stn);
    ma[0]=mi[0]=stn[0];
    for(j=1;j<8;j++){
      for(k=0;k<j;k++)
	if(stn[j]>=ma[k]) break;
      for(l=j;l>k;l--) ma[l]=ma[l-1];
      ma[k]=stn[j];
      for(k=0;k<j;k++)
	if(stn[j]<=mi[k]) break;
      for(l=j;l>k;l--) mi[l]=mi[l-1];
      mi[k]=stn[j];
      ma[8]=mi[8]='\0';
    }
    printf("%d\n",atoi(ma)-atoi(mi));
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>

int insertionSort(int*, int, int);
void shellSort(int*, int);

int insertionSort(int *A, int n, int g){
  int i, j, v;
  int cnt = 0;

  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }

  return cnt;
}

void shellSort(int *A, int n){
  int i, j;
  int cnt = 0;
  int m = 0;
  int *G;

  i = n;
  if(n == 1)  m = 1;
  while(i > 1){
    m++;
    i /= 2;
  }

  G = (int *)malloc(sizeof(int) * m);

  G[0] = n/2;
  for(i=1;i<m;i++){
    G[i] = G[i-1]/2;
  }

  for(i=0;i<m;i++){
    cnt += insertionSort(A, n, G[i]);
  }

  // print
  printf("%d\n",m);
  for(i=0;i<m;i++){
    printf("%d",G[i]);
    if(i != m-1) printf(" ");
    else printf("\n");
  }
  printf("%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
}

int main(){
  int i,n;
  int *A;

  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  shellSort(A, n);

  return 0;
}



Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}
  
   

Measured memory_bytes: 256
import sys

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

if sum(A)<=sum(B):
    print(-1)
    sys.exit()

Y=0
K=0
Q=[]

for i in range(N):
    k=A[i]-B[i]
    if k>0:
        Q.append(k)
    elif k<0:
        K+=1
        Y+=-k

if Y==0:
    print(0)
    sys.exit()
    
Q.sort(reverse=True)
for q in Q:
    Y-=q
    K+=1
    if Y<=0:
        print(K)
        sys.exit()
    


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

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

#define ll long long
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;
int n, m, k, q;

int main()
{
	fast();
	string s;
	cin >> s;
	if(s == "ABC"){
		cout << "ARC";
	}
	else{
		cout <<"ABC";
	}
}



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

using namespace std;

int main()
{
    string N;
    cin >> N;
    for (int i = 0; i < N.size(); i++)
    {
        if (N[i] == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    ll A=4*a*b;
    ll B=(c-a-b)*(c-a-b);
    if(c-a-b>0 && A<B)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int main() {
  IOS;
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  int mx = -INF, mn = INF;
  REP(i,n) {
    chmax(mx,a[i]);
    chmin(mn,a[i]);
  }
  int add = abs(mx) >= abs(mn) ? mx : mn;
  int add_idx = 0;
  REP(i,n) {
    if (a[i] == add) {
      add_idx = i; break;
    }
  }

  vector<P> ans;
  REP(i,n) ans.push_back({ add_idx, i });
  if (add >= 0) {
    REP(i,n-1) ans.push_back({ i, i+1 });
  } else {
    REP(i,n-1) ans.push_back({ n-i-1, n-i-2 });
  }

  COUT(ans.size());
  REP(i,ans.size()) {
    cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

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

    int n, x, y, s, flag, ans = 0, cnt;
    cin >> n;
    vector<pair<int, int>> v[n];
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> s;
        for (int j = 0; j < s; j++) {
            cin >> x >> y;
            x--;
            v[i].push_back({x, y});
        }
    }
    for (int i = 0; i < (1 << n); i++) {
        cnt = 0;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) a[j] = 1;
            else a[j] = 0;
            cnt += a[j];
        }
        flag = 1;
        for (int j = 0; flag && (j < n); j++) {
            if (a[j]) {
                for (int k = 0; flag && (k < v[j].size()); k++) {
                    x = v[j][k].first, y = v[j][k].second;
                    if (a[x] != y) flag = 0;
                }
            }
        }
        if (flag) ans = max(ans, cnt);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//解説AC

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

const long double PI=(acos(-1));//円周率
const long double EPS=0.0000000001;

long double f(long double a,long double b,long double theta){//theta角時の水筒内の体積を求める
    if(theta>PI/2.0-EPS){//PI/2は度数法で180度、thetaが180度を超えたら0return
        return 0.0;
    }
    long double ret;
    if(a*tan(theta)<=b){//a*tanθは、水筒の縦を表し、その長さがbを超えたら不可である
        ret=a*a*b-a*a*a*tan(theta)/2.0;//水の面積が長方形+三角形である時、三角形となっている空白を水筒の体積から差し引き水の体積を求めている
    }else{
        ret=b*b/tan(theta)*a/2.0;//水の部分が三角形onlyである時
    }
    return ret;
}

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    long double ok=PI/2.0;
    long double ng=0.0;
    for(int _=1;_ <=100000;_++){
        long double mid=(ok+ng)/2.0;
        if(f(a,b,mid)<x)ok=mid;//体積より下回ったら、midは有効な数字のため、okに、もしダメだったらngに
        else ng=mid;//にぶたん
    }
    cout<<fixed<<setprecision(10)<<ok/PI*180<<endl;//180=πなので、πで割り、180をかけることで度数法に変換できる。
    
    return 0;
}

//a=97,z=122
/*

*/

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
int dp[200000];

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  dp[0]=3;
  int ans=1;
  for(int i=0;i<n;i++)ans*=dp[v[i]],ans%=MOD,dp[v[i]]--,dp[v[i]+1]++;
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
import sys

class Dise():
    def __init__(self, aLabelList):
        self.LabelList = aLabelList
        self.NEWS = {"N": [0,4,5,1],
                     "E": [0,2,5,3],
                     "W": [0,3,5,2],
                     "S": [0,1,5,4],
                     "R": [1,2,4,3]}
       
    def move(self,aNEWS):
        idx = self.NEWS[aNEWS]
        tmp = self.LabelList[idx[0]]
        self.LabelList[idx[0]] = self.LabelList[idx[3]]
        self.LabelList[idx[3]] = self.LabelList[idx[2]]
        self.LabelList[idx[2]] = self.LabelList[idx[1]]
        self.LabelList[idx[1]] = tmp

def step2():
    for i in range(4):
        if Dise1.LabelList[1] == Dise2.LabelList[1] and \
           Dise1.LabelList[2] == Dise2.LabelList[2] and \
           Dise1.LabelList[3] == Dise2.LabelList[3] and \
           Dise1.LabelList[4] == Dise2.LabelList[4]:
            print("Yes")
            sys.exit()
        else:
            Dise2.move("R")
    print("No")
    sys.exit()

Dise1 = Dise(input().split())
Dise2 = Dise(input().split())

for i in range(4):
    if Dise1.LabelList[0] == Dise2.LabelList[0] and \
       Dise1.LabelList[5] == Dise2.LabelList[5]:
        step2()
    else:
        Dise2.move("E")

Dise2.move("N")
if Dise1.LabelList[0] == Dise2.LabelList[0] and \
   Dise1.LabelList[5] == Dise2.LabelList[5]:
    step2()

Dise2.move("S")
Dise2.move("S")
if Dise1.LabelList[0] == Dise2.LabelList[0] and \
   Dise1.LabelList[5] == Dise2.LabelList[5]:
    step2()

print("No")




Measured memory_bytes: 5576
#include<iostream>
#include <cstdlib>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define cd cout<<"asd"<<endl;
#define pb push_back
const int PI=acos(-1);
const int N=2e5+7;
vector<int>q[N];
int main(){
	int n,m,a,b;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		q[a].pb(b);
		q[b].pb(a);
	}
	int flag=0;
	for(int i=0;i<q[1].size();i++){
		int t=q[1][i];
		for(int j=0;j<q[t].size();j++){
			if(q[t][j]==n){flag=1;break;}
		}
		if(flag==1)break;
	}
	if(flag==1)cout<<"POSSIBLE\n";
	else cout<<"IMPOSSIBLE\n";
}


Measured memory_bytes: 12016
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i * (i + 1) < 2 * n; i++){ans = i;}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int table[50];
 
int main(){
 
  int n,k,count;
  cin >> n >> k;
 
  for(int i=0; i<n; i++){
    cin >> table[i];
  }
 
  sort(table,table + n,greater<int>());
 
  for(int i=0; i<k;i++){
    count += table[i];
  }
  
  cout << count << endl;
 
  return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty()) {
    int u = S.top(); S.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if(color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i++) color[i] = NIL;
  for (int u = 0; u < n; u++) {
    if (color[u] == NIL) dfs(u, id++);
  }
}

int main() {
  int s, t, m, q;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 9020
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    ll sum = accumulate(ALL(A), (ll)0);
    ll lsum = 0;
    ll ans = sum;
    for(ll i = 0; i < N; i++) {
        lsum += A[i];
        ll rsum = sum - lsum;
        chmin(ans, (ll)abs(lsum - rsum));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

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

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if((a+b)>(c+d))
    {
        printf("Left\n");
    }
    else if((a+b)==(c+d))
    {
        printf("Balanced\n");
    }
    else if((a+b)<(c+d))
    {
        printf("Right\n");
    }


    return 0;
}

Measured memory_bytes: 1648
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

class WeightedUnionFind:
    def __init__(self, node:int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]
        self.diff_weight = [0 for i in range(self.n)]
        
    # ノードxのルートを求める
    def find(self, x:int) -> int:
        if x == self.par[x]:
            return x
        else:
            r = self.find(self.par[x])
            self.diff_weight[x] += self.diff_weight[self.par[x]]
            self.par[x] = r
            return self.par[x]
        
    # ノードxのルートからの距離を求める
    def weight(self, x:int) -> int:
        self.find(x)
        return self.diff_weight[x]
        
    # weight(y) - weight(x) = w となるようにする
    def unite(self, x:int, y:int, w:int) -> bool:
        if self.isSame(x,y):
            return False
        
        w += self.weight(x)
        w -= self.weight(y)
        
        rx = self.find(x)
        ry = self.find(y)
        
        if self.rank[rx] < self.rank[ry]:
            rx, ry = ry, rx
            w = -w

        self.par[ry] = self.par[rx]
        self.diff_weight[ry] = w
        
        if self.rank[rx] == self.rank[ry]:
            self.rank[rx] += 1
                
        return True
                
    
    def isSame(self, x:int, y:int) -> bool:
        return self.find(x) == self.find(y)
    
    def diff(self, x:int, y:int) -> int:
        if self.isSame(x,y):
            return self.weight(y)-self.weight(x)
        else:
            raise ValueError("xとyは同じ木に属していません")


n,m = li()

lrd = []
for _ in range(m):
    l,r,d = li()
    l -= 1
    r -= 1
    lrd.append((l,r,d))
 
exist = True

wuf = WeightedUnionFind(n)

for l,r,d in lrd:
    wuf.unite(l,r,d)
    if wuf.diff(l,r) != d:
        exist = False
        break
    
if exist:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40308
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>
 
using namespace std;
 
long long H,N,i,j,k,A[1000],B[1000],memo[100001],ans;
 
long long dp(long long m)
{
  long long s,t,u,temp;
  
  if(memo[m]!=-1)
  {
    return memo[m];
  }
  
  if(m-A[0]<0)
  {
    t=B[0];
  }
  else
  {
    t=dp(m-A[0])+B[0];
  }
  
  for(u=1;u<N;u++)
  {
    if(m-A[u]<0)
    {
      t=min(t,B[u]);
    }
    else
    {
      t=min(t,dp(m-A[u])+B[u]);
    }
  }
  memo[m]=t;
  
  return t;
  
  
}
 
int main()
{
  cin>>H>>N;
 
  for(i=0;i<N;i++)
  {
    cin>>A[i]>>B[i];
  }
  

    for(j=0;j<100001;j++)
    {
      memo[j]=-1;
    }

  memo[0]=0;

  k=0;
  for(i=0;i<N;i++)
  {
    k=max(k,A[i]);
  }
  
  ans=dp(H);

  for(i=0;i<k;i++)
  {
    ans=min(ans,dp(H+i));
  }
  
  cout <<ans;
      
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<ll,ll>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  int x,n,ans=1000;
  vector<int> a(101);
  cin >>x>>n;
  rep(i,n)cin>>a[i];
  for(ll b =-100;b<201;b++){
    bool an=true;
    rep(i,n){
      if(a[i]==b){
        an=false;
        break;
      }
    }
    if(an){
      if(abs(ans-x)>abs(b-x)){
        ans=b;
      }
    }
  }
cout<<ans<<endl;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    double a, b, x;
    cin >> a >> b >> x;
    if(a * b / 2 >= x / a){
        double ans = atan(a * b * b / (2 * x)) * 180 / 3.14159265358979323846;
        printf("%.10f\n", ans); 
    }else{
        double ans = atan((2 * b / a) - 2 * x / (a * a * a)) * 180 / 3.14159265358979323846;
        printf("%.10f\n", ans); 
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
ll n;
vector<ll> adj[100005];
ll dp[100005][2];

void dfs(ll u, ll p){
    for(auto i=adj[u].begin(); i!=adj[u].end(); i++){
        if(*i != p){
            dfs(*i, u);
            dp[u][1] = (dp[u][1]*((dp[*i][0]+dp[*i][1])%mod))%mod;
            dp[u][0] = (dp[u][0]*dp[*i][1])%mod;
        }
    }
}

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    for (int i = 0; i < n-1; ++i)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int i = 1; i < n+1; ++i)
    {
        dp[i][0]=1;
        dp[i][1]=1;
    }

    dfs(1, -1);

    cout<<(dp[1][0]+dp[1][1])%mod;

    return 0;
}


Measured memory_bytes: 16048
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll MOD = (ll)1e9 + 7 ;
const int N = (int)1e4 + 10;

string s;
int k; int n;

int dp[N][100][2];

int rec(int id = 0, int cnt = 0, int lrge = 1){
  	//cout << id << " " << cnt << " " << lrge << '\n';
    if( cnt > k) return 0;
    if( id == n){
        if( cnt == k) 
            return 1;
        else return 0;
    }
  	//cout << "YES ";
    auto & res = dp[id][cnt][lrge];
    if( res != - 1)
        return res;
    res = 0;
  	//cout << "YY \n";
    int LMT;
    if( lrge == 1)
        LMT = s[id] - '0';
    else 
        LMT = 9;
  	//cout << LMT << '\n';
    for(int j = 0; j <= LMT; ++j){
      	//cout << id << " " << j << '\n';
        int ncnt = cnt;
        int nlrge = lrge;
        if( lrge and j < LMT ) nlrge = 0; //the number is smaller now
        if( j ) ncnt++;
        if( ncnt <= k ) res += rec(id + 1, ncnt, nlrge);
    }
    return res;
}

void solve(){
    cin >> s;
    cin >> k;
    n = s.size();
  	//cout << s << " " << n << '\n'; 
    memset(dp, -1, sizeof dp);
    cout << rec() << '\n';
    
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
}

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

int main() {
	
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for(int i = a; i <= b; i++){
		if(i % 10 == (i / 10000) % 10 && (i / 10) % 10 == (i / 1000) % 10){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
 
class Program
{
    static void Main()
    {
    	string[] s = Console.ReadLine().Split(' ');
		int n = int.Parse(s[0]);
		int m = int.Parse(s[1]);
		int l = int.Parse(s[2]);
    	
    	var A = new long [n, m];
    	var B = new long [m, l];
    	
    	for(int i = 0; i < n; i++) {
    		var t = Console.ReadLine().Split(' ');
    		
    		for(int j = 0; j < m; j++) {
    			A[i, j] = long.Parse(t[j]);
    		}
    	}
    	
    	for(int i = 0; i < m; i++) {
    		var t = Console.ReadLine().Split(' ');
    		
    		for(int j = 0; j < l; j++) {
    			B[i, j] = long.Parse(t[j]);
    		}
    	}

    	for(int i = 0; i < n; i++) {
    		var C = new long[l];
    		for(int j = 0; j < l; j++) {
    			for(int k = 0; k < m; k++) {
    				C[j] += A[i, k] * B[k, j];
    			}
    		}
    		var u = Array.ConvertAll(C, x=>x.ToString());
    		Console.WriteLine(string.Join(" ", u));
    	}
    }
}

Measured memory_bytes: 9688
fun main(args: Array<String>) {
    val MOD = 1000000007L
    val SIZE = 2002
    val c = Array<LongArray>(SIZE + 1) { LongArray(SIZE + 1) }
    c[0][0] = 1
    for (i in 0 until SIZE) {
        for (j in 0 until SIZE) {
            c[i + 1][j] += c[i][j]
            c[i + 1][j] %= MOD
            c[i + 1][j + 1] += c[i][j]
            c[i + 1][j + 1] %= MOD
        }
    }
    fun comb(n: Int, k: Int) = if (n < k) 0 else c[n][k]
    fun g(n: Int, k: Int) = comb(n + k - 1, k - 1)
    fun f(n: Int, k: Int) = if (k < 1) 0 else g(n-k, k)

    val (N, K) = listOfInt()
    val R = N - K
    for (i in 1 .. K) {
        val blue = f(K, i)
        val red = g(R - (i - 1), i + 1)
        val ans = blue * red % MOD
        println(ans)
    }
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

Measured memory_bytes: 92236
n, p = map(int, input().split())
a = list(map(int, input().split()))
odd_count = sum([i % 2 == 1 for i in a])
if p == 0:
    if odd_count == 0:
        print(2**(n-odd_count))
    else:
        print((2**(n-odd_count)) * (2 ** (odd_count - 1)))
else:
    if odd_count == 0:
        print(0)
    else:
        print((2**(n-odd_count)) * (2 ** (odd_count - 1)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  set<char> a;
  set<char> b;
  for (int i = 0; i < S.length(); i++) {
    if(S[i]=='N' || S[i]=='S')a.insert(S[i]);
    if(S[i]=='W' || S[i]=='E')b.insert(S[i]);
  }
  cout << ((a.size() == 2 || a.size() == 0) && (b.size() == 2 || b.size() == 0) ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  ll ans = 0;
  if (n >=400 && n < 600) ans = 8;
  if (n >=600 && n < 800) ans = 7;
  if (n >=800 && n < 1000) ans = 6;
  if (n >=1000 && n < 1200) ans =5;
  if (n >=1200 && n < 1400) ans = 4;
  if (n >=1400 && n < 1600) ans = 3;
  if (n >=1600 && n < 1800) ans = 2;
  if (n >=1800 && n < 2000) ans = 1;
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

long long f(long long n) {
  long long ans = 0;
  for (int i = 0; i < 60; ++i) {
    long long sz = 1LL << (i + 1);
    long long a = ((n + 1) / sz) * (sz / 2);
    long long b = (n + 1) % sz - sz / 2;
    b = max(0LL, b);

    long long c = (a + b) % 2;

    ans |= (c << i);
  }

  return ans;
}

int main() { IO;
  long long a, b;
  cin >> a >> b;

  long long ans = f(a - 1) ^ f(b);
  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }


ll func(ll x){
  if(x==1){return 1LL;}
  else{ return 1+func(x/2)*2; }
}

int main(){
  ll H; cin>>H;
  ll ans = func(H);
  cout << ans <<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

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

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

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

    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for(int i = 0; i < q; ++i){
        int type, x, y;
        cin >> type >> x >> y;
        if(!type)   uf.unite(x, y);
        else{
            if(uf.same(x, y))   cout << 1 << '\n';
            else    cout << 0 << '\n';
        }
    }
}


Measured memory_bytes: 3300
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
ll n;
string s;
cin >>n>>s;
ll e=0;
ll w=0;
REP(i,n){
if(s[i]=='E')
e++;
else
w++;
}
ll e1=0;
ll w1=0;
ll min=n;
REP(i,n){
if(s[i]=='E')
e--;
if(e+w1<min){
min=e+w1;
}
if(s[i]=='W')
w1++;

}
cout<<min;
return 0;
}

Measured memory_bytes: 900
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

# 先頭の箱のキャンディを食べるか否か
if A[0] > x:
	ans += A[0] - x
	A[0] -= A[0] - x
	
flg = 1

while flg:
	flg = 0
	for i in range(1, N):
		adj_box_sum = A[i - 1] + A[i]
		if adj_box_sum > x:
			ans += adj_box_sum - x
			A[i] -= adj_box_sum - x
			if A[i - 1] + A[i] > x:
				flg = 1
print(ans)

Measured memory_bytes: 63984
from collections import deque
def main():
  _map, _input, _int = map, input, int
  n, q = _map(_int, _input().split())
  values = [0] * n
  links = [[] for _ in range(n)]
  for _ in range(n - 1):
    a, b = _map(_int, _input().split())
    links[a - 1].append(b - 1)
    links[b - 1].append(a - 1)
  for _ in range(q):
    p, x = _map(_int, _input().split())
    values[p - 1] += x
  d = deque()
  d.append((0, -1))
  while len(d) != 0:
    i, p = d.popleft()
    for j in links[i]:
      if j == p:
        continue
      values[j] += values[i]
      d.append((j, i))
  print(*values)
main()


Measured memory_bytes: 107156
#include<stdio.h>
main(){
  int H,W,c,d;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    for(c=0;c<H;c++){
      for(d=0;d<W;d++){
	if(c==0 || c==H-1){
	    printf("#");
	  }
	else if(d==0 || d==W-1){
	  printf("#");
	}
	else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    string S;
    S = (a>b ? "Alice" : "Bob");
    if(a==1 && b !=1)S = "Alice";
    if(a!=1 && b ==1)S = "Bob";
    S = (a==b ? "Draw": S);
    cout << S;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	vector<int> a(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	for (int i = 0; i < 5; i++)
	{
		cout << a.at(i) << (i == 4 ? "" : " ");
	}

	cout << endl;
}


Measured memory_bytes: 3164
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	int t, n;
	while( scanf( "%d", &t ), t )
	{
		scanf( "%d", &n );

		rep( i, n )
		{
			int s, f;
			scanf( "%d%d", &s, &f );
			t -= f-s;
		}

		if( t > 0 )
			printf( "%d\n", t );
		else
			puts("OK");
	}

	return 0;
}

Measured memory_bytes: 1040
#!/usr/bin/env python3
a, b, c, x, y = map(int, input().split())
answer = 0
if 2 * c < a + b:
    z = min(x, y)
    x -= z
    y -= z
    answer += 2 * c * z
a = min(a, 2 * c)
b = min(b, 2 * c)
answer += a * x
answer += b * y
print(answer)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	for(int i=1; i<=9; i++){
		if(N%i==0 && N/i <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - AtCoder Crackers
https://atcoder.jp/contests/abc105/tasks/abc105_a

"""
import sys


def solve(N, K):
    if N % K:
        return 1
    return 0


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main() {
  int64_t n;
  std::cin >> n;
  if (n == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }

  const int64_t one = 1;

  int64_t range[40][2];
  range[0][0] = 0;
  range[0][1] = 1;

  for (int i = 1; i < 40; i++) {
    if (i % 2 == 0) {
      range[i][0] = range[i - 1][0];
      range[i][1] = range[i - 1][1] + (one << i);
    } else {
      range[i][1] = range[i - 1][1];
      range[i][0] = range[i - 1][0] - (one << i);
    }
  }

  std::string s = "";
  s.reserve(80);

  auto m = n;
  for (int i = 39; 0 < i; i--) {
    if (range[i - 1][0] <= m && m <= range[i - 1][1]) {
      s.push_back('0');
    } else {
      s.push_back('1');
      if (i % 2 == 0) {
        m -= (one << i);
      } else {
        m += (one << i);
      }
    }
  }

  if (m == 0) {
    s.push_back('0');
  } else {
    s.push_back('1');
  }

  bool loop = true;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '0') {
      loop = false;
    }
    if (!loop) {
      std::cout << s[i];
    }
  }
  std::cout << std::endl;
  return 0;
}

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

const int mod = 1e9 + 7, i2 = (mod+1)>>1;

int dp[3000][3000],a[3000];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(a[i]>a[j])
				dp[i][j]=1;
	for(int _=1;_<=q;_++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		if(x>y)	swap(x,y);
		int xy = dp[x][y], yx = dp[y][x];
		for(int i=0;i<n;i++){
			dp[x][i]=dp[y][i]=1LL*(dp[x][i]+dp[y][i])*i2%mod;
			dp[i][x]=dp[i][y]=1LL*(dp[i][x]+dp[i][y])*i2%mod;
		}
		dp[x][y]=dp[y][x]=1LL*(xy+yx)*i2%mod;
	}
	long long int ans = 0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			ans+=dp[i][j];
	ans%=mod;
	for(int i=0;i<q;i++)
		ans=ans*2%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;

    vector<vector<int>> g(n);
    rep(i, n - 1) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[y].push_back(x);
    g[x].push_back(y);

    vector<int> ans(n);
    vector<int> d(n);
    rep(s, n) {
        rep(i, n) d[i] = INF;
        d[s] = 0;
        queue<int> q;
        q.push(s);
        while (sz(q)) {
            int now = q.front();
            q.pop();
            for (int nxt : g[now]) {
                if (d[nxt] != INF) continue;
                d[nxt] = d[now] + 1;
                q.push(nxt);
            }
        }
        rep(i, n) ans[d[i]]++;
    }

    for (int k = 1; k < n; k++) {
        cout << ans[k] / 2 << endl;
    }
}


Measured memory_bytes: 384
# ABC058b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

o = input()
e = input()

for i in range(len(o) + len(e)):
    if (i % 2 == 1):
        print(e[i // 2], end='')
    else:
        print(o[i//2], end='')

Measured memory_bytes: 3060