akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  return a<b?a:b;
}

int main(){
  int elaps=0,c;
  int i,q;
  P u;

  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)
      enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11836
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());

    ll cmin = 1e12, r;
    for(int i = 1; i < n; i++){
        if(abs(2*a[i] -a[0]) < cmin){
            cmin = abs(2*a[i] -a[0]);
            r = a[i];
        }
    }

    cout << a[0] << " " << r << endl;

    return 0;
}

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

const long long INF = 1000000000000000;

struct Edge {long long from, to, cost;};

vector<Edge> es(0);
vector<Edge> cutted(0);

vector<long long> d(2510);
int V, E;

long long max_value(int goal) {
    for (int i = 0; i < V; i++) {
        d.at(i) = -INF;
    }
    d.at(0) = 0;
    for (int i = 0; i < V * 2; i++) {
        for (int j = 0; j < (int)cutted.size(); j++) {
            Edge e = cutted.at(j);
            if (d.at(e.to) < d.at(e.from) + e.cost) {
                d.at(e.to) = d.at(e.from) + e.cost;
                
                if (i == V * 2 - 1) return -1;
            }
        }
    }
    return max(0ll, d.at(goal));
}

vector<vector<int>> G(2510);
void is_ok(int from, vector<bool> &done) {
    if (done.at(from)) return;

    done.at(from) = true;

    for (int i = 0; i < (int)G.at(from).size(); i++) {
        is_ok(G.at(from).at(i), done);
    }
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    V = n;
    E = m;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es.push_back(Edge{a, b, c - p});
        G.at(a).push_back(b);
    }


    vector<bool> done(n, false);
    is_ok(0, done);
    if (!done.at(n - 1)) {
        cout << -1 << endl;
        return 0;
    }

    vector<bool> toN(n, false);
    for (int i = 1; i < n - 1; i++) {
        vector<bool> d(n, false);
        is_ok(i, d);
        if (d.at(n - 1)) toN.at(i) = true;
    }
    toN.at(0) = toN.at(n - 1) = true;
    for (int i = 0; i < m; i++) { 
        if (!(done.at(es.at(i).from)) || !(done.at(es.at(i).to)) || !(toN.at(es.at(i).from)) || !(toN.at(es.at(i).to))) continue;

        cutted.push_back(es.at(i));
    }

    cout << max_value(n - 1) << endl;
}       

Measured memory_bytes: 896
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define double long double
typedef pair<double,double> P;
const ll INF = 1e16;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



///////////////////////___modpow___////////////////////

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


signed main(){
  ll n,a,b;cin>>n>>a>>b;
  ll ans = a*(n/(a+b));
  cout << ans + min(a, n-(a+b)*(n/(a+b))) << endl;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

import math

N, P = map(int, input().split())
ans = 1
target = 2
sum = {}

while True:
    if P % target == 0:
        if target in sum:
            sum[target] += 1
        else:
            sum[target] = 1
        P /= target
        target = 2
    else:
        target += 1
    if math.sqrt(P) < target:
        P = int(P)
        if P in sum:
            sum[P] += 1
        else:
            sum[P] = 1
        break

for fact in sum:
    # print("{} {}".format(fact, sum[fact]))
    while sum[fact] >= N:
        sum[fact] -= N
        ans *= fact

print("{}".format(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

using graph = vector<vector<int>>;

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

        vector<int> h(n);
        rep (i, n) cin >> h[i];

        graph g(n);
        rep (i, m) {
                int a, b;
                cin >> a >> b;
                --a; --b;

                g[a].push_back(b);
                g[b].push_back(a);
        }

        int ans = 0;
        rep (i, n) {
                int m = 0;
                for (int u : g[i]) {
                        m = max(m, h[u]);
                }

                if (h[i] > m) ans++;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 8784
import java.util.*;

class Main{
  public static void swapBall(String[] strArr, boolean[] ball){
    Arrays.sort(strArr);
    if(Arrays.binarySearch(strArr, "A") >= 0) {
      ball[0] = !ball[0];
    }
    if(Arrays.binarySearch(strArr, "B") >= 0) {
      ball[1] = !ball[1];
    }
    if(Arrays.binarySearch(strArr, "C") >= 0) {
      ball[2] = !ball[2];
    }
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    boolean[] ball = {true, false, false};
    while(sc.hasNext()) {
      String str = sc.next();
      String[] strArr = str.split(",");
      swapBall(strArr, ball);
    }
    if (ball[0]) {
      System.out.println("A");
    }
    else if (ball[1]) {
      System.out.println("B");
    }
    else {
      System.out.println("C");
    }
  }
}

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

const int MN = 101234;
int a[MN], b, n;

bool gd() {
	if (n % 2 == 0)
		return true;
	int res = 0;
	for (int i = 0; i < n; i++)
		res += a[i] % 2;
	if (res >= 2)
		return true;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2) {
			if (a[i] == 1)
				return true;
			a[i]--;
		}
	}
		int g = 0;
		for (int i = 0; i < n; i++)
			g = __gcd(g, a[i]);
		for (int i = 0; i < n; i++)
			a[i] = a[i] / g;
		assert(g != 1);
	b = !b;
	return false;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	while (n != 1 && !gd());
	long long sum;
	for (int i = 0; i < n; i++)
		sum += a[i];
	if (n == 1 && sum == 1)
		cout << "Second";
	else if (n == 1)
	 	cout << "First";
	else
		return cout << (b ^ (n % 2) ^ (sum % 2)? "First": "Second"), 0;
}

Measured memory_bytes: 4016
#include<iostream>
#include<cmath>
using namespace std;
bool isprime(long x){
    if(x == 2) 
      return true;
    if(x % 2 == 0 || x < 2) 
      return false;
    long j = 3;
    while(j <= sqrt(x)){
      if(x % j == 0) 
        return false;
      j += 2;
    }
    return true;
    
}

int main(){
  long n, cnt;
  cin >> n;
  for(int i = 0; i < n; i++){
    long x;
    cin >> x;
    if(isprime(x)) cnt++;
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, T;
    cin >> N >> T;
    int ans = INF;
    REP(i, N) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            chmin(ans, c);
        }
    }
    if (ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int inf =1e9;
struct segtree{
    int n;
    vector<int> dat;
    vector<int> lazy;
    segtree(int _n):n(_n),
    dat(4*n, -inf),
    lazy(4*n, 0){}

    int q(int n, int a, int b, int l, int r){
        if(r<l || r<a || b<l) return -inf;
        if(l<=a && b<=r) return dat[n];
        if(lazy[n]){
            for(int j : {2*n, 2*n+1}){
                dat[j]+=lazy[n];
                lazy[j]+=lazy[n];
            }
            lazy[n] = 0;
        }
        return max(q(2*n, a, (a+b)/2, l, r), q(2*n+1, (a+b)/2+1, b, l, r));
    }
    int qq(int l, int r){
        return q(1, 0, n-1, l, r);
    }
    void u(int n, int a, int b, int l, int r, int val){
        if(r<l ||r<a || b<l) return;
        if(l<=a && b<=r){
            dat[n]+=val;
            lazy[n]+=val;
            return;
        }
        if(lazy[n]){
            for(int j : {2*n, 2*n+1}){
                dat[j]+=lazy[n];
                lazy[j]+=lazy[n];
            }
            lazy[n] = 0;
        }
        u(2*n, a, (a+b)/2, l, r, val);
        u(2*n+1, (a+b)/2+1, b, l, r, val);
        dat[n] = max(dat[2*n], dat[2*n+1]);
    }
    void uu(int l, int r, int val){
        u(1, 0, n-1, l, r, val);
    }
};

using ll = long long;

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int TTT; cin >>TTT;
    while(TTT--){
    #endif // LOCAL_RUN

    int n, q; cin >> n;
    vector<int> a(n);
    for(auto &e:a) cin >> e;
    cin >> q;
    vector<vector<int> > qs(n+1);
    for(int i=0;i<q;++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        qs[a].push_back(b);
    }
    segtree st(n+5);
    auto add_val = [&](int i, int v){
        int old = st.qq(i, i);
        if(v>old){
            st.uu(i, i, v-old);
        }
    };
    add_val(0, 0);
    for(int i=0;i<n;++i){
        // check updates
        for(int j : qs[i]){
            add_val(j+1, st.qq(0, j));
        }
        if(a[i] == 0){
            st.uu(0, i, 1);
        } else {
            st.uu(i+1, n+1, 1);
        }
        //cerr << i << " : " << st.qq(0, n+1) << "\n";
    }
    int ans = st.qq(0, n+1);
    ans = n-ans;
    cout << ans << "\n";


    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


Measured memory_bytes: 15872
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;

	bool ans = true;
	map<string, int> mp;
	char prevEnd;
	REP(i, N) {
		string strOne;
		cin >> strOne;
		if (0 < i) {
			if (prevEnd != strOne[0]) {
				ans = false;
				break;
			}
			if (mp.find(strOne) != mp.end()) {
				ans = false;
				break;
			}
		}
		mp[strOne] = 1;
		prevEnd = strOne[strOne.size() - 1];
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2010, MOD = (int)(1e9 + 7);
int dp[N][N],n,k;
typedef long long ll;
ll power(ll a,int b) {
  ll ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}
ll jc[N * N],inv[N * N];
ll comb(int a,int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return 1ll * jc[a] * inv[b] % MOD * inv[a-b] % MOD;
}
int main() {
  scanf("%d%d",&n,&k);
  if (k == 1) return puts("1"), 0;
  jc[0] = 1;
  for (int i = 1 ; i <= n * k ; ++ i)
    jc[i] = 1ll * jc[i-1] * i % MOD;
  inv[n*k] = power(jc[n*k],MOD-2);
  for (int i = n*k-1 ; i >= 0 ; -- i)
    inv[i] = 1ll * inv[i+1] * (i+1) % MOD;
  dp[0][0] = 1;
  for (int i = 0 ; i <= n ; ++ i)
    for (int j = 0 ; j <= i ; ++ j) {
      (dp[i+1][j] += dp[i][j]) %= MOD;
      if (i > j) (dp[i][j+1] += 1ll * comb(n*k-j*k-(i-j)-1,k-2) * dp[i][j] % MOD) %= MOD;
    }
  printf("%lld\n",1ll * dp[n][n] * jc[n] % MOD);
  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int A, B, C; cin >> A >> B >> C;

	set<int> mod; mod.clear();
	for(int i = 1;; ++i){
		int ans = A * i;
		int curr = ans % B;
//		cerr << "curr: " << curr << endl;
		if (!mod.count(curr)){
			mod.insert(curr);
		}else{
			break;
		} // end if
	} // end for

	if (mod.count(C)){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	} // end if

	return 0;
}

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

int main(){
  int n; cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; ++i) cin >> s[i];
  
  vector<vector<int>> letter(n, vector<int>(26, 0));
  for(int i=0; i<n; ++i){
    for(char x : s[i]){
      ++letter[i][(int)x - 97];
    }
  }
  
  vector<bool> use(26, true);
  for(int i=0; i<n; ++i){
    for(int j=0; j<26; ++j){
      if(letter[i][j] == 0){
        use[j] = false;
      }
    }
  }
  
  vector<int> res(26, 0);
  for(int i=0; i<26; ++i){
    if(!use[i]) continue;
    int minuse = letter[0][i];
    for(int j=1; j<n; ++j){
      minuse = min(minuse, letter[j][i]);
    }
    res[i] = minuse;
  }

  for(int i=0; i<26; ++i){
    if(res[i] == 0) continue;
    char c = (char)(i+97);
    for(int j=0; j<res[i]; ++j){
      cout << c;
    }
  }
  cout << endl;
  
  return 0;
}

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

int main()
{
    int N, L;
    cin >> N >> L;
    vector<int> azi(N+1);
    int min_azi_abc = 1e9;
    int min_index;\
    ll sum = 0;
    REP(i, N)
    {
        azi[i] = L + i;
        sum += azi[i];
        if (abs(azi[i] < min_azi_abc))
        {
            min_azi_abc = abs(azi[i]);
            min_index = i;
        }
    }

    cout << sum - azi[min_index] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
long long minim(long long a, long long b) { return a < b ? a : b; }
long long maxim(long long a, long long b) { return a > b ? a : b; }
int main(){
    long long n,i,sign=0,ans=0,minus,a[100010]={},b[100010]={};
    scanf("%lld",&n);
    for(i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    for(i=0; i<n; i++){
        if(a[i]<0)sign++;
    }
    if(sign%2==0){
        for(i=0; i<n; i++){
            ans+=maxim(a[i],-a[i]);
        }
        printf("%lld",ans);
        return 0;
    }
    for(i=0; i<n; i++){
        a[i]=maxim(a[i],-a[i]);
    }
    for(i=0; i<n; i++){
        ans+=a[i];
    }
    minus=a[0];
    for(i=0; i<n; i++){
        minus=minim(minus,a[i]);
    }
    ans-=2*minus;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 896
n, k = map(int, input().split())
mod = 10**9+7
mina = [0]*(n-k+2)
maxa = [0]*(n-k+2)
mina[0] = (k-1)*k//2
for i in range(k):
    maxa[0] += n-i
for i in range(1, n-k+2):
    mina[i] = mina[i-1]+i+k-1
    maxa[i] = maxa[i-1]+(n-k-i+1)
    if mina[i]>=mod and maxa[i]>=mod:
        mina[i] %= mod
        maxa[i] %= mod
ans = 0
for i in range(n-k+2):
    ans += maxa[i]-mina[i]+1
    ans %= mod
print(ans%mod)

Measured memory_bytes: 69416
## x座標かy座標で隣り合わないものを繋ぐ辺は間に存在する点との接続で事足りるので不要
N = int(input())
city = []
for i in range(N):
    city_i = [i] + list(map(int,input().split()))
    city.append(city_i)
#print(city)

edges = []
city.sort(key = lambda x:x[1])
for i in range(N-1):
    w = city[i+1][1] - city[i][1]
    edges.append((w,city[i][0],city[i+1][0]))

city.sort(key = lambda x:x[2])
for i in range(N-1):
    w = city[i+1][2] - city[i][2]
    edges.append((w,city[i][0],city[i+1][0]))
edges.sort()
#print(edges)



def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def same(x,y):
    return find(x) == find(y)

par = [-1]*N

ans = 0
for e in edges:
    if same(e[1],e[2]):
        continue
    unite(e[1],e[2])
    ans += e[0]
print(ans)



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

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	int a = n / 100;
	int b = n / 10 - a * 10;
	int c = n % 10;
	if (a == 7 || b == 7 || c == 7) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3608
S=input()
MOD=10**9+7
dp=[0]*13
dp[0]=1
r=1
for i in range(len(S)):
    new_dp=[0]*13
    s=S[-1-i]
    if s=="?":
        for j in range(10):
            rem=(j*r)%13
            for k in range(13):
                new_dp[(k+rem)%13]+=dp[k]
    else:
        rem=(int(s)*r)%13
        for k in range(13):
            new_dp[(k+rem)%13]+=dp[k]
    for l in range(13):
        new_dp[l]%=MOD
    dp=new_dp
    r=(r*10)%13
print(dp[5])


Measured memory_bytes: 42860
using System.Linq;

namespace ABC
{
    using static System.Console;
    using static System.Math;
    public class Program
    {
        private const int MOD = 1000000007;
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        public static string Solve()
        {
            var xa = ReadLine().Split().Select(int.Parse).ToArray();
            return xa[0] < xa[1] ? "0" : "10";
        }
    }
}


Measured memory_bytes: 13396
x,k,d = list(map(int,input().split()))

count = abs(x) // d

if k > count+1:
    ans = min(abs(abs(x) - count * d),abs(abs(x) - (count + 1) * d))
    if min(abs(abs(x) - count * d),abs(abs(x) - (count + 1) * d)) == abs(abs(x) - (count + 1) * d):
        k += 1
    if (k - count) % 2 == 1:
        ans = abs(ans - d)
    print(ans)
else:
    print(abs(abs(x) - k * d))

Measured memory_bytes: 9240
i,o,t,j,l,s,z = map(int,input().split())

k = 0
k += (i // 2) *2
k += o
k += (j //2) *2
k += (l //2) *2
if i % 2 == 1 and j % 2 == 1 and l % 2 == 1:
	k += 3
elif (i % 2 + j % 2 + l % 2 == 2) and i > 0 and j > 0 and l > 0:
	k += 1
print(k)

Measured memory_bytes: 3192
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;

#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;

long long n;
long long a[200011],b[200011];

long long c[200011];
long long ans=0;

long long gao(long long x,long long t)
{
    long long from,to,mid;
    from=1;to=n;
    while(from<to)
    {
        mid=(from+to)/2;
        if(c[mid]+x<t)
        {
            from=mid+1;
        }
        else
        {
            to=mid;
        }
    }
    
    if(c[from]+x<t)from++;
    
    return n-from+1;
}


long long dp[41];
long long rr[41];

int main()
{
    long long i,j,k;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&b[i]);
    }
    
    long long f=1;
    
    for(i=0;i<=30;i++)
    {
        long long xx=0,yy=0,zz=0;
        
        for(j=1;j<=n;j++)
        {
            c[j]=(b[j]&f);
            
            if((b[j]&((f+1)>>1))!=0)
            {
               yy++;
            }
            
            //cout<<b[j]<<' '<<((f+1)>>1)<<"  !!!"<<endl;
        }
        sort(c+1,c+n+1);
        /*
        for(j=1;j<=n;j++)
        {
            cout<<c[j]<<' ';
        }
        cout<<"ccc"<<endl;
        */
        long long r=0;
        for(j=1;j<=n;j++)
        {
            long long cc=gao(a[j]&f,f+1);
            r+=cc;
            
            if((a[j]&((f+1)>>1))!=0)
            {
               xx++;
            }
        }
        
        //cout<<i<<"   "<<xx<<' '<<yy<<' '<<zz<<endl;
        
        //cout<<xx<<' '<<yy<<' '<<r<<endl;
        
        zz=xx*((long long)n-yy)+yy*((long long)n-xx);
        
        rr[i+1]=r;
        dp[i]=zz;
        
        f=f*2+1;
    }
    
    
    for(i=0;i<=28;i++)
    {
        if((dp[i]+rr[i])%2ll==1)
        {
            ans+=(1<<i);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> l(N), r(N);
  l[0] = A[0];
  for (int i = 1; i < N; i++)
    l[i] = gcd(l[i - 1], A[i]);
  r[N - 1] = A[N - 1];
  for (int i = N - 2; i >= 0; i--)
    r[i] = gcd(r[i + 1], A[i]);

  int ans = 0;
  rep(i, N) {
    int l_gcd = (i == 0) ? 0 : l[i - 1];
    int r_gcd = (i == N - 1) ? 0 : r[i + 1];
    ans = max(ans, gcd(l_gcd, r_gcd));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
import queue
q = queue.Queue()
for i in range(1, 10): q.put(i)

K = int(input())
t = 0
ans = 0

while t < K:
  t += 1
  ans = q.get()
  p = int(str(ans)[-1])
  for i in range(-1, 2):
    if 0 <= p+i < 10: q.put(int(str(ans) + str(p+i)))

print(ans)


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

using namespace std;

int main () {

    int N, A;
    cin >> N >> A;

    vector<int> x(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> x[i];
    }

    long dp[51][51][2501] = {};
    for (int j = 0; j <= N; j++) {
        dp[j][0][0] = 1;
    }
    
    // j個の整数からk個選び、その和がsとなる選び方
    for (int s = 0; s <= N * 50; s++) {
        for (int k = 1; k <= N; k++) {
            for (int j = 1; j <= N; j++) {
                if (x[j] > s) {
                    dp[j][k][s] = dp[j-1][k][s];
                } else {
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
                }
            }
        }
    }

    // N個の整数からk個選び、その和がk * Aとなる選び方 (= k個選んだ平均がA)
    long ans = 0;
    for (int k = 1; k <= N; k++) {
        ans += dp[N][k][k * A];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 51072
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int N;

int main(){
    cin >> N;

    if(N >= 10 && 100 > N){
        N = N - (N / 10 * 10);
    }
    if(N >= 100){
        N = N - (N / 10 * 10);
    }

    string ans = "hon";
    if(N == 3){
        ans = "bon";
    }
    if(N == 0 || N == 1 || N == 6 || N == 8){
        ans = "pon";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
//Tonight's the night and it is going to happen again and again.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define T ll t; cin>>t; while(t--)
#define mod 1000000007
#define inf 1000000000000000000
#define mem(name,val) memset(name,val,sizeof(name))
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define endl "\n"
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
   ll n;
   cin>>n;ll a[n],b[n];ll max1=-inf,max2=-inf,max3=-inf;ll min1=inf;
   f(n)
   {
    cin>>a[i]>>b[i];
    max1=max(max1,a[i]+b[i]);
    min1=min(min1,a[i]+b[i]);
    max2=max(max2,a[i]-b[i]);
    max3=max(max3,b[i]-a[i]);
   }
   cout<<max(max1-min1,max2+max3);
   //max(abs(a[i]-a[j])+abs(b[i]-b[j]))
}

Measured memory_bytes: 6696
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int n;
	string s, t;
	cin >> n >> s >> t;

	int ans = -1;
	rep(i, s.size()) {
		if (s.substr(i) == t.substr(0, s.size() - i)) {
			ans = s.size() + i;
			break;
		}
	}
	cout << (ans == -1 ? s.size() + t.size() : ans) << endl;
}




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


	solve();
	system("PAUSE");
	return 0;
}

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

int main() {
	long n,m,i,j,k,ans,cur,res;
	cin >> n;
	ans=0;
	for(i=1; i<=n; i++){
		if(i%3 && i%5){
			ans+=i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i=0; i<N; i++) {
    cin >> P.at(i);
  }
  int count = 0;
  int min = P.at(0);
  for (int i=0; i<N; i++) {
    if (P.at(i) <= min) {
      count++;
      min = P.at(i);
    }
    if (min == 1) {
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int N, K, a, b, x[109], dp[109][3][2];
int main() {
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		cin >> a >> b; a--;
		x[a] = b;
	}
	if (x[0] == 0) {
		dp[0][0][0] = 1;
		dp[0][1][0] = 1;
		dp[0][2][0] = 1;
	}
	else dp[0][x[0] - 1][0] = 1;
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			if (x[i] != 0 && x[i] != j + 1) continue;
			for (int k = 0; k < 3; k++) {
				for (int l = 0; l < 2; l++) {
					if (j == k && l == 1) continue;
					if (j == k) dp[i][j][1] += dp[i - 1][k][l];
					else dp[i][j][0] += dp[i - 1][k][l];
				}
			}
			dp[i][j][0] %= 10000;
			dp[i][j][1] %= 10000;
		}
	}
	int ret = 0;
	for (int i = 0; i < 3; i++) ret += dp[N - 1][i][0] + dp[N - 1][i][1];
	cout << ret % 10000 << endl;
	return 0;
}

Measured memory_bytes: 3128
#include<iostream>
using namespace std;
int main()
{
    int a,m;
    cin>>a>>m;
    if(a==1)
        {
            a=14;
        }
    if(m==1)
        {
            m=14;
        }
    if(a==m)
        {
            cout<<"Draw";
        }
    else if(a<m)
        {
            cout<<"Bob";
        }
    else
        {
            cout<<"Alice";
        }
    return 0;
}


Measured memory_bytes: 256
def main(num, string):
	e = string.count("E")
	w = num-e
	handol = e 
	minval = e 
	for s in string:
		if s =="E":
			handol -= 1
		else:
			handol += 1
		minval = min(minval, handol)
	return minval
	
	

num = int(input())
string = input()

print(main(num, string))

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if(a<b){
     printf("a < b\n");   
    }
    else if(a>b){
     printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}



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

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

    if(s.size() == 1) {
        cout << 0 << endl;
        return 0;
    }

    int cnt[26] = {0};
    for(int i=0; i<s.size(); ++i) {
        int temp = (int)(s[i] - 'a');
        ++cnt[temp];
    }

    int odd = false;
    for(int i=0; i<26; ++i) {
        if(i==23) continue;
        if(cnt[i] % 2 == 1) {
            if(odd) {
                cout << -1 << endl;
                return 0;
            } else {
                odd = true;
            }
        }
    }

    int sl,sr;
    int l = 0;
    int r = s.size()-1;
    while((odd && r -l > 0) || r-l > 1) {
        if(s[l] == s[r]) {++l; --r;}
        else if(s[l] == 'x') ++l;
        else if(s[r] == 'x') --r;
        else l++;
    }
    sl = l;
    sr = r;

    int ans = 0;

    while(sl >= 0 || sr < s.size()) {
        if(sl >= 0 && sr < s.size()) {
            if(s[sl] == s[sr]) {
                --sl; ++sr;
            } else if(s[sl] == 'x') {
                ++ans; --sl;
            } else if(s[sr] == 'x') {
                ++ans; ++sr;
            } else {
                cout << -1 << endl;
                return 0;
            }
        } else if (sl >= 0 && s[sl] == 'x') {
            ++ans; --sl;
        } else if(s[sr] == 'x') {
            ++ans; ++sr;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

string qwerty = "yuiophjklnm";
int check(char c){
	for(int i = 0; i < qwerty.size(); i++){
		if(qwerty[i] == c) return 1; //right 
	}
	return 0; //left
}

int main(){
	string s;
	while(cin >> s, s != "#"){
		int prev = check(s[0]);
		int cnt = 0;
		for(int i = 1; i < s.size(); i++){
			int cur = check(s[i]);
			if (prev != cur) cnt++;
			prev = cur;
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int x[310000];
int t[310000];
int p[310000];
int q[310000];
int at[310000];
int v[310000];
int w[310000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",x+i);
	}
	for(int i=0;i<a;i++){
		scanf("%d",t+i);
	}
	long long ret=a+1;
	for(int i=0;i<a;i++){
		ret+=t[i]/(b*2)*2;
		t[i]%=b*2;
		if(t[i]==0)ret-=2;
	}
	for(int i=0;i<a;i++){
		if(t[i]==0){
			p[i]=q[i]=1;
		}else{
			if(t[i]>x[i]*2)q[i]=1;
			if(t[i]>(b-x[i])*2)p[i]=1;
		}
	}
	int sz=0;
	int z=0;
	int s=0;
	int y=0;
	int sz2=0;
	int rem=0;
	for(int i=0;i<a;i++){
		if(p[i]==0&&q[i]==1)rem++;
	}
	for(int i=0;i<a;i++){
	//	printf("%d %d\n",p[i],q[i]);
		if(p[i]+q[i]==2){
			ret++;
			v[i]=3;
		}
		if(p[i]+q[i]==0){
			if(y<sz2){
				v[i]=1;
				v[w[y++]]=2;
			}else at[sz++]=i;
			if(sz-z>=rem+2){
				v[at[z]]=2;
				v[at[z+1]]=1;
				z+=2;
			}
		}
		if(p[i]==0&&q[i]==1){
			rem--;
			if(z<sz){
				v[i]=1;
				v[at[z++]]=2;
			}
		}
		if(p[i]==1&&q[i]==0){
			w[sz2++]=i;
		}
	}
 
	int la=-1;
	bool nd=true;
	for(int i=0;i<a;i++){
		if(!v[i]){
			s++;
			la=i;
			if(p[i]==1)nd=false;
		}
	}
	for(int i=la+1;i<a;i++)if(v[i]==2)nd=false;
  if(v[a-1]==3)nd=false;
//	printf("%d %lld\n",s,ret);
	ret+=s-1;
	if(!nd)ret+=2;
	if(ret%2)ret++;
	printf("%lld\n",ret*b);
}

Measured memory_bytes: 7808
#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()
{
  int n;
  cin >> n;
  vector<int> sq(8);
  int tmp = 1;
  rep(i, 8)
  {
    sq[i] = tmp;
    tmp *= 2;
  }
  rep(i, 8)
  {
    if (n < sq[i])
    {
      cout << sq[i - 1] << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
	
		if(0 <= x - r && x + r <= W && 0 <= y -r && y + r <= H){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26108
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a > b {
		a, b = b, a
	}
	if v := abs(a - b); v%2 == 0 {
		fmt.Println(a + v/2)
		return
	}
	fmt.Println("IMPOSSIBLE")
}


Measured memory_bytes: 512
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,taro_point = 0,hanako_point = 0,j;
    char taro_card[101],hanako_card[101];
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%s %s",taro_card,hanako_card);
        for(j = 0; taro_card[j] != '\0' && hanako_card[j] != '\0' && taro_card[j] == hanako_card[j];j++);
        if(taro_card[j] == '\0'){
            if(hanako_card[j] == '\0'){
                taro_point += 1;
                hanako_point += 1;
            }else{
                hanako_point += 3;
            }
        }else if(hanako_card[j] == '\0'){
            taro_point += 3;
        }else if(hanako_card[j] > taro_card[j]){
            hanako_point += 3;
        }else{
            taro_point += 3;
        }
    }
    printf("%d %d\n",taro_point,hanako_point);
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
	cin >> n;
	double x;
	string u;
	double ans=0;
	REP(i,n){
		cin >> x >> u;
		if(u=="JPY") ans+=x;
		else ans+=x*380000.0;
	}	
	cout << fixed << setprecision(8) << ans << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
N,T=map(int, input().split())
time = list(map(int, input().split()))

ans = T

for i in range(1,N):
    if time[i]-time[i-1] >= T:
        ans += T
    else:
        ans += T
        ans = ans - (T-(time[i]-time[i-1]))

print(ans)

Measured memory_bytes: 108528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;
static const int SQRT_N = 500;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	++n;
	vector<vector<ll>> small_cycles(SQRT_N);
	vector<ll> small_deltas(SQRT_N);
	for(int i = 1; i < SQRT_N; ++i){
		small_cycles[i].assign(i, 0);
	}
	ll large_count = 0, large_delta = 0;
	vector<ll> large_dd(n);
	for(int i = 0; i < m; ++i){
		ll a, b;
		cin >> a >> b;
		if(b >= SQRT_N){
			const ll offset = b - a;
			large_count++;
			large_delta += a;
			for(ll j = offset; j < n; j += b){
				large_dd[j] += b;
			}
		}else{
			small_deltas[b] += (a == 0 ? b : a);
			++small_cycles[b][(b - a) % b];
		}
	}
	vector<ll> x(n);
	for(int i = 0; i < n; ++i){
		large_delta -= large_dd[i];
		x[i] = large_delta;
		large_delta += large_count;
	}
	for(int i = 1; i < SQRT_N; ++i){
		const auto& sc = small_cycles[i];
		const int k = accumulate(sc.begin(), sc.end(), 0);
		ll delta = small_deltas[i];
		for(int j = 0, t = 0; j < n; ++j, ++t){
			if(t == i){ t = 0; }
			delta -= sc[t] * i;
			x[j] += delta;
			delta += k;
		}
	}
	for(int i = 1; i < n; ++i){
		cout << x[i] << "\n";
	}
	return 0;
}




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


void solve(long long R){
    if(R < 1200) cout << "ABC" << endl;
    else if(R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long R;
    scanf("%lld",&R);
    solve(R);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
multiset<string> sak;
multiset<string>::iterator it;
int main(){
//	freopen("F.in","r",stdin);
	int x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	for(int i=1;i<=x;i++) sak.insert("a");
	for(int i=1;i<=y;i++) sak.insert("b");
	for(int i=1;i<=z;i++) sak.insert("c");
	string s1,s2;
	while(sak.size()>1){
		it=sak.begin();
		s1=*it;
		sak.erase(it);
		it=sak.end();
		it--;
		s2=*it;
		sak.erase(it);
		s1=s1+s2;
		sak.insert(s1);
	}
	s1=*sak.begin();
	cout<<s1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	int ans = 0;
	cin >> s;
	set<string> st;
	string co = "";
	string co1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
	for (int i = 0; i < s.size(); i++) {
		co += s[i];
		if (co1 == co) {
			continue;
		}
		else {
			co1 = co;
			co = "";
			ans++;
			continue;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import sys
class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    y = None  # xの親
    x = root
    while x:
        y = x
        x = x.left if key < x.key else x.right
    if y is None:  # Tが空の場合
        root = Node(key)
    elif key < y.key:
        y.left = Node(key)
    else:
        y.right = Node(key)

def in_order(node):
    if node is None:
        return ''
    return in_order(node.left) + f' {node.key}' + in_order(node.right)
def pre_order(node):
    if node is None:
        return ''
    return f' {node.key}' + pre_order(node.left) + pre_order(node.right)
input()
for e in sys.stdin:
    if e[0] == 'i':
        insert(int(e[7:]))
    else:
        print(in_order(root))
        print(pre_order(root))


Measured memory_bytes: 63328
#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
using namespace std;
int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	int a = 0;
	if ((W / 2 == x) && (H / 2 == y)) {
	 a = 1;
	}
	cout << (W * H) / 2 << endl;
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;

void main() {
    int[] w;
    foreach (i; 0..10) {
        w ~= readln.chomp.to!int;
    }
    int[] k;
    foreach (i; 0..10) {
        k ~= readln.chomp.to!int;
    }

    writefln("%d %d", solve(w), solve(k));
}

int solve(int[] a) {
    return a.sort!("a > b")[0..3].reduce!("a + b");
}

Measured memory_bytes: 1076
import java.util.Scanner;

public class Main {
	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {
		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			String x = String.valueOf(a + b);
			System.out.println(x.length());
		}

	}

}

Measured memory_bytes: 26360
#include<iostream>
#include<cstdio>
using namespace std;
long long ans=0;
void so(long long a,long long b)
{
	if(b==0){ans-=a;return;}
	ans+=a/b*b*2;so(b,a%b);
}
int main()
{
	long long n,x;scanf("%lld%lld",&n,&x);so(x,n-x);
	printf("%lld",n+ans);return 0;
}

Measured memory_bytes: 256
divider = "#" * 20
input = Hash.new(0)
gets.to_i.times do
  b, f, r, v = gets.split.map!(& :to_i)
  input[[b,f,r]] += v
end
1.upto(4) do |i|
  1.upto(3) do |j|
    1.upto(10) do |k|
      print " #{input[[i,j,k]]}"
    end
    puts
  end
  if (i != 4) then 
  	puts divider
  end 
end 

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define MAX 1000000001



int main(){
    ll n,k,s;
    cin>>n>>k>>s;

    vector<ll> ans(n);

    for(int i=0;i<n;i++){
        if(i<k) {
            ans.at(i) = s;
        }else{
            if(s!=1000000000) {
                ans.at(i) = s + 1;
            }else{
                ans.at(i) = s - 1;
            }
        }
        cout<<ans.at(i)<<" "<<endl;
    }


}

Measured memory_bytes: 2176
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  for (int i = 0; i < 1000000; i++) {
    if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) break;
    ll ac, bc, cc;
    ac = a;
    bc = b;
    cc = c;
    a = (bc + cc) / 2;
    b = (ac + cc) / 2;
    c = (ac + bc) / 2;
    cnt++;
  }
  if (cnt == 1000000)
    cout << -1 << endl;
  else
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<pii> edge;
void input(){
    fast_io();
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int a,b; cin >> a >> b;
        a--,b--;
        edge.emplace_back(a,b);
    }
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
  bool same(int x,int y){
      x = find(x),y=find(y);
      return (x==y);
  }
};


int solve(){
    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        UnionFind uf(N);
        for (int j = 0; j < M; j++)
        {
            if(i!=j) uf.unite(edge[j].first,edge[j].second);
        }
        ans += !uf.same(edge[i].first,edge[i].second);
    }
    cout << ans << endl;    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256