akhauriyash/Code-Regression huggingface dataset:
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "vowel"; }
  string_type do_falsename() const { return "consonant"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  int H, W;
  cin >> H >> W;
  REP(i,H) {
    string s;
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
  return;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#define LEN 100001
#define MAX 100001
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head, tail, n;
 
void enqueue(P x){
  Q[tail]=x;
  if(tail + 1 == MAX)
    tail=0;
  else
    tail++;
}
 
P dequeue(void){
  P x;
  x=Q[head];
  if(head+1 == MAX)
    head=0;
  else head++;
  return x;
}
 
 
int main(){
  int elaps = 0, c;
  int i, q;
  P p;
  scanf("%d %d", &n, &q);
 
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
    head = 0;
    tail = n;

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

Measured memory_bytes: 10756
package main

import (
	"fmt"
	"strconv"
)

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

func main() {
	var n int
	fmt.Scan(&n)

	b := -2
	ans := ""
	for n != 0 {
		r := abs(n % b)
		ans = strconv.Itoa(r) + ans
		n -= r
		n /= b
	}
	if ans == "" {
		ans = "0"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  for ( int i = 0; i< N.size();i++ ) {
    if ( N[i] == '1' ) {
      N[i] = '9';
    }
    else if ( N[i] == '9' ) {
      N[i] = '1';
    }
  }
  cout << N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int n;
bool Ans[100100];
vector < pair < ll , int > > v[100100];

void DFS(int x , int p , int s){

    if(s % 2 == 0)  Ans[x] = 1;
    for(auto j : v[x]){
        if(j.first != p)  {
            DFS(j.first , x , (s + j.second)%2);
        }
    }
}

int main()
{

    int n;  cin >> n;
    for(int i = 0;i<n - 1;i++){
        int x,y,w;  cin >> x >> y >> w;
        v[x].push_back({y , w % 2});
        v[y].push_back({x , w % 2});
    }
    Ans[1] = 0;
    DFS(1 , -1 , 0);
    for(int i = 1;i<=n;i++)  cout << Ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b){if (b == 0) return a;return gcd(b, a % b);}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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


int main(){
    int A, B, K;
    cin >> A >> B >> K;
    int r = B - A + 1;
    if(r <= K * 2) {
        for(int i = A; i <= B; i++) {
            cout << i << endl;
        }
    }
    else {
        for(int i = A; i < A+K; ++i){
            cout << i << endl;
        }
        for(int i = B-K+1; i <= B; i++) {
            cout << i << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3616
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<queue>
#include<algorithm>
#include<vector>
#include<tuple>

using namespace std;

typedef long long LL;
const LL INF = 1e17;


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)


typedef tuple<LL, int, int> edge;
typedef priority_queue<edge> QUE;
typedef vector<LL> V;
typedef vector<V> VV;
int N, M, L, E, s, t;
int a[112345];
int b[112345];
LL c[112345];
int l[1123];
VV dist(int s,VV g) {
	VV res(N, V(M + 1, INF));
	QUE que;
	que.push(edge{0,s,M});
	res[s][M] = 0;
	while (que.size()) {
		LL cost; int v, m;
		tie(cost, v, m) = que.top(); que.pop();
		cost = -cost;
		if (res[v][m] < cost)continue;
		if (l[v] == 1 && m < M) {
			if (res[v][m + 1]>cost + 1) {
				res[v][m + 1] = cost + 1;
				que.push(edge{ -cost - 1,v,m + 1 });
			}
		}
		for (auto &e : g[v]) {
			int u = v^a[e] ^ b[e];
			int nxt_m = m - c[e];
			if (nxt_m < 0)continue;
			LL nxt_cost = cost + c[e];
			if (res[u][nxt_m]>nxt_cost) {
				res[u][nxt_m] = nxt_cost;
				que.push(edge{ -nxt_cost,u,nxt_m });
			}
		}
	}

	return res;
}
int main() {
	while (cin >> N >> M >> L >> E >> s >> t,N+M+L+E+s+t) {
		REP(i, N)l[i] = 0;
		REP(i, L) {
			int p; cin >> p;
			l[p] = 1;
		}
		VV g(N);
		REP(i, E) {
			cin >> a[i] >> b[i] >> c[i];
			g[a[i]].push_back(i);
			g[b[i]].push_back(i);
		}
		auto d = dist(s, g);
		LL res = INF;
		REP(i, M + 1)res = min(res, d[t][i]);
		if (res == INF)cout << "Help!" << endl;
		else cout << res << endl;
	}


}

Measured memory_bytes: 3460
import scala.io.StdIn

object Main extends App {
  val pat = Array(9,0,2,0,1,0,1,0,0,1,0,1,0)
  val r = StdIn.readLine().split(" ").map(_.toInt)
  if(pat(r(0)) == pat(r(1))) println("Yes")
  else println("No")

}

Measured memory_bytes: 25396
#include<iostream>
#include<cstdio>
#define eps 10e-9
using namespace std;
int main()
{
	int data[10],sum=0;
	int v1,v2;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7],&data[8],&data[9],&v1,&v2)!=EOF)
	{
		sum=data[0];
		for(int i = 1; i < 10; ++i)
		{
			sum+=data[i];
			data[i]=sum;
		}
		//cout<<"sum="<<data[9]<<endl;
		double t=data[9]/(double)(v1+v2);
		//printf("t=%.9lf\n",t);
		for(int i = 0; i < 10; ++i)
		{
			if(v1*t<(double)data[i]+eps)
			{
				cout<<i+1<<endl;
				break;
			}
		}
	}
  return 0;
}

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

using namespace std;

int n;
const int N = 109, W = 1e5 + 9;
long long a[N][2], dp[N][W];

long long sol(int i, long long w){
    if(w<0) return -1E9;
    if(i==n) return 0;

    long long &ret = dp[i][w];
    if(~ret) return ret;

    return ret = max(a[i][1]+sol(i+1, w-a[i][0]), sol(i+1, w));
}

int main(){

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

    memset(dp, -1, sizeof dp);
    cout << sol(0, w);
}


Measured memory_bytes: 85376
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;


int main(void){
	          int i,j,k;

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

	      	  string x;
	      	  cin >> x;

	      	  int a=x[0]-'0',b=x[1]-'0',c=x[2]-'0',d=x[3]-'0';
	      	  string e[2];
	      	  e[0]="+",e[1]="-";

	      	  for(i=0;i<=1;i++){
	      		  for(j=0;j<=1;j++){
	      			  for(k=0;k<=1;k++){
	      				  int p=a;
	      				  if(e[i]=="+") p+=b;
	      				  if(e[i]=="-") p-=b;
	      				  if(e[j]=="+") p+=c;
	      				  if(e[j]=="-") p-=c;
	      				  if(e[k]=="+") p+=d;
	      				  if(e[k]=="-") p-=d;

	      				  if(p==7){
	      					  cout << a << e[i] << b << e[j] << c << e[k] << d << "=" << 7 << endl;
	      					  return 0;
	      				  }

	      			  }
	      		  }
	      	  }

	          return 0;
}


Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
cnt = 0
for i in b:
    left = -1
    right = len(a) 
    while right - left > 1:
        mid = (right + left) //2 
        if a[mid] <  i:
            left = mid 
        else :
            right = mid 
    left2 = -1
    right2 = len(c)
    while right2 - left2 > 1:
        mid2 = (right2 + left2) //2
        if c[mid2] > i:
            right2 = mid2
        else :
            left2 = mid2
    cnt += (left+1)*(n-right2)

print(cnt)





Measured memory_bytes: 105292
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int ma = 10000000;

int N, A, B, C;
vector<int> l;

int dfs(int cnt, int a, int b, int c) {
    if(cnt == N) {
        int ret = abs(A - a) + abs(B - b) + abs(C - c) - 30;
        if(a && b && c)
            return ret;
        else
            return ma;
    }
    int tmp[4];
    tmp[0] = dfs(cnt + 1, a, b, c);
    tmp[1] = dfs(cnt + 1, a + l[cnt], b, c) + 10;
    tmp[2] = dfs(cnt + 1, a, b + l[cnt], c) + 10;
    tmp[3] = dfs(cnt + 1, a, b, c + l[cnt]) + 10;
    int mi = tmp[0];
    for(int i = 1; i < 4; ++i)
        mi = min(mi, tmp[i]);
    return mi;
}

int main() {
    cin >> N >> A >> B >> C;
    l.resize(N);
    for(int i = 0; i < N; ++i)
        cin >> l[i];
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define be(x) (x).begin(),(x).end()
int n,ans;
string s;
void solve(){
    ll x,y;
    cin>>x>>y;
    ll ans=x,cnt=1;
    while(ans*2<=y){
      if(ans*2<=y){
        ans*=2;
        cnt++;
      }
      else break;
    }
    cout<<cnt<<endl;
}

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

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

const int N = 9;
int l[N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    for(int i = 0; i< n; i++)cin>>l[i];
    
    int ans = 1e9;
    for(int i = 1; i<=(1<<(2*n)); i++){
        int x[3] = {0,0,0}, cnt = 0;
        for(int j = 0; j<n; j++){
            int state = (i>>(2*j)) &3;
            if(state != 3) x[state] += l[j], cnt++;
        }
        if(x[0]*x[1]*x[2]){
            ans = min(ans, (cnt-3)*10 + abs(x[0] - a) + abs(x[1] - b)+abs(x[2] - c));
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> B(N);
    rep(n,0,N) cin>>B.at(n);

    list<int> l;
    rep(n,0,N) l.push_back(B.at(n));

    vector<int> ans;
    while(!l.empty()){
        int minN,minD=INT_MAX;
        auto itr=l.begin();
        for(auto i=l.begin(); i!=l.end(); i++){
            int idx=distance(l.begin(),i)+1;
            if(idx<*i){cout<<-1<<endl; exit(0);}
            else{
                if(minD>=idx-*i){minD=idx-*i; minN=*i; itr=i;}
            }
        }
        l.erase(itr);
        ans.push_back(minN);
    }
    
    reverse(ToEnd(ans));
    for(auto a:ans) cout<<a<<endl;
}

Measured memory_bytes: 256
N, D = list(map(int,input().split()))
a = []
for i in range(N):
    a.append(list(map(int,input().split())))
    
ans = 0
for i in range(N):
    if a[i][0] ** 2 + a[i][1] ** 2 <= D ** 2:  ans += 1
print(ans)

Measured memory_bytes: 102392
/**********************************************************
* @Author: 			   Kirito
* @Date:   			   2020-04-12 20:01:09
* @Last Modified by:   Kirito
* @Last Modified time: 2020-04-12 20:02:52
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

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

const int maxn=111111;


int main()
{
	int n;
	while(cin >> n)
	{
		bool fl = false;
		while(n)
		{
			if(n % 10 == 7){
				fl = true; 
				break;
			}
			n /= 10;
		}
		fl ? cout << "Yes" << endl : cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
int d[305], nd[305];
int f[305][305], nf[305][305];
const int MOD = int(1e9) + 7;

inline void add(int &x, LL y) {
    x = (x + y) % MOD;
}

int main() {
    cin >> n >> m;
    memset(d, 0, sizeof d);
    memset(f, 0, sizeof d);
    d[1] = 1;
    forn(times, m) {
        memset(nd, 0, sizeof nd);
        memset(nf, 0, sizeof nf);
        for (int i = 1; i <= n; ++i) {
            add(nd[i], (LL)d[i] * i);
            add(nf[i + 1][i], (LL)d[i] * (n - i));
        }
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j < i; ++j) {
                if (f[i][j] == 0) {
                    continue;
                }
                add(nf[i + 1][j], (LL)f[i][j] * (n - i));
                add(nf[i][j], (LL)f[i][j] * (i - j));
                add(nd[i], (LL)f[i][j] * j);
            }
        }
        memcpy(d, nd, sizeof d);
        memcpy(f, nf, sizeof f);
    }
    cout << d[n] << endl;
    return 0;
}


Measured memory_bytes: 1152
n = gets.to_i
a = gets.split.map(&:to_i)

# (i - j).abs =  a[i] + a[j]
# i - a[i] = j + a[j]
# or
# - i - a[i] = - j + a[j]
# i + a[i] = j - a[j]


diff = {}
sum = {}
result = 0
n.times do |i|
  d = (i+1) - a[i]
  s = (i+1) + a[i]
  if sum[d]
    result += sum[d]
  end
  diff[d] ||= 0
  diff[d] += 1
  sum[s] ||= 0
  sum[s] += 1

end

puts result

Measured memory_bytes: 42252
#include <iostream>
#include <string>
#include <vector>
#include <cctype>

using namespace std;

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

int main()
{
	int n;
	cin >> n;
	vector<string> v(n);

	REP(i,n){
		cin >> v[i];
	}

	bool flag = true;

	REP(i,n-1){
		if(v[i].back() == v[i+1].front() )continue;
		else{
			flag = false;
			break;
		}
	}

	REP(i,n){
		for(int j=i+1;j<n;j++){
			if(v[i]==v[j]){
				flag = false;
				break;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

/*
!) 0-indexed
!) [a, b)に対する演算
!) merge, updateNodeを書く
*/
template<typename Monoid>
struct Segtree{
    int n;
    vector<Monoid> dat;
    Monoid m0; // データの初期化値
    Segtree(int sz, Monoid m0) : m0(m0){
        n = 1;
        while(n < sz) n *= 2;
        dat.assign(2*n-1, m0);
    }

    Monoid merge(Monoid a, Monoid b){ return min(a,b); }
    void updateNode(int k, Monoid x){ dat[k] = x; }

    void update(int k, Monoid x){
        k += n-1;
        updateNode(k, x);
        while(k > 0) {
            k = (k-1)/2;
            dat[k] = merge(dat[k*2+1], dat[k*2+2]);
        }
    }
    Monoid query(int a, int b){
        Monoid L = m0, R = m0;
        int A = a+n-1;
        int B = b+n-1;
        while(A < B) {
            if((A&1) == 0) L = merge(L, dat[A++]);
            if((B&1) == 0) R = merge(dat[--B], R);
            A >>= 1;
            B >>= 1;
        }
        return merge(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k+n-1]; }
};

int main(){
    fastcin();

    int n, m;
    cin>> n >> m;
    vector<pair<LL, pair<LL, LL>>> e(m);
    rep(i, m){
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;
        e[i] = make_pair(r, make_pair(l, c));

    }
    sort(all(e));
    // rep(i, m) cout << e[i].first << endl;
    Segtree<LL> dp(n, LLINF);

    dp.update(0, 0);
    rep(i, m){
        LL l, r, c;
        r = e[i].first;
        tie(l, c) = e[i].second;
        LL newcost = dp.query(l, r) + c;
        if(dp[r] > newcost) dp.update(r, newcost);
    }
    // rep(i, n) cout << dp[i] << endl;
    LL ans = dp[n-1];
    if(ans == LLINF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 4608
#include <stdio.h>
#include<algorithm>
using namespace std;
int dp[2][3];
int memo[3];
int k[2] = { 0,1 };

int main(){
    int day;
    scanf("%d", &day); 
    int i = 1;
    while (day--) {
        scanf("%d%d%d", &memo[0], &memo[1], &memo[2]);
        dp[k[i % 2]][0] = memo[0] + max(dp[k[(i + 1) % 2]][1], dp[k[(i + 1) % 2]][2]);
        dp[k[i % 2]][1] = memo[1] + max(dp[k[(i + 1) % 2]][0], dp[k[(i + 1) % 2]][2]);
        dp[k[i % 2]][2] = memo[2] + max(dp[k[(i + 1) % 2]][1], dp[k[(i + 1) % 2]][0]);
        i++;
    }
    printf("%d\n", max(max(dp[k[(i + 1) % 2]][0], dp[k[(i + 1) % 2]][1]), dp[k[(i + 1) % 2]][2]));
    return 0;
}


Measured memory_bytes: 128
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let (n, k) = input!(u32, u32);
    if n % k != 0 {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
N = int(input())
W = list(map(int, input().split()))

min_diff = 10000

for i in range(1, N):
    left = W[:i]
    right = W[i:]

    diff = abs(sum(left) - sum(right))

    if min_diff > diff:
        min_diff = diff

print(min_diff)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n, a, b;
int h[114514];
signed main() {
	cin >> n >> a >> b;
	rep(i, n)cin >> h[i];
	int ng = 0, ok = 1000000000, mid;
	while (ok - ng > 1) {
		mid = (ok + ng) / 2;
		int memo = 0;
		rep(i, n) {
			int p = max((int)0, h[i] - b * mid);
			memo += (p + a - b - 1) / (a - b);
		}
		if (memo > mid)ng = mid;
		else ok = mid;
	}
	cout << ok << endl;
	ggr
}

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) cout << mat[i][j] << " "; cout << endl; }

using namespace std;

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


int main(){

	int a, b; cin >> a >> b;
	
	//a-k = -b + k
	//a + b = 2k
	
	//a-k = b-k
	//a = b F
	
	if((b+a)%2==0){
		printf("%d\n", (b+a)/2);
	}else{
		puts("IMPOSSIBLE");
	}
	
	return 0;
}

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

constexpr int MAXN = (int)2e5;
constexpr long long INF = (long long)1e15;


int main()
{
    int n,k; cin >> n >> k;
    vector<int> h(n + 1), dp(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> h[i];
    }
    dp[1] = 0;
    for(int i = 2; i <= n; ++i){
        dp[i] = (int)1e9;
        for(int j = 1; j <= k && i - j >= 1; ++j){
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n];

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
 
using namespace std;
 
int main()
{
	
	int a[10];
	for (int i =0; i<6; i++) cin >> a[i];
	
	for (int i = 0; i<5; i++)
	{
		
		for (int j = i+1; j<5; j++)
		{
			if (a[j]-a[i] > a[5])
			{
				cout << ":(" <<endl;
				return 0;
			}
		}
	}
	
	cout << "Yay!" << endl;
	return 0;
	
		
	
	
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M; 
  cin >> N >> M;

  vector<vector<int>> vec(100010);
  REP(i, N){
    int a, b;
    cin >> a >> b;
    a--;
    vec[a].emplace_back(b);
  }

  int ans = 0;
  priority_queue<int> q;
  REP(i, M){
    for(int v : vec[i]){
      q.push(v);
    }
    if(!q.empty()){
      ans += q.top(); q.pop();
    }
  }

  cout << ans << endl;


  return 0;
}

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

typedef pair<int,int> P;

int n;
map<int,int> sc;

int main(void){
	while(cin>>n,n){
		sc.clear();

		for(int i=0;i<n;i++){
			int m,a,b;
			cin>>m>>a>>b;
			sc[a] += m;
			sc[b] -= m;
		}

		vector<P> v;
		for(map<int,int>::iterator iter=sc.begin();iter!=sc.end();iter++){
			v.push_back(P(iter->first,iter->second));
		}
		sort(v.begin(),v.end());

		int w = 0;
		int i;
		for(i=0;i<v.size();i++){
			w += v[i].second;
			if(w > 150){
				break;
			}
		}
		cout<<(i==v.size() ? "OK" : "NG")<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
	int num[12]={0,2,0,1,0,1,0,0,1,0,1,0};
	int x,y;
	scanf("%d%d",&x,&y);
	if(num[x-1]==num[y-1]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

long long int nikou(long long int x){
    return x*(x-1)/2;
};

int main(){
    long long int n;
    cin >> n;
    map<long long int,long long int> mp;
    long long int sum=0;
    long long int a[n];

    for(int i=0; i<n; i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    for(int i=0; i<n+1; i++){
        sum+=nikou(mp[i]);
    }

    for(int k=0; k<n; k++){
        cout << sum-nikou(mp[a[k]])+nikou(mp[a[k]]-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 16640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int[] a = nia(n);

        TreeSet<Integer> set = new TreeSet<>();

        set.add(a[0]);

        for (int i = 1; i < n; i++) {
            if (set.last() < a[i]) {
                set.add(a[i]);
            } else {
                set.remove(set.ceiling(a[i]));
                set.add(a[i]);
            }
        }

        out.println(set.size());
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 51340
#include <bits/stdc++.h>
#define N 5010
using namespace std;
typedef long long ll;
int n,K,A[N];
ll Sum[N];
int mem[N][N],used[N][N],ans[N];

ll dfs(int pos,ll sum){
  if(sum>=K) return sum;
  if(used[pos][sum]++) return mem[pos][sum];
  if(Sum[pos+1]+sum<K)return 1LL<<30;
  if(Sum[pos+1]+sum==K) {
    for(int i=0;i<=pos;i++) ans[i]=1;
    return K;
  }


  ll a=dfs(pos-1,sum+A[pos]);
  if(a>=K&&a-A[pos]<K)ans[pos]=1;
  ll b=dfs(pos-1,sum);
  if(b<a&&b>=K)a=b;
  return mem[pos][sum]=a;
}

int main(){
  cin>>n>>K;
  for(int i=0;i<n;i++)cin>>A[i];
  sort(A,A+n);
  for(int i=1;i<=n;i++) Sum[i]=A[i-1]+Sum[i-1];
  
  dfs(n-1,0);
  int cnt=0;
  for(int i=0;i<n;i++) if(ans[i])cnt++;
  cout<<n-cnt<<endl;
  return 0;
}


Measured memory_bytes: 194560
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
#define fo(f) freopen(f".in","r",stdin);freopen(f".out","w",stdout);
#define gc getchar()
inline int read()
{
	int x=0;char c=gc;
	for(;c<48||c>57;c=gc);
	for(;c>47&&c<58;c=gc)
		x=(x<<1)+(x<<3)+c-48;
	return x;
}

typedef long long ll;
#define maxn 405
int n;
struct data
{
	int c[4];
	data(int c0=0,int c1=0,int c2=0,int c3=0)
	{
		c[0]=c0;c[1]=c1;c[2]=c2;c[3]=c3;
	}
	inline friend bool operator<(data a,data b)
	{
		for(int i=0;i<4;++i)
			if(a.c[i]^b.c[i])return a.c[i]<b.c[i];
		return 0;
	}
	inline void rotate()
	{
		int t=c[0];
		c[0]=c[1];c[1]=c[2];c[2]=c[3];c[3]=t;
	}
	inline friend bool operator==(data a,data b)
	{
		for(int j=0;j<4;++j)
		{
			int fl=1;
			for(int i=0;i<4;++i)
				if(a.c[i]!=b.c[(i+j)&3])
				{
					fl=0;
					break;
				}
			if(fl)return true;
		}
		return false;
	}
}sq[maxn];
map<data,int> mp;

inline void inc(data d)
{
	for(int i=0;i<4;++i)
	{
		++mp[d];
		d.rotate();
	}
}
inline void dec(data d)
{
	for(int i=0;i<4;++i)
	{
		--mp[d];
		d.rotate();
	}
}

inline void init()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<4;++j)
			sq[i].c[j]=read();
		inc(sq[i]);
	}
}

ll ans;

inline void calc(data l,data r,data u,data d)
{
	if(!mp[l]||!mp[r]||!mp[u]||!mp[d])return;
	ll a=mp[l],b,x,y;
	dec(l);
	b=mp[r];
	dec(r);
	x=mp[u];
	dec(u);
	y=mp[d];
	inc(u);
	inc(r);
	inc(l);
	ans+=a*b*x*y;
}

inline void solve()
{

	data l,r,u,d;
	for(int i=1;i<n;++i)
	{
		dec(sq[i]);
		for(int j=i+1;j<=n;++j)
		{
			dec(sq[j]);
			for(int k=0;k<4;++k)
			{
				l=data(sq[j].c[1],sq[i].c[0],sq[i].c[3],sq[j].c[2]);
				r=data(sq[i].c[1],sq[j].c[0],sq[j].c[3],sq[i].c[2]);
				u=data(sq[j].c[1],sq[j].c[0],sq[i].c[1],sq[i].c[0]);
				d=data(sq[i].c[3],sq[i].c[2],sq[j].c[3],sq[j].c[2]);
				calc(l,r,u,d);
				sq[i].rotate();
			}
			inc(sq[j]);
		}
		inc(sq[i]);
	}
	printf("%lld\n",ans/3);
}

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

Measured memory_bytes: 20352
import string
N = int(input())
L = [input() for _ in range(N)]
M = {}
for s in string.ascii_lowercase:
    M[s] = float('inf')
for s in string.ascii_lowercase:
    for l in L:
        M[s] = min(M[s],l.count(s))
ans = ''
for s in string.ascii_lowercase:
    ans += s*M[s]
print(ans)

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

using ll = long long;

class Edge{
public:
    int from, to;
    long long value;
    Edge(int a, int b, long long c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};

std::vector<long long> dijkstra(int s, int N, std::vector<Edge> E){
    std::vector<long long> ans(N, 1e18);
    std::vector<std::vector<Edge>> Edges(N);
    for(auto e : E){
        Edges.at(e.from).push_back(e);
    }
    std::priority_queue<std::pair<long long, int>, std::vector<std::pair<long long, int>>, std::greater<std::pair<long long, int>>> que;
    ans.at(s)= 0;
    que.push(std::make_pair(0, s));
    while(!que.empty()){
        std::pair<long long, int> p = que.top();
        que.pop();
        if(ans.at(p.second) < p.first)continue;
        for(int i = 0;i < Edges.at(p.second).size();i++){
                if(ans.at(p.second) + Edges.at(p.second).at(i).value < ans.at(Edges.at(p.second).at(i).to)){
                ans.at(Edges.at(p.second).at(i).to) = ans.at(p.second) + Edges.at(p.second).at(i).value;
                que.push(std::make_pair(ans.at(Edges.at(p.second).at(i).to),Edges.at(p.second).at(i).to));
            }
        }
    }
    return ans;
}
int H, W;
int index_to_point(int y, int x){
    return H * x + y;
}

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

int main(){
    cin >> H >> W;
    int Hs, Ws;cin >> Hs >> Ws;
    int Ht, Wt;cin >> Ht >> Wt;
    vector<string> field;

    for(int i = 0;i < H;i++){
        string s;cin >> s;
        field.push_back(s);
    }

    vector<Edge> E;

    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(field[i][j] != '#'){
                for(int k = 0;k < 4;k++){
                    if(0 <= i + dy[k] && i + dy[k] < H && 0 <= j + dx[k] && j + dx[k] < W){
                        if(field[i + dy[k]][j + dx[k]] == '.'){
                            E.push_back(Edge(index_to_point(i, j), index_to_point(i + dy[k], j + dx[k]), 0));
                        }
                    }
                }

                for(int k = -2;k <= 2;k++){
                    for(int l = -2;l <= 2;l++){
                        if(0 <= i + k && i + k < H && 0 <= j + l && j + l < W){
                            if(field[i + k][j + l] == '.'){
                                E.push_back(Edge(index_to_point(i, j), index_to_point(i + k, j + l), 1));
                            }
                        }
                    }                    
                }
            }            
        }
    }


    vector<ll> w = dijkstra(index_to_point(Hs - 1, Ws - 1), H * W, E);
    if(w[index_to_point(Ht - 1, Wt - 1)] == 1e18)cout<<"-1"<<endl;
    else cout<<w[index_to_point(Ht - 1, Wt - 1)]<<endl;

    return 0;
}


Measured memory_bytes: 439508
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}

int main(){
    ll H,W;
    cin >> H >>W;
    ll a,b,c;
    ll ans=INF;
    
    FOR(k,0,2){
        FOR(i,1,H){
            a = i*W;

            b = (W/2) * (H-i);
            c = ((W+1)/2) * (H-i);
            ans = min(ans, abs( max({a,b,c}) - min({a,b,c})   ));

            b = ((H-i)/2) * W;
            c = ((H-i+1)/2) * W;
            ans = min(ans, abs( max({a,b,c}) - min({a,b,c})   ));
        }
        swap(H,W);
    }
    cout << ans <<endl;
}






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

int main(void){
	int n, d;
  	scanf("%d %d", &n, &d);
  	int x[n][d];
  	
  	for(int i = 0; i < n; i++)
      for(int j = 0; j < d; j++)
      	scanf("%d", &x[i][j]);
  
  	int count = 0;
  	double s = 0;
  	for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        s = 0;
        for(int k = 0; k < d; k++){
          	s += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        s = sqrt(s);
        if(ceil(s) == floor(s))
         count++;
      }
    }
  
  	printf("%d\n", count); 
  	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B, K;
    cin >> A >> B >> K;

    if (K < A) {
        cout << A-K << " " << B << endl;
    } else if (K < A+B) {
        cout << 0 << " " << A+B-K << endl;
    } else {
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<int(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
int solve(int x){
	int ans = 0;
	while(x){
		ans += x%10;
		x/=10;
	}
	return ans;
}
int n,ans;
int main(){
	n = rd();
	ans = 0x3f3f3f3f;
	Rep(A,1,n-1){
		int B = n - A;
		ans = min(ans,solve(A)+solve(B));
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 768
lists = [list(input()) for i in range(3)]
player= {"a":0,"b":1,"c":2}
turn = player["a"]
while True:
    if not lists[turn]:
        break
    x = lists[turn][0] #character
    del lists[turn][0] # delete the first element
    turn = player[x]
if turn == 0:
    print("A")
elif turn == 1:
    print("B")
else:
    print("C")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
void tbd(){

    string s; cin >> s;
    int month = stoi( s.substr(5,2) );
    int day = stoi( s.substr(8,2) );
    if (month >= 5){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }

}

int main(){

    tbd();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
}; 

int main(){
    Stream io;
    
    int A, B, C;
    io.read(A, B, C);
    vector<int> v = {A, B, C};
    sort(v.begin(), v.end());
    int ans;
    if(v[0] == v[1] && v[0] == v[2]){
        ans = 0;
    }
    else if(v[0] == v[1]){
        ans = v[2] - v[0];
    }
    else{
        ans = 0;
        if(v[1] != v[2]){
            ans += v[2] - v[1];
            v[0] += v[2] - v[1];
            v[1] = v[2];
        }
        ans += ((v[1] - v[0]) + (v[1] - v[0]) % 2) / 2;
        v[0] += (v[1] - v[0]) + (v[1] - v[0]) % 2;
        if(v[0] > v[1]) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i < M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;

ll euclidean_gcd(ll a, ll b) {
	if (a < b) euclidean_gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}


int main() {
	ll N,X;
	cin >> N>>X;
	vll x(N),y(N);
	rep(i, 0, N) {
		cin >> x[i];
		y[i] = x[i] - X;
		y[i] = abs(y[i]);
	}
	sort(y.begin(), y.end());
	y.erase(unique(y.begin(), y.end()), y.end());
	// y became unique positive

	ll res = y[0];
	rep(i, 1, y.size()) {
		res = euclidean_gcd(res, y[i]);
	}
	cout << res;

}
//ll N;
//cin >> N;
//vll a(N);
//rep(i,0, N) cin >> a[i];

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

int N;
vector<vector<pair<int,int>>> G;
vector<int> seen;
void dfs(int a,int b){
  seen[a]=b;
  for(auto x:G[a]){
    int s,t;
    tie(s,t)=x;
    if(seen[s]==-1){
      dfs(s,(b+t)%2);
    }
  }
}

int main() {
  cin>>N;
  G.resize(N);
  seen.resize(N);
  for(int i=0;i<N;i++){
    seen[i]=-1;
  }
  for(int i=1;i<N;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    G[b].push_back(make_pair(a,c));
    G[a].push_back(make_pair(b,c));
  }
  dfs(0,0);
  for(int i=0;i<N;i++){
    cout<<seen[i]<<endl;
  }
}

Measured memory_bytes: 10228
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int,int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


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

  vector<ll> members(n*3);
  rep(i, n*3)  cin >> members[i];
  sort(members.begin(), members.end());
  
  ll index = n*3-1;
  ll sum = 0;
  rep(i, n) {
      if (members[index] == members[i-1]) sum += members[index-2];
      else { sum += members[index-1]; index--;}
      index--;
    //   cout << sum << endl;
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 2560
use proconio::input;

fn main() {
    input!{
        s: String
    }

    println!("{}", 
        if s.contains("RRR") { 3 }
        else if s.contains("RR") { 2 }
        else if s.contains("R") { 1 }
        else { 0 }
    );
}


Measured memory_bytes: 2188
def main():
    width_of_window,width_of_cartain = map(int,input().split())
    print(cover_window(width_of_window,width_of_cartain))

def cover_window(width_of_window,width_of_cartain):
    if width_of_window <= width_of_cartain*2:
        return 0
    else:
        return width_of_window - width_of_cartain*2

main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n,a;
  int r[1000001]={};
  cin >> n;
  rep(i,n){
    cin >> a;
    if(a==0) {r[a]++; r[a+1]++;}
    else {r[a]++; r[a-1]++; r[a+1]++;}
  }
  int ans = 0;
  rep(i,100005){
    ans = max(ans,r[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int s(int q[],int n){
    int cont=0,mi;
    for(int i=1;i<=n;i++){
        mi = i;
        for(int j=i;j<=n;j++)
            if(q[mi]>q[j]) mi = j;
        if(i==mi) continue;
        swap(q[i],q[mi]);
        cont++;
    }
    return cont;
}
int main(){
    int n,q[101],c;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>q[i];
    c = s(q,n);
    for(int i=1;i<=n;i++)
        if(i==1) cout<<q[i];
        else cout<<' '<<q[i];
    cout<<endl<<c<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n[5];
  for(int i=0; i<5; i++)
    cin >> n[i];
  sort(n, n+5);
  for(int i=4; i>0; i--)
    cout << n[i] << " ";
  cout << n[0] << endl;

  return 0;
}

Measured memory_bytes: 1176