akhauriyash/Code-Regression huggingface dataset:
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            ll d,n;
    cin>>d>>n;
    if(n==100)
    n++;
    ll ans=pow(100,d)*n;
    cout<<ans;
            
 
    }
  return 0;
  }

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    int k, x;
    cin >> k >> x;
    cout << (k * 500 < x ? "No\n" : "Yes\n"); 
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


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

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

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

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

int main(){
    int n; cin>>n;
    string s; cin>>s;
    vector<int> esum(n), wsum(n);
    if(s[0]=='W') wsum[0]=1;
    else wsum[0]=0;
    if(s[n-1]=='E') esum[n-1]=1;
    else esum[n-1]=0;
    for(int i=1; i<n; i++){
        if(s[i]=='W') wsum[i]=wsum[i-1]+1;
        else wsum[i]=wsum[i-1];
    }

    for(int i=n-2; i>=0; i--){
        if(s[i]=='E') esum[i]=esum[i+1]+1;
        else esum[i]=esum[i+1];
    }

    int ans=1e9;
    for(int i=0; i<n; i++){
        if(i==0) ans=min(ans, esum[1]);
        else if(i==n-1) ans=min(ans, wsum[n-2]);
        else ans=min(ans, wsum[i-1]+esum[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define pb push_back
#define INF (ll)1e9
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define fixed setprecision(9)
using namespace std;
using ll = long long;

int main(){
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u == s){
		a--;
	}
	else{
		b--;
	}
	cout<<a<<" "<<b;
		
	
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <cmath>
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
typedef long long lli;
typedef long li;
typedef pair<int,int> PI;
typedef pair<long,int> PLI;
typedef pair<int,long> PIL;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<long long> VLL;
typedef priority_queue<int> PQ;
typedef priority_queue<long> PQL;
typedef priority_queue<long long> PQLL;
#define FAST ios::sync_with_stdio(0)
#define forz(n) for (long i = 0; i < n; i++)
#define forv(i,x,y) for (long i=x; i<y; i++)
#define rforz(a,n) for (long i = a; i < n; i++)
#define forlz(n) for (long int i = 0; i < n; i++)
#define TRAV(it, v) for(auto it = v.begin(); it != v.end(); it++) 
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define SQ(a) (a)*(a)
#define UM unordered_map
#define US unordered_set
#define LB(v,x) lower_bound(v.begin(),v.end(),x);
#define UB(v,x) upper_bound(v.begin(),v.end(),x);
#define CUBE(a) (a)*(a)*(a)
#define SORT(v) sort(v.begin(),v.end());
#define SORTC(v,c) sort(v.begin(),v.end(),c);
#define Pi 3.14159265358979323846
 
 
#define module 1000000007
 
 
lli gcd(lli x,lli y){
    if(x==0) return y;
    return gcd(y%x,x);
}
 
PL Egcd(lli x,lli y){
    if(x==0) return MP(0,1);
    PL t=Egcd(y%x,x);
    return MP(t.S-t.F*(y/x),t.F);
}
 
 
lli powerget(lli y, lli x) { 
    lli temp; 
    if( y == 0) 
        return 1; 
    temp = powerget(y/2, x); 
    if (y%2 == 0) 
        return (temp*temp); 
    else{
        lli t = (temp*temp);
        t = t;
        return (x*t); 
    }
} 
 

void solve2(){
    int n;
	cin>>n;
	int m = n%100;
	n = n/100;
	if(n==0 || m==0){
		if(n==0 && m==0){
			cout<<"NA\n";
		}else if(n==0 && m<13){
			cout<<"YYMM\n";
		}else if(m==0 && n<13){
			cout<<"MMYY\n";
		}else{
			cout<<"NA\n";
		}
		return;
		
	}
	if(n<13 && m<13 ){
		cout<<"AMBIGUOUS\n";
	}else if(n<13){
		cout<<"MMYY\n";
	}else if(m<13){
		cout<<"YYMM\n";
	}else{
		cout<<"NA\n";
	}
}   
 
int main(){
    FAST;
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //=====================================code starts here
    // lli n;
    // cin>>n;
    // while(n--){
        solve2();
    // }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char a,b; cin>>a>>b;
	if (a==b) cout<<"H";
	else cout<<"D"<<endl;
	return 0;
}


Measured memory_bytes: 3640
# ABC052D - Walk and Teleport (ARC067D)
import sys
input = sys.stdin.readline

def main():
    N, A, B = tuple(map(int, input().split()))
    X = tuple(map(int, input().split()))
    D = [j - i for i, j in zip(X, X[1:])]  # distance
    ans = sum(min(A * d, B) for d in D)
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
	int N;
	cin >> N;
	string ans = "Three";
		for (int i = 0; i < N; ++i) {
			string s;
			cin >> s;
			if ("Y" == s) {
				ans = "Four";
			}
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#include <cmath>
#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	string s;

	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		cout << 'x';
	}

	cout << endl;

	

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int f(int x){
  int cnt=0;
  for(int i=1;i<=x;i++){
    if(x%i==0){cnt++;}
  }
  return cnt;
}

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int MAX=0;
  string t="AGCT";
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      bool ok=false;  
      for(int v=0;v<4;v++){
        if(s[j]==t[v]){ok=true;}
      }
      if(!ok){break;}
      else{chmax(MAX,j-i+1);}
    }
  }
  cout<<MAX<<endl;
  return 0;  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    int k; string s;string ans;
    cin>>k>>s;
    if(k>=s.size()){ans=s;}
    else{
        rep(i,k) {
            ans+=s.at(i);
        }
        ans+="...";
    }
    cout<<ans<<endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a<b){
    cout << "a < b" << endl;
  }
  else if(a>b){
    cout << "a > b" << endl;
  }
  else{
    cout << "a == b" << endl;
  }
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int min(int a,int b){
  if(a < b){
    return a;
  }else{
    return b;
  }
}

int main(){
  int N;
  scanf("%d",&N);
  int h[N];
  for(int i = 0;i < N;i++){
    scanf("%d",&h[i]);
  }
  int C[N];
  C[0] = 0;
  C[1] = abs(h[0]- h[1]);
  for(int i = 2;i < N;i++){
    C[i] = min(C[i-2] + abs(h[i] - h[i-2]), C[i-1] + abs(h[i] - h[i-1]));
  }
  printf("%d\n",C[N-1]);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B,C,D,E;
  cin>>N>>A>>B>>C>>D>>E;
  long long x=min(A,min(B,min(C,min(D,E))));
  cout<<4+N/x+(N%x+x-1)/x<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
inline void putint(int X) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (X >= 10000) {
		if (X >= 100000) dig = 6;
		else dig = 5;
	}
	else {
		if (X >= 1000) dig = 4;
		else if (X >= 100) dig = 3;
		else if (X >= 10) dig = 2;
	}
	rep1(i, dig) {
		di[dig - i] = '0' + X % 10;
		X /= 10;
	}
	di[dig] = '\n';
	di += dig + 1;
}
const int bm = 500001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A < bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
int L[500001], R[500001], C[500001], ne[500001];
int are[500001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), Q = getint();
	rep1(i, N) C[i] = getint();
	rep1(i, Q) {
		L[i] = getint();
		int r = getint();
		ne[i] = R[r];
		R[r] = i;
	}
	rep1(i, N) {
		if (are[C[i]]) add(are[C[i]]);
		are[C[i]] = i;
		
		for (int r = R[i]; r; r = ne[r]) {
			L[r] = i - L[r] - query(L[r]) + 1;
		}
	}

	rep1(i, Q) putint(L[i]);
	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 15008
#include <iostream>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, m, i;
  long long ans=0;
  cin >> n >> m;
  pair<long long, long long> ab[n];
  for(i=0; i<n; i++)
    cin >> ab[i].first >> ab[i].second;
  sort(ab, ab+n);
  for(i=0; m>0; i++)
    if(m>=ab[i].second){
      m-=ab[i].second;
      ans+=ab[i].first*ab[i].second;
    }
    else{
      ans+=m*ab[i].first;
      m=0;
    }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
judge=["WA"]*n
count=[0]*n
ac=0
pena=0
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if s=="AC" and judge[p]=="WA":
    judge[p]="AC"
    ac+=1
    pena+=count[p]
  elif s=="WA":
    count[p]+=1
print(ac,pena)

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

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

  auto keta = [&](ll n){
    int res = 0;
    ll tmp = n;

    while(tmp>0){
      res++;
      tmp /= 10;
    }

    return res;
  };

  auto F = [&](ll a,ll b){
    return keta(max(a,b));
  };

  vector<pair<ll,ll>> y;
  for(ll i=1; i<=sqrt(n); i++){
    if(n%i==0) y.push_back(make_pair(i,n/i));
  }

  int ans = 12;
  for(auto p : y){
    int tmp = F(p.first,p.second);
    ans = min(ans,tmp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = 0;
    rep(i, n) {
        if (a[i] <= b[i]) {
            ans += a[i];
            b[i] -= a[i];
            if (a[i+1] <= b[i]) {
                ans += a[i+1];
                a[i+1] = 0;
            }
            else {
                ans += b[i];
                a[i+1] -= b[i];
            }
        }
        else {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
    }

    cout << ans << endl;

}

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

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

typedef long long ll;

#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 INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int k;
    string s;
    cin>>s>>k;
    int n=s.size();
    ll dp0[n+1][k+1]={},dp1[n+1][k+1]={};
    dp0[0][1]=1; // 丁度の場合
    dp1[0][0]=1; // 0の場合
    dp1[0][1]=s[0]-'0'-1; // それ以外
//    cout<<"1 ";
//    rep(j,k+1)cout<<dp1[0][j]<<" ";
//    cout<<endl;
    for(int i=1;i<n;i++){
      rep(j,k+1){
        if(s[i]!='0') {
            if(j<k) {
              dp0[i][j+1]+=dp0[i-1][j];
            }
          }
        else{
          dp0[i][j]+=dp0[i-1][j];
        }
        // 0が追加
        dp1[i][j]+=dp1[i-1][j];
        if(s[i]!='0') dp1[i][j]+=dp0[i-1][j];
        // 1~9の場合
        if(j<k){
          dp1[i][j+1]+=dp1[i-1][j]*9;
//          rep(j,k+1)cout<<dp1[i][j]<<" ";
//          cout<<endl;      
          if(s[i]!='0') dp1[i][j+1]+=dp0[i-1][j]*(s[i]-'0'-1);
        } 
      }
//        cout<<i<<" ";
//        rep(j,k+1)cout<<dp1[i][j]<<" ";
//        cout<<endl;      
    }
//    cout<<dp1[n-1][k]<<endl;
    cout<<dp0[n-1][k]+dp1[n-1][k]<<endl;
    return 0;
}

Measured memory_bytes: 256
def p(n, k):
    if n >= k:
        return 1
    num = 0
    while n < k:
        n *= 2
        num += 1
    return 1 / 2 ** num

N, K = map(int, input().split())

ans = 0
for n in range(1, N + 1):
    ans += p(n, K)

ans /= N

print(ans)

Measured memory_bytes: 9124
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

list<long long int> Prime(long long int num) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	list<int>edge[100001] = {};
	bool used[100001] = {};
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	int a, b;
	a = 1;
	b = *edge[1].begin();
	used[a] = true;
	used[b] = true;
	stack<pair<int, int>>s;
	s.push({ a, 0 });
	s.push({ b,1 });
	list<int>ret;
	ret.push_back(a);
	ret.push_back(b);
	while (!s.empty()) {
		int c;
		int d;
		c = s.top().first;
		d = s.top().second;
		s.pop();
		for (auto i : edge[c]) {
			if (!used[i]) {
				s.push({ i,d });
				used[i] = true;
				if (!d)ret.push_front(i);
				else ret.push_back(i);
				break;
			}
		}
	}
	cout << ret.size() << endl;
	int box = 0;
	for (auto i : ret) {
		if (box)cout << " ";
		cout << i;
		box++;
	}
	cout << endl;
	return 0;
}




Measured memory_bytes: 11904
kensaku=list(input())
moji=0
n=[]
ans=[]
for i in range(len(kensaku)):
    if kensaku[i]==' ' or kensaku[i]=='.' or kensaku[i]==',':
        if 3<=moji<=6:
            ans=ans+n+[' ']
        n.clear()
        moji=0
    else:
        n.append(kensaku[i])
        moji+=1
del ans[-1]
for i in range(len(ans)):
    print(ans[i],end='')
print()


Measured memory_bytes: 5596
// AOJ 2544: Older Research Bldg. No.7
// 2017.10.5 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct { int y; char nm[32]; } T;
T tbl[52];

int cmp(T *a, T *b) { return a->y - b->y; }

int main()
{
	int n, q, i;

	tbl[0].y = 1, strcpy(tbl[0].nm, "kogakubu10gokan");
	scanf("%d%d", &n, &q); n++;
	for (i = 1; i < n; i++) scanf("%d%s", &tbl[i].y, tbl[i].nm);
	qsort(tbl, n, sizeof(T), cmp);
	for (i = 1; i < n; i++) if (tbl[i].y > q) break;
	printf("%s\n", tbl[i-1].nm);
	return 0;
}

Measured memory_bytes: 1704
#include<stdio.h>
int main(){
  int n,t[100],a,c,i,j,b,m;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    int h[201]={0};
    for(i=0;i<n;i++){
      scanf("%d",&t[i]);
      h[t[i]]=1;
      for(j=i;j;j--){
    if(t[j-1]>t[j]){
      m=t[j-1];
      t[j-1]=t[j];
      t[j]=m;
    }
      }
    }
    b=0;
    i=0;
    j=1;
    a=c=n;
    while(a&&c){
      for(;i<n;i++)if(b<t[i])break;
      if(i==n){
    b=0;
    i=0;
    j=1;
      }
      else{
    b=t[i];
    a--;
    t[i]=0;//printf("t%d\n",b);
      }
      if(!(a&&c))break;
      for(;j<2*n+1;j++)if(h[j]==0&&b<j)break;
      if(j==2*n+1){
    b=0;
    i=0;
    j=1;
      }
      else{
    c--;
    b=j;
    h[j]=1;//printf("h%d\n",b);
      }    
    }
    printf("%d\n%d\n",c,a);
  }
  return 0;
}

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

int main(){
	int n,m,ans=0;
	cin>>n>>m;
	
	while(n>0)
	{
		ans+=n-1;
		n--;
	}
	while(m>0)
	{
		ans+=m-1;
		m--;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=2e5+5;
typedef long long ll;
int n,d,a;
struct node{
	ll x;
	int h;
}mons[MAXN];
bool operator <(node a,node b){
	return a.x<b.x;
}
ll sum[MAXN];
ll ans;
int main(){
	scanf("%d%d%d",&n,&d,&a);
	for(int i=1; i<=n; i++)
		scanf("%lld%d",&mons[i].x,&mons[i].h);
	sort(mons+1,mons+n+1);
	ll cnt=0;
	for(int i=1,r=1; i<=n; i++){
		while(r<n&&mons[r+1].x<=mons[i].x+d*2) r++;
		cnt+=sum[i];
		mons[i].h-=cnt;
		if(mons[i].h<=0) continue;
		ll t=(mons[i].h+a-1)/a;
		ans+=t;
		sum[i]=t*a;
		sum[r+1]-=t*a;
		cnt+=sum[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

int cnt[N];
vector<int> adj[N];
bool ok = true;

void dfs(int v, int p)
{
	int bad = 0;
	cnt[v] = 1;
	for (auto u : adj[v])
	{
		if (u == p)
			continue;
		dfs(u, v);
		cnt[v] += cnt[u];
		if (cnt[u] % 2 == 1)
			bad++;
	}
	if (bad > 1)
		ok = false;
}

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	for (int i=1; i<n; i++)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	dfs(0, -1);
	if (!ok || cnt[0] % 2 == 1)
		cout << "First\n";
	else
		cout << "Second\n";

	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const int MAX = 200002;

ll N,M;
char a[MAX];

int main()
{
    cin>>N>>M;
    ll sum = 0;
    if(M==0)cout<<N*N<<endl;
    else {
        sum += ((N-M)*(N-M+1))/2;
        for(int i = M+1;i <=N;i++){
        ll temp = (N-i+1)/i*(i-M);
        ll temp2 = ((N-i+1)%i-M)<0?0:((N-i+1)%i-M);
        sum += temp+temp2;
    }
    cout<<sum<<endl;

    }

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
// Thanks to @hamadu for referring to code
use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::min;
use std::collections::HashMap;

fn dfs(r: usize, a: usize, b: usize, c: usize, d: usize, m: &mut HashMap<usize, usize>) -> usize {
    let mut res = if let Some(k) = r.checked_mul(d){ k } else { std::usize::MAX };
    if r == 0 { return 0; }
    if r == 1 { return d; }
    if m.contains_key(&r) {
        return *m.get(&r).unwrap();
    }
    res = min(res, dfs(r / 2, a, b, c, d, m) + a + d * (r % 2));
    res = min(res, dfs((r + 1) / 2, a, b, c, d, m) + a + d * (r % 2));
    res = min(res, dfs(r / 3, a, b, c, d, m) + b + d * (r % 3));
    res = min(res, dfs((r + 2) / 3, a, b, c, d, m) + b + d * (3 - r % 3));
    res = min(res, dfs(r / 5, a, b, c, d, m) + c + d * (r % 5));
    res = min(res, dfs((r + 4) / 5, a, b, c, d, m) + c + d * (5 - r % 5));
    m.insert(r, res);
    res
}

#[fastout]
fn main() {
    input! {
    t: usize,
    nabcds: [[usize; 5]; t]
    }
    for nabcd in nabcds {
        let mut m = HashMap::new();
        let (r, a, b, c, d) = (nabcd[0], nabcd[1], nabcd[2], nabcd[3], nabcd[4]);
        let ans = dfs(r, a, b, c, d, &mut m);
        println!("{}", ans);
    }
}


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

long long n;

long long solve();

int main() {
  cin >> n;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for(int i = 1; i <= n; ++i) {
    if(i % 10 == 0) continue;
    long long now = i, pre = i % 10, suf = i % 10;
    while(now > 0) {
      suf = now % 10;
      now /= 10;
    }
    if(pre == suf && suf <= n) ++res;
    for(long long ten = 10; pre * ten + suf <= n;
        ten *= 10) {
      now = n - pre * ten - suf;
      if(ten == 10) {
        ++res;
        continue;
      }
      res += min((long long)ten / 10, now / 10 + 1);
    }
  }
  return res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int min_a = INF, min_b = INF;
  REP(i, A) {
    cin >> a[i];
    min_a = min(min_a, a[i]);
  }
  REP(i, B) {
    cin >> b[i];
    min_b = min(min_b, b[i]);
  }
  int ans = min_a + min_b;
  REP(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    ans = min(ans, a[x - 1] + b[y - 1] - c);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 1024
def main():
    N, M = list(map(int, input().split()))
    SC = [tuple(map(int, input().split())) for _ in range(M)]
    V = [-1] * N
    for s, c in SC:
        s -= 1
        if V[s] == -1 or V[s] == c:
            V[s] = c
        else:
            return -1
    if N == 1:
        if V[0] == -1:
            V[0] = 0
        return V[0]
    if V[0] == 0:
        return -1
    if V[0] == -1:
        V[0] = 1
    for i in range(1, N):
        if V[i] == -1:
            V[i] = 0
    return ''.join(str(v) for v in V)

print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 
int main(){
    ll N; cin>>N;
    VL A(N);
    ll ans=0;
    rep(i,0,N)cin>>A[i];
    rep(i,0,N){
        rep(j,0,N){
            if(i==j)continue;
            ans=max(abs(A[i]-A[j]),ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int Arr[n][3];
    for(int i=0;i<n;i++)
    {
        cin >> Arr[i][0];
        cin >> Arr[i][1];
        cin >> Arr[i][2];
    }
    int hpp[n][3];
    hpp[0][0]=Arr[0][0];
    hpp[0][1]=Arr[0][1];
    hpp[0][2]=Arr[0][2];
    if(n>1)
    {
        for(int i=1;i<n;i++)
        {
            for(int j=0;j<3;j++)
            {
                if(j==0)
                {
                    hpp[i][0]=max(hpp[i-1][1],hpp[i-1][2])+Arr[i][0];
                }
                else if(j==1)
                {
                    hpp[i][1]=max(hpp[i-1][0],hpp[i-1][2])+Arr[i][1];
                }
                else{
                    hpp[i][2]=max(hpp[i-1][0],hpp[i-1][1])+Arr[i][2];
                }
            }
        }
        cout << max(max(hpp[n-1][0],hpp[n-1][1]),hpp[n-1][2]);
    }
    else
        cout << max(max(Arr[0][0],Arr[0][1]),Arr[0][2]);
}


Measured memory_bytes: 2560
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def solve(N, K):
    if K == 0:
        return N * N

    ans = 0
    for b in range(1, N + 1):
        now = K
        while K <= b and now <= N:
            ans += min(N, now + (b - K) - 1) - now + 1
            now += b
    return ans

def main():
    N, K = map(int, input().split())

    print(solve(N, K))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N;
  int a[N+2]; a[0] = 0; a[N+1] = 0;
  for(int i=1; i<N+1; i++){
    cin >> a[i];
  }
  int sum = 0;
  rep(i, N+1){
    sum += abs(a[i+1] - a[i]);
  }
  rep(i, N){
    if(((a[i+1]<a[i]) && (a[i+2]<a[i+1])) || ((a[i+1]>a[i]) && (a[i+2]>a[i+1]))){
      cout << sum << endl;
    }
    else{
      int k = min(abs(a[i+1] - a[i]), abs(a[i+2] - a[i+1]));
      cout << sum - 2*k << endl;
    }
  }
 
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	long long ans = 0;
	string x;
	cin >> x;
	stack<char> st;
	ans = x.size();

	st.push(x[0]);
	for(int i=1; i<x.size(); i++){
		if(x[i] == 'T' && (!st.empty() && st.top() == 'S')){
			st.pop();
			ans -= 2;
		}else{
			st.push(x[i]);
		}
	}

	if(st.empty()){
		cout << '0' << endl;
	}else{
		cout << st.size() << endl;
	}


	

	return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    string s;
    vector<char> fs,bs;
    bool fbs =true;
    cin>>s;
    ll q;
    cin>>q;
    rep(i,q){
        ll t;
        cin>>t;
        if(t==1){
            if(fbs)fbs=false;
            else fbs=true;
        }else{
            ll f;
            cin>>f;
            char c;
            cin>>c;
            if(f==1){
               if(fbs)fs.push_back(c);
               else bs.push_back(c);
            }else{
                if(fbs)bs.push_back(c);
               else fs.push_back(c);
            }
            
        }
    }
    if(fbs){
    reverse(ALL(fs));
    rep(i,fs.size())cout<<fs.at(i);
    cout<<s;
    rep(i,bs.size())cout<<bs.at(i);
    cout<<endl;
    }else{
        rep(i,bs.size())cout<<bs.at(bs.size()-i-1);
        reverse(ALL(s));
        cout<<s;
        rep(i,fs.size())cout<<fs.at(i);
        
    }
    
}
   



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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    double p = 1.0;
    for(int i = 1; i < min(k, n + 1); ++i) {
        int x = 1;
        for(; i * (1 << x) < k; x += 1);
        p -= (1.0 - pow(0.5, x)) / (double) n;
    }   
    cout << setprecision(12) << fixed << p << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a < b){
		cout << "a < b" << endl;
	}else if (a>b){
		cout << "a > b" << endl;
	}
	else if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,a[101],b[101][101],r[101];
int main()
{
 cin>>n>>m;
 for(int i=1;i<=m;i++) cin>>a[i];
 for(int i=1;i<=m;i++){
  for(int j=1;j<=n;j++){cin>>b[i][j];
   if(b[i][j]==a[i]) r[j]++;
   else r[a[i]]++;
  }
 }
 for(int i=1;i<=n;i++) cout<<r[i]<<endl;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if (a >= b) cout << "delicious" << endl;
    else if ((x + a) >= b) cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}

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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> A(N);

    rep(i, N){
        int tmp;
        cin >> tmp;
        A.at(i) = abs(tmp - X);
    }
    
    int ans = A.at(0);
    rep(i, N){
        ans = gcd(ans, A.at(i));
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
	 Scanner scan = new Scanner(System.in);
	 
	 int k = scan.nextInt(); 
	 int n = scan.nextInt();
	 int[] a = new int[n];
	 
	 for(int i = 0; i < n; i++ ) {
		 a[i] = scan.nextInt();
	 }
	 
	 int big = 0;
	 int first = 0;
	 int end = 0;
	 int tmp = 0;
	 int exc = 0;
	 int ans = 0;
	 int total = 0;
	 
	 for(int i = 0; i < n; i++) {
		 
		 
		 if(i < n - 1 ) {
			 tmp = a[i+1] - a[i];
			 total += tmp;
		 }
		 else if(i == n - 1) {
			 exc =  k - a[n-1] + a[0];
			 total += exc;
		 }
		 
		 
		 if(big < tmp ) {
			 big = tmp;
			 first = i;
			 end = i + 1;
		 }
		 if(big < exc ) {
			 big = exc;
			 first = 0;
			 end = n-1;
		 }
	 }
	 
	 if(first == 0) {
		 ans = a[end] - a[first];
	 }
	 else {
		 ans = k - a[end] + a[first];
	 }
	 
	 
	 System.out.println(total - big);
	 
	 
}
}


Measured memory_bytes: 89532
a, b, c, k = list(map(int, input().split()))

cnt = 0
ret = 0

cnt += a
ret += a
if(cnt > k):
  ret -= cnt-k
if(cnt < k):
  cnt += b
if(cnt < k):
  cnt += c
  ret -= c
  if(cnt > k):
    ret += cnt-k

print(ret)

Measured memory_bytes: 9192
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toLong)
    val A = readLine()!!.split(" ").map(String::toLong)
    val b0 = LongArray(41)
    val b1 = LongArray(41)
    val acc = LongArray(41)
    var b = 1L
    for (i in 0 until 41) {
        var c0 = 0L
        var c1 = 0L
        for (a in A) {
            if (((a shr i) and 1) == 1L) ++c1
            else ++c0
        }
        b0[i] = c0 * b
        b1[i] = c1 * b
        if (i > 0) {
            acc[i] += acc[i-1]
        }
        acc[i] += Math.max(c0, c1) * b
        b *= 2
    }
    (acc.joinToString(" "))
    var tmp = 0L
    val cand = mutableListOf<Long>()
    cand.add(0)
    for (i in 40 downTo 0) {
        b /= 2
        if ((K and b) == 0L) {
            tmp += b1[i]
        } else {
            if (i > 0) {
                cand.add(tmp + b1[i] + acc[i - 1])
            } else {
                cand.add(tmp + b1[i])
            }
            tmp += b0[i]
        }
    }
    println(Math.max(tmp, cand.max()!!))
}

Measured memory_bytes: 73996
A, B = (int(x) for x in input().split())
def exor(n):
  m = n % 4
  if m == 0:
    return n
  elif m == 1:
    return 1
  elif m == 2:
    return n+1
  else:
    return 0
ans = exor(A-1)^exor(B)
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main() {
    
    
    
    while(1) {
        
        string num;
        
        cin >> num;
        
        if (num[0] == '0') break;
        
        int sum = 0;
        
        for (int i = 0; i < num.size(); i ++) {
            
            sum += num[i] - '0';
            
        }
        
        cout << sum << endl;
        
        
    }
}


Measured memory_bytes: 3172
def inpl(): return list(map(int, input().split()))
W, H, w, h, x, y = inpl()

a = (min(W//2 , x + w//2) + max(-W//2, x-w//2))
b = (min(H//2 , y + h//2) + max(-H//2, y-h//2))
print(b/a)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    double a, b;
    cin >> a >> b;
    cout << a/b << endl;
    return 0;
}

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

int main() {
  long int a,b;
  cin >> a >> b;
  long long x = a * b;
  if(a<b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  cout << x/b;
}

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

int main(){
  int k, u, p, c, cnt, i, n;
  char str[300];
  k=u=p=c=0;
  cnt=0;
  scanf("%s", str);
  n=strlen(str);
  for(i=0; i<n; i++){
    if(str[i]=='K') k++;
    else if(str[i]=='U') u++;
    else if(str[i]=='P') p++;
    else if(str[i]=='C') c++;
  }
  for(i=0; i<n/4; i++){
    if(k>0 && u>0 && p>0 && c>0){
      cnt++;
      k--;
      u--;
      p--;
      c--;
    }
  }
  printf("%d\n", cnt);
  return 0;  
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];
    for(int i=0;i<m;i++) cin >> c[i] >> d[i];

    for(int i=0;i<n;i++){
        int md = INF;
        int mi = -1;
        for(int j=0;j<m;j++){
            int dd = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(dd < md){
                md = dd;
                mi = j;
            }
        }
        cout << mi+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

string s;

LL cntb;
LL ans;
int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'B')cntb++;
		else ans += cntb;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

string s;

signed main() {
	cin >> s;
	int n = s.length();
	int i, j;
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		for (j = i; j < n; j++) {
			if (s[j] != 'A' && s[j] != 'G' && s[j] != 'C' && s[j] != 'T') {
				break;
			}
		}
		ans = max(ans, j - i);
	}
	cout << ans << endl;
	return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

void addX(const int &node, const int &x, int *count, vector< vector<int> > &tree){
  count[node] += x;
  for(auto child:tree[node]){
    addX(child,x,count,tree);
  }
}

signed main() {
  int n,q;
  cin >> n >> q;
  vector< vector<int> > tree(n);
  int a,b;
  for(int i=0;i<n-1;i++){
    cin >> a >> b;
    a--;b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  unordered_map<int,int> parent;
  char flag[n] = {};
  queue<int> que;
  que.push(0);
  while(!que.empty()){
    int node = que.front();que.pop();
    for(auto ch:tree[node]) {
      if(ch!=parent[node]){
        parent[ch] = node;
        que.push(ch);
      }
    }
  }

  int count[n] = {};
  int p,x;
  for(int i=0;i<q;i++){
    cin >> p >> x;
    p--;
    count[p] += x;
  }

  que.push(0);
  while(!que.empty()){
    int node = que.front();que.pop();
    for(auto ch:tree[node]) {
      if(ch!=parent[node]){
        parent[ch] = node;
        que.push(ch);
        count[ch] += count[node];
      }
    }
  }

  for(auto x:count){
    cout << x << " ";
  }
  cout << endl;
  return 0;
}




Measured memory_bytes: 24920
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if((A==B & A!=C) || (A==C & A!=B) || (C==B & B!=A)){
      System.out.println("Yes");
    }else{
       System.out.println("No");
    }
  }
}

Measured memory_bytes: 35708
n = int(raw_input())
s = raw_input()
uppercase = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
t = ''
for ch in s:
    ind = uppercase.index(ch)
    ind = (ind + n) % 26
    t += uppercase[ind]
print t

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<pii, int> ppl;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

lint ans[110][110], c_dist[110][110];
lint q[60], r[60], c_cost[60];

int main(){
    int n, m, c, s, g;
    while(scanf("%d%d%d%d%d", &n, &m, &c, &s, &g) && n){
        --s; --g;
        vector<ppl> c_line[c];
        rep(i, m){
            int tx, ty, tc;
            lint td;
            scanf("%d%d%lld%d", &tx, &ty, &td, &tc);
            c_line[--tc].push_back(ppl(pii(--tx, --ty), td));
        }
        int p[c];
        rep(i, c) scanf("%d", &p[i]);
        rep(i, n){
            rep(j, n) ans[i][j] = 1e18;
            ans[i][i] = 0;
        }
        rep(comp, c){
            q[0] = 0;
            rep(i, p[comp]-1) scanf("%lld", &q[i+1]);
            q[p[comp]] = 1e18;
            rep(i, p[comp]) scanf("%lld", &r[i]);
            c_cost[0] = 0;
            rep(i, p[comp]-1) c_cost[i+1] = c_cost[i] + r[i] * (q[i+1] - q[i]);
            rep(i, n){
                rep(j, n) c_dist[i][j] = 1e18;
                c_dist[i][i] = 0;
            }
            for(ppl e: c_line[comp]){
                c_dist[e.fi.fi][e.fi.se] = min(c_dist[e.fi.fi][e.fi.se], (lint)e.se);
                c_dist[e.fi.se][e.fi.fi] = min(c_dist[e.fi.se][e.fi.fi], (lint)e.se);
            }
            rep(k, n)rep(i, n)rep(j, n)if(c_dist[i][k] < 1e18 && c_dist[k][j] < 1e18){
                c_dist[i][j] = min(c_dist[i][j], c_dist[i][k] + c_dist[k][j]);
            }
            rep(i, n)rep(j, n)if(c_dist[i][j] < 1e18){
                rep(k, p[comp]+1)if(c_dist[i][j] < q[k]){
                    lint tmp = c_cost[k-1] + r[k-1] * (c_dist[i][j] - q[k-1]);
                    ans[i][j] = min(ans[i][j], tmp);
                    break;
                }
            }
        }
        rep(k, n)rep(i, n)rep(j, n)if(ans[i][k] < 1e18 && ans[k][j] < 1e18){
            ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);
        }
        printf("%lld\n", (ans[s][g] == 1e18 ? -1 : ans[s][g]));
    }
}


Measured memory_bytes: 3504
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> VI;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	int maxn = 1e5 + 10;
	VI used(maxn, 0);
	int dups = 0;
	for (int i = 0, x; i < n; ++i) {
		cin >> x;
		if (used[x]) ++dups;
		used[x] = 1;
	}
	int unq = n - dups;
	if (dups&1) --unq;
	cout << unq;
}

Measured memory_bytes: 640