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

const int M=1e6;
int a[M];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
    int n;
    string s;
    cin >> n >> s;
    
    s = s+s;
    
    for(int i1=0; i1<2; i1++){
    	for(int i2=0; i2<2; i2++){
    		a[0] = i1;
    		a[1] = i2;
    		for(int i=2; i<=n+1; i++){
    			if(s[i-1]=='o' && a[i-1]==0) a[i] = 1-a[i-2];
    			if(s[i-1]=='o' && a[i-1]==1) a[i] = a[i-2];
    			if(s[i-1]=='x' && a[i-1]==0) a[i] = a[i-2];
    			if(s[i-1]=='x' && a[i-1]==1) a[i] = 1-a[i-2];
			}
			if(a[n]==a[0] && a[n+1]==a[1]){
				for(int i=0; i<n; i++)
				    cout << (a[i]?"S":"W");
				return 0;
			}
		}
	}
	cout << -1;
	return 0;
}

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

int main() {
  int i, j, k, a, b;
  
  j = 0;
  
  cin >> k >> a >> b;
  
  if (a << k && k << b) {
    for (i = a; i <= b; i++) {
      if (i % k == 0) {
        j=1;
        cout << "OK" << endl;
        break;
      }
    }
    if (j == 0) {
      cout << "NG" << endl;
    }
  }
  else {
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N ; cin >> N ;
  ll power = 1 ;
  rep(i,N){
    power *= (i+1);
    power %= 1000000007;
  }
  cout << power << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

using namespace std;

int calc_max(vector<int>& jewelries, vector<int>& costs, int index, int current,
             int cost) {
    if (index >= jewelries.size())
        return current - cost;

    int v1 = calc_max(jewelries, costs, index + 1, current + jewelries[index],
                      cost + costs[index]);
    int v2 = calc_max(jewelries, costs, index + 1, current, cost);
    return max(v1, v2);
}

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

    vector<int> jewelries(n);
    vector<int> costs(n);
    for (int i = 0; i < n; ++i)
        cin >> jewelries[i];
    for (int i = 0; i < n; ++i)
        cin >> costs[i];
    cout << calc_max(jewelries, costs, 0, 0, 0) << '\n';
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

ll MOD = ll(1e9 + 7);

ll add(ll x, ll y){
    x += y;
    if(x >= MOD) x -= MOD;
    return x;
}

ll sub(ll x, ll y){
    x -= y;
    x += MOD;
    if(x >= MOD) x -= MOD;
    return x;
}

ll mul(ll x, ll y){
    return (x % MOD * y % MOD) % MOD;
}

ll pwr(ll x, ll p){
    if(p == 0) return 1;
    if(p == 1) return x;
    if(p&1) return mul(x, pwr(x, p-1));
    ll t = pwr(x, p/2);
    return mul(t, t);
}

ll inv(ll x){
    return pwr(x, MOD-2);
}

int main(){
    fcin;

    int n;
    cin >> n;
    vector<ll> o(62, 0);

    for(int i = 0; i < n; i++){
        ll x;  cin >> x;
        for(int j = 0; j < 62; j++){
            o[j] += ((x >> j) & 1);
        }
    }

    ll ans = 0;

    for(int j = 0; j < 62; j++){
        ll m = mul(o[j], n - o[j]);
        m = mul(m, pwr(2, j));
        ans = add(ans, m);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
p = int(input())
lst = [int(i) for i in input().split()]
c = 0
for i in range(1,p-1):
    if (lst[i] > lst[i-1] and lst[i] < lst[i+1]) or (lst[i] < lst[i-1] and lst[i] > lst[i+1]):
        c += 1
print(c)


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

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

constexpr ll INF = 1e18;

int main() {
    int N, K; cin >> N >> K;
    vector<Pli> sushi(N);
    for (int i = 0; i < N; i++) {
        cin >> sushi[i].second >> sushi[i].first;
    }
    map<int, int> types;
    vector<ll> base_points(N+1, -INF);
    ll temp = 0;
    sort(sushi.begin(),sushi.end(), greater<Pli>());
    for (int i = 0; i < K; i++) {
        types[sushi[i].second]++;
        temp += sushi[i].first;
    }
    int a = types.size();
    base_points[a] = temp;
    int j = K;
    for (int i = K-1; 0 <= i; i--) {
        if (types[sushi[i].second] != 1) {
            while (j < N) {
                if (types[sushi[j].second] == 0) {
                    temp = temp - sushi[i].first + sushi[j].first;
                    base_points[++a] = temp;
                    types[sushi[i].second]--;
                    types[sushi[j].second]++;
                    break;
                } else {
                    j++;
                }
            }
            if (j == N) break;
        }
    }
    ll ans = base_points[0];
    for (int i = 0; i <= N; i++) {
        ans = max(ans, base_points[i] + (ll)i * i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5504
import sys

sys.setrecursionlimit(10**9)

input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
put = []

for i in reversed(range(N)):
    if A[i]:
        put.append(i + 1)

        tmp = 1
        n = i + 1
        while tmp * tmp <= n:
            if n % tmp == 0:
                A[tmp - 1] ^= 1
                if tmp != n // tmp:
                    A[n // tmp - 1] ^= 1
            tmp += 1

if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)


Measured memory_bytes: 69112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
int main(){
string s,t;
cin>>s>>t;
ll ca = 0;
for(ll i=0; i<3; i++){
if(s.at(i)==t.at(i)){
ca++;}}
cout << ca << endl;}

Measured memory_bytes: 3584
/*
 本問から一般化できる教訓をまとめる
 
 * 木を探索するときの常套手段は「根をとりあえず１つ決めること」である
 
 
 */
 
 
 /*
 ツリー探索のテンプレは以下の通りである.
 
 using Graph = vector<vector<int>> ;
 Graph G;
 
 // vは現在見ている頂点を表し, pはvのparentを表す
 
void dfs(int v, int p){
    
    // nv : new vという意味である.
    for (auto nv : G[v){
        
        if (nv == p) continue // 根から葉に向かって逆流することを防ぐ
        
        dfs(nv, v); // もぐる
    }
}

int main(){
    
    int root = 0;
    
    dfs(root, -1); // root のparentはいないから-1を設定しておく
}
 
 */
 
 
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
using Edge = pair<int,int>;

// vをcで塗る
void dfs(int v, int p, int c,vector<vector<pair<int, int>>> &G,vector<int> &res){
    
    res[v] = c; // vをcで塗る
    
    for (auto e : G[v]){
        
        if (e.first == p) continue; // 逆流を防止する
        
        if (e.second & 1) dfs(e.first, v, 1-c, G, res);
        else dfs(e.first, v, c, G, res);  // 根からの距離が同じ色で塗る
    }

}

int main(){
    
    int n;
    cin >> n;
    
    vector<vector<pair<int,int>>> G(n,vector<pair<int,int>>());
    
    for (int i = 0; i < n-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        
        u--, v--;
        
        G[u].push_back(pair<int, int>(v,w));
        G[v].push_back(pair<int, int>(u,w));
        
        
    }
    
    vector<int> res(n,0);
    
    dfs(0,-1,1, G, res);
    
    for (auto v : res) cout << v << endl;
    
}


/*

その重さが奇数だったら、長さが 1 の辺
その重さが偶数だったら、長さが 0 の辺 (あるいは u-v だとすると、u-w-v と間に頂点 w が挿入された長さ 2 の状態)
という感じ。
これはなぜか？？？？？

*/
 

Measured memory_bytes: 9728
//ABC136A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = max(0,c-a+b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int a[1000],n,i=0,maxi,mini;
 cin>>n;
 for(i=0;i<n;i++)
 {
     cin>>a[i];
 }
 mini=maxi=a[0];
    for(i=1; i<n; i++)
    {
         if(mini>a[i])
		  mini=a[i];
		   if(maxi<a[i])
		    maxi=a[i];
    }
    cout<<maxi-mini<<endl;

}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;

int main() {
    int N;
    cin >> N;
    ll res = 0;
    int A[1000010]{0};
    for (int i = 0; i < N; ++i) {
        int el;
        cin >> el;
        A[el]++;
        res += el;
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int B, C;
        cin >> B >> C;
        res += (C-B) * A[B];
        A[C] += A[B];
        A[B] = 0;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 7536
import sys

n, s = sys.stdin.read().split()

def main():
    cnt = s.count('E')
    cur = 'E'
    res = [cnt]
    for c in s:
        if cur == 'W': cnt += 1
        if c == 'E': cnt -= 1
        res.append(cnt)
        cur = c
    print(min(res))
    
if __name__ ==  '__main__':
    main()

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

typedef  long long ll;
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;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[110];
int cnt[110]={0};
int n;
int ans=0;
void mizuyari(int,int);
void chk(int left,int right){
    int l=-1,r=-1;
    int i=left;
    while(i<=right){
        if((cnt[i]<h[i])&&(l==-1)){
           l=r=i;
        }
        else if((cnt[i]<h[i])&&(l!=-1)){
            r=i;
        }
        else if(l!=-1){
            mizuyari(l,r);
            l=r=-1;
        }
        i++;
    }
    if(l!=-1)mizuyari(l,r);
}
void mizuyari(int left,int right){
    ans++;
    rep2(i,left,right)cnt[i]++;
    chk(left,right);
}
int main(){
    cin>>n;
    rep(i,n)cin>>h[i];
    int l=0,r=(n-1);
    chk(l,r);
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int A[50], B[50];
int C[50], D[50];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N) cin >> A[i] >> B[i];
  rep(i, M) cin >> C[i] >> D[i];
  rep(i, N) {
    int x = A[i], y = B[i];
    int m = 2147483647, mi = -1;
    rep(j, M) {
      int d = abs(C[j]-x) + abs(D[j]-y);
      if (d < m) {
        m = d;
        mi = j;
      }
    }
    cout << mi + 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

StoT = {}
TtoS = {}

for s,t in zip(S,T):
    if s in StoT.keys():
        if StoT[s] != t:
            print('No')
            exit()
    elif t in TtoS.keys():
        if TtoS[t] != s:
            print('No')
            exit()
    else:
        StoT[s] = t
        TtoS[t] = s
print('Yes')

Measured memory_bytes: 42060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e6+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
  int n;
  cin>>n;
  ll ans = power(10,n) - power(9,n) - power(9,n) + power(8,n);
  ans %= mod;
  if(ans < 0) ans += mod;
  cout << ans;
}

int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a<=111)
		{
		cout<<"111";
		return 0;
		}
	if(a<=222)
		{
		cout<<"222";
		return 0;
		}
		if(a<=333)
		{
		cout<<"333";
		return 0;
		}
		if(a<=444)
		{
		cout<<"444";
		return 0;
		}
		if(a<=555)
		{
		cout<<"555";
		return 0;
		}
		if(a<666)
		{
		cout<<"666";
		return 0;
		}
		if(a<=777)
		{
		cout<<"777";
		return 0;
		}
		if(a<=888)
		{
		cout<<"888";
		return 0;
		}
		if(a<=999)
		{
		cout<<"999";
		return 0;
		}						
    return 0;
}

Measured memory_bytes: 256
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]

c = 0
for i in range(n) :
    if d[i][0] == d[i][1] :
        c += 1
    else :
        c = 0
    if c >= 3 :
        print("Yes")
        break
else :
    print("No")


Measured memory_bytes: 9196
#include <iostream>
#include <stdio.h>

using namespace std;
int a[55];
int main()
{
    int n,m,n1,n2;
    scanf("%d%d",&n,&m);
    for(int i = 0;i < m;i++)
    {
        scanf("%d%d",&n1,&n2);
        a[n1]++;
        a[n2]++;
    }
    for(int i = 1;i <= n;i++)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];

  rep(i, k, n) {
    if (a[i] > a[i - k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 4780
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int[] sum1 = new int[n + 1], sum2 = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sum1[i] = sum1[i - 1] + (s.charAt(n - i) == '#' ? 0 : 1);
            sum2[i] = sum2[i - 1] + (s.charAt(i - 1) == '.' ? 0 : 1);
        }

        int ans = 2 * n;
        for (int i = 0; i <= n; i++) {
            ans = Math.min(ans, sum1[i] + sum2[n - i]);
        }
        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



Measured memory_bytes: 42172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  
  int ans = 1, countans = 0;
  
  for (int i = 1; i <= n; i++) {
    int a = i;
    int counta = 0;
    while (a % 2 == 0) {
      counta ++;
      a /= 2;
    }
    if (counta > countans) {
      ans = i;
      countans = counta;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int a[200000];
signed main(){
  string str;
  cin >> str;
  if(str == "A")cout << "T";
  else if(str == "T")cout << "A";
  else if(str == "G")cout << "C";
  else if(str == "C")cout << "G";
  return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	Yes(a == b&&b == c);
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	N := getStdinInt64()
	H := getStdinIntArr64()

	var i int64 = 0
	var prev int64 = -2
	for ; i < N-1; i++ {
		i0 := H[i]
		i1 := H[i+1]
		if prev != -2 {
			i0 = prev
		}

		if i0 <= i1-1 {
			prev = i1 - 1
		} else if i0 <= i1 {
			prev = i1
		} else {
			fmt.Printf("No\n")
			return
		}
	}
	fmt.Printf("Yes\n")
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 7892
# coding: utf-8

import sys

lines = sys.stdin.readlines()

n,a,b,c = lines
n = int(n.strip('\n'))
a = str(a.strip('\n'))
b = str(b.strip('\n'))
c = str(c.strip('\n'))

num = 0
if not(n == a == b == c):
  for i in range(n):
    if not(a[i] == b[i] == c[i]):
      if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        num = num+1
      else:
        num = num+2

print(num)       

sys.exit(0)

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

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

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

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

    for(int i=n; i>=0; i--){
        string x;

        int j=i, k=0;
        while(k<=n){
            x[k] = s[j];
            k++;
            j++;
            if(j>n) j=0;
        }

        for(int l=0; l<=n; l++){
            if(x[l] != t[l]) goto END;
        }
        cout << "Yes" << endl;
        return 0;
        END:;
    }
    cout << "No" << endl;
}

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

using namespace std;

int main(void) {
    string a;
    string b[3];
    int j = 0;
    for(int i = 0;i < 3;i++){
        cin >> a;
        b[i] = a[i];
    }
    for(int i = 0;i < 3;i++){
        cout << b[i];
    }


}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)

h, w = map(int, input().split())
ls = [input().rstrip() for _ in range(h)]
ds = [[float('inf') for _ in range(w)] for _ in range(h)]
ds[0][0] = 1

dxdy = [(-1, 0), (1, 0), (0, -1), (0, 1)]


def dfs(x, y):
    for i in range(4):
        dx, dy = dxdy[i]
        nx = x + dx
        ny = y + dy
        if 0 <= nx < w and 0 <= ny < h and ls[ny][nx] == '.':
            if ds[ny][nx] > ds[y][x] + 1:
                ds[ny][nx] = ds[y][x] + 1
                dfs(nx, ny)


dfs(0, 0)
d = ds[h - 1][w - 1]
if d < float('inf'):
    s = sum([l.count('.') for l in ls])
    print(s - d)
else:
    print(-1)

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

int main() {
    int N, sum;
    cin >> N;

    int temp = N;

    while (temp > 0) {
        sum += temp % 10;
        temp /= 10;
    }

    if (N % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

bool check(string s1,string s2){
	int l=0,r=0;
	bool flag=false;
	int cnt=0;
	while(l<s1.size() || r<s2.size()){
		if(s1.size()==l || s2.size()==r)return false;
		if(s1[l]!=s2[r])return false;
		if(s1[l]=='"'){
			l++;
			string ss="";
			while(s1[l]!='"'){
				ss+=s1[l];
				l++;
			}
			l++;
			r++;
			string ss2="";
			while(s2[r]!='"'){
				ss2+=s2[r];
				r++;
			}
			r++;
			if(ss!=ss2){
				cnt++;
			}
		}else{
			l++;
			r++;
		}
	}
	return (l==s1.size() && r==s2.size() && cnt<=1);
}

int main(void){
	while(1){
		string s1,s2;
		cin >> s1;
		if(s1==".")break;
		cin >> s2;
		if(s1==s2){
			printf("IDENTICAL\n");
		}else{
			printf("%s\n",check(s1,s2)?"CLOSE":"DIFFERENT");
		}
	}
	return 0;
}

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	const string s = "CODEFESTIVAL2016";
	string t;

	cin >> t;
	int ans = 0;
	REPU(i, 0, t.size()) if (t[i] != s[i]) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ld long double
const ld pi=3.1415926535897932384626433;


int main()
{
	int a[5];
	rep(i, 4) cin >> a[i];
	sort(a, a+4);
	cout << abs(a[0]+a[3]-a[1]-a[2]) << endl;
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <atcoder/mincostflow>
#include <atcoder/maxflow.hpp>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

int N,K;
vector<vector<ll>> A;
inline void input(){
    fast_io();
    cin >> N >> K;
    A.assign(N,vector<ll>(N,0));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> A[i][j];
}

inline int solve(){
    atcoder::mcf_graph<ll, ll> g(2*N+10);
    int s = 0, t = 2*N+1;
    ll INF = 1e9;
    for (int i = 1; i <= N; i++)
    {
        g.add_edge(s, i, K, 0);
        g.add_edge(N+i, t, K, 0);
    }
    g.add_edge(s, t, N*K, INF);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            g.add_edge(i+1, N+j+1, 1, INF - A[i][j]);
        }
    }
    ll _cap, cost;
    tie(_cap, cost) = g.flow(s, t, N*K);
    // cout << cap << endl;
    cout << (N*K*INF - cost) << endl;
    vector<string> Ans(N,string(N,'.'));
    for(auto e:g.edges()){
        int i = e.from-1;
        int j = e.to-N-1;
        if(e.flow==1 && 0<=i && i<N && 0<=j && j<N){
            Ans[i][j] = 'X';
        }
        // debug(e.from, e.to, e.cap, e.cost, e.flow);
    }
    for(auto a:Ans) cout << a << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3876
use std::io::prelude::*;
use std::cmp::min;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

static ABMAX: usize = 10;
static NMAX: usize = 40;
fn main() {
    let n = input::<usize>();
    let ma = input::<usize>();
    let mb = input::<usize>();
    let abc = (0..n)
        .map(|_| (input::<usize>(), input::<usize>(), input::<usize>()))
        .collect::<Vec<_>>();

    let mut d = vec![vec![vec![usize::max_value(); NMAX*ABMAX+1]; NMAX*ABMAX+1]; NMAX+1];
    d[0][0][0] = 0;
    for (i, (a, b, c)) in abc.into_iter().enumerate() {
        for ca in 0..NMAX * ABMAX {
            for cb in 0..NMAX * ABMAX {
                if d[i][ca][cb] == usize::max_value() {continue;}
                d[i+1][ca][cb] = min(d[i+1][ca][cb], d[i][ca][cb]);
                d[i+1][ca+a][cb+b] = min(d[i+1][ca+a][cb+b], d[i][ca][cb] + c);
            }
        }
    }

    let mut ans = usize::max_value();
    for ca in 1..NMAX * ABMAX {
        for cb in 1..NMAX * ABMAX {
            if ca * mb == cb * ma {
                ans = min(ans, d[n][ca][cb]);
            }
        }
    }

    if ans == usize::max_value() {
        println!("-1");
        return;
    }
    println!("{}", ans);
}


Measured memory_bytes: 63740
#include <iostream>
#include <deque>
using namespace std;
int main () 
{
string s;
cin>>s;
deque<int>q;
for (int i=0;i<s.size();i++){
	if (s[i]=='1'){
		q.push_back(1);
	}
	else if (s[i]=='0'){
	    q.push_back(0);
	}
	else {
	    if (!q.empty()){
	        q.pop_back();
	    }
		
	
	}
}
while (!q.empty()){
    cout<<q.front();
    q.pop_front();
}
}

Measured memory_bytes: 256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

from collections import Counter
c = Counter(rs())
ans = 'Yes'
for i in c.values():
    if i % 2 == 1:
        ans = 'No'
print(ans)

Measured memory_bytes: 9400
import sys
if __name__ == "__main__":
    a, b, c, d = list(map(int, (input().split(' '))))
    if abs(a - c) <= d:
        print('Yes')
        sys.exit()
    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
        sys.exit()
    print('No')

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

long long GCD(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    vector<ll> left(N), right(N);
    left[0] = A[0], right[N - 1] = A[N - 1];
    rep(i, N - 1) { left[i + 1] = GCD(A[i + 1], left[i]); }

    for (int i = N - 1; i > 0; i--) {
        right[i - 1] = GCD(A[i - 1], right[i]);
    }

    ll res = 0;
    res = max(right[1], left[N - 2]);
    for (int i = 1; i < N - 1; i++) {
        res = max(res, GCD(left[i - 1], right[i + 1]));
    }

    cout << res << endl;
}

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

using namespace std;
using ll=long long;

int main()
{
   int c[9][9];
   for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
        c[i][j]=(i+1)*(j+1);
    }
   }
   int n;cin >>n;
   bool flg=false;
   for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
        if(c[i][j]==n)flg=true;
    }
   }
   if(flg)puts("Yes");
   else puts("No");
    return 0;
}


Measured memory_bytes: 256
/*
    Take me to church
    I'll worship like a dog at the shrine of your lies
    I'll tell you my sins and you can sharpen your knife
    Offer me that deathless death
    Good God, let me give you my life
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, Mn, A[N], M[N];
vector < pair < int , int > > Adj[N];
void DFS(int v, int tp)
{
    M[v] = tp;
    Mn = min(Mn, A[v]);
    for (auto u : Adj[v])
        if (M[u.first] != tp)
            A[u.first] = A[v] + u.second, DFS(u.first, tp);
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i ++)
    {
        int v, u, d;
        scanf("%d%d%d", &v, &u, &d);
        Adj[v].push_back({u, d});
        Adj[u].push_back({v, - d});
    }
    for (int i = 1; i <= n; i ++)
        if (!M[i])
        {
            A[i] = Mn = 0;
            DFS(i, 1);
            if (Mn < 0)
                A[i] = - Mn, DFS(i, 2);
        }
    for (int i = 1; i <= n; i ++)
        if (A[i] < 0 || A[i] > (int)(1e9))
            return !printf("N00o\n");
    for (int i = 1; i <= n; i ++)
        for (auto u : Adj[i])
            if (A[i] + u.second != A[u.first])
                return !printf("No\n");
    return !printf("Yes\n");
}

Measured memory_bytes: 12416
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

const ll mod = 1e9+7;

vector<ll> dp(3000, -1);

int main(){
    ll s;  cin >> s;
    REP(i, 3, 6){
        dp[i] = 1;
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;
    REP(i, 6, s+1){
        ll k = 1;
        REP(l, 3, i-2){
            k += dp[i-l];
            k %= mod;
        } 
        dp[i] = k;
    }
    cout << dp[s] % mod << endl;
}

Measured memory_bytes: 3616
const main = args => {
  const [a, b, c, x] = args.split('\n').map(arg => Number(arg));
  let ans = 0;
  [...Array(a+1)].forEach((_, i) => { [...Array(b+1)].forEach((_, j) => { [...Array(c+1)].forEach((_, k) => { if (500 * i + 100 * j + 50 * k === x) ++ans }) }) });
  
  console.log(ans);
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << 'A' << endl;
	}
	else {
		cout << 'B' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import heapq


class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = 3 * 10 ** 5 + 10
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        route_count = [0 for _ in range(num_of_city)]
        route_count[self.start_point] = 1
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
                if dist[dest] == dist[src] + cost:
                    route_count[dest] += route_count[src]

        if self.goal_point is not None:
            return self._get_path(self.goal_point, prev)
        else:
            return dist, route_count

    def _get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))


N, M = map(int, input().split())
from collections import defaultdict

graph = defaultdict(dict)
for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    graph[u][v + N] = 1
    graph[u + N][v + 2 * N] = 1
    graph[u + 2 * N][v] = 1
S, T = map(int, input().split())
S -= 1
T -= 1
dj = Dijkstra(graph, S)

dist, _ = dj.execute()
if dist[T] % 3 == 0:
    print(dist[T] // 3)
else:
    print(-1)


Measured memory_bytes: 151732
s=input()
n=input()
d=dict()
dd=dict()
ans="Yes"
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]]=n[i]
  elif d[s[i]]!=n[i]:
    ans="No"
  if n[i] not in dd:
    dd[n[i]]=s[i]
  elif dd[n[i]]!=s[i]:
    ans="No"
print(ans)

Measured memory_bytes: 3760
#include <stdio.h>
 
int Fib(int);


 
main(){
  int n,i,sum=1,x1=1,x2=1;
 
  scanf("%d",&n);
 
  for(i=1;i<n;i++){
    sum=x1+x2;
    x1=x2;
    x2=sum;
  }

  printf("%d\n",sum);
 
  return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int h,w;
    cin >> h >> w;
    int ch,cw,dh,dw;
    cin >> ch >> cw;
    cin >> dh >> dw;

    ch--; cw--; dh--; dw--;

    vector<string> s(h);

    rep(i, h){
        cin >> s[i];
    }
    
    vector<vector<int>> dist(h, vector<int>(w, h * w));

    int pattern = 2; //01BFSなら2, 012BFSなら3のように(最大値 + 1)
    vector<queue<pair<int, pair<int, int>>>> qv(pattern);

    int lastd = 0;
    int stateNum = 0;

    qv[lastd].push(make_pair(0, make_pair(ch, cw)));
    stateNum++;

    while(stateNum > 0){

        if(qv[lastd].empty()){
            lastd = (lastd + 1) % pattern;
        }else{

            int tmpd = qv[lastd].front().first;
            int tmpy = qv[lastd].front().second.first;
            int tmpx = qv[lastd].front().second.second;

            qv[lastd].pop();
            stateNum--;

            if(tmpd < dist[tmpy][tmpx]){
                dist[tmpy][tmpx] = tmpd;

                for(int i = -2; i <= 2; i++){
                    for(int j = -2; j <= 2; j++){
                        int ny = tmpy + i;
                        int nx = tmpx + j;

                        if(i == 0 && j == 0) continue;

                        if(0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.'){
                            if(abs(i) + abs(j) == 1){
                                qv[lastd].push(make_pair(tmpd, make_pair(ny, nx)));
                                stateNum++;
                            }else{
                                qv[(lastd + 1) % pattern].push(make_pair(tmpd + 1, make_pair(ny, nx)));
                                stateNum++;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << (dist[dh][dw] == h * w ? -1 : dist[dh][dw]) << endl;

}

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

const lli MAXN = 101;
const lli MAXM = 17;
const lli MAXT = 17;
lli N;
lli M[MAXN], L[MAXN];
lli S[MAXN][MAXM], E[MAXN][MAXM], C[MAXN];
lli dp[1<<MAXT];

int main() {
  for(; cin >> N && N; ) {
    for(lli i = 0; i < N; ++i) {
      cin >> M[i] >> L[i];
      C[i] = 0;
      for(lli j = 0; j < M[i]; ++j) {
        cin >> S[i][j] >> E[i][j];
        for(lli t = S[i][j]; t < E[i][j]; ++t) {
          C[i] |= 1 << (t-6);
        }
      }
    }
    memset(dp, 0, sizeof(dp));
    for(lli i = 0; i < N; ++i) {
      for(lli k = (1<<MAXT)-1; k >= 0; --k) {
        if(k & C[i]) continue;
        lli nk = k | C[i];
        dp[nk] = max(dp[nk], dp[k] + L[i]);
      }
    }
    cout << *max_element(dp, dp+(1<<MAXT)) << endl;
  }
  return 0;
}

Measured memory_bytes: 2216
use std::cmp;

fn main(){
    let nm: Vec<u32> = read_vec();
    let n: u32 = nm[0];
    let m: u32 = nm[1];
    
    let mut ab: Vec<Vec<i64>> = read_vec2(m);
    ab.sort_by(|a, b| b[1].cmp(&a[1]));
    
    let mut ans = 0;
    
    while !ab.is_empty() {
        let min_b = ab.pop().unwrap();
        ans += 1;
        ab.retain(|ref x| {!(min_b[1] <= x[1] && min_b[1] > x[0])});
    } 
    
    println!("{}", ans);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
int main()
{
	// freopen("AGC008-D.in", "r", stdin);
	int n;
	cin >> n;
	vector<int> arr(n), ans(n * n, -1), cnt(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), arr.begin());
	for_each(arr.begin(), arr.end(), [&] (int &x) { x--; });
	for (int i = 0; i < n * n; i++) {
		for (int j = 0; j < n && -1 == ans[i]; j++) {
			if (arr[j] == i) {
				ans[i] = j + 1;
			}
		}
		int pos = -1;
		for (int j = 0; j < n && -1 == ans[i]; j++) {
			if (i < arr[j] && cnt[j] < j) {
				if (pos == -1 || arr[j] < arr[pos]) {
					pos = j;
				}
			}
		}
		if (~pos) {
			cnt[pos]++;
			ans[i] = pos + 1;
		}
		for (int j = 0; j < n && -1 == ans[i]; j++) {
			if (arr[j] < i && cnt[j] != n - 1 && cnt[j] >= j) {
				cnt[j]++;
				ans[i] = j + 1;
			}
		}
		if (-1 == ans[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	copy(ans.begin(), ans.end(), ostream_iterator<int>(cout, " "));
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int binpow (int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n-1) * a;
	else {
		int b = binpow (a, n/2);
		return b * b;
	}
}
int main() {
	int n;
	cin >> n;
	cout << binpow(n , 3);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define fall(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main() {
	ll n,k;
  	cin>>n>>k;
  	ll a[n+1];
  	ll dp[n+1];
  	for(int i=1;i<=n;i++)cin>>a[i];
  	dp[0]=0;
  	dp[1]=0;
  	a[0]=a[1];
  	for(int i=2;i<=n;i++)
    {
      ll mini=INT_MAX,x;
      for(int j=1;j<=k && i-j>=0;j++)
      {
        x=dp[i-j]+abs(a[i]-a[i-j]);
        if(x<mini)mini=x;
      }
	dp[i]=mini;		
    }
  	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    vi d(n*3);
    rep(i, n*3) {
        cin >> d[i];
    }
    sort(all(d));

    int ans = 0;

    int i = 0, j = (3 * n)-1;
    for (int i = 0; i < n; i++) {
        ans += d[j-1];
//        cout << j-1 << endl;
        j -= 2;
    }
    
    cout << ans << endl;



    return 0;
}



Measured memory_bytes: 2560
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

B1 = []
count = 0
for i in A1:
    count += i
    B1.append(count)

B2 = []
for i in range(N):
    if i == 0:
        B2.append(B1[i] + A2[i])
    else:
        B2.append(max(B1[i], B2[i - 1]) + A2[i])

print(B2[-1])


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

int main(){
  int n;
  cin >> n;
  vector<string> w(n);
  map<string, int> cnt;
  for(int i = 0; i < n; i++){
    cin >> w.at(i);
    cnt[w.at(i)]++;
  }
  
  reverse(w.at(0).begin(), w.at(0).end());
  char now = w.at(0).at(0);
  bool ok = true;
  for(int i = 1; i < n; i++){
    if(now == w.at(i).at(0)){
      reverse(w.at(i).begin(), w.at(i).end());
      now = w.at(i).at(0);
      continue;
    }
    
    ok = false;
    break;
  }
  if(cnt.size() != n) ok = false;
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
S=int(input())

MOD = 10 ** 9 + 7

if S <= 2:
  print('0')
  exit(0)
elif 3 <= S <= 5:
  print('1')
  exit(0)

s = [0] * (S+1)
s[1] = 0
s[2] = 0
s[3] = 1
s[4] = 1
s[5] = 1


def calc(n):
  tmp = 0
  for i in range(n-3,2,-1):
    tmp += s[i]%MOD
  return tmp+1

result = 0
for i in range(5,S+1):
  s[i] = calc(i)
  
print(s[S]%MOD)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M;
  cin >> N >> M;
  if(N>=2 && M>=2){cout << (N-2)*(M-2) << endl;}
  else if(N==1 && M>=2){cout << M-2 << endl;}
  else if(N==1 && M==1){cout << 1 << endl;}
  else if(M==1 && N>=2){cout << N-2 << endl;}
}

Measured memory_bytes: 256