akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
#include <tuple>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)
#define tl tuple<ll,ll,ll>


ll N,C;
vector<ll> s(100010);
vector<ll> t(100010);
vector<ll> c(100010);
vector<ll> ctl(200020);
vector<ll> cover(200020);
ll ans = 0;


int main() {
    cin >> N >> C;
    rep(i,N){
        cin >> s[i] >> t[i] >> c[i];
    }
    rep(i,31){
        rep(j,200020) ctl[j] = 0;
        rep(j,N){
            if (c[j] == i){
                ctl[s[j]*2-1]++;
                ctl[t[j]*2]--;
            }
        }
        rep(j,200020-1) ctl[j+1] += ctl[j];
        rep(j,200020){
            if (ctl[j] > 0) cover[j]++;
        }
    }
    rep(i,200020){
        ans = max(ans,cover[i]);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5888
def read():
    N = int(input().strip())
    return N, 

def solve(N):
    x = 1
    y = N - x
    count = 0
    while x < N - x:
        x += 1
    return x - 1

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 38384
n, t = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
m = []
for j in range(n):
    if l[j][1] <= t:
        m.append(l[j][0])
if len(m) == 0:
    print("TLE")

else:
    print(min(m))
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define le long long

using namespace std;

int main()
{
    string s;
    cin >> s;
    int m = 0, r = 0;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == 'S')
            r = 0;
        else
            r++;
        m = max(r, m);
    }
    cout << m;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

/////////////////////////////////////////////////////////
class UnionFind {
 public:
  static const int MAX_N_LIB = (int)(2e5 + 100);

  int uf_par[MAX_N_LIB];
  int uf_rank[MAX_N_LIB];
  int uf_size[MAX_N_LIB];

  UnionFind(int n) { init(n); }

  void init(int n) {
    for (int i = 0; i < n; ++i) {
      uf_par[i] = i;
      uf_rank[i] = 0;
      uf_size[i] = 1;
    }
  }

  int find(int x) {
    if (uf_par[x] == x)
      return x;
    else {
      return uf_par[x] = find(uf_par[x]);
    }
  }

  void unite(int leaf_x, int leaf_y) {
    int x = find(leaf_x);
    int y = find(leaf_y);

    if (x == y) return;

    if (uf_rank[x] < uf_rank[y]) {
      uf_par[x] = y;
      uf_size[y] += uf_size[x];
    } else if (uf_rank[x] > uf_rank[y]) {
      uf_par[y] = x;
      uf_size[x] += uf_size[y];
    } else {
      uf_par[y] = x;
      uf_size[x] += uf_size[y];
      uf_rank[x] += 1;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return uf_size[find(x)]; }
};
/////////////////////////////////////////////////////////

const int MAX_N = (int)(1e5 + 5);

int n, m;
vector<pair<int, int>> edge;

int out[MAX_N];
vector<int> graph[MAX_N];

UnionFind uf(MAX_N);

vector<pair<int, int>> ans;

void routine(int cur, int parent) {
  if (out[cur] % 2 == 1) {
    ans.push_back(make_pair(cur, parent));
    out[cur] += 1;
  } else {
    ans.push_back(make_pair(parent, cur));
    out[parent] += 1;
  }
  return;
}

void dfs(int cur, int parent) {
  if (graph[cur].size() > 1) {
    for (auto &e : graph[cur]) {
      if (e == parent) continue;
      dfs(e, cur);
    }
  }

  routine(cur, parent);
  return;
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);

    edge.push_back(make_pair(a, b));
  }

  if (m % 2 == 1) {
    printf("%d\n", -1);
    return 0;
  }

  for (int i = 1; i <= n; ++i) {
    out[i] = 0;
  }

  for (auto &e : edge) {
    if (uf.same(e.first, e.second)) {
      int inkey = min(e.first, e.second);
      int outkey = max(e.first, e.second);
      ans.push_back(make_pair(outkey, inkey));
      out[outkey] += 1;
    } else {
      graph[e.first].push_back(e.second);
      graph[e.second].push_back(e.first);
      uf.unite(e.first, e.second);
    }
  }

  for (auto &e : graph[1]) {
    dfs(e, 1);
  }

  for (auto &e : ans) {
    printf("%d %d\n", e.first, e.second);
  }

  return 0;
}


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

int N,M;
int A, B, C;
struct edge {
  int to;
  ll t;
  edge(){

  }
  edge(int to,ll t):to(to),t(t){}
};
struct state{
  int id,v,f;
  ll c;
  state(){

  }
  state(int id,int v,int f,ll c):id(id),v(v),f(f),c(c){}
  bool operator<(const state &st) const {
    return c > st.c;
  }
};

ll H[555][55][2];
const ll INF = (ll)(1<<29)*(ll)(1<<29);
vector<edge> G[555];

ll dijk(int v0){
  priority_queue<state> q;
  fill( H[0][0], H[553][51], INF );
  q.push( state(0,v0,0,0) );
  H[0][v0][0] = 0LL;
  while( !q.empty() ){
    state p = q.top(); q.pop();
    if( H[p.id][p.v][p.f] < p.c ) continue;
    for( edge e : G[p.id] ){
      int nv = (A * p.v + B)%C;

      int nf = p.f; if( e.to == N-1 ) nf = 1;
      ll nc = (ll)p.v * e.t + p.c;
      if( H[e.to][nv][nf] > nc ){
        H[e.to][nv][nf] = nc;
        q.push( state( e.to, nv, nf, nc ) );
      }
    }
  }
  ll res = INF;
  for(int i=0;i<=C;i++)
    res = min( res, H[0][i][1] );
  return res;
}

int main(){
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int x,y; ll t;
    cin >> x >> y >> t; --x; --y;
    G[x].emplace_back( y, t );
    G[y].emplace_back( x, t );
  }
  int v0; cin >> v0;
  cin >> A >> B >> C;
  cout << dijk(v0) << endl;
}

Measured memory_bytes: 9688
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    int n; cin >> n;
    map<int,int> mp;
    map<int,int>::iterator itr;
    for(int i=0; i<n; i++){
        int x; cin >> x;
        itr = mp.find(x);
        if(itr!=mp.end()){
            mp[x] += 1;
        }
        else{
            mp[x] = 1;
        }
    }
    int ans = 0;
    for(itr=mp.begin(); itr!=mp.end(); itr++){
        if(itr->second % 2 == 1) ans += 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4864
#include <stdio.h>
#define N 251

int main() {
  int i, h;
  int A[N];

  scanf("%d", &h);
  for(i = 1; i <= h; i++) {
    scanf("%d", &A[i]);
  }

  for(i = 1; i <= h; i++) {
    printf("node %d: key = %d, ", i, A[i]);
    if(i != 1) printf("parent key = %d, ", A[i/2]);
    if(i*2 <= h) printf("left key = %d, ", A[i*2]);
    if(i*2+1 <= h) printf("right key = %d, ", A[i*2+1]);
    printf("\n");
  }

  return 0;
}

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

map<int,int> a;
long long b[200005]={0};

int main() {
    long long m,n,i,cnt=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>b[i];
        a[b[i]+i]++;
    }
    for(i=1;i<=n;i++){
        cnt+=a[i-b[i]];
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 22200
A,B,C = map(int,input().split())
K = int(input())
if A<B<C:
  print("Yes")
  exit()
for i in range(K):
  if A >= B:
    B = B*2
  elif B >= C:
    C = C*2
  if A<B<C:
    print("Yes")
    exit()
print("No")

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

using namespace std;


int main()
{
    long A, B;
    int K;

    cin >> A >> B >> K;

    for (int i = 0; i < K; i++) {
        if (i % 2 == 0) {
            //takahashi
            if (A % 2 != 0) {
                A--;
            } 
            B += A/2;
            A /= 2;
        } else {
            if (B % 2 != 0) {
                B--;
            }
            A += B/2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;
    return 0;   
}

Measured memory_bytes: 256
h,w=map(int,input().split())

if h%3==0 or w%3==0:
    print(0)
    exit()
T=min(h,w)

hh=h//2
ww=w//2
hhh=-(-h//3)
www=-(-w//3)
a=www*h
b=hh*(w-www)
c=h*w-a-b
L=max(abs(a-b),abs(b-c),abs(c-a))
a=hhh*w
b=ww*(h-hhh)
c=h*w-a-b
R=max(abs(a-b),abs(b-c),abs(c-a))
hhh=h//3
www=w//3
a=www*h
b=hh*(w-www)
c=h*w-a-b
U=max(abs(a-b),abs(b-c),abs(c-a))
a=hhh*w
b=ww*(h-hhh)
c=h*w-a-b
D=max(abs(a-b),abs(b-c),abs(c-a))
T=min(T,L,R,U,D)
print(T)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    const int f=55555;
    bool isPrime[f+1];
    fill(isPrime,isPrime+f+1,true);
    isPrime[0]=isPrime[1]=false;
    for(int i=2;i<=f;i++){
        if(isPrime[i]){
            for(int j=i+i;j<=f;j+=i){
                isPrime[j]=false;
            }
        }
    }
    int n;
    cin>>n;
    for(int i=0;n;i++){
        if(isPrime[i]&&i%5==1){
            cout<<i;
            if(--n)cout<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(std::string S, std::string T, long long A, long long B, std::string U){
  map<string, int> m;
  m[S] = A;
  m[T] = B;
  m[U] += -1;
  cout << m[S] << ' ' << m[T] << endl;
}

signed main(){
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  std::string U;
  std::cin >> U;
  solve(S, T, A, B, U);
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll fun(vector<ll>&w,vector<ll>&v,ll n,ll W)
{
    ll dp[n+1][W+1];
    for(ll i=0;i<n+1;i++)
    {
        for(ll j=0;j<W+1;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
        }
    }
    for(ll i=1;i<n+1;i++)
    {
        for(ll j=1;j<W+1;j++)
        {
            
             if(w[i-1]<=j)
            {
                dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    return dp[n][W];
}
int main()
{
    ll n,W;
    cin>>n>>W;
    vector<ll>w;
    vector<ll>v;
    for(ll i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        w.push_back(a);
        v.push_back(b);
    }
    
cout<<fun(w,v,n,W)<<endl;
    return 0;
}


Measured memory_bytes: 82408
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define sint(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;


typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    map<char,int> mp;
    mp['q'] = 1,mp['w'] = 1,mp['e'] = 1,mp['r'] = 1,mp['t'] = 1,mp['a'] = 1,mp['s'] = 1,mp['d'] = 1,mp['f'] = 1;
    mp['g'] = 1,mp['z'] = 1,mp['x'] = 1,mp['c'] = 1,mp['v'] = 1,mp['b'] = 1;
    while(1){
        string s;
        cin >> s;
        if(s == "#"){
            break;
        }
        int ans = 0;
        int bf = mp[s[0]];
        rep(i,s.length()-1){
            if(mp[s[i+1]] != bf){
                bf = mp[s[i+1]];
                ans++;
            }
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] lines=br.readLine().split(" ");
        int a=Integer.parseInt(lines[0]);
        int b=Integer.parseInt(lines[1]);
        int c=Integer.parseInt(lines[2]);
        int count=0;
        for(int i=a;i<=b;i++){
            if(c%i==0){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24472
#include <iostream>
#include <cstdlib>
using namespace std;
int S[1000], top;
void push(int i){
	S[top] = i;
	top++;
}
int pop() {
	int i = S[top-1];
	top--;
	return i;
}
int main() {
	int i, j;
	char c[100];
	while (cin >> c) {
		if (c[0] == '+') {
			i = pop();
			j = pop();
			push(i + j);
		}
		else if (c[0] == '-') {
			i = pop();
			j = pop();
			push(j - i);
		}
		else if (c[0] == '*') {
			i = pop();
			j = pop();
			push(i*j);
		}
		else push(atoi(c));
	}
	cout << pop() << endl;
	return 0;
}

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

int main(){
  int N; cin >> N;
  int d[110];
  for(int i = 0; i < N; i++) cin >> d[i];
  
  
  int num[110] = {0}; //バケット, 0<= d <= 100より、この大きさに。
  for(int i = 0; i < N; i++){
    num[d[i]]++;
  }
  
  int ans = 0;
  for(int i = 0; i <=100; i++){
    if(num[i] > 0) ans++;
  }  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int long long
#define mp make_pair
//#define for(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define N 1000000007
#define pq priority queue
#define pb push_back
#define mt make_tuple
#define prec(a) fixed<<setprecision(9)<<a
#define endl "\n"
#define fast_set s.max_load_factor(0.25);s.reserve(500);
const long double PI = (long double)(3.1415926535897932384626433832795);
int parity_check(int n)
{
	int par=n;
	par = par ^ (par >> 1); 
    par = par ^ (par >> 2); 
    par = par ^ (par >> 4); 
    par = par ^ (par >> 8); 
    par = par ^ (par >> 16); 
  
    if(par%2==1)
    {
    	return 1;
    }
    else
    {
    	return 0;
    }
    // true means odd parity
    // false means even parity
}
ll gcd(ll a,ll b)
{
	if(a==0)
	{
		return b;
	}
	return gcd(b%a,a);
}
int sz[100001];
ll lcm(ll a,ll b)
{
	ll pro=a*b;
	ll ans=gcd(a,b);
	pro=pro/ans;
	return pro;
}
ll fast_power(ll a,ll b,ll p)
{
	if(b==0)
	{
		return (1%p);
	}
	ll t=fast_power(a,b/2,p);
	ll ans=(t*t)%p;
	if(b%2)
	{
		ans=(ans*(a%p))%p;
	}
	return ans;
}

void dfs(ll s,vector<ll>vert,map<ll,ll>&visited,set<pair<ll,ll> >se)
{
	visited[s]=1;
	for(ll i=0;i<vert.size();i++)
	{
		if(!visited[vert[i]]&&se.find(mp(s,vert[i]))!=se.end())
		{
			visited[vert[i]]=1;
			dfs(vert[i],vert,visited,se);
			//sz[s] = sz[v[s][i]]+sz[s];
		}
	}
	//sz[s]=sz[s]+1;
}
ll fact(int n)
{
	ll prod=1;
	for(int i=1;i<=n;i++)
	{
		prod=prod*i;
	}
	return prod;
}

ll connec(vector<ll> vert,map<ll,ll>visited,set<pair<ll,ll> >s)
{
	ll count=0;
	for(ll i=0;i<vert.size();i++)
	{
		if(!visited[vert[i]])
		{
			dfs(vert[i],vert,visited,s);
			count++;
		}
	}
	return count;
}
int main()
{
	fast;
	
	int n,i,j,k,a,b;
	cin>>n;
	vector<pair<int,int> >v;
	for(i=0;i<n;i++)
	{
		cin>>a>>b;
		v.pb(mp(a,b));
	}
	double sum=0.000;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			ll dist=((v[j].F - v[i].F)*(v[j].F - v[i].F))+((v[j].S - v[i].S)*(v[j].S - v[i].S));
			//cout<<dist<<endl;
			sum=sum+(double)sqrt(dist);
			//cout<<sum<<endl;
		}
	}
	sum=sum*(double)2;
	sum=sum/(double)n;

	cout<<prec(sum);
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> value(N);
    for (int i = 0; i < N; i++) cin >> value.at(i);
    vector<int> cost(N);
    for (int i = 0; i < N; i++) cin >> cost.at(i);
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int k = value.at(i) - cost.at(i);
        if (k >= 0) ans += k;
    }
    
    cout << ans << endl;
}

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

typedef struct {
	int a,b;
	int cost;
} bridge_t;

int qsort_comp(const void* x,const void* y) {
	const bridge_t* a=(const bridge_t*)x;
	const bridge_t* b=(const bridge_t*)y;
	if((a->cost)>(b->cost))return 1;
	if((a->cost)<(b->cost))return -1;
	return 0;
}

int tosi_num,bridge_num;
bridge_t* bridge_list;

int tosi_uf[100];

void uf_init(void) {
	int i;
	for(i=0;i<100;i++)tosi_uf[i]=0;
}

void uf_merge(int a,int b) {
	int next;
	int rank_a=0,rank_b=0;
	while(tosi_uf[a]>0) {
		next=tosi_uf[a]-1;
		if(tosi_uf[next]>0)tosi_uf[a]=tosi_uf[next];
		a=next;
		rank_a++;
	}
	while(tosi_uf[b]>0) {
		next=tosi_uf[b]-1;
		if(tosi_uf[next]>0)tosi_uf[b]=tosi_uf[next];
		b=next;
		rank_b++;
	}
	if(a!=b) {
		if(rank_a<=rank_b)tosi_uf[a]=b+1;
		else tosi_uf[b]=a+1;
	}
}

int uf_isgroup(int a,int b) {
	int next;
	while(tosi_uf[a]>0) {
		next=tosi_uf[a]-1;
		if(tosi_uf[next]>0)tosi_uf[a]=tosi_uf[next];
		a=next;
	}
	while(tosi_uf[b]>0) {
		next=tosi_uf[b]-1;
		if(tosi_uf[next]>0)tosi_uf[b]=tosi_uf[next];
		b=next;
	}
	return (a==b)?1:0;
}

int main(void) {
	int i,j;
	int result;
	while(1) {
		scanf("%d%d",&tosi_num,&bridge_num);
		if(tosi_num==0 && bridge_num==0)break;
		bridge_list=malloc(bridge_num*sizeof(bridge_t));
		if(bridge_list==NULL)return 1;//error
		for(i=0;i<bridge_num;i++) {
			scanf("%d%d%d",
				&bridge_list[i].a,&bridge_list[i].b,
				&bridge_list[i].cost);
		}
		qsort(bridge_list,bridge_num,sizeof(bridge_t),qsort_comp);
		uf_init();
		result=0;
		for(i=0,j=1;i<bridge_num && j<tosi_num;i++) {
			if(!uf_isgroup(bridge_list[i].a,bridge_list[i].b)) {
				uf_merge(bridge_list[i].a,bridge_list[i].b);
				result+=bridge_list[i].cost;
				j++;
			}
		}
		free(bridge_list);
		printf("%d\n",result);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

int n;
long long k;

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

int main() {
	std::cin >> n >> k;
	long long m = 0;
	long long g;
	for (int i = 0; i < n; ++i) {
		long long a;
		std::cin >> a;
		if (i == 0)
			g = a;
		m = std::max(m, a);
		g = gcd(a, g);
	}

	if (k <= m && k%g == 0)
		std::cout << "POSSIBLE" << std::endl;
	else
		std::cout << "IMPOSSIBLE" << std::endl;

	return 0;
}


Measured memory_bytes: 764
abcd = gets.chomp!.chars
ops = ['+', '-']
(1 << 3).times do |i|
  ans = 0
  ans = eval("#{abcd[0]} #{ops[i >> 0 & 1]} #{abcd[1]} #{ops[i >> 1 & 1]} #{abcd[2]} #{ops[i >> 2 & 1]} #{abcd[3]}")
  if ans == 7
    puts "#{abcd[0]}#{ops[i >> 0 & 1]}#{abcd[1]}#{ops[i >> 1 & 1]}#{abcd[2]}#{ops[i >> 2 & 1]}#{abcd[3]}=7"
    break
  end
end


Measured memory_bytes: 14264
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
 
int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while (a >= b)
    {
        b *= 2;
        cnt++;
    }
    while (b >= c)
    {
        c *= 2;
        cnt++;
    }
    if (cnt <= k)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <boost/range/adaptors.hpp>
#include <iomanip>
#include <tuple>
#include <numeric>

int main() {
    long long N;
    long long K;
    std::cin >> N >> K;

    if (N == 0) {
        std::cout << 0 << std::endl;
    } else {
        long long x = N / K;
        std::cout << std::min(N - K * x, K * x + K - N) << std::endl;
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    
    vector<string> v(N), w(N);
    for (int i=0; i<N; ++i) {
        cin >> v[i];
        w[i] = v[i];
    }
    sort(w.begin(), w.end());
    
    for (int i=0; i<N; ++i) {
        int win = lower_bound(w.begin(), w.end(), v[i]) - w.begin();
        int lose = w.end() - upper_bound(w.begin(), w.end(), v[i]);
        int draw = N - win - lose - 1;
        cout << win * 3 + draw << endl;
    }
    return 0;
}


Measured memory_bytes: 8588
#include <iostream>

using namespace std;

int main() {
    long long n, d;
    cin >> n >> d;

    int res = 0;
    for (int i = 0; i < n; i++) {
        long long x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    vector<vector<int>> dp(1<<N, vector<int>(51, 1<<30));
    dp[0][0] = 0;
    for(int i=0; i<(1<<N); i++){
        int cnt = __builtin_popcount(i);
        for(int j=0; j<=50; j++){
            for(int k=0; k<N; k++){
                if(i&(1<<k)) continue;
                int dist = abs(cnt-k);
                int val;
                if(dist%2==0) val = A[k];
                else val = B[k];
                if(val < j) continue;
                int to = i|(1<<k);

                int dist2=0;
                for(int j=0; j<k; j++)
                    if(!(i&(1<<j))) dist2++;
                dp[to][val] = min(dp[to][val], dp[i][j] + dist2);
            }
        }
    }
    int ans = *min_element(dp.back().begin(), dp.back().end());
    if(ans==(1<<30)) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 65792
//Priyanshu Kumar : IIIT Allahabad
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define MAX 100005
#define MOD 1000000007
#define sz size()
#define ln length()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pin(n) printf("%d\n",n);
#define pl(n) printf("%lld",n)
#define pln(n) printf("%lld\n",n);
#define FUCK_YEAH ios_base::sync_with_stdio(false);cin.tie(NULL)
inline ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
inline ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
inline ll powmod(ll a,ll b,ll mod) 
{
    ll res=1;
    a%=mod; 
    assert(b>=0); 
    for(;b;b>>=1)
    {
        if(b&1)res=res*a%mod;
        a=a*a%mod;
    }
    return res;
}
inline ll mulmod(ll a, ll b, ll c)
{
    if(!b)return 0;
    ll x = mulmod(a, b/2, c);
    if (b & 1)return (x+x+a)%c;
    return (x+x)%c;
}

int main()
{
    FUCK_YEAH;
    ll a,b;
    string s;
    cin >> a >> b >> s;
    ll len = s.length(), f = 0;
    for(int i= 0; i < len; i++) {
        if((i == a && s[i] == '-') || (i != a && s[i] >= '0' && s[i] <= '9')) {
            //good
        }
        else {
            f = 1;
            break;
        }
    }
    if(f) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
import math
N, K = map(int,input().split())
MOD = 10**9 + 7
ans = 0
if K == 1:
    print(1)
else:
    ans = 0
    a = [0]*(K+1)
    for k in range(K,0,-1):
        s = K//k
        t = k*2
        u = 0
        while t <= K:
            u += a[t]
            t += k
        ans += k*(pow(s,N,MOD)-u)
        ans %= MOD
        a[k] = pow(s,N,MOD)-u
    print(ans)


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

int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}

int gcd_3(int x, int y, int z){
  return gcd(gcd(x,y),z);
}

int main() {
  
  int k; cin >> k;
  
  int ans = 0;
  for(int a=1; a<=k; a++){
    for(int b=a; b<=k; b++){
      for(int c=b; c<=k; c++){
        
        if(a==b && b==c) ans += gcd_3(a,b,c);
        else if(a != b && b != c) ans += 6 * gcd_3(a,b,c);
        else ans += 3 * gcd_3(a,b,c);
        
      }
    }
  }
  
  cout << ans << endl;
}


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

int main() {
	int n, k; cin >> n >> k;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	int cnt = 0; n--; k--;
	while (n > 0) {
		n -= k, cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
S = []
g1 = []
g2 = []
g3 = []

ans = 0
for _ in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == 'B' and s[-1] == 'A':
        g1.append(s)
    if s[0] == 'B' and s[-1] != 'A':
        g2.append(s)
    if s[0] != 'B' and s[-1] == 'A':
        g3.append(s)


# g1が存在しない = B* と *A の組を作る
if len(g1) == 0:
    ans += min(len(g2), len(g3))
    print(ans)

# B*A が存在する場合
else:
    if len(g2) + len(g3) == 0:
        # B*A しか存在しない場合，これをくっつける
        ans += len(g1) - 1
    else:
        # B*A がlen(g1)個
        # B*  がlen(g2)個
        # *A  がlen(g3)個 ある
        # -> *A B*A B* の形を作れるだけ作る
        ans += len(g1) + min(len(g2), len(g3))
        pass
    print(ans)


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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define qi queue<int>
#define si set<int>
#define inf LLONG_MAX


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

	int n,i;
	cin>>n;
	inp(a,n,0);
	int ans=1000,mn=a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]>mn)
		{
			int s=ans/mn;
			ans%=mn;
			ans+=s*a[i];
			mn=a[i];
		}
		mn=min(mn,a[i]);
	}
	cout<<ans;
	return 0;
}


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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  ll N;
  cin >> N;
  cout << pow(N , 3) << endl;
  return 0;
}



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

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

  while (1) {
    int n = s.size();
    if (n % 2 == 0) {
      string t = s.substr(n / 2), u = s.substr(0, n / 2);
      if (t == u) {
        cout << n << endl;
        return 0;
      }
    }
    s.pop_back();
  }
}

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

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n), b(n);
    int res = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n - 1; i++){
        b[i] = a[i+1] - a[i];
    }
    b[n-1] = k - a[n-1] + a[0];
    res = k -*max_element(begin(b), end(b));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
int main()
{
    int a,b,res,c;
    scanf("%d %d",&a,&b);
    c=0;
    res=1;
    while(res<b)
    {
        res--;
        res+=a;
        c++;
    }
    printf("%d\n",c);
    return 0;
}


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

using namespace std;

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

constexpr int cm = 1<<17;
char buff[cm], *ci = buff + cm, ct;

inline char readchar() {
  if (ci - buff == cm) {
    fread(buff, 1, cm, stdin);
    ci = buff;
  }
  return *ci++;
}

inline int readint() {
  int num = 0;
  if (ci - buff + 16 > cm) {
    while ((ct = readchar()) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  } else {
    while ((ct = *ci++) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  }
  return num;
}

int main(){
  auto start = chrono::system_clock::now();

  int n = readint();

  vector<queue<int>> v(1002, queue<int> ());
  rep(i, n) {
    rep(j, n - 1) {
      int a = readint();
      v[i + 1].emplace(a);
    }
  }

  for (int day = 1; day <= n * (n - 1) / 2; ++day) {
    bool done[1002] = {};
    for (int i = 1; i <= n; ++i) {
      if (done[i]) continue;
      if (v[i].empty()) continue;
      int next = v[i].front();
      if (done[next]) continue;
      if (v[next].front() == i) {
        v[i].pop(); v[next].pop();
        done[i] = done[next] = true;
      }
    }
    if (all_of(done, done + n, [](const bool& x){return x == false;})){
      printf("-1");
      return 0;
    }
    if (all_of(v.begin(), v.end(), [](const queue<int>& x){return x.empty();})) {
      printf("%d", day);
      return 0;
    }
    auto now = chrono::system_clock::now();
    auto dur = now - start;
    auto msec = chrono::duration_cast<chrono::microseconds>(dur).count();
    if (msec >= 26900) {
      printf("%d", n * (n - 1) / 2);
      return 0;
    }
  }

  return 0;
}


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

int main(){
	int n;
	int x[210000];
	cin>>n;
	for(int i=0; i<n; i++) cin>>x[i];
	int y[210000];
	for(int i=0; i<n; i++) y[i]=x[i];
	sort(y, y+n);
	for(int i=0; i<n; i++){
		if(x[i]<=y[(n/2)-1]) cout<<y[n/2]<<endl;
		else if(x[i]>=y[n/2]) cout<<y[(n/2)-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,x;
inline ll f(ll n){
	if(-1==n){
		return 0;
	}else{
		return n/x+1;
	}
}
int main(){
	cin>>a>>b>>x;
	cout<<f(b)-f(a-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int m = in.ni();
        int sum = 0;
        for (int i = 0; i < m; i++) {
            sum += in.ni();
        }
        if(sum>n)out.println(-1);
        else out.println(n-sum);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 34212
from collections import deque
S = input()
d = deque()
for s in S:
  d.append(s)
flag = True # 正順ならTrue, 逆順ならFalse
for i in range(int(input())):
  query = input().split()
  if query[0] == '1':
    flag = not flag
  if query[0] == '2':
    if query[1] == '1':
      if flag:
        d.appendleft(query[2])
      if not flag:
        d.append(query[2])
    if query[1] == '2':
      if flag:
        d.append(query[2])
      if not flag:
        d.appendleft(query[2])
if flag:
  for i in d:
    print(i, end='')
if not flag:
  for i in reversed(d):
    print(i, end='')

Measured memory_bytes: 94552
A, B = list(map(int, input().split()))
m = 0
if A < B:
    m = m + B
    B = B -1
else:
    m = m + A
    A = A - 1

if A < B:
    m = m + B
    B = B -1
else:
    m = m + A
    A = A - 1

print(m)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int M, D;
    cin >> M >> D;
    int ans = 0;
    rep(i, 10, D + 1) {
        int mul = (i / 10) * (i % 10);
        if (M >= mul && i / 10 >= 2 && i % 10 >= 2) ans++;
    }
    
    output(ans);
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=190;

int n,m;
char mp[N][N];
int f[N][N][N],g[N][N][N],sum[N][N];
int nf[N][N][N],ng[N][N][N];

bool all_same(int h1,int h2,int l1,int l2)
{
	int x=(h2-h1+1)*(l2-l1+1),y=sum[h2][l2]-sum[h2][l1-1]-sum[h1-1][l2]+sum[h1-1][l1-1];
	return (y==0)||(x==y);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",mp[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+(mp[i][j]=='.');
	for(int h1=1;h1<=n;h1++)
	{
		for(int h2=h1;h2<=n;h2++)
		{
			for(int l1=1;l1<=m;l1++)
			{
				int l=l1-1,r=m,mid;
				while(l<r)
				{
					mid=(l+r+1)/2;
					if(all_same(h1,h2,l1,mid))l=mid;
					else r=mid-1;
				}
				f[h1][h2][l1]=l;
				//cerr<<h1<<' '<<h2<<' '<<l1<<' '<<l<<'\n';
			}
		}
		for(int l1=1;l1<=m;l1++)
		{
			for(int l2=l1;l2<=m;l2++)
			{
				int l=h1-1,r=n,mid;
				while(l<r)
				{
					mid=(l+r+1)/2;
					if(all_same(h1,mid,l1,l2))l=mid;
					else r=mid-1;
				}
				g[l1][l2][h1]=l;
			}
		}
	}
	for(int ans=0;;++ans)
	{
		if(f[1][n][1]==m)return printf("%d\n",ans),0;
		for(int h1=1;h1<=n;h1++)
		{
			for(int h2=h1;h2<=n;h2++)
			{
				for(int l1=1,nx;l1<=m;l1++)
				{
					nx=f[h1][h2][l1];
					if(nx<m)nx=f[h1][h2][nx+1];
					nf[h1][h2][l1]=nx;
				}
			}
			for(int l1=1;l1<=m;l1++)
			{
				for(int l2=l1,nx;l2<=m;l2++)
				{
					nx=g[l1][l2][h1];
					if(nx<n)nx=g[l1][l2][nx+1];
					ng[l1][l2][h1]=nx;
				}
			}
		}
		for(int h1=1;h1<=n;h1++)
		{
			for(int h2=h1;h2<=n;h2++)
			{
				for(int l1=1,r;l1<=m;l1++)
				{
					r=nf[h1][h2][l1];
					while(r<m)
					{
						if(ng[l1][r+1][h1]>=h2)++r;
						else break;
					}
					f[h1][h2][l1]=r;
				}
			}
			for(int l1=1;l1<=m;l1++)
			{
				for(int l2=l1,r;l2<=m;l2++)
				{
					r=ng[l1][l2][h1];
					while(r<n)
					{
						if(nf[h1][r+1][l1]>=l2)++r;
						else break;
					}
					g[l1][l2][h1]=r;
				}
			}
		}
	}
}

Measured memory_bytes: 106752
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;



int main() {

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

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

	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}




Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    x, y = [int(x) for x in input().strip().split()]
    dist = abs(abs(x) - abs(y))
    if x + dist == y:
        print(dist)
    elif - x + dist == y or - (x + dist) == y:
        print(dist + 1)
    elif - (- x + dist) == y:
        print(dist + 2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		b,c,h,i,j,k,l,m,n,q,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;
	map<ll,ll>	ac;
	for(i=0;i<n;i++) {
		cin >> x;
		ac[x]++;
		ans += x;
	}
	cin >> q;

	vector<ll>	bb(q),cc(q);
	for(i=0;i<q;i++) {
		cin >> bb[i] >> cc[i];
	}
	for(i=0;i<q;i++) {
		b = bb[i];
		c = cc[i];
		if (ac.count(b)) {
			ans += (c-b)*ac[b];
			ac[c] += ac[b];
			ac.erase(b);
		}

		cout << ans << endl;
	}

	return 0;
}




Measured memory_bytes: 8800
import sys
N=int(input())
for i in range(N):
    a=input()
    b=input()
    len_a=len(a)
    len_b=len(b)
    c=[]
    kuriage=0
    if(len_a>=len_b):
        for i in range(len_b):
            c.append((kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))%10)
            kuriage=(kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))//10
        for i in range(len_b,len_a):
            c.append((kuriage+int(a[len_a-1-i]))%10)
            kuriage=(kuriage+int(a[len_a-1-i]))//10



    else :
        for i in range(len_a):
            c.append((kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))%10)
            kuriage=(kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))//10
        for i in range(len_a,len_b):
            c.append((kuriage+int(b[len_b-1-i]))%10)
            kuriage=(kuriage+int(b[len_b-1-i]))//10

    if(kuriage==1):
        c.append(1)

    if(len(c)>=81):
        print('overflow')

    else:
        for i in c[::-1]:
            print(i,end='')
        print('')

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

//関数


    
    
    
//main関数
int main() {
    
    
    //入力
    int N;
    string s,t;
    cin>>N>>s>>t;
    
    
    
    
    
    
    
    //計算
    int ans;
    for(int i=0;i<=N;i++){
        if(s.substr(N-i,i)==t.substr(0,i)){
            ans=2*N-i;
        }
    }
    
    //出力
    cout <<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ITP1_6_A
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.ReadLine();
			List<string> vs = Console.ReadLine().Split(' ').ToList();

			vs.Reverse();
			int i = 0;
			foreach(string v in vs) {
				if(i++ == 0) {
					Console.Write($"{v}");
				}
				else {
					Console.Write($" {v}");
				}
			}
			Console.WriteLine();
		}
	}
}



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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T, typename U>
ostream& operator<<(ostream& o, const pair<T,U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

const int INF = 1e18;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  vi hs(n);
  for (int& hi : hs)
    cin >> hi;
  vvi g(n);
  for (int i=0; i<m; ++i) {
    int ai, bi;
    cin >> ai >> bi;
    --ai; --bi;
    g[ai].pb(bi);
    g[bi].pb(ai);
  }

  int cnt = 0;
  for (int i=0; i<n; ++i) {
    bool perf = true;
    for (int neigh : g[i]) {
      if (hs[neigh] >= hs[i]) {
        perf = false;
        break;
      }
    }
    cnt += perf;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 9800
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  string S[101];
  map<string,bool> mp;
  cin >> N;
  REP(i,N)cin >> S[i];
  REP(i,N-1){
    if((S[i][S[i].size()-1] != S[i+1][0]) || (mp[S[i]])){
      cout << "No" << endl;
      return 0;
    }
    mp[S[i]] = true;
  }
  if(mp[S[N-1]]){
    cout << "No" << endl;
  	return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
class SegTree
  attr_reader :size, :e, :f
  attr_accessor :seg

  def self.create(a=[],e,f)
    n = 1
    n *= 2 while n < a.size
    this = new(n,e,f)
    a.size.times do |i|
      this.seg[i+n] = a[i]
    end
    (n-1).downto(1) do |i|
      this.seg[i] = f[ this.seg[i*2],this.seg[i*2+1] ]
    end
    this
  end

  def initialize(n=2**32,e,f)
    @size = n
    @e = e
    @f = f
    @seg = Array.new(size*2, e)
  end

  def [](i)
    i += size
    seg[i]
  end

  def update(i,x)
    i += size
    seg[i] = x
    while i > 1
      i /= 2
      seg[i] = f[ seg[i*2], seg[i*2+1] ]
    end
  end

  def query(a,b)
    ans = e
    a += size; b += size
    while a < b
      (ans = f[ ans, seg[a] ]; a += 1) if a.odd?
      (b -= 1; ans = f[ ans, seg[b] ]) if b.odd?
      a /= 2; b /= 2
    end
    ans
  end

  def inspect
    { size: size, seg: seg }.to_s
  end
end

# SegTree.new(N,E,F)
# := 要素数N、単位元E、演算Fで初期化、ただしNは2の冪
# SegTree.create(A,E,F)
# := 配列A、単位元E、演算Fで初期化で初期化
# update(i,x) := A[i]をxに更新
# query(a,b) := 半開区間[a,b)でのA[i]の演算結果

# S = gets.chomp.chars.map{|c| 1 << c.ord - ?a.ord}
# N = S.size
# T = SegTree.create(S, 0xFFFF_FFFF, ->x,y{x&y})

# N.times do |i|
#   if T.query(0,N-i) != 0
#     puts i
#     exit
#   end

#   (N-i-1).times do |j|
#     T.update(j, T[j] | S[j+i+1])
#   end
# end

n = gets.to_i
a = gets.split.map &:to_i
E = -1
F = -> x,y { x == E ? y : y == E ? x : x.gcd(y) }
T = SegTree.create(a,E,F)
ans = 0

n.times do |i|
  s = T.query(0,i)
  t = T.query(i+1,n)
  u = F[s,t]
  ans = u if ans < u
end

puts ans

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

int main(void){
  int a,b,c,d,e,tmp,i;
  cin >> a >> b >> c >> d >> e;
  int arr[5] = {a, b, c, d, e};
  for (i = 1; i < 5; ++i) {
    if (arr[i] % 10 == 0 || arr[i - 1] % 10 < arr[i] % 10) {
      arr[i - 1] ^= arr[i];
      arr[i] ^= arr[i - 1];
      arr[i - 1] ^= arr[i];
    }
  }
  tmp = 0;
  for (i = 0; i < 4; ++i) {
    tmp += arr[i] % 10 == 0 ? arr[i] : arr[i] - (arr[i] % 10) + 10;
  }
  cout << tmp + arr[4];
}

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

int main() {
    int n;
    cin >> n;
    string s[n];
    int t[n];
    long long sum = 0;
    for(int i = 0 ; i < n; i++){
        cin >> s[i] >> t[i];
        sum += t[i];
    }
    string x;
    cin >> x;
    bool p = true;;
    for(int i = 0; i < n; i++){
        if(p){
            sum -= t[i];
        }
        if(x == s[i]){
            p = false;
        }
    }
    cout << sum << endl;
    return 0;
}

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

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

    string g;
    int y, m, d;
    while (true) {
        cin >> g;
        if (g == "#") {
            break;
        }
        cin >> y >> m >> d;
        if (y >= 31) {
            if (y == 31 && m < 5) {
            } else {
                y -= 30;
                g = "?";
            }
        }
        cout << g << " " << y << " " << m << " " << d << endl;
    }
}


Measured memory_bytes: 3176