akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> long long sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

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

int dp[3003];
int main() {
        int r,g,b,n;
        cin>>r>>g>>b>>n;
        dp[0]=1;
        for (int i = r; i <= n; i++) {
                dp[i]+=dp[i-r];
        }
        for (int i = g; i <= n; i++) {
                dp[i]+=dp[i-g];
        }
        for (int i = b; i <= n; i++) {
                dp[i]+=dp[i-b];
        }
        cout<<dp[n]<<endl;
        return 0;
}


Measured memory_bytes: 256
#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> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0, mx = 0;
    rep(i, n)
    {
        ans += p[i];
        mx = max(mx, p[i]);
    }
    ans -= mx / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b * 2);

    return 0;
}


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

int main() {
    int n;
    cin>>n;
    ll arr[n],ans=0;
    rep(i,0,n)
        cin>>arr[i];
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k]){
                    if(arr[i]+arr[j]>arr[k] && arr[j]+arr[k]>arr[i] && arr[i]+arr[k]>arr[j]){
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

int main() {
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    string S, T;
    cin >> S;
    cin >> T;
    cout << T << S << endl;
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  ll q;
  cin >> q;

  bool rev = false;
  for (ll i = 0; i < q; ++i) {
    ll t;
    cin >> t;
    if (t == 1) {
      rev = rev ? false : true;
    } else {
      ll f;
      string c;
      cin >> f >> c;

      if (rev) {
        if (f == 1) {
          //s = s + c;
          s.append(c);
        } else {
          //s = c + s;
          s.insert(0, c);
        }
      } else {
        if (f == 1) {
          //s = c + s;
          s.insert(0, c);
        } else {
          //s = s + c;
          s.append(c);
        }
      }
    }
  }

  if (rev) reverse(s.begin(), s.end());
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
vector<int> dad, sizes;
 
void create(int n){
    dad.resize(n);
    sizes.assign(n, 1);
    for(int i = 0; i < n; i++)
        dad[i] = i;
}
 
int find_set(int u){
    return u == dad[u] ? (u) : (u = find_set(dad[u]));
}
 
void union_set(int u, int v){
    u = find_set(u);
    v = find_set(v);
    if(u != v){
        if(sizes[u] < sizes[v])
            swap(u, v);
        sizes[u] += sizes[v];
        dad[v] = u;
    }
}
 
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    int i, n, m, j, u, v;
    cin >> n >> m;
    create(n);
    for(i = 0; i < m; i++){
        cin >> u >> v;
        u--; v--;
        union_set(u, v);
    }
    int ans = 0;
    for(i = 0; i < n; i++){
        ans = max(ans, sizes[find_set(i)]);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4688
#include <iostream>
#define ll long long
#define MAX 100
using namespace  std;

int g[MAX + 1][MAX + 1];
int n;

int ans = 0;

int calc(int i,int j)

{
    if(i < 0 or j < 0 or i > 1 or j > n-1) return 0;
    if(i == 1 && j == n-1)
    {
        return g[i][j];
    }
    
    
    int path1 = calc(i+1,j);
    int path2 = calc(i,j+1);
    
    return g[i][j] + max(path1,path2);
    
    
    
}

int main() {

cin >> n;

for(int i = 0 ; i < 2 ;i++)
{
    for(int j = 0 ; j < n ; j++) cin >> g[i][j];
}


cout << calc(0,0);



}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;

#define int long long 
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;



// ユークリッドの互除法を用いて再帰関数を書けばよい。
ll my_gcd(ll & a, ll & b) {
	if (b == 0) return a;
	ll temp = a % b;
	return my_gcd(b, temp);
}


signed main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a.at(i);
	rep(i, N) a.at(i)--;
	
	bool able = false;
	int first_zero = 0;

	rep(i, N) {
		if (a.at(i) == 0) {
			first_zero = i;
			able = true;
			break;
		}
	}


	int res = first_zero;
	if (able) {
		int now_number = 0;
		for (int i = first_zero; i < N; i++) {
			if (a.at(i) == now_number) {
				now_number++;
			}
			else {
				res++;
			}
		}
	}
	





	if (!able) cout << "-1" << endl;
	else {
		cout << res << endl;
	}

}

Measured memory_bytes: 1792
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int can1[200];
int can2[4100];

int main()
{
  _int64 ans1,ans2,tmp1,tmp2;
  int a,b,c,d,e,f,i,j;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
  memset(can1,0,sizeof(can1));
  can1[0]=1;
  for (i=0;i<200;i++)
    if (can1[i]==1)
    {
      if (i+a<200) can1[i+a]=1;
    }
  for (i=0;i<200;i++)
    if (can1[i]==1)
    {
      if (i+b<200) can1[i+b]=1;
    }
  memset(can2,0,sizeof(can2));
  can2[0]=1;
  for (i=0;i<4100;i++)
    if (can2[i]==1)
    {
      if (i+c<4100) can2[i+c]=1;
    }
  for (i=0;i<4100;i++)
    if (can2[i]==1)
    {
      if (i+d<4100) can2[i+d]=1;
    }
  ans1=-1;ans2=1;
  for (i=1;i*100<=f;i++)
    if (can1[i]==1)
    {
      for (j=0;i*100+j<=f&&j<=i*e;j++)
      {
        if (can2[j]==1)
        {
          tmp1=j;
          tmp2=i*100+j;
          if (tmp1*ans2>tmp2*ans1)
          {
            ans1=tmp1;
            ans2=tmp2;
          }
        }
      }
    }
  printf("%lld %lld\n",ans2,ans1);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int sosuu(int);
int main()
{
  int n,i,num=0;
  
  scanf("%d",&n);
  int a;
  for(i =0;i<n;i++)
    {
      scanf("%d",&a);
      if(sosuu(a)==0)
	{
	  num++;
	}
    }
  printf("%d\n",num);
  return 0;
}

int sosuu(int x)
{
  int i;
  
  if (x==2) return 0; 
  else if(x <2 || x%2==0)return 1;
  for(i =3; i <= sqrt(x);i=i+2)
    {
      if(x%i==0)return 1;
    }
  return 0; 
}
      

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main()
{
    int a, b, c, d, e, k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    cout << ((e - a) > k ? ":(" : "Yay!") << endl;

    return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int n=0;
    for(int i=0;i<s.size()-t.size()+1;i++){
        int nn=0;
        for(int j=0;j<t.size();j++){
            if(s.at(i+j)==t.at(j)){
                nn++;
            }
        }
        if(nn>n)
        n=nn;
    }
    cout << t.size()-n <<endl;
}

Measured memory_bytes: 3628
using System;

class AtCoder {
  static void Main() {
    var S = Console.ReadLine().Trim();
    var answer = 0;
    
    var y = new string[7]{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for(var i = 0; i < y.Length; i++) {
      if(y[i] == S) {
        answer = 7 - i;
        break;
      }
    }
    Console.WriteLine(answer);
  }
}

Measured memory_bytes: 13140
N, X = list(map(int, input().split()))

layers={0:1}
def layers_of_level(n):
    if n in layers:
        return layers[n]
    layers[n] = 2*layers_of_level(n-1)+3
    return layers[n]

def how_many_putty(n,x):
    if n==0 and x==1:
        return 1
    if n==layers_of_level(n):
        return 2**(n+1)-1

    total_layers = layers_of_level(n)
    if x==1:
        return 0
    if x <= 1+layers_of_level(n-1):
        return how_many_putty(n-1, x-1)
    if x == 1+layers_of_level(n-1)+1:
        return how_many_putty(n-1, x-2)+1
    if x <= 1+2*layers_of_level(n-1)+1:
        return how_many_putty(n-1,layers_of_level(n-1))+1+ how_many_putty(n-1,x-layers_of_level(n-1)-2)
    else:
        return 2*how_many_putty(n-1,layers_of_level(n-1))+1

print(how_many_putty(N,X))

Measured memory_bytes: 3064
n,k = map(int,input().split())
l = list(map(int,input().split()))

dp = [float('inf')]*n
dp[0] = 0
for i in range(1,k+1):
    dp[i] = abs(l[0]-l[i])
    
    if i == n-1:
        break

for i in range(k+1,n):
    dp_min = float('inf')
    for j in range(1,k+1):
        tmp = dp[i-j] + abs(l[i] - l[i-j])
        dp_min = min(dp_min, tmp)
    
    dp[i] = dp_min
    
print(dp[n-1])

Measured memory_bytes: 55264
N,M = input().split()
N = int(N)
M = int(M)

def prime_decomposition(n):
    i = 2
    table = []
    counter = []
    while i * i <= n:
        count = 0
        while n % i == 0:
            n /= i
            table.append(int(i))
            count += 1
        counter.append(count)
        i += 1
    count = 0
    if n > 1:
        table.append(int(n))
        count += 1
        counter.append(count)
    return table, counter

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


def cmb_(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p;
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result;


table, counter = prime_decomposition(M)
result = 1

for i in counter:
    a = cmb_(int(i)+int(N)-1,int(N)-1)

    result *= a

print(result%(10**9+7))

Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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 = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

vector<pii> G[200010];
int n;

ll prim(vector<pii> G[]){
    ll cost = 0;
    int used[100100] = {0};
    priority_queue<pii, vector<pii>, greater<pii>> que;
    for(int i = 0; i < G[0].size(); i++) que.push({G[0][i].se, G[0][i].fi});
    used[0] = 1;
    for(int _ = 0; _ < n-1; _++){
        int nv, c;
        while(!que.empty()){
            pii P = que.top();
            que.pop();
            nv = P.se; 
            c = P.fi;
            if(!used[nv])break;
        }
        used[nv] = 1;
        cost += c;
        for(int i = 0; i < G[nv].size(); i++){
            que.push({G[nv][i].se, G[nv][i].fi});
        }
    }
    return cost;
}

struct point{
    int x; int y; int idx;
};

bool cmp(const point &a, const point &b)
{
    return a.x < b.x;
}

int main(){
    cin >> n;
    vector<point> XY, YX;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        XY.pb({x, y, i});
        YX.pb({y, x, i});
    }
    sort(all(XY), cmp);
    sort(all(YX), cmp);
    // for(int i = 0; i < n; i++){
    //     cout << XY[i].idx << ": " <<  XY[i].x  << " " << XY[i].y << endl;
    //     cout << YX[i].idx << ": " <<  YX[i].x  << " " << YX[i].y << endl;
    // }
    // cout << endl;
    for(int i = 0; i < n-1; i++){
        int u = XY[i].idx, v = XY[i+1].idx, d = abs(XY[i].x - XY[i+1].x);
        G[u].pb({v, d});
        G[v].pb({u, d});
        u = YX[i].idx; v = YX[i+1].idx; d = abs(YX[i].x - YX[i+1].x);
        G[u].pb({v, d});
        G[v].pb({u, d});
    }
    // for(int i = 0; i < n; i++){
    //     cout << i << ": ";
    //     for(int j = 0; j < G[i].size(); j++){
    //         cout << "(" << G[i][j].fi << " " << G[i][j].se << ") ";
    //     }
    //     cout << endl;
    // }
    cout << prim(G) << endl;
    return 0;
}

Measured memory_bytes: 15916
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	int a=n/100;
	if(a*111>=n) cout<<a*111<<endl;
	else cout<<(a+1)*111<<endl;
	
	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.at(i);
  }
  bool ans=true;
  for(int i=0;i<N-1;i++){
    if(S.at(i).at((S.at(i)).size()-1)!=S.at(i+1).at(0)){
      ans=false;
    }
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i)==S.at(j)){
        ans=false;
      }
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <climits>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
template <typename... tail> void outl(tail&&... t) {out(move(t)...); out('\n');}
#undef vo

int tax(int p, int r) {
	return p * (100 + r) / 100;
}
int fix(int p, int r) {
	return p - p * r / (100 + r);
}

int main() {
	for (int x, y, s; x = in(), y = in(), s = in(), x || y || s;) {
		int m = INT_MIN;
		for (int i = 1, e = s / 2; i <= e; i++) {
			int a = fix(i, x), b = fix(s - i, x);
			if (tax(a, x) + tax(b, x) == s)
				m = max(m, tax(a, y) + tax(b, y));
		}
		outl(m);
	}
}


Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<double> input(int N) {
  vector<double> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n;
  cin >> n;
  vector<double> v=input(n);
  
  rep(i,n){
    v[i] = 1/v[i];
  }
  double sum=0;
  rep(i,n){
    sum += v[i];
    }
  cout << 1/sum << endl;
}


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

using namespace std;
typedef long long ll;

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


//aよりbは左にあるs
//比較関数についてtrueだったら並び替えない,falseだったらaとbをswap
bool compare1(pair<string, ll> a, pair<string, ll> b)
{
  if(a.first == b.first)
    return a.second > b.second;//降順
  else
    return a.first < b.first;//昇順
}

int main()
{
  ll N;
  cin >> N;
  /*
  vector<string> S(N);
  vector<int> P(N);
  set<string> ST; 
  for(int i=0; i<N; i++)
    {
       cin >> S[i] >> P[i];
       ST.insert(S[i]);
    }
  */
  
   

  
  
  vector<pair<string, ll>> SP(N);
  for(int i=0; i<N; i++)
    cin >> SP[i].first >> SP[i].second;

  map<pair<string, int>,int> m;
 for(int i=0; i<N; i++)
   m[SP[i]]=i;

 sort(SP.begin(), SP.end(), compare1);

 //sort(SP.begin(), SP.end(), compare2);

 
 for(int i=0; i<N; i++)
   cout << m[SP[i]]+1 << endl;
  
  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



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

#define N_ARR 10

int main(void)
{
  int N;  
  scanf("%d", &N);
  
  int *v = (int *)malloc(sizeof(v)*N);
  int i;
  
  for(i=0;i<N;i++){
    scanf("%d", &(v[i]));
  }
  
  int n = 0;
  int j;
  int min=999999;
  
  for(i=0;i<N;i++){
    if(min>v[i]){
      min = v[i];
    }
    if(v[i]==min){
      n++;
    }
  }
  
  
  
  printf("%d\n", n);
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,t,a,ans;
  cin>>n>>t>>a;
  int h[n];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  ans=0;
  rep(i,n){
  if(abs(t-h[ans]*0.006-a)>abs(t-h[i]*0.006-a)){
      ans=i;
    }
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 256
l1 = gets.split
n = l1[0].to_i
x = l1[1].to_i
z = gets.split.map(&:to_i)
ans = 0
b = 0
t = 0
n.times do
    b += z[t]
    t += 1
    if b <= x
        ans += 1
    end

end

puts ans + 1

Measured memory_bytes: 1788
#include <cstdio>


int main() {

    int a, b, c, sum;
    scanf("%d%d%d", &a, &b, &c);
    int max = a;
    sum = b + c;
    if(b > max) {
        max = b;
        sum = a + c;
    }
    if(c > max) {
        max = c;
        sum = a + b;
    }
    if(max == sum)
        printf("Yes");
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D,E,X,cou=0,v[3];
    char S[10];
    scanf("%d",&A);
    B=A/1000;
    C=A/100-B*10;
    D=A/10-A/100*10;
    E=A%10;
    if((B==C)&&(C==D)){
        printf("Yes");
    }else if((C==D)&&(D==E)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    int n; cin>>n;
    int s=196471;
    REP(i,n){
        int y,m,d;
        cin>>y>>m>>d;
        for(int i=1;i<=y-1;i++){
            if(i%3==0) d+=200;
            else d+=195;
        }
        for(int i=1;i<=m-1;i++){
            if(y%3==0||i%2==1) d+=20;
            else d+=19;
        }
        cout<<s-d<<endl;
    }
}

Measured memory_bytes: 3108
# 我ながらリスト作成よくやったと思う
# 逃げずにしっかり多次元リストを使った
n = int(input())
rid1 = [[0] * 10 for i in range(3)]
rid2 = [[0] * 10 for i in range(3)]
rid3 = [[0] * 10 for i in range(3)]
rid4 = [[0] * 10 for i in range(3)]
Ridge = [rid1, rid2, rid3, rid4]
for i in range(n):
    b, f, r, v = input().split()
    b = int(b);  f = int(f);  r = int(r);  v = int(v)
    Ridge[b-1][f-1][r-1] += v

#i,jはオブジェクト型だね
# 問題の要求上ボツ（笑）
# for i in Ridge:
#     for j in i:
#         for k in j:
#             print(" %d" %k, end="")
#         print()
#     print("#" * 20)

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" %d" %Ridge[i][j][k], end="")
        print()
    if i != 3:
        print("#" * 20)


Measured memory_bytes: 5620
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int N, M, L, R, C; string S; char Q[4];

	scanf("%d", &N);
	scanf("%d", &M);
	
	cin >> S;

	L = 0;
	R = 0;
	C = 0;

	vector<vector<int> > F(N + 1, vector<int>());

	for (int i = 0; i < M; i++)
	{
		scanf("%s", Q);

		if (Q[0] == 'L' && Q[1] == '+') { L++; }
		if (Q[0] == 'L' && Q[1] == '-') { L--; }
		if (Q[0] == 'R' && Q[1] == '+') { R++; }
		if (Q[0] == 'R' && Q[1] == '-') { R--; }

		F[R - L + 1].push_back(L);

		C = max(C, R - L + 1);
	}

	vector<vector<int> > D(N + 1, vector<int>());

	for (int i = 1; i <= N; i++)
	{
		sort(F[i].begin(), F[i].end());

		if (F[i].size())
		{
			D[i].push_back(F[i][0]);
		}

		for (int j = 1; j < F[i].size(); j++)
		{
			if (F[i][j - 1] != F[i][j])
			{
				D[i].push_back(F[i][j]);
			}
		}
	}

	int Answer = 0;

	for (int i = 1; i <= C; i++)
	{
		set<string> s;

		for (int j = 0; j < D[i].size(); j++)
		{
			s.insert(S.substr(D[i][j], i));
		}

		Answer += s.size();
	}

	cout << Answer << endl;

	return 0;
}

Measured memory_bytes: 36532
#include<stdio.h>

int main()
{
    char b[1];
    scanf("%s",b);
    for(int i=0;i<1;i++)
    {
        if(b[i]=='A'){printf("T\n");}
        if(b[i]=='T'){printf("A\n");}
        if(b[i]=='G'){printf("C\n");}
        if(b[i]=='C'){printf("G\n");}
    }
    return 0;
}

Measured memory_bytes: 1632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz 100010
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

int const N = 6;
int color[N+1][N+1];
int n, m, k, tot;

int go(int r, int mask) {
    if(r == n+m) {
        int sum = 0;
        for(int i=0;i<n;i++) {
            for(int j=0;j<m;j++) {
                if((mask&(1<<i)) && (mask&(1<<(j+n))))
                    sum += color[i][j];
            }
        }
        return (sum == k);
    }
    int ans = go(r+1, mask);
    ans += go(r+1, mask|(1<<r));
    return ans;
}

int main() {
    BeatMeScanf;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++) {
        string str; cin>>str;
        for(int j=0;j<m;j++) {
            color[i][j] = (str[j]=='#') ? 1 : 0;
            if(color[i][j] == 1) tot++;
        }
    }
    ll ans = 0;
    ans = go(0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
int n=0;
int S[2000000+1];

void maxHeapify(int i){
    int l = i*2+1;
    int r = i*2+2;
    ll largest = 0;
    if(l < n && S[l] > S[i]){
        largest = l;
    }else{
        largest = i;
    }
    if(r < n && S[r] > S[largest]){
        largest = r;
    }
    if(largest != i){
        swap(S[i],S[largest]);
        maxHeapify(largest);
    }
}

void heapIncreaseKey(int i, int key){
    if(key < S[i]){
        return;
    }
    S[i] = key;
    while(i > 0 && S[(i-1)/2] < S[i]){
        swap(S[i],S[(i-1)/2]);
        i = (i-1)/2;
    }
}

void insert(int k){
    n++;
    S[n-1] = -MOD;
    heapIncreaseKey(n-1,k);
}

int extractMax(){
    if(n-1 < 0) return -MOD;
    int maxnum = S[0];
    S[0] = S[n-1];
    n--;
    maxHeapify(0);
    return maxnum;
}


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    string order;
    while(1){
        cin >> order;
        if (order == "insert"){
            int num;
            cin >> num;
            insert(num);
        }else if(order == "extract"){
            cout << extractMax() << endl;
        }else if(order == "end"){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 7100
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: A to Z String
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int i, j;
  for (i = 0; s[i] != 'A'; i++);
  for (j = s.size() - 1; s[j] != 'Z'; j--);
  printf("%d\n", j + 1 - i);
  return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int n,t,x;
	cin >> n>>x>>t;
	int c = 0;

	while (1) {
		c += t;
		n -= x;
		if (n<=0) {
			break;
		}
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <iomanip>
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
vector <vector<int> >A;
int magic(int n){
	int c=1,x=n/2,y=x+1;
	while(1){
		A[y][x]=c;
		if(c== n*n)break;
		while(1){
			x=(x+1)%n;
			y=(y+1)%n;
			if(A[y][x]==0)break;
			x=(x+n-1)%n;
			y=(y+1)%n;
			if(A[y][x]==0)break;
		}
		c++;
	}
	return 0;
}
int main(){
	int n,i,j;
	while(cin>>n,n!=0){
		A.resize(n);
		for(i=0;i<n;i++)A[i].resize(n,0);
		magic(n);
		stringstream buf;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++)buf<<setw(4)<<setfill(' ')<< A[i][j];
			cout<<buf.str()<< endl;
			buf.str("");
		}
		A.clear();
	}
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> Pairs;

const int N = 202020;

inline char get(void) {
	static char buf[100000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
template<typename T>
inline void read(T &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int n;
ll addl, addr, ans;
int l[N], r[N];
priority_queue<ll> L;
priority_queue<ll, vector<ll>, greater<ll> > R;

template<typename T>
inline T Abs(T x) {
	return x < 0 ? -x : x;
}

int main(void) {
	read(n);
	for (int i = 1; i <= n; i++) {
		read(l[i]); read(r[i]);
		if (i == 1) {
			L.push(l[i]); R.push(l[i]);
			addl = addr = 0;
			continue;
		}
		int len2 = r[i] - l[i], len1 = r[i - 1] - l[i - 1];
		addl -= len2;
		addr += len1;
		ll lb = L.top() + addl, rb = R.top() + addr;
		if (l[i] < lb) {
			ans += Abs(lb - l[i]);
			R.push(lb - addr);
			L.push(l[i] - addl);
			L.push(l[i] - addl);
			L.pop();
		} else if (l[i] > rb) {
			ans += Abs(rb - l[i]);
			L.push(rb - addl);
			R.push(l[i] - addr);
			R.push(l[i] - addr);
			R.pop();
		} else {
			L.push(l[i] - addl);
			R.push(l[i] - addr);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2924
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  char c; cin >> c;
  cout << ++c << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int[] num = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        System.out.println(num[N-1]);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

bool is_sorted(vector<int> &v) {
    for (size_t i = 0; i < v.size() - 1; i++) {
        if (!(v[i] < v[i + 1])) {
            return false;
        }
    }
    return true;
}

signed main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (auto &x : p) cin >> x;
    if (is_sorted(p)) {
        YES(1);
        return 0;
    }
    FOR(i, 0, N) {
        FOR(j, i + 1, N) {
            swap(p[i], p[j]);
            if (is_sorted(p)) {
                YES(1);
                return 0;
            }
            swap(p[i], p[j]);
        }
    }
    YES(0);
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
n2 = N % 2
if n2 != 0:
  ans = 0
elif N <= 2:
  ans =0
else:
  a = int(np.log(N) // np.log(5))
  A = [N // (2 * (5 ** (i + 1))) for i in range(a)]
  ans = np.sum(A)
print(ans)

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

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back


struct Edge
{
  int from, to;
  ll cap, flow;
};
const int maxn = 1e3+1;
const ll inf = 1e18;
struct ISAP
{
  int n, m, s, t;
  vector<Edge> edges;
  vector<int> g[maxn];
  bool vis[maxn];
  int d[maxn];
  int cur[maxn];
  int p[maxn];
  inline void init(int n)
  {
    this->n = n;
    m = 0;
    for (int i = 0; i < n; ++i)
      g[i].clear();
    edges.clear();
  }
  inline void add(int u, int v, ll cap)
  {
    edges.pb((Edge){u, v, cap, 0});
    edges.pb((Edge){v, u, 0, 0});
    m = edges.size();
    g[u].pb(m-2);
    g[v].pb(m-1);
  }
  inline void bfs()
  {
    fill(d, d+n, n);
    queue<int> q;
    q.push(t);
    d[t] = 0;
    while (!q.empty())
      {
	int cur = q.front();
	q.pop();
	for (int i = 0; i < g[cur].size(); ++i)
	  {
	    Edge &e = edges[g[cur][i]^1];
	    if (d[e.from] == n && e.cap > e.flow)
	      {
		vis[e.from] = true;
		d[e.from] = d[e.to]+1;
		q.push(e.from);
	      }
	  }
      }
  }
  ll add()
  {
    int x = t;
    ll a = inf;
    while (x != s)
      {
	Edge &e = edges[p[x]];
	a = min(a, e.cap-e.flow);
	x = edges[p[x]].from;
      }
    x = t;
    while (x != s)
      {
	edges[p[x]].flow += a;
	edges[p[x]^1].flow -= a;
	x = edges[p[x]].from;
      }
    return a;
  }
  int num[maxn];
  ll maxflow(int s, int t)
  {
    this->s = s, this->t = t;
    ll flow = 0;
    memset(num, 0, (n+1)*sizeof(int));
    for (int i = 0; i < n; ++i)
      ++num[d[i]];
    int x = s;
    memset(cur, 0, n*sizeof(int));
    while (d[s] < n)
      {
	if (x == t)
	  {
	    flow += add();
	    x = s;
	  }
	int ok = 0;
	for (int i = cur[x]; i < g[x].size(); ++i)
	  {
	    Edge &e = edges[g[x][i]];
	    if (e.cap > e.flow && d[x] == d[e.to]+1)
	      {
		ok = 1;
		p[e.to] = g[x][i];
		cur[x] = i;
		x = e.to;
		break;
	      }
	  }
	if (!ok)
	  {
	    int m = n-1;
	    for (int i = 0; i < g[x].size(); ++i)
	      {
		Edge &e = edges[g[x][i]];
		if (e.cap > e.flow) m = min(m, d[e.to]);
	      }
	    if (--num[d[x]] == 0) break;
	    num[d[x]=m+1]++;
	    cur[x] = 0;
	    if (x != s) x = edges[p[x]].from;
	  }
      }
    return flow;
  }
} isap;

int n;
ll a[maxn];

int main()
{
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%lld", a+i);
  isap.init(n+10);
  const int src = isap.n-1, dest = src-1;
  ll tot=0;
  for (int i = 1; i <= n; ++i)
    a[i] *= -1;
  for (int i = 1; i <= n; ++i)
    if (a[i] >= 0)
      isap.add(src, i, a[i]), tot += a[i];
    else
      isap.add(i, dest, -a[i]);
  for (int i = 1; i <= n; ++i)
    for (int j = 2*i; j <= n; j += i)
      isap.add(i, j, inf);
  ll tmp=tmp=isap.maxflow(src, dest);
  //  cerr << "flow = " << tmp << endl;
  //  cerr << "tot = " << tot << endl;
  ll sum = 0;
  for (int i = 1; i <= n; ++i)
    sum += a[i];
  tot -= tmp;
  //  cerr << "sum = " << sum << endl;
  printf("%lld\n", -sum+tot);
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T>
istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }

class UnionFind {
private:
  vector<int> par;
  vector<int> rnk;
  int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
public:
  UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; }
  void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } }
  bool same(int x, int y) { return find(x) == find(y); }
};

struct InitCpp { InitCpp() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
} } initCpp;

using P = pair<int, i64>;
signed main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<i64> S(a), T(b);
  cin >> S >> T;
  S.insert(S.begin(), -INF<i64>);
  T.insert(T.begin(), -INF<i64>);
  S.push_back(INF<i64>);
  T.push_back(INF<i64>);
  vector<P> X(q);
  REP(i, q) {
    X[i].first = i;
    cin >> X[i].second;
  }
  sort(ALL(X), [](P p1, P p2) { return p1.second < p2.second; });
  int i = 0, j = 0;
  REP(k, q) {
    i64 x = X[k].second;
    while (S[i + 1] < x) i += 1;
    while (T[j + 1] < x) j += 1;
    i64 sl = x - S[i],
        sr = S[i + 1] - x,
        tl = x - T[j],
        tr = T[j + 1] - x;
    if (min({sl,sr,tl,tr})<0)
      cerr << "err";
    X[k].second = min({
      max(sl, tl),
      max(sr, tr),
      sl * 2 + tr,
      sl + tr * 2,
      sr * 2 + tl,
      sr + tl * 2,
    });
  }
  sort(ALL(X), [](P p1, P p2) { return p1.first < p2.first; });
  for (P p : X) {
    cout << p.second << endl;
  }
}

Measured memory_bytes: 4448
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int binary_search(int key, vector<ll> a) {
	int left = 0, right = (int)a.size() - 1; // 配列 a の左端と右端
	while (right >= left) {
		int mid = left + (right - left) / 2; // 区間の真ん中
		if (a[mid] == key) return mid;
		else if (a[mid] > key) right = mid - 1;
		else if (a[mid] < key) left = mid + 1;
	}
	return -1;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	int S = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		S ^= a[i];
	}
	for (int i = 0; i < n; i++) {
		int ans = S^a[i];
		cout << ans << " ";
	}
	return 0;
}

Measured memory_bytes: 4824
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

const int INF = 1e7;
size_t N;
int cost_min = INF;
vector<int> a;

int calc_cost(int b)
{
    int cost = 0;
    for (size_t i = 0; i < N; i++) {
        cost += (a[i] - b) * (a[i] - b);
    }
    return cost;
}

int main()
{
    cin >> N;
    a.resize(N);

    for (size_t i = 0; i < N; i++) {
        cin >> a[i];
    }

    for (int b = -100; b <= 100; b++) {
        cost_min = min(cost_min, calc_cost(b));
    }

    cout << cost_min << endl;

    return 0;
}

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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (B == 1) {
		cout << 0 << endl;
	}
	else {
		int cnt = 0;
		B--;
		while (B > 0)B -= (A - 1), cnt++;
		cout << cnt << endl;
	}
	return 0;
}

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

const int MAXN = 100010;
const long long MODK = 1000000000ll + 7;
int main() {
	string s;
	cin>>s;
	long long dp[MAXN][3];
	memset(dp, 0, sizeof(dp));
	//dp[0][0]=dp[0][1]=dp[0][2]=0;
	if (s[0]=='?' || s[0]=='A')
		dp[0][0]=1;
	long long count = (s[0]=='?'?3:1);
	for (int i=1; i<s.size(); i++) {
		if (s[i]=='A' || s[i]=='?') {
			dp[i][0] = (count + dp[i-1][0])%MODK;
			dp[i][1] = (dp[i][1] + dp[i-1][1])%MODK;
			dp[i][2] = (dp[i][2] + dp[i-1][2])%MODK;
		}
		if (s[i]=='B' || s[i]=='?') {
			dp[i][0] = (dp[i][0] + dp[i-1][0])%MODK;
			dp[i][1] = (dp[i][1] + dp[i-1][1] + dp[i-1][0])%MODK;
			dp[i][2] = (dp[i][2] + dp[i-1][2])%MODK;
		}
		if (s[i]=='C' || s[i]=='?') {
			dp[i][0] = (dp[i][0] + dp[i-1][0])%MODK;
			dp[i][1] = (dp[i][1] + dp[i-1][1])%MODK;
			dp[i][2] = (dp[i][2] + dp[i-1][2] + dp[i-1][1])%MODK;
		}
		if (s[i]=='?')
			count = count*3%MODK;
		// cout<<"i="<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	}
	cout<<dp[s.size()-1][2]<<endl;
	return 0;
}


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

int main(){
    int N, L[2000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> L[i];
    sort(L, L+N);
    int64_t ans = 0;
    for(int i=0; i<N; i++) for(int j=0; j<i; j++){
        int ng = lower_bound(L, L+N, L[i]+L[j]) - L;
        ans += max(0, ng-i-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int ll;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int n; cin >>n;
  vector<ll> a(n);
  cinf(n,a);
  int right=0;
  ll ans=0;
  ll sum=a[0];
  ll xorsum=a[0];
  int cnt=0;
  for(int left=0;left<n;left++){
    while(sum==xorsum){
      if(right>=n)break;
      cnt++;
      right++;
      if(right==n)break;
      sum+=a[right];
      xorsum=xorsum^a[right];
    }
    ans+=cnt;
    sum-=a[left];
    xorsum=xorsum^a[left];
    cnt--;
  }
  cout << ans << endl;
}

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

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

	int N; cin>>N;
	vector<int> L(N);
	if(N<3){
		cout << 0 << endl;
		return 0;
	}
	rep(i,N) cin>>L[i];
	sort(L.begin(),L.end());

	int ans=0;
	for(int i=0; i<L.size()-2; i++){
		for(int j=i+1; j<L.size()-1; j++){
			if(L[i]==L[j]) continue;
			auto itel = upper_bound(L.begin(), L.end(), L[j]);
			int l = itel - L.begin();
			
			auto ite = lower_bound(L.begin(), L.end(), L[i]+L[j]);
			int r = ite - L.begin();
			// cerr << l << " " << r << endl;
			ans += r - l;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

int h[100000 + 10];
int costs[100000 + 10];

int cost(int x)
{
  assert(0 <= x);
  if (x == 0)
    return 0;
  if (x == 1)
    return abs(h[1] - h[0]);

  if (costs[x] != -1) {
    return costs[x];
  }

  int a = cost(x - 1) + abs(h[x] - h[x - 1]);
  int b = cost(x - 2) + abs(h[x] - h[x - 2]);
  return costs[x] = min(a, b);
}

int main()
{
  int n, tmp, i = 0;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    costs[i] = -1;
    cin >> h[i];
  }
  cout << cost(n - 1) << endl;

  return 0;
}


Measured memory_bytes: 4096
using System;

class Program
{
    static void Main(string[] args)
    {
        int[] a = new int[100000];
        int n = int.Parse(Console.ReadLine());
        int i, divs;
        long ans;
        for (i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine());
        ans = a[0] - 1;
        divs = 2;
        for (i = 1; i < n; i++)
        {
            if (a[i] == divs) divs++;
            else
            {
                ans = ans + (a[i] - 1) / divs;
            }
        }
        Console.WriteLine(ans);
    }
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int h,w;cin>>h>>w;
    string s,a;
    while (h--){
        cin>>s;
        cout<<s<<endl<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 256