akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int k,x; cin >> k >> x;
    for(int i = x-k+1; i < x+k; i++){
        cout << i << " ";
    }
    cout << endl;
}


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

const int maxK = 20;

long long D, answer;
long long power[maxK];

long long count_n(int l, int r, long long d) {
    if (l < r) {
        return !d;
    }

    long long cnt = 0;
    for (int i = (d / power[r] % 10 + 10) % 10; i > -10; i -= 10) {
        if (!r && i > 0) continue;

        int k = 10 - abs(i);
        if (!r && i <= 0) k--;
        cnt += k * count_n(l - 1, r + 1, d + i * power[l] - i * power[r]);
    }
    return cnt;
}

int main() {
   // freopen("input.in", "r", stdin);
 //   freopen("output.out", "w", stdout);

    scanf("%lld", &D);

    power[0] = 1;
    for (int i = 1; i <= 18; ++i) power[i] = power[i - 1] * 10;

    for (int i = 0; i < 18; ++i) {
        answer += count_n(i, 0, D);
    }

    printf("%lld\n", answer);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
    cin >> s;
    int n = s.size();
    int start = 0;
    int goal = s.size() - 1;
    int ans = 0;
    while(goal>start){
    	if(s[start] != s[goal]) ans++;
        start++;
        goal--;
    }
    cout << ans;
}

Measured memory_bytes: 256
n = int( input() )
A = []
B = []
for i in range(n):
  a, b = map( int, input().split() )
  A.append( a )
  B.append( b )
A = sorted( A )
B = sorted( B )

ret = 0
if n % 2 == 0:
  i = n // 2 - 1
  ret = B[ i + 1 ] + B[ i ] - ( A[ i + 1 ] + A[ i ] ) + 1
else:
  i = ( n + 1 ) // 2 - 1
  ret = B[ i ] - A[ i ] + 1
  
print( ret )

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

int n, L, a[1000];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n >> L;
    int sum = 0, tmp;
    for (int i = 1; i <= n; ++i)
        a[i] = L + i - 1, sum += (a[i]);
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= n; ++i)
        if (abs(a[i]) < ans) ans = abs(a[i]), tmp = a[i];
    cout << sum - tmp << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
int n;
string s;
unordered_map<string, long long> mp[19];
int main(){
  prep();
  
  cin >> n;
  cin >> s;
  int cnts[26] = {0};
  int cnts2[26] = {0};
  for (int i=0; i<n; i++){
      cnts[s[i]-'a']++;
  }
  for (int i=n; i<2*n; i++){
      cnts2[s[i]-'a']++;
  }
  for (int i=0; i<26; i++){
      if (cnts[i] != cnts2[i]){
          cout << 0;
          return 0;
      }
  }
  int poww = pow(2, n);
  long long res = 0;
  for (int i=0; i<poww; i++){
      bitset<18> bs(i);
      string front = "";
      string endd = "";
      for (int j=0; j<n; j++){
          if (bs[j]){
              front += s[j];
          }else{
              endd += s[j];
          }
      }
      //cout << front << " " << endd << endl;
      reverse(endd.begin(), endd.end());
      for (int i=0; i<endd.size(); i++){
          front += endd[i];
      }
      reverse(front.begin(), front.end());
      mp[bs.count()][front]++;
  }
  for (int i=0; i<poww; i++){
      bitset<18> bs(i);
      string front = "";
      string endd = "";
      for (int j=n; j<2*n; j++){
          if (bs[j-n]){
              front += s[j];
          }else{
              endd += s[j];
          }
      }
      //cout << front << " " << endd << endl;
      reverse(endd.begin(), endd.end());
      for (int i=0; i<front.size(); i++){
          endd += front[i];
      }
      auto val = mp[bs.count()].find(endd);
      if (val != mp[bs.count()].end()){
          res += val->second;
      }
      
  }
  cout << res;
  return 0; 
}


Measured memory_bytes: 32176
t = int(input())

import sys

sys.setrecursionlimit(10 ** 6)


def calc(x):
    if x in dp:
        return dp[x]

    divs = [5, 3, 2]
    costs = [c, b, a]
    res = d * x

    for div, cost in zip(divs, costs):
        dived = x // div
        res = min(res, calc(dived) + cost + abs(x - dived * div) * d)
        if x > div:
            dived = x // div + 1
            res = min(res, calc(dived) + cost + abs(x - dived * div) * d)
    dp[x] = res

    return res


for _ in range(t):
    n, a, b, c, d = list(map(int, input().split()))
    dp = {}
    dp[0] = 0
    dp[1] = d
    print(calc(n))

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

// Process
#define rep(i, l, r) for(int i = (l); i <= (r); i++)

// Debug
template<typename F, typename S>
ostream& operator << (ostream& os, pair<F, S>& p){
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	os << '[';
	bool flg = 1;
	for(auto i : v){
		flg ? os << "" : os << ", ";
		os << i;
		flg = 0;
	}
	os << ']';
	return os;
}
#define deb(x) cerr << #x << " = " << (x) << "\n"
#define mes(x) cerr << "/ " << x << " /\n"

// Global variable
int n;

void solve(){
	cin >> n;
	cout << (n % 1000 == 0 ? 0 : 1000 - (n % 1000)) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("E:/PROGRAM/CP/std.in", "r", stdin);
		freopen("E:/PROGRAM/CP/std.out", "w", stdout);
		freopen("E:/PROGRAM/CP/std.err", "w", stderr);
	#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int t = 1;
	// cin >> t;
	while(t--) solve();

	return 0;
}

Measured memory_bytes: 3652
def is_prime(n):
    n = abs(n)
    if n==2: return True
    if n<2 or n%2==0: return False
    return pow(2, n-1, n) == 1

cnt = 0
for i in range(int(input())):
    if is_prime(int(input())): cnt+=1
print(cnt)

Measured memory_bytes: 7644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long
const int maxn = 1e5 + 10;
int b[maxn] = {0}, l[maxn] = {0}, u[maxn] = {0};
long long pre[maxn] = {0}, sum[maxn] = {0};

int mult(int who, int k){
    if(k >= b[who]){return u[who];}
    return l[who];
}

//vector <pair <long long, int> > G;

pair <long long, int> a[maxn];

bool check(int n, int m, int k){
    for(int i = 1; i <= m; i++){
        int p = a[i].second;
        //int p = G[i - 1].second;
        int multi = mult(p, k);
        long long a1 = sum[m + 1] - sum[i] + sum[i - 1] + (long long)(k - b[p]) * multi;
        long long a2 = pre[n] - pre[m + 1];
        /*if(sum[m + 1] - sum[i] + sum[i - 1] +
           (long long)(k - b[p]) * multi - pre[n] + pre[m + 1] >= 0){
            return true;
        }*/
        if(a1 >= a2){
            return true;
        }
    }
    for(int i = m + 1; i <= n; i++){
        int p = a[i].second;
        //int p = G[i - 1].second;
        int multi = mult(p, k);
        long long a1 = sum[m] + (long long)(k - b[p]) * multi;
        long long a2 = pre[n] - pre[i] + pre[i - 1] - pre[m];
        /*if(sum[m] + (long long)(k - b[p]) * multi
           - pre[n] + pre[i] - pre[i - 1] + pre[m] >= 0){return true;}*/
        if(a1 >= a2){return true;}
    }
    //system("pause");
    return false;
}

/*int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    for(int i = 1; i <= n; i++){
        scanf("%d%d%d", &B[i], &L[i], &U[i]);
        long long anw = (long long)B[i] * L[i] + (long long)((x - B[i]) * U[i]);
        //G.push_back(make_pair(anw, i));
        G[i] = make_pair(anw, i);
    }
    sort(G + 1, G + 1 + n);
    reverse(G + 1, G + 1 + n);
    //sort(G.begin(), G.end());
    //reverse(G.begin(), G.end());
    for(int i = 1; i <= n; i++){
        int j = G[i].second;
        //int j = G[i - 1].second;
        pre[i] = pre[i - 1] + (long long)(B[j] * L[j]);
        sum[i] = sum[i - 1] + (long long)((x - B[j]) * U[j]);
    }
    long long L1 = 0, R = (long long)n * x;
    while(L1 < R){
        long long mid = (L1 + R) >> 1;
        if(check(n, mid / x, mid % x)){
            R = mid;
        }
        else{
            L1 = mid + 1;
        }
    }
    printf("%lld", L1);
    return 0;
}*/

int main()
{
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d%d%d", &b[i], &l[i], &u[i]);
		long long anw = (long long)b[i] * l[i] + (long long)(x - b[i]) * u[i];
		a[i] = make_pair(anw, i);
		//a[i] = make_pair((ll)(x-b[i])*u[i]+(ll)b[i]*l[i], i);
	}
	sort(a+1, a+1+n);
	reverse(a+1, a+1+n);
	for(int i = 1; i <= n; i++)
	{
	    int j = a[i].second;
		pre[i] = pre[i-1]+(long long)b[j]*l[j];
		sum[i] = sum[i-1]+(long long)(x-b[j])*u[j];
	}
	ll l = 0, r = (ll)n*x;
	while(l<r)
	{
		ll mid = (l+r)>>1;
		if(check(n, mid/x, mid%x))
		{
			r = mid;
		}
		else
		{
			l = mid+1;
		}
	}
	printf("%lld\n", l);
	return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main(){cin.tie(0);ios::sync_with_stdio(0);_main();}
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




deque<pair<double, double>> que; // pair<V,VT>
//---------------------------------------------------------------------------------------------------
void _main() {
    int N;
    double L; cin >> N >> L;
    double Vma = 0, VTma = 0;
    rep(i, 0, N) {
        double T, V; cin >> T >> V;

        if (i) {
            double d = V;
            while (0 < d) {
                auto p = que.back(); que.pop_back();
                if (p.first <= d) {
                    d -= p.first;
                    Vma -= p.first, VTma -= p.second;
                } else {
                    Vma -= d, VTma -= p.second * d / p.first;
                    que.push_back({ p.first - d, p.second - p.second * d / p.first });
                    d = 0;
                }
            }
        }

        Vma += V;
        VTma += T * V;
        printf("%.10f\n", VTma / Vma);
        que.push_front({ V, T * V });

        while (1 < que.size()) {
            auto p1 = que.front(); que.pop_front();
            auto p2 = que.front(); que.pop_front();
            if (p1.second / p1.first <= p2.second / p2.first)
                que.push_front({ p1.first + p2.first, p1.second + p2.second });
            else {
                que.push_front(p2);
                que.push_front(p1);
                break;
            }
        }
    }
}

Measured memory_bytes: 18708
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<set>
#include<list>
#include<bitset>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<limits.h>
#define null NULL
using namespace std;
template <typename T> void sortV(vector<T> &x){ sort(x.begin(),x.end());};
#define dbg(name) printer(#name, (name))
template<typename T> void printer(string name, T value) {
    cerr<<name<<" :\t"<<value<<"\n";
}
void Solve(){
  int n;
  cin>>n;
  vector<int> h(n);
  for(auto&x:h) cin>>x;
  vector<int> dp(n,INT_MAX);
  dp[n-1] = 0;
  for(int i=n-1;i>=0;i--){
      if(i+1<n) dp[i] = min(dp[i],dp[i+1]+abs(h[i]-h[i+1]));
      if(i+2<n) dp[i] = min(dp[i],dp[i+2]+abs(h[i]-h[i+2]));
  }
  cout<<dp[0];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); 
    //int t;cin>>t;while(t--)
        Solve();
    return 0;
}

Measured memory_bytes: 1024
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , m , K , pre[N] , fa[N];
int F(int x) {return fa[x] == x ? x : fa[x] = F(fa[x]);}

int main(){
  scanf("%d%d",&n,&m);
  memset(pre , -1 , sizeof(fa));
  rep(i,0,n) fa[i] = i;
  rep(i,0,n) {
    int l , x;
    scanf("%d",&l);
    rep(j,0,l) {
      scanf("%d",&x);
      if(pre[x] != -1) {
        fa[F(pre[x])] = F(i);
      }
      pre[x] = i;
    }
  }
  bool ok = true;
  rep(i,0,n) ok &= F(i) == F(0);
  puts(ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <climits>

using namespace std;

int main()
{
    int N; cin >> N;
    int *R = new int[N];
    
    
    for(int i = 0; i < N; ++i)
        cin >> R[i]; 
    
    int minv = R[0], maxv = INT_MIN;
    for(int i = 1; i < N; ++i)
    {
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    delete [] R;
    
    return 0;
    
}


Measured memory_bytes: 3528
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
chk_C = False
if s[0] != "A":
    print("WA")
    exit()
else:
    for i in range(len(s)):
        if i == 0:
            pass
        else:
            if s[i] == "C" and chk_C == False and i >= 2 and i <= len(s)-2:
                chk_C = True
                pass
            elif s[i] == s[i].lower():
                pass
            else:
                print("WA")
                exit()
    if chk_C == True:
        print("AC")
    else:
        print("WA")

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll i, o, j, l;
    cin >> i >> o >> j >> j >> l;
    cout << o+max((i/2+j/2+l/2)*2, ((i-1)/2+(j-1)/2+(l-1)/2)*2+(i*j*l != 0)*3) << "\n";
    return 0;
}


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

signed main(){
	int N, i;
	scanf("%lld", &N);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	int now = 1, ans = A[0] - 1;
	for(i = 1; i < N; i++){
		if(A[i] == now + 1){
			now++;
		}
		else if(A[i] > now + 1){
			ans += (A[i] - 1) / (now + 1);
		}
//		printf("(now, ans)[%lld] = (%lld, %lld)\n", i, now, ans);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >>a>>b;
	
	int wa,sa,seki;
	wa = a+b;
	sa = a-b;
	seki = a*b;
	int ans = max(wa,sa);
	ans = max(ans,seki);
	cout <<ans<<endl;
	
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int n,r;
    cin>>n>>r;
    if(n<10)cout<<r+(10-n)*100<<endl;else cout<<r<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int H,W;
int A[81][81];
int B[81][81];
int C[81][81];
bool check[82][82][6501];
//vector<int>v[82][82];
 
 
int main(){
	cin>>H>>W;
	REP(i,H){
		REP(j,W){
			cin>>A[i][j];
		}
	}
	REP(i,H){
		REP(j,W){
			cin>>B[i][j];
		}
	}
	REP(i,H){
		REP(j,W){
			C[i][j]=abs(A[i][j]-B[i][j]);
		}
	}
	REP(i,82){
		REP(j,82){
			REP(k,6401){
				check[i][j][k]=false;
			}
		}
	}
	check[0][0][0]=true;
	REP(i,H){
		REP(j,W){
			REP(k,6401){
				if(check[i][j][k]==true){
					//cout<<i<<" "<<j<<" "<<k<<endl;
					check[i+1][j][k+C[i][j]]=true;
					check[i+1][j][abs(k-C[i][j])]=true;
					check[i][j+1][k+C[i][j]]=true;
					check[i][j+1][abs(k-C[i][j])]=true;
				}
			}
		}
	}
	LL ans=1e9;
	REP(i,6401){
		if(check[H-1][W-1][i]==true){
			ans=min(ans,(LL)abs(i-C[H-1][W-1]));
			ans=min(ans,(LL)abs(i+C[H-1][W-1]));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 43008
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

int
main(int argc, char *argv[])
{
  int n;
  ll a[100010];
  scanf("%d", &n);
  ll b = 0, sign = -1;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    sign *= -1;
    b += sign * a[i];
  }

  for (int i = 0; i < n; i++) {
    printf("%lld ", b);
    b = (ll)2 * a[i] - b;
  } endl;

  return 0;
}
  


Measured memory_bytes: 2048
package main

import (
	"fmt"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, d)
		for j := range x[i] {
			fmt.Scan(&x[i][j])
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ { // (i,j) (i<j)の組を全列挙する
			var sq int
			for k := 0; k < d; k++ { // 点iと点jが決定したので、ユークリッド距離の二乗を計算する
				sq += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
			}
			for k := 1; k <= sq; k++ { // sqが整数の二乗であれば答えを1増やす
				if k*k == sq {
					ans++
					break
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> v(n);
        map<ll,ll> cnt;
        ll sum = 0;
        for(i = 0; i < n; i++){
            cin >> v[i];
            sum += v[i];
            cnt[v[i]]++;
        }
        ll q;
        cin >> q;
        while(q--){
            ll b, c;
            cin >> b >> c;
            cnt[c] += cnt[b];
            sum -= cnt[b] * b;
            sum += cnt[b] * c;
            cnt[b] = 0;
            cout << sum << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 10004
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define SENTINEL 1000000001

using namespace std;

int n, *S, cnt;

void printv(int v[], int len) {
	int ifs = 1;
	for (int i = 0; i < len; i++) {
		if (ifs == 0)
			cout << " ";
		cout << v[i];
		ifs = 0;
	}
	cout << endl;
}

void Merge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int *L = new int[n1+1];
	int *R = new int[n2+1];
	memcpy(L, &A[left], sizeof(int) * n1);
	memcpy(R, &A[mid],  sizeof(int) * n2);
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	for (int i = 0, j = 0, k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		} else {
			A[k] = R[j];
			j++;
		}
		cnt++;
	}
	delete[] L;
	delete[] R;
}

void MergeSort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

int main() {
	cnt = 0;
	cin >> n;
	S = new int[n];
	for (int i = 0; i < n; i++)
		cin >> S[i];
	MergeSort(S, 0, n);
	printv(S, n);
	cout << cnt << endl;
	delete[] S;
	return 0;
}

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

long long MOD = 1e9 + 7;
long long fact[1000001], inv[1000001];

long long modRecursive(long long a, long long b, long long c) {
	if (b == 0) return 1;
	if (b % 2 == 0) return modRecursive((a * a) % c, b / 2, c);
	else return ((a % c) * (modRecursive((a * a) % c, b / 2, c))) % c;
}

int main() {
	fact[0] = 1; inv[0] = 1;
	for (int i = 1; i <= 1000000; i++) {
		fact[i] = (i * fact[i - 1]) % MOD;
		inv[i] = modRecursive(fact[i], MOD - 2, MOD);
	}
	long long h, w, a, b, ans = 0;
	cin >> h >> w >> a >> b;
	for (long long i = b; i < w; i++) {
		long long p = i, q = h - a - 1;
		long long r = w - i - 1, s = a - 1;
		long long x = (((fact[p + q] * inv[p]) % MOD) * inv[q]) % MOD;
		x *= (((fact[r + s] * inv[r]) % MOD) * inv[s]) % MOD;
		ans = (ans + x) % MOD;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main(){
	char* s = (char*)calloc(4, sizeof(char));
	cin >> s;
	
	for(int i = 0; i < 3; i++){
		for(int j = i+1; j < 3; j++){
			if(s[i] != s[j]) {cout << "Yes" << endl; return 0;}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3644
// b

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    // 単発入力
    string S;

    cin >> S;

    for (int i =0; i < S.length(); i++)
    {
        cout << 'x';
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
w = [input() for _ in range(n)]

if len(set(w)) != len(w):
    print('No')
else:
    ans = True
    for i in range(n - 1):
        if w[i][-1] != w[i + 1][0]:
            ans = False
            break

    print('Yes') if ans else print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PL;
typedef vector<PL> VPL;

int main() {
  int N;
  LL D, A, ret = 0, cur_bomb = 0;
  cin >> N >> D >> A;
  VPL X;
  REP(i, N) {
    LL _X, _H;
    cin >> _X >> _H;
    X.push_back(make_pair(_X, _H));
  }
  sort(X.begin(), X.end());
  queue<PL> seg_end;
  REP(i, N) {
    PL tX = X[i];
    while(!seg_end.empty()) {
      PL f = seg_end.front();
      if(f.first < tX.first) {
        seg_end.pop();
        cur_bomb -= f.second;
      } else {
        break;
      }
    }
    tX.second -= A * cur_bomb;
    if(tX.second > 0) {
      int t_bomb = (tX.second-1)/A + 1;
      ret += t_bomb;
      cur_bomb += t_bomb;
      seg_end.push(make_pair(tX.first + 2 * D, t_bomb));
    }
  }
  cout << ret << endl;
}

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

int main(){
  int n , k , ans = 0;
  cin >> n;
  for (int i = 1 ; i <= n ; i ++) {
    cin >> k;
    if (i % 2 == 0) {
      continue;
    }
    if (k % 2 == 1) {
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define N 100005
#define M -1
int n,Parent[N],Right[N],Left[N],D[N];

int GetDepth(int);
void SetDepth(int,int);
void Print(int);

int main(){
  int i,j,v,l,c,d,r;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    Parent[i]=Right[i]=Left[i]=M;
  }
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	Left[v]=c;
      }
      else{
	Right[l]=c;
      }
      l=c;
      Parent[c]=v;
    }
  }
  
  for(i=0;i<n;i++){
    if(Parent[i]==M){
      r=i;
    }
  }
  SetDepth(r,0);
  for(i=0;i<n;i++){
    Print(i);
  }
  return 0;
}

int GetDepth(int u){
  int d=0;
  while(Parent[u]!=M){
    u=Parent[u];
    d++;
  }
  return d;
}

void SetDepth(int u,int p){
  D[u]=p;
  if(Right[u]!=M){
    SetDepth(Right[u],p);
  }
  if(Left[u]!=M){
    SetDepth(Left[u],p+1);
  }
}

void Print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",Parent[u]);
  printf("depth = %d, ",GetDepth(u));
  if(Parent[u]==M){
    printf("root, ");
  }
  else if(Left[u]==M){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }
  printf("[");
  for(i=0,c=Left[u];c!=M;i++,c=Right[c]){
    if(i){
      printf(", ");
    }
    printf("%d",c);
  }
  printf("]\n");
}
      
      
    



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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 105;

typedef pair<int,int>   ii;

char w[N][N];
int  f[N][N];

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

    int n;  cin >> n;
    int m;  cin >> m;

    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < m ; ++j)
        cin >> w[i][j];

    if (w[0][0] == '#')
        f[0][0] = 1;

    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < m ; ++j)    if (i || j) {
        f[i][j] = 1e9;

        if (w[i][j] == '#') {
            if (i)  f[i][j] = min(f[i][j],f[i - 1][j] + (w[i - 1][j] == '.'));
            if (j)  f[i][j] = min(f[i][j],f[i][j - 1] + (w[i][j - 1] == '.'));
        }
        if (w[i][j] == '.') {
            if (i)  f[i][j] = min(f[i][j],f[i - 1][j]);
            if (j)  f[i][j] = min(f[i][j],f[i][j - 1]);
        }
    }
    cout << f[n - 1][m - 1] << endl;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    print(n * n * n);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    int a[n], d[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        d[i]=a[i];
    }
    sort(a, a+n);
    int b=a[n-1], c=a[n-2];
    for (int i=0;i<n;i++)
    {
        if (d[i]==b)
        {
            cout<<c<<"\n";
        }
        else
        {
            cout<<b<<"\n";
        }

    }
    return 0;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

bool same_vec(vector<int> a, vector<int> b){
    if(a.size() != b.size()) return false;
    for(int i=0; i<a.size(); i++){
        if(a[i] != b[i]) return false;
    }
    return true;
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    vector<int> q(n);
    for(int i=0; i<n; i++){
        cin >> q[i];
    }

    vector<int> b(n);
    for(int i=1; i<=n; i++){
        b[i-1] = i;
    }
    int cnt = 1;
    int p_cnt, q_cnt;
    do{
        if(same_vec(p, b)) p_cnt = cnt;
        if(same_vec(q, b)) q_cnt = cnt;
        cnt++;
    }while(next_permutation(b.begin(), b.end()));
    cout << abs(p_cnt-q_cnt) << endl;

    return 0;
}

Measured memory_bytes: 3568
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int k, a, b;
	cin >> k >> a >> b;
	bool flag = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			flag = true;
			break;
		}
	}
	cout << (flag ? "OK" : "NG");
}

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


Measured memory_bytes: 3648
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
  print('Possible')
else:
  print('Impossible')









Measured memory_bytes: 27204
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = [0 for _ in range(N)]
    B = [0 for _ in range(N)]
    for i in range(N):
        A[i], B[i] = Scanner.map_int()
    A.sort()
    B.sort()
    if N % 2 == 0:
        mA = A[N // 2] + A[N // 2 - 1]
        mB = B[N // 2] + B[N // 2 - 1]
        print(mB - mA + 1)
    else:
        mA = A[N // 2]
        mB = B[N // 2]
        print(mB - mA + 1)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 27108
#include<iostream>

using namespace std;

#define ull unsigned long long 

ull S(ull x) {
	ull ret = 0;
	while (x > 0) {
		ret += x % 10;
		x /= 10;
	}
	return ret;
}

int main() {
	ull K;
	cin >> K;
	
	ull cnt = 1;
	ull base = 1;
	ull diff = 1;
	while (cnt <= K && cnt < 10) {
		cout << cnt << endl;
		++cnt;
	}

	ull val = 9;
	ull x = 10;
	ull buf, s1, s2;
	while (cnt <= K) {
		val += x;
		cout << val << endl;

		s1 = S(val + x);
		s2 = S(val + 10 * x);

		if ((val + x * 10) * s1 <= (val + x) * s2) {
			x *= 10;
		}
		++cnt;
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

int na2;
int na;

typedef lli type;
typedef struct dynamic {
	type val;
	bool bl;
} dynamic;

lli solve(int j,int t,int *y,dynamic **dp){
	//printf("j = %2d t = %2d y = %2d\n", j,t,y[j]);
	if(dp[j][t].bl){
		return dp[j][t].val;
	}
	dp[j][t].bl = true;
	if(j == 0 && t == 0){
		return dp[j][t].val = 1;
	}else if(j > 0 && (t - y[j] < -na || t - y[j] > na)){
		return dp[j][t].val = solve(j-1,t,y,dp);
	}else if(j > 0){
		return dp[j][t].val = solve(j-1,t,y,dp) + solve(j-1,t-y[j],y,dp);
	}
	return dp[j][t].val = 0;
}

int main(void){
	int i,j;
	int n,a;
	dynamic **dp;
	int x;
	int *y;
	scanf("%d%d",&n,&a);
	dp = calloc(sizeof(dynamic*),n+1);
	y = calloc(sizeof(int),n+1);
	na2 = n*a*2;
	na = n*a;
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		y[i] = x - a;
	}
	for(i=0;i<=n;i++){
		dp[i] = calloc(sizeof(dynamic),na2+3);
		dp[i] += na + 1;
	}
	printf("%lld\n", solve(n,0,y,dp)-1);

	return 0;
}
/*
想定解法2
*/

Measured memory_bytes: 3840
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    bool can_buy = false;
    if (n % 7 == 0 || n % 4 == 0) {
        can_buy = true;
    } else {
        for (int i = 0; i <= n; i += 7) {
            if ((n - i) % 4 == 0) {
                can_buy = true;
                break;
            }
        }
        for (int i = 0; i <= n; i += 4) {
            if ((n - i) % 7 == 0) {
                can_buy = true;
                break;
            }
        }
    }

    if (can_buy)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
string s;
int main(){
    cin >> s;
    int fi = (10*(s[0]-'0') + (s[1]-'0'));
    int se = (10*(s[2]-'0') + (s[3]-'0'));
    if(1 <= fi && fi <= 12 && 1 <= se && se <= 12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if(1 <= fi && fi <= 12){
        cout << "MMYY" << endl;
        return 0;
    } 
    if(1 <= se && se <= 12){
        cout << "YYMM" << endl;
        return 0;
    }
    cout << "NA" << endl;
}



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

int main() {
  int k;
  cin >> k;
  
  int tmp = k / 2;
  if (k & 1) {
    cout << tmp * (tmp + 1) << endl;
  } else {
    cout << tmp * tmp << endl;
  }
  
  return 0;
}
    

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    ll ans = 0;
    for(int i = 0; i < 61; i++){
        ll cnt = 0;
        for(int j = 0; j < n; j++)  cnt += ((a[j]>>i)&1);
        ans += (1ll<<i)%mod * cnt % mod * (n-cnt);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

const int N = 7;
const int DICE_COUNT = 100;

const int ROTATION_MAX = 4;
const int ROTATION_KIND = 3;

const int ROTATION_PATTERN_COUNT = ROTATION_MAX * ROTATION_MAX * ROTATION_MAX;

const int ROTATION_X = 0;
const int ROTATION_Y = 1;
const int ROTATION_Z = 2;

const int ROTATION_MAP[3][N] = {
  {0, 2, 6, 3, 4, 1, 5},
  {0, 3, 2, 6, 1, 5, 4},
  {0, 1, 3, 5, 2, 4, 6}
};

typedef struct {
  int origin[N];
  int panels[N];
} Dice;

void rotate_dice(int op, Dice *dice) {
  int a[N] = {0};
  
  for (int i = 1; i < N; i++) {
    a[ROTATION_MAP[op][i]] = dice->panels[i];
  }

  for (int i = 1; i < N; i++) {
    dice->panels[i] = a[i];
  }  
}

bool compare(int rotationTable[ROTATION_PATTERN_COUNT][ROTATION_KIND], Dice *d1, Dice *d2) {
  bool found = false;
  
  for (int n = 0; n < (ROTATION_PATTERN_COUNT); n++) {
    for (int i = 1; i < N; i++) {
      d2->panels[i] = d2->origin[i];
    }
    
    for (int i = 0; i < rotationTable[n][ROTATION_X]; i++) {
      rotate_dice(ROTATION_X, d2);
    }
    
    for (int i = 0; i < rotationTable[n][ROTATION_Y]; i++) {
      rotate_dice(ROTATION_Y, d2);      
    }

    for (int i = 0; i < rotationTable[n][ROTATION_Z]; i++) {
      rotate_dice(ROTATION_Z, d2);
    }

    found = true;

    for (int i = 1; i < N; i++) {
      if (d1->panels[i] != d2->panels[i]) {
	found = false;
	
	break;
      }
    }

    if (found) {
      break;
    }
  }

  return found;
}

int main(void) {
  Dice dices[DICE_COUNT];

  int n = 0;

  std::cin >> n;

  for (int i = 0; i < DICE_COUNT; i++) {
    for (int j = 1; j < N; j++) {
      std::cin >> dices[i].origin[j];
      
      dices[i].panels[j] = dices[i].origin[j];
    }
  }

  int rotationTable[ROTATION_PATTERN_COUNT][ROTATION_KIND] = {0};
  int count = 0;
  
  for (int i = 0; i < ROTATION_MAX; i++) {
    for (int j = 0; j < ROTATION_MAX; j++) {
      for (int k = 0; k < ROTATION_MAX; k++) {
	rotationTable[count][ROTATION_X] = i;
	rotationTable[count][ROTATION_Y] = j;
	rotationTable[count][ROTATION_Z] = k;

	count++;
      }
    }
  }

  bool found = false;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (compare(rotationTable, &dices[i], &dices[j])) {
	found = true;

	break;
      }
    }
  }

  if (!found) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }  
  
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  int N,i,ans=0;
  scanf("%d",&N);
  FOR(i,1,10)if(N%i==0&&N/i<10){
    ans=1;break;
  }

  if(ans==1)printf("Yes");
  else printf("No");

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


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n, l; cin >> n >> l;
	int mini = 1e9;
	vector<int>ringo(n);
	for (int i = 0; i < n; i++) {
		int tmp = l + i;
		ringo[i] = tmp;
		if (abs(mini) > abs(tmp))
			mini = tmp;
	}
	for (vector<int>::iterator x = ringo.begin(); x != ringo.end(); x++) {
		if (*x == mini) {
			swap(*x, ringo.back());
		}
	}
	ringo.pop_back();
	int ans = 0;
	for (int i = 0; i < n-1; i++) ans += ringo[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC154D - Dice in Line  ... TLE

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] p = new int[n];
        int[] p3 = new int[n];

        int max = 0;
        int idx = 0;

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
            if (i == k - 1) {
                for (int j = 0; j < k; j++) {
                    p3[i - k + 1] += p[i - j];
                }
                max = p3[i - k + 1];
                idx = i - k + 1;
            } else if (i > k - 1) {

//                System.out.println("------------------");
//                System.out.println("p3[" + (i - k + 1) + "]=" + p3[i - k + 1]);
//                System.out.println("max=" + max);
//                System.out.println("idx=" + idx);
                p3[i - k + 1] = p3[i - k] + p[i] - p[i - k];
                if (max < p3[i - k + 1]) {
                    max = p3[i - k + 1];
                    idx = i - k + 1;
//                    System.out.println("->max=" + max);
//                    System.out.println("->idx=" + idx);
                }
            }
        }

        double[] e = new double[k];
        double ans = 0;

        // 期待値
        for (int i = 0; i < k; i++) {
            for (int j = 1; j <= p[idx + i]; j++) {
                e[i] += j;
            }
            e[i] /= p[idx + i];
            ans += e[i];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 74696
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    if(s[0] == s[1] && s[0] == s[2])cout << "No" << endl;
    else if(s[0] == s[1] && s[2] == s[3])cout << "Yes" << endl;
    else if(s[0] == s[2] && s[1] == s[3])cout << "Yes" << endl;
    else if(s[0] == s[3] && s[1] == s[2])cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256