akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int N, Enum, res;
    string S;
    stack<char> Scp;
	cin >> N >> S;
    res = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] != 'E') {
            Scp.push(S[i]);
        } else {
            if (Scp.size() >= 1 && Scp.top() == 'W') {
                Scp.pop();
                res++;
            }
        }         
    }  
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 900
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int dp[20001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H = getint(), N = getint();
	rep1(i, 20000) dp[i] = 1e9;

	rep(i, N) {
		int a = getint();
		int b = getint();
		rep(j, H) if (dp[j + a] > dp[j] + b) dp[j + a] = dp[j] + b;
	}
	int kotae = *min_element(dp + H, dp + H + 10001);
	printf("%d", kotae);

	Would you please return 0;
}

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

using namespace std;

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int idx[3] = {0};

	string s[3];

	for(int i = 0; i < 3; i++) cin >> s[i];

	int cur = 0;

	while(idx[cur] < s[cur].size()) {

		int temp = s[cur][idx[cur]] - 'a';
		idx[cur]++;
		cur = temp;
	}

	cout << (char)(cur+'A') << '\n';

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  for(int i=0; i<n-1; i++) {
    sort(v.rbegin(), v.rend());
    v[n-2-i] = (v[n-2-i]+v[n-1-i])/2;
    v.pop_back();
  }
  
  cout << fixed << setprecision(10) << v[0] << endl;
  return 0;
}

Measured memory_bytes: 3740
#関数リスト
import sys
from collections import defaultdict
input = sys.stdin.readline
def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))

class BIT():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n+1)

    #bit_indexにxをO(log(n))で加算する
    def add(self,i,x):
        #if(i<=0 or i>n):return iに0以下の数字は代入しない
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)
    #bit_1 + bit_2 + …  + bit_n をO(log(n))で求める
    def sum(self,i):
        s = 0
        #iに0以下の数字は代入しない。
        while i > 0:
            s+=self.bit[i]
            i -= (i & -i)
        return s
    def rangesum(self,i,k):
        return self.sum(k) - self.sum(i)
    #a_1 + a_2 + … + a_i >= x となるような最小のiを求める(a_k >= 0)
    #xが0以下の場合は該当するものなし→0を返す
    def lower_bound(self,x):
        if x <= 0:
            return 0
        else:
            i = 0
            r = 1
            #最大としてありうる区間の長さを取得する
            #n以下の最小の二乗のべき(BITで管理する数列の区間で最大のもの)を求める
            while(r<self.n):
                r=r<<1
            len = r
            while len > 0:
                if(i+len<self.n and self.bit[i+len]<x):
                    x-=self.bit[i+len]
                    i+=len
                len = len >> 1
            return i+1

def main():
    N, Q = MI()
    mylist = LI()
    q = []
    for i in range(Q):
        l, r = MI()
        #データ圧縮
        q.append(r * 10**12 + l * 10**6 + i)
    q.sort()
    last = defaultdict(int)
    r0 = q[0] // 10**12
    for i, c in enumerate(mylist):
        if i+1 > r0:break
        last[c] = i+1
    tree = BIT(N)
    for i in range(N):
        if last[i+1] != 0:
            tree.add(last[i+1], 1)
    ans = [0] * Q
    pre_R = r0
    for x in q:
        r, x = x // 10**12, x % 10**12
        l, q2 = x // 10**6, x % 10**6
        if r > pre_R:
            for i in range(pre_R, r):
                if last[mylist[i]] != 0:
                    tree.add(last[mylist[i]],-1)
                last[mylist[i]] = i+1
                tree.add(i+1,1)
        #ans[q2] = tree.sum(r)-tree.sum(l-1)
        ans[q2] = tree.rangesum(l-1,r)
        pre_R = r
    for a in ans: print(a)

if __name__ == "__main__":
    main()


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

int main(){
  ll a,b,n,x,ans;
  cin >> a >> b>> n;
  x = n;
  if (n >= b - 1) x = b - 1;
  ans = a*(x%b)/b;
  cout << ans <<endl;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for(auto x : mp){
        if(x.second >= x.first)ans += x.second-x.first;
        else ans += x.second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int res = 1;
    int c = 0;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        c += t;
        if (c <= x) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n, k;
  cin >> n >> k;

  ll arr[n + 5];
  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  sort(arr + 1, arr + n + 1);

  k = min(k, n);
  ll res = 0;
  for (ll i = 1; i <= n - k; i++) {
    res += arr[i];
  }
  cout << res << en;

  return 0;
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

long long a,b,c,d,ans;
string s,t,u;

int main(){
  cin>>a;
  c=a;
  while(a){
    b+=a%10;
    a/=10;
  }
  if(c%b==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def main():
    mod = 10**9+7
    k = int(input())
    s = input()
    n = len(s)
    fact = [1, 1]
    for i in range(2, 2*(10**6)+1):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r, mod=10**9+7):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    ans = 0
    for i in range(k+1):
        ans = (ans+nCr(n+k, i)*pow(25, i, mod)) % mod
    print(ans)


main()


Measured memory_bytes: 213348
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
long long a,b,k;
cin>>a>>b>>k;
if(k>=a+b)
cout<<0<<" "<<0<<endl;
else if(k>=a)
cout<<0<<" "<<b-(k-a)<<endl;
else
cout<<a-k<<" "<<b<<endl;  
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
num_O=sum(map(lambda x:1 if not x%2 else 0,a))
num_T=sum(map(lambda x:1 if not x%4 else 0,a))
if(n//2-num_T-(num_O-num_T)//2<=0):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 14252
C = 3.times.map{gets.split.map(&:to_i)}
S = C.map{|row| row.inject(0,&:+) }.inject(0,&:+)
r,m = S.divmod(3)

if m == 0 && [0,1,2].permutation.all?{|i,j,k| C[0][i] + C[1][j] + C[2][k] == r}
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 3836
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int W,H,N;
    cin >> W >> H >> N;

    int x,y,a;
    int xmin=0,xmax=W;
    int ymin=0,ymax=H;

    REP(i,N){
        cin >> x >> y >> a;
        switch (a)
        {
        case 1:
            if(x>xmin)xmin=x;
            break;
        case 2:
            if(x<xmax)xmax=x;
            break;
        case 3:
            if(y>ymin)ymin=y;
            break;
        case 4:
            if(y<ymax)ymax=y;
            break;
        default:
            break;
        }
    }
    if(xmax>xmin && ymax>ymin){
        cout << (xmax-xmin)*(ymax-ymin) << endl;
    }else{
        cout << "0" << endl;
    }
    return 0;

}

Measured memory_bytes: 504
#include <iostream>
using namespace std;
 
int main(){
    long long int N,set;
    char head;
    int node[5]={0,0,0,0,0};
    string S;
 
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>S;
        head=S[0];
        if(head=='M') node[0]+=1;
        if(head=='A') node[1]+=1;
        if(head=='R') node[2]+=1;
        if(head=='C') node[3]+=1;
        if(head=='H') node[4]+=1;       
    }
 
    set=0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                set+=1LL*node[i]*node[j]*node[k];
            }
        }
    }
 
 
    cout<< set <<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    ll K, ans = 0;
    cin >> K;
    repd(i, 1, K + 1) {
        repd(j, 1, K + 1) {
            ll t = gcd(i, j);
            repd(k, 1, K + 1) {
                ans += gcd(t, k);
            }
        }
    }

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

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, ans=0;
	ll A[100005], B[100005];

	cin >> N;
	rep(i,N) cin >> A[i] >> B[i];

	rrep(i,N){
		ll a = (A[i] + ans) % B[i];
		if( a == 0 ) continue;
		ans += B[i] - a;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
//Tenka1 Programmer Beginner Contest 2019
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b)
    {
        cout << "Yes" << endl;
    }
    else if (b <= c && c <= a)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
	// write your code here
        Scanner scanner = new Scanner(System.in);
        Integer a = scanner.nextInt();
        Integer b = scanner.nextInt();
        Integer c = scanner.nextInt();
 
        Integer temp = a;
        a = b;
        b = temp;
 
        temp = a;
        a = c;
        c = temp;
 
        System.out.format("%d %d %d", a, b, c);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define pb push_back
#define ff first
#define ss second
#define memo(a,b) memset(a,b,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;

int main(){
		string s;cin>>s;
		int n=s.size();
		ll ans=0;
		int cntb=0;
		for(int i=0;i<n;++i){
			if(s[i]=='B')cntb++;
			else{
				ans+=cntb;
			}
		}
		cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 640
import math

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

class Vector():
    def __init__(self, start, end):
        self.x = end.x - start.x
        self.y = end.y - start.y
        self.r = math.sqrt(pow(self.x, 2) + pow(self.y, 2))
        self.theta = math.atan2(self.y, self.x)

x0, y0, x1, y1 = list(map(int, input().split(' ')))
p0, p1 = Point(x0, y0), Point(x1, y1)
vec1 = Vector(p0, p1)

q = int(input())
for i in range(q):
    x2, y2 = list(map(int, input().split(' ')))
    p2 = Point(x2, y2)
    vec2 = Vector(p0, p2)
    if vec2.r == 0:
        print('ON_SEGMENT')
    elif vec1.theta == vec2.theta:
        if vec1.r < vec2.r:
            print('ONLINE_FRONT')
        else:
            print('ON_SEGMENT')
    elif abs(vec1.theta - vec2.theta) == math.pi:
        print('ONLINE_BACK')
    elif (0 < vec2.theta - vec1.theta and vec2.theta - vec1.theta < math.pi)  or vec2.theta - vec1.theta < -1*math.pi:
        print('COUNTER_CLOCKWISE')
    elif (-1*math.pi < vec2.theta - vec1.theta and vec2.theta - vec1.theta < 0) or vec2.theta - vec1.theta > math.pi:
        print('CLOCKWISE')



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
ll gcd(ll x,ll y){
  if(x<y)swap(x,y);
  if(x%y==0)return y;
  return gcd(x%y,y);
}


int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  ll t=gcd(a,b);
  for(int i=t;i>=1;i--){
    if(t%i==0)k--;
    if(k==0){cout << i << endl;return 0;}
  }
}


Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

ll n, m , x, y, adeg[202020], bdeg[202020] ;
vi adj[202020];
bool deleted[202020];
string s;
queue<int> q;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> m;
cin >> s;



rep(i, 1, m){
    cin >> x >> y;
    adj[x].pb(y);
    adj[y].pb(x);
}

rep(i, 1, n){
    for(auto t : adj[i]){
        if(s[t-1]=='A')adeg[i]++;
        if(s[t-1]=='B')bdeg[i]++;
    }
    if(adeg[i]<1 || bdeg[i]<1)  {q.push(i);deleted[i]=true;}
}

while(!q.empty()){

    x = q.front();q.pop();

    for(auto t: adj[x]){

        if(s[x-1]=='A')adeg[t]--;
        if(s[x-1]=='B')bdeg[t]--;

        if((adeg[t]<1 || bdeg[t]<1) && !deleted[t] ){
            q.push(t);deleted[t]=true;
        }

    }

}

rep(i, 1, n){
    if(!deleted[i]){
        cout << "Yes" << endl;
        return 0;
    }
}

cout <<"No"<< endl;


return 0;}
///....


Measured memory_bytes: 14160
#include<bits/stdc++.h>
 using namespace std;
  int main()
  {
      
      int n;
       cin>>n;
        unordered_map<string, int>mp;
        for(int i=0; i<n; i++)
        {
            string s;
             cin>>s;
              mp[s]++;
        }
          auto it= mp.find("AC");
           if(it==mp.end())
           cout<<"AC "<<"x "<<0<<endl;
            else
             cout<<"AC "<<"x "<<it->second<<endl;
             
              auto it1= mp.find("WA");
           if(it1==mp.end())
           cout<<"WA "<<"x "<<0<<endl;
            else
             cout<<"WA "<<"x "<<it1->second<<endl;
             
             
                  auto it2= mp.find("TLE");
                  
           if(it2==mp.end())
           cout<<"TLE "<<"x "<<0<<endl;
            else
             cout<<"TLE "<<"x "<<it2->second<<endl;
             
                  auto it3= mp.find("RE");
           if(it3==mp.end())
           cout<<"RE "<<"x "<<0<<endl;
            else
             cout<<"RE "<<"x "<<it3->second<<endl;
             
             
         
             
           
  }

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    long n,k,sum=0;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    if(n > k){
        for(int i=0;i<n-k;i++){
            sum += a[i];
        }
    }
    cout << sum <<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

i64 N;
vector<vector<i64>> G;

vector<i64> A, B;
vector<i64> D;

void dfs(i64 v, i64 f) {
  for(auto t: G[v]) {
    if(t == f) continue;
    dfs(t, v);
    D[v] += D[t];
  }
}

vector<i64> X;

void dfs2(i64 v, i64 f) {
  for(auto t: G[v]) {
    if(t == f) continue;
    X[t] = X[v] - D[t];
    dfs2(t, v);
  }
}

int main() {
  cin >> N;
  G.resize(N);
  rep(i,0,N - 1) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  A.resize(N);
  B.resize(N);
  D.resize(N);
  rep(i,0,N) {
    cin >> A[i];
  }
  rep(i,0,N) {
    cin >> B[i];
  }
  rep(i,0,N) {
    D[i] = B[i] - A[i];
  }

  dfs(0, -1);
  X.resize(N);
  dfs2(0, -1);

  i64 MIN = *min_element(all(X));
  i64 ans = 0;
  rep(i,0,N) {
    ans += X[i] - MIN;
  }
  cout << ans << endl;
}



Measured memory_bytes: 17304
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
   int x,a,b;
   cin >> x >> a >> b;
   
   if(abs(x-a) > abs(x-b)){
       cout << "B" << endl;
   }
   else{
       cout << "A" << endl;
   }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    string s;
    cin >> s;
    int a = 0,b = 0;
    for (int i = 0;i < s.size();i++){
        if (s[i] == 'A') a++;

        if (s[i] == 'B') b++;
    }

    if (a > 0 && b > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
def p(x):
  answer = True
  while(x > 1):
    if x % 2 == 0:
      x =  x // 2
    else:
      answer = False
      break
  return answer

N = int(input())
for i in range(N,0,-1):
  if p(i) == True:
    print(i)
    break


Measured memory_bytes: 5596
#include <stdio.h>

int main()
{
    int n,h[20];
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&h[i]);
    }
    
    int cnt = 1,max = h[0];
    for (int i = 1; i < n; i++)
    {
        if (max <= h[i])
        {
            cnt ++;
            max = h[i];
        }
        
    }
    printf("%d",cnt);
}

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

using namespace std;

#define ll long long
int main()
{
    ll int n,w;
    cin>>n>>w;
    vector<pair<ll int,ll int>> v;
    ll int sum=0;
    for(int i=0;i<n;i++)
    {
        ll int x,y;
        cin>>x>>y;
        v.push_back({x,y});
        sum+=y;
    }
    ll int dp[n*1000+2];
    for(int i=0;i<=n*1000;i++)
    dp[i]=INT_MAX;
    dp[0]=0;
    for(ll int i=0;i<n;i++)
    {
        for(int j=sum;j>=v[i].second;j--)
        {
           // cout<<"ans is "<<dp[j]<<endl;
            dp[j]=min(dp[j],dp[j-v[i].second]+v[i].first);

        }
    }
    for(int j=sum;j>=0;j--)
        {
            if(dp[j]<=w)
            {
                cout<<j<<endl;
                break;
            }
        }



}


Measured memory_bytes: 1024
def sq(a, b, mod):  # aのb乗を剰余
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod
  
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def nCk(n,k,mod):
  prev=1
  for i in range(1,min(k,n-k)+1):
    v=(prev * (n+1-i) % mod * modinv(i, mod) % mod)
    prev=v
  return prev

x,y=map(int,input().split())
mod=10**9+7

if (x+y)%3!=0:
  print(0)
else:
  n=(x+y)//3
  k=(2*x-y)//3
  if k<0 or k>n:
    print(0)
  else:
    print(nCk(n,k,mod))

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

using namespace std;

#define INF 1e9

int MOD=1e9+7;

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

    int n;
    cin>>n;

    long long ans=0;

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

        while(1){
            if(a%2==1)break;
            a/=2;
            ans++;
        }
    }

    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
while True:
    m,n = map(int,input().split())
    sw = []
    bw = []
    if m == 0 and n == 0:
        break
    for i in range(2*n-1):
        if i % 2 == 0:
            sw.append(list(map(int,input().split())))
        else:
            bw.append(list(map(int,input().split())))
    flag = [[0 for i in range(m)] for j in range(n)]
    l = [(0,0,1)]
    res = 0
    while l:
        bf = l.pop(0)
        x,y,z = bf[0],bf[1],bf[2]
        if x == n-1 and y == m-1:
            res = z
            break
        if 1 <= x and bw[x-1][y] == 0 and flag[x-1][y] == 0:
            flag[x-1][y] = 1
            l.append((x-1,y,z+1))
        if y < m-1 and sw[x][y] == 0 and flag[x][y+1] == 0:
            flag[x][y+1] = 1
            l.append((x,y+1,z+1))
        if 1 <= y and sw[x][y-1] == 0 and flag[x][y-1] == 0:
            flag[x][y-1] = 1
            l.append((x,y-1,z+1))
        if x < n-1 and bw[x][y] == 0 and flag[x+1][y] == 0:
            flag[x+1][y] = 1
            l.append((x+1,y,z+1))
    print(res)

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



int main() {

    int N;
    int A[100001];
    cin >> N;
    for (int i = 0; i < N + 1; i++) cin >> A[i];
    //今の深さの点の数
    long long now = 1;
    //int mae = 0;
    long long ans = 0;
    //末端の数
    long long sum = 0;
    //分岐した回数
    long long route = 1;
    
    for (int i = 0; i < N + 1; i++)
    {
        sum += A[i];
    }
    long long s = sum;
    //cout << sum << endl;
    for (int i = 0; i < N + 1; i++)
    {
        /*
        //cout << now <<route<< endl;
        ans += now;
        //cout << now<< " ";
        now -= A[i];
        sum -= A[i];
        now = min(now * 2, sum);

        //cout << now << endl;
        if (i != N && now <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else if (i == N && now != 0)
        {
            cout << -1 << endl;
            return 0;
        }*/

        
        ans += now;
        now -= A[i];
        s -= A[i];
        //できるだけ早く分岐しておく
        long long a = now;
        
        //now 2倍ルート
        if (route + a < sum)
        {
            //新しい分岐はa個
            now += a;
            route += a;
        }
        //nowがそれ以降の和になるルート
        else
        {
            //基本的にrouteは1+枝の数
            //ある瞬間のroute-1がそれまでの葉の数と等しければいい
            //分岐した数だけ葉が増える、route+=nはA[i]=nを意味する
            //つまりrouteはそれまでのA[i]の和、route= sum-sumA[i]
            //now-A[i]（分岐＝葉の数）=葉以外の数、
            //葉の枚数＋全部の和-分岐の数（）

            //now=sum-sumA[i-1]なら、

            //新しい分岐はsum-route個
            //（最終的な道の数）ー（今の道の数）をnow（今の道の数）に足して（最終的な道の数）にする
            now += sum - route;
            //now = s;
            route += sum - route;
        }
        //now = min(a * 2, s);

        if (i != N && now <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else if (i == N && now != 0)
        {
            cout << -1 << endl;
            return 0;
        }


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

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

int fr[26];

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

    for(int i=0;i<4;i++)
        fr[s[i]-'A']++;
    for(int i=0;i<26;i++)
    {
        if(fr[i]==0 || fr[i]==2)
            continue;
        else
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    if m < n * 2 {
        return format!("{}", m / 2);
    }

    let mut ans = n;
    let m = m - n * 2;
    ans += m / 4;

    return ans.to_string();
}


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

using namespace std;

#define int long long

signed main() {
 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string a;
  cin >> a;
  cout << (a == "ABC" ? "ARC" : "ABC") << '\n';  

  return 0;
}

Measured memory_bytes: 3612
n, a, b = map(int, input().split())

if abs(a-b) % 2 == 0:
    print(abs(a-b)//2)

else:
    to_top = max(a-1, b-1)
    to_end = max(n-a, n-b)
    to_top_2 = min(a-1, b-1)
    to_end_2 = min(n-a, n-b)
    wait = min(to_top, to_end)
    go = min(to_top_2, to_end_2) + (b-a)//2 + 1
    print(min(wait, go))


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

int main(){
    string s;
    cin >> s;
    int l = s.length();
    vector<vector<ll>> dp(l+1, vector<ll>(13,0));
    dp[0][0] = 1;
    int m[12];
    m[0] = 1;
    rep(i,11) m[i+1] = (m[i]*10) % 13;
    rep(i,l){
        rep(j,13){
            if(s[i] != '?'){
              int a = (s[i] -'0')*m[(l-i-1)%12]; 
              dp[i+1][(j+a)%13] = (dp[i+1][(j+a)%13] + dp[i][j]) % mod;
            } else {
              rep(k, 10){
                int a = k*m[(l-i-1)%12];
                 dp[i+1][(j+a)%13] = (dp[i+1][(j+a)%13] + dp[i][j]) % mod;
              }
            }
        }
    }
    cout << dp[l][5] << endl;
    return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int count = 0, count2 = 0;
  for (int i = 0; i < n;i++){
    cin >> a[i];
    if(a[i]%4==0){
      count++;
    }else if(a[i]%2==0){
      count2++;
    }
  }
  count2 /= 2;
  n -= count2*2;
  if(count>=n/2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

int main(){
	int h,w;
	char color[52][52];
	scanf("%d %d",&h,&w);
	for(int i=0;i<h+2;i++)
	{
		for(int j=0;j<w+2;j++)
		{
			if(i==0||j==0||i==h+1||j==w+1)
			{
				color[i][j]='.';
			}else if(j == 1)
			{
				scanf("%s",color[i]);
			}
				
				if(i>1 && j != 0 && j != w+1 && color[i][j]=='.' && color[i-1][j]=='#' && color[i-2][j]=='.' && color[i-1][j-1]=='.' && color[i-1][j+1]=='.')
				{
					printf("No");
					return 0;
				}
			
		}
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

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

    bool flag = false;
    for(int i = 0; i <= x; i++){
        int num = 2*i + 4*(x-i);
        if(num == y){
            flag = true;
            break;
        }
    }    

    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int[] arr = new int[26];
			String sentence = null;

			while (sc.hasNext()) {
				sentence = sc.nextLine();
				for (char c : sentence.toCharArray()) {
					int num = Character.toLowerCase(c) - 'a';  // 文字 ch の番号
					if (0 <= num  && num < 26) {
						arr[num]++;
					}
				}
			}
			java.util.stream.IntStream.range(0, arr.length)
				.forEachOrdered(i ->System.out.println((char) ('a' + i) + " : " + arr[i]));
		}
	}
}


Measured memory_bytes: 32044
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int> dp(3);
    for(int i = 0; i < n; i++) {
        vector<int> c(3);
        for(int i = 0; i < 3; i++)
            cin >> c[i];
        vector<int> new_dp(3, 0);
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                if(i != j) {
                    new_dp[i] = max(dp[j]+c[i], new_dp[i]);
                }
            }
        }
        dp = new_dp;
    }
    cout << max(dp[0], max(dp[2], dp[1]) );
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){

    int m,f,r;
    
    while(1){
        cin >> m >> f >> r;
        if(m==-1 and f==-1 and r==-1){
            break;
        }else if(m==-1 or f==-1){
            cout << "F" << endl;
        }else if(m+f>=80){
            cout << "A" << endl;
        }else if(m+f>=65){
            cout << "B" << endl;
        }else if(m+f>=50){
            cout << "C" << endl;
        }else if(m+f>=30 and r>=50){
            cout << "C" << endl;
        }else if(m+f>=30){
            cout << "D" << endl;
        }else{
            cout << "F" << endl;
        }
    }

    return 0;
}



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

using namespace std;

int main() {
  int n, m, temp;
  std::cin >> n >> m;

  for (int i = 0; i < m; ++i) {
    cin>>temp;
    if (n >= temp) {
      n -= temp;
    } else {
      n = -1;
      break;
    }
  }

  std::cout << n << "\n";

  return 0;
}


Measured memory_bytes: 3596
import sys
N = int(input())
x = list(map(int,input().split()))
 
z = 1
if 0 in x:
  print(0)
  sys.exit()
  
for a in x:
  z = a*z
  if z > 10**18:
    print(-1)
    sys.exit()
  
print(z)

Measured memory_bytes: 21784
n,k,q=map(int,input().split())
A=[int(input()) for i in range(q)]
li=[k-q for i in range(n)]
for i in range(q):
    li[A[i]-1]=li[A[i]-1]+1
for i in range(n):
    if li[i]>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
cnt = Counter(SR(n))
L = [(k, v) for k, v in cnt.items()]
L.sort()
L.sort(key=lambda x:x[1], reverse=True)
pre_v = L[0][1]
for k, v in L:
    if v != pre_v:
        break
    print(k)

Measured memory_bytes: 101384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  cout << (s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[3] ? "Good" : "Bad") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int D;
	cin >> D;
	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	vector<int> t(D);
	vector<int> last_date(26, 0);
	vector<ll> sat(D+1, 0);
	REP(i, 26){
		cin >> c[i];
	}
	REP(i, D){
		REP(k, 26){
			cin >> s[i][k];
		}
	}
	REP(i, D){
		cin >> t[i];
		last_date[t[i]-1] = i+1;
		sat[i] += s[i][t[i]-1];
		REP(k, 26){
			sat[i] -= c[k]*(i+1-last_date[k]);
		}
		sat[i+1] = sat[i];
	}
	REP(i, D){
		cout << sat[i] << endl;
	}
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec A(n);
    loop(i, n) cin >> A[i];
    vec x(n + 1), y(n + 1), z(n + 1);
    loop(i, n)
    {
        if (x[i] == A[i])
        {
            x[i + 1] = x[i] + 1;
            y[i + 1] = y[i];
            z[i + 1] = z[i];
        }
        else
        {
            if (y[i] == A[i])
            {
                x[i + 1] = x[i];
                y[i + 1] = y[i] + 1;
                z[i + 1] = z[i];
            }
            else
            {
                if (z[i] == A[i])
                {
                    x[i + 1] = x[i];
                    y[i + 1] = y[i];
                    z[i + 1] = z[i] + 1;
                }
            }
        }
    }
    ll ans = 1;
    loop(i, n)
    {
        ll count = 0;
        if (x[i] == A[i])
            count++;
        if (y[i] == A[i])
            count++;
        if (z[i] == A[i])
            count++;
        ans *= count;
        ans %= mod;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

b=input()

d={'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}

print(d[b])


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let a: Vec<i32> = s.split_whitespace().map(|a| a.parse().unwrap()).collect();
	println!("{}", std::cmp::max(a[0] + a[1].abs(), a[0] * a[1]));
}

Measured memory_bytes: 4352
a, b, c, d, e, f = map(int, input().split())
limit = 100 * e / (100 + e)
mx = -1

waters = set()
for i in range(0, f + 1, 100 * a):
    for j in range(0, f + 1, 100 * b):
        if i + j <= f:
            waters.add(i + j)

sugars = set()
for i in range(0, f + 1, c):
    for j in range(0, f + 1, d):
        if i + j <= f:
            sugars.add(i + j)

for i in waters:
    for j in sugars:
        if i + j <= f and i + j != 0:
            noudo = 100 * j / (i + j)
            if noudo <= limit:
                if noudo > mx:
                    mx = noudo
                    x, y = i + j, j
print(x, y)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int leng;
    cin>>a;
    leng=a.length();
    int tmp=0;
    for(register int i=0;i<leng;i++)
    {
        if(tmp==0&&a[i]=='C') tmp++;
        else if(tmp==1&&a[i]=='F') tmp++;
    }
    if(tmp>=2) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

bool us[201][201][201];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n; cin >> n;
	
	long long sum = 0;
	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				if (!us[i][j][k]) {
					sum += __gcd(i, __gcd(j, k));
					us[i][j][k] = true;
				}
			}
		}
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 11432
def can_be_month(n):
    if 0 < int(n) < 13:
        return True
    return False


S = input()

if can_be_month(S[:2]) and can_be_month(S[2:]):
    print('AMBIGUOUS')
elif can_be_month(S[:2]):
    print('MMYY')
elif can_be_month(S[2:]):
    print('YYMM')
else:
    print('NA')


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

int main(){
  int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  int ans=10e9;
  for (int i=0; i<=max(x,y)*2; i+=2){
    int t_ans=0;
    t_ans+=max(a*(x-i/2),0);
    t_ans+=max(b*(y-i/2),0);
    t_ans+=c*i;
    ans=min(ans,t_ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

n = int(input())
x_buf = input().split()
y_buf = input().split()

x = []
y = []
for i in range(n):
    x.append(int(x_buf[i]))
    y.append(int(y_buf[i]))

sum1 = 0
sum2 = 0
sum3 = 0
sum_inf = 0
max_inf = 0
for i in range(n):
    sum1 += abs(x[i] - y[i])
    sum2 += abs(x[i] - y[i]) ** 2
    sum3 += abs(x[i] - y[i]) ** 3
    sum_inf = abs(x[i] - y[i])
    if max_inf < sum_inf:
        max_inf = sum_inf

d1 = sum1
d2 = math.sqrt(sum2)
d3 = sum3 ** (1/3)
d4 = max_inf

print(d1)
print(d2)
print(d3)
print(d4)



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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (998244353))
#define umap unordered_map

struct Node
{
    long total = 1;
    set<long> adj;
};

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

    long t = 1;
    //cin >> t;

    while (t--) {
        string s;
        cin >> s;

        if (s[2] == s[3] and s[4] == s[5]) puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1, T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};

const int mod = 1000000007;

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

LL p2[200123]{1};

int main()
{
	Rep(i, 200000) {
		p2[i] = p2[i-1] * 2;
		if(p2[i] >= mod) p2[i] -= mod;
	}
	int n, sum = 0;
	cin >> n;
	unordered_map<pair<LL, LL>, int, pair_hash> p, q;
	LL x, y;
	rep(i, n) {
		scanf("%lld%lld", &x, &y);
		if(x == 0 && y == 0) continue;
		LL t = gcd(x, y);
		x /= t; y /= t;
		if(y < 0) x = -x, y = -y;
		if(x == 1 && y == 0) x = -1;
		if(x >= 0) ++q[{x, y}];
		else ++p[{y, -x}];
		++sum;
	}
	LL ans = 1, z = n - sum;
	for(auto& kv: p) {
		auto it = q.find(kv.first);
		if(it == q.end()) continue;
		sum -= it->second + kv.second;
		ans = ans * (p2[it->second] + p2[kv.second] - 1) % mod;
	}
	ans = ans * p2[sum] % mod;
	--ans;
	ans += z;
	if(ans < 0) ans += mod;
	if(ans >= mod) ans -= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16204