akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    private static void prin(String ans){
    System.out.println(ans);
    }

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int upp = N/100;
        int downn = N%100;
        boolean my = ((1<=upp)&&(upp<=12));
        boolean ym = ((1<=downn)&&(downn<=12));
        
        if (my&&ym)
          prin("AMBIGUOUS");
        else if(my)
          prin("MMYY");
        else if(ym)
          prin("YYMM");
        else
          prin("NA");
	}
}



Measured memory_bytes: 21844
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define int __int64_t
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}

multiset<int> s1;
multiset<int> s2;
multiset<int> s3;

int min_R_1;
int min_R_2;


pair<int, int> a[MAXN];
int n;

int alp_salganda_newe(pair<int,int> x) {
	s1.erase(s1.find(x.S));
    auto nxt = s1.end();
    int res = 0;
	if (nxt != s1.begin()) {
        nxt--;
        res = max(1ll * min(1ll * x.S, 1ll * (*nxt)) - x.F + 1, 0ll) +
                      max(1ll * min((s1.size() > 0 ? *s1.begin() : (int)MOD), min_R_2) - a[n].F + 1, 0ll);
	}
	s1.insert(x.S);
	return res;
}


 main() {
  n = readInt();
  for (int i = 1; i <= n; i++) {
    a[i] = {readInt(), readInt()};
  }
  sort(a + 1, a + 1 + n);
  
  for (int i = 1; i <= n; i++) {
    s2.insert(a[i].S);
  	s3.insert(a[i].F);
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
  	s2.erase(s2.find(a[i].S));
	s3.erase(s3.find(a[i].F));
	ans = max(ans, 1ll * a[i].S - a[i].F + 1 + max(0ll, 1ll * (*s2.begin()) - *s3.rbegin() + 1));	    	
	s2.insert(a[i].S);
  	s3.insert(a[i].F);
  }
  for (int i = 1; i < n; i++) {
    /// min(R) - max(L) + 1
    s2.erase(s2.find(a[i].S));
    s1.insert(a[i].S);
    
    min_R_1 = *s1.begin();
    min_R_2 = *s2.begin();
    
    ans = max(ans, max(1ll * min_R_1 - a[i].F + 1, 0ll) +
                       max(1ll * min_R_2 - a[n].F + 1, 0ll));
  	
  	//ans = max(ans, alp_salganda_newe(a[i]));
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 11136
n,*d=map(int,open(0).read().split());f=[d[i]-d[n+i]for i in range(n)];m=[v for v in f if v<0];p=sorted(v for v in f if v>0);c=len(m);s=sum(m)
while s<0and p:s+=p.pop();c+=1
print([c,-1][s<0])

Measured memory_bytes: 25076
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
int main(){
fast
string s;
cin>>s;
if(s[0]==s[1]&& s[1]==s[2])
{
cout<<"No";
}
else 
cout<<"Yes";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
ll ABS(ll x){
	return x<0?-x:x;
}
int main(){
	int n;
	long long a,b,c,d,mx=0LL;
	cin>>n>>a>>b>>c>>d;
	for(int cur=1;cur<=n;cur+=2){
		ll lb=b-a-mx,rb=b-a+mx;
		if(c*(n-cur)<=rb&&lb<=d*(n-cur)){
			cout<<"YES\n";
			return 0;
		}
		if(-d*(n-cur)<=rb&&lb<=-c*(n-cur)){
			cout<<"YES\n";
			return 0;
		}
		mx+=d-c;
	}
	cout<<"NO\n";
	return 0;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


const int maxn = 2e5+5;
map<LL,LL> mp;
LL sum[maxn];


int main()
{
    LL N,K;
    scanf("%lld %lld",&N,&K);
    LL cnt = 0;
    memset(sum,0,sizeof(sum));
    mp[0] = 1;

    _rep(i,1,N){
        LL a;
        scanf("%lld",&a);
        sum[i] = sum[i-1] + a;
        LL k = (sum[i] - i)%K;
        if(i >= K) {
            LL j = (sum[i-K] - (i-K))%K;
            mp[j]--;
        }

        cnt += mp[k];
        mp[k]++;

    }
    printf("%lld\n",cnt);

    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  string s,t;

  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(), t.end(), greater<int>());

  string ans;
  if(s < t){
    ans = "Yes";
  }else{
    ans = "No";
  }

  cout << ans;
}


Measured memory_bytes: 384
import sys;sys.setrecursionlimit(int(1e7))

N = int(input())
ABC = [list(map(int,input().split())) for _ in range(N-1)]
Q,K = map(int,input().split())
XY = [list(map(int,input().split())) for _ in range(Q)]

tree = [[] for _ in range(N+1)]
depth = [None]*(N+1)
for abc in ABC:
    tree[abc[0]].append([abc[1],abc[2]])
    tree[abc[1]].append([abc[0],abc[2]])

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e[0] != p:
            DFS(e[0], v, d + e[1])

DFS(K,0,0)

for i in range(Q):
    print(depth[XY[i][0]] + depth[XY[i][1]])

Measured memory_bytes: 171284
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

int main(void){
 
  ll n,k;
  cin >> n >> k;
  ll a[n];
  REP(i,n){
    cin >> a[i];
  }
  for(int i=k; i<n; i++){
    if( a[i] > a[i-k] ){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 5176
import functools
MOD=10**9+7
def euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b)

def multiple(a, b):
  return a*b // euclid(a, b)

def lcm(nums):
  return functools.reduce(multiple, nums)
n=int(input())
a=list(map(int,input().split()))
x=lcm(a)
sum=0
for i in range(n):
    sum+=x//a[i]
print(sum%MOD)

Measured memory_bytes: 4708
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{
    ll n,m;
    cin>>n>>m;
    ll a = n*(n-1)/2 + m*(m-1)/2;
    cout<<a<<endl;






return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------

void solve()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll dp[n];
    for(ll i=0;i<n;i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
        if(i==1)
        {
            dp[i]=abs(arr[i]-arr[0]);
        }
        else
        {
            dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
        }
    }
    cout<<dp[n-1]<<endl;
}

int main()
{
    IOS
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 5208
import sys
input=sys.stdin.readline
import math

N=int(input().rstrip('\n'))
n = math.floor(math.sqrt(N))
res_dict={i:0 for i in range(1,N+1)}
for x in range(1,n):
  for y in range(1,n):
    for z in range(1,n):
      ans = x**2 +y**2+z**2+x*y+y*z+x*z
      if ans in res_dict:
        res_dict[ans] += 1
      else:
        res_dict[ans] = 1
for i in range(1,N+1):
  print(res_dict[i])

Measured memory_bytes: 11508
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int n, m;
    //year, p
    priority_queue<pair<int,int>> q;
    //p,year
    vector<pair<int,int>> v;
    //year id
    map<int,int> m1;
    //p,cnt
    map<int,int> m2;

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int p,y;
        cin >> p >> y;
        q.push(make_pair(-1 * y,p));
        v.push_back(make_pair(p,y));
    }

    while(!q.empty()){
        int year = -1 * q.top().first;
        int p = q.top().second;

        m2[p]++;

        m1[year] = m2[p];
        q.pop();
    }

    int vsize = v.size();

    for(int i = 0; i < vsize; i++){
        cout << setfill('0') << right << setw(6) << v[i].first;
        cout << setfill('0') << right << setw(6) << m1[v[i].second] << endl;
    }

    return 0;
}

Measured memory_bytes: 12396
#include<cstdio>
#include<algorithm>
using namespace std;
int n,l,sum;
int main(){
	scanf("%d%d",&n,&l);
	if(l>=0)sum-=l;
	else if(l+n-1>=0)sum-=0;
	else if(l+n-1<0)sum-=l+n-1;
	for(int i=1;i<=n;i++)
		sum+=l+i-1;
	printf("%d\n",sum);
}

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

int x[9], y[9], a[9];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    iota(a, a + n, 0);
    int c = 0;
    auto r = 0.;
    do {
        auto s = 0.;
        for(int i = 1; i < n; i++)
            s += sqrt((x[a[i - 1]] - x[a[i]]) * (x[a[i - 1]] - x[a[i]]) +
                      (y[a[i - 1]] - y[a[i]]) * (y[a[i - 1]] - y[a[i]]));
        r += s;
        c++;
    } while(next_permutation(a, a + n));
    cout.precision(18);
    cout << r / c << endl;
    return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	if (a == 0) {
		cout << b / x + 1 << endl;
		return 0;
	}
	ll m = (a - 1) / x*x;
	ll M = b / x*x;
	cout << (M - m) / x << endl;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

int N, M;

int main(void)
{
	cin >> N >> M;
	
	int ans = 1;
	for(int i = 1; i*i <= M; i++){
		if(M%i) continue;
		if(i <= M/N) ans = max(ans, i);
		if((M/i) <= M/N) ans = max(ans, M/i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }

    queue<pair<int, int>> q;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                if (i > 0)
                    if (A[i - 1][j] == '.') q.push(make_pair(i - 1, j));
                if (j > 0)
                    if (A[i][j - 1] == '.') q.push(make_pair(i, j - 1));
                if (i < H - 1)
                    if (A[i + 1][j] == '.') q.push(make_pair(i + 1, j));
                if (j < W - 1)
                    if (A[i][j + 1] == '.') q.push(make_pair(i, j + 1));
            }
        }
    }

    int ans = 0;
    while (true) {
        bool flag = false;
        if (q.empty()) {
            cout << ans << endl;
            return 0;
        }
        int n = q.size();
        for (int t = 0; t < n; t++) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            if (A[i][j] == '#') continue;
            flag    = true;
            A[i][j] = '#';
            if (i > 0)
                if (A[i - 1][j] == '.') q.push(make_pair(i - 1, j));
            if (j > 0)
                if (A[i][j - 1] == '.') q.push(make_pair(i, j - 1));
            if (i < H - 1)
                if (A[i + 1][j] == '.') q.push(make_pair(i + 1, j));
            if (j < W - 1)
                if (A[i][j + 1] == '.') q.push(make_pair(i, j + 1));
        }
        if (flag == false) {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }

    return 0;
}


Measured memory_bytes: 8208
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

print((1000-n%1000)%1000)

Measured memory_bytes: 70996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

map<ll, int> prime_factor(ll n){
	map<ll, int> res;
	for(ll i = 2; i*i<=n; i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1) res[n]++;
	return res;
}

int main(){
	ll n, p;
    cin >> n >> p;
	map<ll,int> res = prime_factor(p);
	ll ans = 1;
	for(auto e: res){
		while(e.second >= n) ans *= e.first, e.second -= n;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import collections

n = int(input())
v = list(map(int, input().split()))
v1 = collections.Counter([x for i, x in enumerate(v) if i % 2 == 0]).most_common()
v2 = collections.Counter([x for i, x in enumerate(v) if i % 2 == 1]).most_common()
v1.append((0, 0))
v2.append((0, 0))

if v1[0][0] != v2[0][0]:
    print(n - v1[0][1] - v2[0][1])
else:
    print(min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1]))


Measured memory_bytes: 20700
#include <stdio.h>
int main() {
  int n;
  scanf("%d", &n);
  int a[n+1];
  int c[n+1];

  a[1]=0; c[1]=0;
  for(int i=2;i<n+1;i++){ scanf("%d", &a[i]); c[i]=0; }

  for(int i=1;i<n+1;i++) c[a[i]]++;
  
  for(int i=1;i<n+1;i++) printf("%d\n", c[i]);

  return 0;
}


Measured memory_bytes: 3284
s = input()
formerh = int(s[0:2])
latterh = int(s[2:4])


if (formerh > 12 or formerh == 0) and (latterh > 12 or latterh == 0):
  print('NA')
elif (formerh > 12 or formerh == 0):
  print('YYMM')
elif (latterh > 12 or latterh == 0):
  print('MMYY')
else: 
  print('AMBIGUOUS')

Measured memory_bytes: 38384
# 鉄道と道路の各無効グラフを生成して連結してるかdfsで調べる。

a, b, c, k = map(int, input().split())
base = 10**18
if not k % 2 == 0:
  if b - a > base:
    print('Unfair')
  else:
    print(b - a)
else:
  if a - b > base:
    print('Unfair')
  else:
    print(a - b)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;
vector<vector<ll>> g(10, vector<ll>());
ll ans = 0;
ll n, m;
void dfs(ll v, ll cnt, vector<bool> seen)
{
    seen[v] = true;
    cnt++;
    if (cnt == n)
    {
        ans++;
    }
    for (auto f : g[v])
    {
        if (seen[f])
        {
            continue;
        }
        dfs(f, cnt, seen);
    }
}
int main()
{
    cin >> n >> m;
    for (ll i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    vector<bool> seen(n, false);
    dfs(0, 0, seen);
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll comb2(ll n){
  return n * (n - 1) / 2;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  ll m; cin >> m;
  ll sum[n+1]; sum[0] = 0;
  for(int i=1;i<=n;i++){
    ll a; cin >> a;
    sum[i] = sum[i-1] + a;
  }
  map<ll, ll> mp;
  for(int i=0;i<=n;i++){
    mp[(sum[i] %m)]++;
  }
  ll cnt = 0;
  for(auto mpi: mp){
    if(mpi.second <= 1) continue;
    cnt += comb2(mpi.second);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll X,Y,Z;cin>>X>>Y>>Z;
  cout<< Z<<" "<<X <<" "<< Y<<endl;
  
  
}





Measured memory_bytes: 256
/* 解説放送観てその通りに作っただけ */

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll m, k, e;
	cin >> m >> k;
	e = (1 << m);

	if(e <= k) {
		cout << "-1" << endl;
		return 0;
	} else if(m == 0) {
		cout << "0 0" << endl;
		return 0;
	} else if(m == 1) {
		if(k == 0) {
			cout << "0 0 1 1" << endl;
			return 0;
		} else {
			cout << "-1" << endl;
			return 0;
		}
	}

	vector<ll> a(e), b, ret, K(1, k);
	rep(i, e) a[i] = i;
	a.erase(a.begin() + k);
	b = a;
	reverse(b.begin(), b.end());
	ret.insert(ret.end(), a.begin(), a.end());
	ret.insert(ret.end(), K.begin(), K.end());
	ret.insert(ret.end(), b.begin(), b.end());
	ret.insert(ret.end(), K.begin(), K.end());

	ll n = e * 2 - 1;
	rep(i, n) cout << ret[i] << " ";
	cout << ret[n] << endl;

	return 0;
}


Measured memory_bytes: 5880
from bisect import bisect

num_a,num_b,num_q = map(int, input().split(' '))

lsa = [int(input()) for _ in range(num_a)]
lsb = [int(input()) for _ in range(num_b)]
lsa.sort()
lsb.sort()
# print(lsa)
# print(lsb)
lsq = [int(input()) for _ in range(num_q)]

for ques in lsq:
    lower_bound_a = bisect(lsa, ques)
    lower_bound_b = bisect(lsb, ques)
    upper_bound_a = lower_bound_a - 1
    upper_bound_b = lower_bound_b - 1

    min_cand = 9223372036854775807
    if lower_bound_a < num_a and lower_bound_b < num_b:
        min_cand = min(min_cand, max(lsa[lower_bound_a], lsb[lower_bound_b]) - ques)
    if upper_bound_a >= 0 and upper_bound_b >= 0:
        min_cand = min(min_cand, ques - min(lsa[upper_bound_a], lsb[upper_bound_b]))
    if upper_bound_a >= 0 and lower_bound_b < num_b:
        min_cand = min(
            min_cand, 
            lsb[lower_bound_b] - ques + lsb[lower_bound_b] - lsa[upper_bound_a],
            ques - lsa[upper_bound_a] + lsb[lower_bound_b] - lsa[upper_bound_a],
        )
    if lower_bound_a < num_a and upper_bound_b >= 0:
        min_cand = min(
            min_cand, 
            lsa[lower_bound_a] - ques + lsa[lower_bound_a] - lsb[upper_bound_b],
            ques - lsb[upper_bound_b] + lsa[lower_bound_a] - lsb[upper_bound_b],
        )
    
    print(min_cand)


Measured memory_bytes: 16168
fun main(args: Array<String>) {
    abc062c()
}

fun abc062c() {
    val (h, w) = readLine()!!.split(" ").map { it.toLong() }

    // h or wが3の倍数の場合は直線に三分割
    if (h % 3L == 0L || w % 3L == 0L) {
        println(0)
        return
    }

    val minDiffOfAll = Math.min(calcAnswer(h, w), calcAnswer(w, h))

    println(minDiffOfAll)
}

private fun calcAnswer(h: Long, w: Long): Long {
    var minDiffOfAll = Long.MAX_VALUE
    for (i in 1 until h) {
        val piece1 = i * w
        val remainHeight = h - i
        // 横の字に切るパターン
        val pieceH = (remainHeight / 2) * w
        val pieceHLarger = if (remainHeight % 2L == 0L) pieceH else (remainHeight / 2 + 1) * w
        val maxPieceH = Math.max(piece1, pieceHLarger)
        val minPieceH = Math.min(piece1, pieceH)
        val diffH = maxPieceH - minPieceH
        // 横/Tの字に切るパターン
        val pieceV = remainHeight * (w / 2)
        val pieceVLarger = if (w % 2L == 0L) pieceV else remainHeight * (w / 2 + 1)
        val maxPieceV = Math.max(piece1, pieceVLarger)
        val minPieceV = Math.min(piece1, pieceV)
        val diffV = maxPieceV - minPieceV

        val minDiff = Math.min(diffH, diffV)
        if (minDiff < minDiffOfAll) minDiffOfAll = minDiff
    }
    return minDiffOfAll
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll k, t; cin >> k >> t;
  vll a(t); rep(i, t) cin >> a[i];
  ll flag = (*max_element(all(a)) * 2 - accumulate(all(a), 0));
  ll ans = 0;
  fin(max(ans, flag - 1));
}

//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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


int main() {
  double n;cin>>n;
  cout<<ceil(n/1000)*1000-n;
}

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

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define PI 3.14159265
#define take(a,n) for(int i=0;i<(n);i++) cin>>(a)[i]
#define out(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int (i)=0;i<(n);(i)++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
using namespace std;


ll poww(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=b;i++)
  {
    ans*=a;
  }
  return ans;
}


int max(int a,int b,int c)
{
  if(a>=b && a>=c) return a;
  if(b>=a && b>=c) return b;
  return c;
}

ll ncr(int n,int r)
{
  ll ans=1;
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

int main()
{
  int n,b;
  cin>>n;
  int a[n];
  take(a,n);
  int ans=0;
  forup(i,n-1)
  {
    int z=0;
    while(i<n-1 && a[i]>=a[i+1]) {z++;i++;}
    ans=max(ans,z);
  }


  cout<<ans;
}


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

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

	vector<bool> red(n);
	red[0] = true;

	vector<int> cnt(n, 1);

	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--; y--;

		if (red[x]) {
			if (cnt[x] >= 2) {
				red[y] = true;
				cnt[y]++;
				cnt[x]--;
			} else {
				red[y] = true;
				red[x] = false;
				cnt[y]++;
				cnt[x]--;
			} 
		} else {
			cnt[y]++;
			cnt[x]--;
		}
	}

	cout << count(red.begin(), red.end(), true) << endl; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  string s;
  cin>>s;
  vi a(3);
  for (char c : s) a[c-'a']++;
  sort(rng(a));
  puts(a.back()-a[0]<=1?"YES":"NO");
  return 0;
}






















Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int ch_sign(int n){
    if(n == 0)return 0;
    return (n>0)-(n<0);
}

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

    int sign1 = 1, sign2 = -1;
    long long s1 = 0, s2 = 0;
    long long ans1 = 0, ans2 = 0;
    for(int i = 0; i<n; ++i){
        //cout << a[i] << ',' <<  s << ',' << sign << endl;
        //while(abs(a[i]) <= abs(s)){ ++ans; a[i] -= sign;}
        //int dis = abs(s) - abs(a[i]) + 1;
        //cout << dis << endl << endl;
        //if(dis > 0){ans += dis; a[i] -= sign*dis;}
        //s += a[i]; sign *= -1;

        s1 += a[i]; s2 += a[i]; sign1 *= -1; sign2 *= -1;
        if(ch_sign(s1) != sign1){ ans1 += abs(s1)+1; s1 = sign1;}
        if(ch_sign(s2) != sign2){ ans2 += abs(s2)+1; s2 = sign2;}
    }
    cout << min(ans1,ans2) << endl; return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int p[20];
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int num = 0;
    for(int i = 1; i < n-1; i++) {
        if(p[i-1] > p[i]) {
            if(p[i+1] < p[i]) {
                num++;
            }
        }
        else if (p[i-1] < p[i]) {
            if(p[i+1] > p[i]) {
                num++;
            }
        }
    }
    cout << num;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String s = sc.next();
        int n = sc.nextInt();
        String ans[] = s.split("");
        int i;
      	for(i = 0;i < s.length();i++){
          if(i == 0 || i % n == 0){
            System.out.print(ans[i]);
          }
          
        }
    }
}

Measured memory_bytes: 36080
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> h(6);
    int k;
    int flag = 0;

    int tmp = 0;
    int i = 0;
    while(cin >> tmp) {
        h[i] = tmp;
        i ++;
        if(i >= 6) {
            break;
        }
    }

    k = h[5];

    for(int i = 0; i < 5; i++) {
        for(int j = i+1; j < 5; j++) {
            if( (h[j] - h[i]) > k ) {
                flag = 1;
            }
        }
    }

    if(flag == 1) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }


}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val ABC = Array.fill(3)(sc.nextInt).sorted

    (ABC(2) * 10 + ABC(1) + ABC(0)).toString
  }
}


Measured memory_bytes: 25428
import sys
input=sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    s = input().strip()
    if len(a) > 0:
        if s in a:
            print("No")
            exit()
        elif a[-1][-1] == s[0]:
            a.append(s)
        else:
            print("No")
            exit()
    else:
        a.append(s)
        
print("Yes")


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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    
    int N;
    cin >> N;
    vector<int> A(N, 0), B(N, 0);
    for(int i = 1; i < N; i++){
        cin >> A[i];
        B[A[i]-1]++;
    }
    rep(i, N){
        cout << B[i] << endl;
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 4768
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
int n,z,w;
vector<int>a(2001);
vector<int>dp(4001,-1);

int dfs(int num=0,bool isz=1,int tz=z,int tw=w)
{
  if(num==n)return abs(tz-tw);
  if(dp[num*2+isz]>-1)return dp[num*2+isz];
  if(isz)
  {
    int t=0;
    repi(i,num,n)
    {
      chmax(t,dfs(i+1,!isz,a[i],tw));
    }
    return dp[num*2+isz]=t;
  }
  else
  {
    int t=1e9+7;
    repi(i,num,n)
    {
      chmin(t,dfs(i+1,!isz,tz,a[i]));
    }
    return dp[num*2+isz]=t;
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>z>>w;
  rep(i,n)cin>>a[i];
  cout<<dfs()<<endl;



  return 0;

}


Measured memory_bytes: 384
function Main(input){
	input = input.split("\n");
  var n = ~~input.shift();
  
 	var sum = 0;
  
  for(var i = 0; i < n; i++){
  	var xu = input.shift().split(" ");
    var x = xu[0];
    var u = xu[1];
    if(u == "BTC"){
    	x = x.split(".").map(a=>~~a);
      x[0] *= 380000;
      x[1] *= 0.0038;
      sum += x[0] + x[1];
    }else{
    	sum += ~~x;
    }
  }
  
  return sum;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
3
100000000 JPY
100.00000000 BTC
0.00000001 BTC
`);

Measured memory_bytes: 7372
from decimal import *
import re
def solve2(m, n):
    maxlen = 160
    PREC=200
    getcontext().prec = PREC
    x = Decimal(m) / Decimal(n)
    s = x.to_eng_string()
    if len(s) < PREC:
        return(s[2:],'')
    rep = 1
    while True:
        r = r'(.{%d})\1{%d,}' % (rep, int(maxlen/rep)-1)  #ex. '(.{6})\\1{12,}'
        a=re.search(r, s)
        if a:
            break
        rep += 1
        if rep > maxlen:
            raise ValueError('This cannot happen.rep=%d' % rep)

    u = s[2:a.start()+len(a.group(1))]
    v = (' '*PREC + '^'*len(a.group(1)))[-len(u):]
    return(u,v)

while True:
    try:
        m,n = map(int, input().strip().split())
        s,t = solve2(m, n)
        print(s)
        if t!='':
            print(t)
    except EOFError:
        break

Measured memory_bytes: 9944
n = int(input())
st = []
for i in range(n):
    st.append(list(input().split()))
x = input()

ans = 0
sleeped = False
for sti in st:
    if sleeped:
        ans += int(sti[1])
    if sti[0] == x:
        sleeped = True
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<queue>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;



int main(){
	int n, k;cin >> n >> k;
	double p[n];
	double sum[n+1] = {0.0};
	for (int i = 0;i < n;i++){
		cin >> p[i];
		sum[i+1] = sum[i] + (p[i] + 1.0) / 2.0;
	}

	double ans = 0;
	for (int i = 0;i+k < n+1;i++){
		ans = max(ans, sum[i+k] - sum[i]);
	}

	cout << fixed << setprecision(15) << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  int ans = 1e9;
  for (int i = 0; i < N; i++) cin >> x.at(i);
  
  for (int i = 0; i < N - K + 1; i++) {
    int l;
    if (x.at(i) < 0 && x.at(i+K-1) > 0) {
      l = abs(x.at(i+K-1)-x.at(i)) + min(abs(x.at(i)),abs(x.at(i+K-1)));
    } else l = max(abs(x.at(i)),abs(x.at(i+K-1)));
    
    ans = min(ans,l);
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
  public static void main(String args[]) {
    // (??????????¨?) (??????????¨?) (???????¨?)
    Scanner scanner = new Scanner(System.in);
    while (true) {
      String gradeString = scanner.nextLine();
      if (gradeString.equals("-1 -1 -1")) {
        break;
      }
      String[] gradeStrArr = gradeString.split(" ");
      int[] gradeIntArr = new int[3];
      for (int i = 0; i < 3; i++) {
        gradeIntArr[i] = Integer.parseInt(gradeStrArr[i]);
      }
      System.out.println(judge(gradeIntArr));
    }
  }
  static String judge(int[] scores) {
    String ans = "";
    int sum = scores[0] + scores[1];
    if (scores[0] == -1 || scores[1] == -1) {
      ans = "F";
    } else if (sum >= 80) {
      ans = "A";
    } else if (sum >= 65) {
      ans = "B";
    } else if (sum >= 50) {
      ans = "C";
    } else if (sum >= 30 && scores[2] >= 50) {
      ans = "C";
    } else if (sum >= 30) {
      ans = "D";
    } else if (sum < 30) {
      ans = "F";
    }
    return ans;
  }
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl             '\n'
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr <<'}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i);cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int string_to_int(string s){
	int ans = 0;
	int p=1;
	for(int i=s.size()-1;i>=0;i--){
		ans += (s[i]-'0')*p;
		 p *= 10;
	}
	return ans;
}

void t_c_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int a; cin >> a;
	int ans = 0;
	ans += a;
	ans += a*a;
	ans += a*a*a;
	cout << ans << endl;
}

int32_t main()
{
	t_c_c();
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
	int i,j,tail=0,f=0,f2=0;
	int num,mem;
	long long int sum[4000]={0};
	int list[4000]={0};
	long long int m,count;
	while(1){
		for(i=0;i<4000;i++)sum[i]=0;
		tail=0;
		f=0;
		scanf("%d",&mem);
		if(mem==0) break;
		for(i=0;i<mem;i++){
			scanf("%d %lld %lld",&num,&m,&count);
			if(sum[num]!=-1)sum[num]+=m*count;
			if(sum[num]>=1000000){
				f2=1;
				for(j=0;j<tail;j++){
					if(list[j]==num)f2=0;
				}
				if(f2==1)list[tail++]=num;
				sum[num]=-1;
				f=1;
			}
		}
		for(i=0;i<tail;i++)printf("%d\n",list[i]);
		if(f==0)printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n;string T;vector<int>v;
long long search(string S){
	v.clear();
	for(int i=0;i<(int)S.size();i++){
		if(S[i]=='J')v.push_back(0);
		if(S[i]=='O')v.push_back(1);
		if(S[i]=='I')v.push_back(2);
	}
	vector<vector<long long> >dp(v.size()+1,vector<long long>(4,0));
	dp[0][0]=1;
	for(int i=0;i<(int)v.size();i++){
		dp[i+1][v[i]+1]+=dp[i][v[i]];
		for(int j=0;j<4;j++)dp[i+1][j]+=dp[i][j];
	}
	return dp[v.size()][3];
}
int main(){
	cin>>n>>T;long long ret=0;
	ret=max(ret,max(search("J"+T),search(T+"I")));
	long long c1=0,c2=0,w=search(T);
	for(int i=0;i<(int)T.size();i++){if(T[i]=='I')c2++;}
	for(int i=0;i<(int)T.size();i++){
		if(T[i]=='J')c1++;if(T[i]=='I')c2--;
		ret=max(ret,w+c1*c2);
	}
	cout<<ret<<endl;
	return 0;
}

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

int main(){

    string s,t;
    cin >>  s >> t;

    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;

    if(s==u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 764