akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int H,W;  cin>>H>>W;
  int N;  cin>>N;
  vector<int> v(N);
  rep(i,0,N) cin>>v[i];
  int now=0;
  int d[H][W];
  memset(d, 0, sizeof(d));
  rep(i,0,H){
    rep(j,0,W){
      d[i][j] = now+1;
      v[now]--;
      if(!v[now]) now++;
    }
  }
  rep(i,0,H){
    rep(j,0,W){
      int x = d[i][j];
      if(i%2==1) x = d[i][W-1-j];
      cout<<x<<" ";
    }
    cout<<endl;
  }
  return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count = n;
    vector<int> lefts(n + 1);
    vector<int> rights(n + 1);
    
    if (s.at(0) == 'W') lefts.at(0) = 1;
    for (int i = 1; i < n; i++) {
        lefts.at(i) = lefts.at(i - 1);
        if (s.at(i) == 'W') lefts.at(i)++;
    }

    for (int i = n - 1; i >= 0; i--) {
        rights.at(i) = rights.at(i + 1);
        if (s.at(i) == 'E') rights.at(i)++;
    }
    count = min(rights.at(1), count);
    for (int i = 1; i < n; i++) {
        count = min(lefts.at(i - 1) + rights.at(i + 1), count);
    }
    cout << count << endl;

return 0;
}

Measured memory_bytes: 6156
def change(array):
    output = array[0]
    for a in array[2:]:
        output = output[int(a):]+output[:int(a)]
    return output


temp_arr = []
while True:
    temp = input()
    if temp == '-':
        break
    temp_arr.append(temp)

each_item = []
each_temp = []
for a in temp_arr:
    if not a.isdigit():
        each_item.append(each_temp)
        each_temp = []
    each_temp.append(a)
each_item.append(each_temp)
each_item.pop(0)


for item in each_item:
    print(change(item))






Measured memory_bytes: 5600
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

for i in range(k,n):
  if t[i]==t[i-k]:
    t[i]="a"
print((t.count("r")*p)+(t.count("s")*r)+(t.count("p")*s))

Measured memory_bytes: 4084
t = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

f_a = t[0]*a[0]
f_b = t[0]*b[0]
if f_a < f_b:
    x = 1
else:
    x = -1

s_a = f_a + t[1]*a[1]
s_b = f_b + t[1]*b[1]
if s_a < s_b:
    y = 1
else:
    y = -1

if s_a==s_b:
    print('infinity')
else:
    if x==y:
        print(0)
    else: 
        s = abs(f_a-f_b)
        t = abs(s_a-s_b)
        print((s//t*2)+(s%t!=0))


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

long long int gcd(long long int n, long long int m)
{
    if(m == 0) return n;
    return gcd(m, n % m);
}

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

bool possible(long long int N, long long int M, long long int L, string S, string T)
{
    long long int i = 0;
    long long int g = gcd(N, M);
    for(i = 0; i < g; ++i) {
        if(S[N/g * i] != T[M/g * i]) return false;
    }
    return true;
}

int main()
{
    long long int N, M;
    cin >> N >> M;
    string S, T;

    cin >> S;
    cin >> T;

    long long int L = lcm(N, M);

    if(possible(N, M, L, S, T)) {
        cout << L;
    } else {
        cout << -1;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  cout << ((-n)%1000+1000)%1000 << newl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <algorithm>

int main() {
	int N;
	bool judge = true;
	std::cin >> N;
	std::vector<std::string>shiri(100);
	std::vector<std::string>shiri2;

	for (int i = 0; i < N; i++) {
		std::cin >> shiri[i];
	}

	for (int i = 0; i < N - 1; i++) {
		if (shiri[i].back() != shiri[i + 1].front()) {
			judge = false;
		}
	}

	for (int i = 0; i < N; i++) {

		for (int j = 0; j < N; j++) {
			if (i != j) {
				shiri2.push_back(shiri[j]);
			}
		}

		for (int j = 0; j < N - 1; j++) {
			if (shiri[i] == shiri2[j + i * (N - 1)]) {
				judge = false;
			}
		}

	}

	if (judge == true) {
		std::cout << "Yes" << std::endl;
	}
	else if (judge == false) {
		std::cout << "No" << std::endl;
	}

}

Measured memory_bytes: 768
#include <stdio.h>

int main(void) {
	int a,b,c,z;
	scanf("%d%d%d",&a,&b,&c);
	
	if(a>b){
		z=a;
		a=b;
		b=z;
	}
	
	if(b>c){
		z=b;
		b=c;
		c=z;
	}
	
if(a>b){
		z=a;
		a=b;
		b=z;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int p[4];
int t[4];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 1e9;
    int N;
    cin >> N;
    for(int i = 0; i <= 3; i++) cin >> p[i];
    for(int i = 0; i <= 3; i++) cin >> t[i];
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= 100; j++) {
            for(int k = 0; k <= 100; k++) {
                for(int l = 0; l <= 100; l++) {
                    if(t[0] * i + t[1] * j + t[2] * k + t[3] * l >= N) {
                        chmin(ans, p[0] * i + p[1] * j + p[2] * k + p[3] * l);
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;
#define ll long long
#define mod 1000000007

ll powx(ll x){
    if(x==0){
        return 1;
    }else{ 
        ll y=powx(x/2);
        if(x%2==0){
            return ((y%mod)*(y%mod))%mod;
        }else{
            return ((y%mod)*(y%mod)*2)%mod;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,z,p,q,r,s,t,k;
    string a,b,c;
    cin>>x>>k;
    ll ar[x],arr[x];
    for(ll i=0;i<x;i++){
        cin>>ar[i];
    }
    arr[0]=0;
    arr[1]=abs(ar[1]-ar[0]);
    for(ll i=2;i<x;i++){
        arr[i]=arr[i-1]+abs(ar[i]-ar[i-1]);
        for(ll j=2;j<=k;j++){
            if(i>=j){
                arr[i]=min(arr[i-j]+abs(ar[i]-ar[i-j]),arr[i]);
            }
        }
    }
    cout<<arr[x-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
#define SIZE 1111
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<ll, pii>pi3;
ll mod = 1000000007;
vector<pii>pat[1111];
bool flag[1111];
ll dist[1111][1111];
void dfs(int node, ll now, int p)
{
	if (flag[node])return;
	flag[node] = true;
	dist[p][node] = now;
	for (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i].first, max(now, pat[node][i].second), p);
}
int main()
{
	int num, way;
	ll mok;
	scanf("%d%d%lld", &num, &way, &mok);
	map<ll, vector<pii> >ma;
	for (int i = 0; i < way; i++)
	{
		ll za, zb, zc;
		scanf("%lld%lld%lld", &za, &zb, &zc);
		za--, zb--;
		ma[zc].push_back(make_pair(za, zb));
	}
	uf.init();
	int prb = 0;
	ll mst = 0;
	map<ll, vector<pii> >::iterator it = ma.begin();
	for (;;)
	{
		if (it == ma.end())break;
		vector<pii>v = (*it).second;
		for (int i = 0; i < v.size(); i++)if (uf.find(v[i].first) != uf.find(v[i].second))prb++;
		for (int i = 0; i < v.size(); i++)if (uf.find(v[i].first) != uf.find(v[i].second))
		{
			uf.unite(v[i].first, v[i].second);
			mst += (*it).first;
			pat[v[i].first].push_back(make_pair(v[i].second, (*it).first));
			pat[v[i].second].push_back(make_pair(v[i].first, (*it).first));
		}
		it++;
	}
	if (mst > mok)
	{
		printf("0\n");
	}
	else if (mst == mok)
	{
		ll ans = 1, mns = 2;
		for (int i = 0; i < way; i++)ans = ans * 2 % mod;
		for (int i = 0; i < way - prb; i++)mns = mns * 2 % mod;
		printf("%lld\n", (ans + mod - mns) % mod);
	}
	else
	{
		for (int i = 0; i < num; i++)fill(flag, flag + num, false), dfs(i, 0, i);
		int c1 = 0, c2 = 0;
		map<ll, vector<pii> >::iterator it = ma.begin();
		for (;;)
		{
			if (it == ma.end())break;
			vector<pii>v = (*it).second;
			for (int i = 0; i < v.size(); i++)
			{
				if (dist[v[i].first][v[i].second] + mok - mst == (*it).first)c1++;
				if (dist[v[i].first][v[i].second] + mok - mst < (*it).first)c2++;
			}
			it++;
		}
		ll t1 = 1, t2 = 1;
		for (int i = 0; i < c1; i++)t1 = t1 * 2 % mod;
		for (int i = 0; i < c2; i++)t2 = t2 * 2 % mod;
		printf("%lld\n", 2LL * (t1 - 1)*t2%mod);
	}
}

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


int n;
int sc[51][32];
bool scj[51][31];
int S;

bool dfs(int me, vector<vector<int> > e){
    bool res = false;
   // cout << me << " " << S << endl;
    if(!((~S)&((1<<n)-1))) return true;
    
   
    
    for(int i = 0; i < e[me].size(); i++){
        if(!(S & (1<<e[me][i]))) {
            S |= (1<<e[me][i]);
            res = dfs(e[me][i],e);
        }
        if(res) return true;
    }
    return false;
}

int main(){
    int cc = 0;
    while(cin >> n, n){
        cc += 1 + n;
        for(int i = 0; i < n; i++){
            cin >> sc[i][0];
            for(int j = 0; j < sc[i][0]; j++){
                cin >> sc[i][j+1];
            }
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= 30; j++){
                scj[i][j] = false;
            }
        }
        for(int i = 0; i < n; i++){
            for(int j = 1; j <= sc[i][0]; j++){
                scj[i][sc[i][j]] = true;
            }
        }
        vector<vector<int> > e(n);
        int k;
        bool have[51][51];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++) {
                if(i == j)have[i][j] = true;
                else have[i][j] = false;
            }
        }
       
        for(k = 1; k < 31; k++){
            bool sum[51] = {0};
            for(int i = 0; i < n; i++){
                if(scj[i][k]) {
                    for(int j = 0; j < n; j++) sum[j] |= have[i][j];
                 //   cout << " aa" << i << endl;
                }
            }
            for(int i = 0; i < n; i++){
                if(scj[i][k]) {
                    for(int j = 0; j < n; j++) have[i][j] = sum[j];
                }
            }
           // cout << sum << endl;
            bool flag3 = false;
            for(int j = 0; j < n; j++){
                if(!sum[j]) flag3 = true;
            }
            if(!flag3) break;
        }
        
        if(k > 30) cout << -1 << endl;
        else cout << k << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1208
use std::io::*;

fn read() -> String {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
    
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let s = read();
  println!("{}",
    match &*s {
      "SUN" => 7,
      "MON" => 6,
      "TUE" => 5,
      "WED" => 4,
      "THU" => 3,
      "FRI" => 2,
      "SAT" => 1,
      _ => 0
    }
  );
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define inf 1<<31

#define MX 100

int main()
{
    //freopen("input.txt","r",stdin);

    int n,a,b;
    cin>>n>>a>>b;

    int dif =abs(a-b)-1;
    string ans="";

    if(dif%2==0)
    {
        if(a<b)ans="Borys";
        else ans="Alice";

    }else{
        if(a>b)ans="Borys";
        else ans="Alice";

    }
    cout<<ans<<endl;




    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    string S,T;
    cin >> S>>T;
    
    int flag=0;
    for (int i=0; i<S.size(); i++) {
        T.push_back(T[0]);
        T.erase(T.begin());
        if (T==S) {
            flag=1;
        }
    }
    if (flag==1) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    
    int H , W ;
    
    do{
        cin >> H >> W ;
        if((H == 0)&&(W == 0)){
        }else{
            for(int i = 1 ; i <= H ; i++){
                if(i % 2 == 1){
                    for(int j = 1 ; j <= W ; j++){
                        if(j % 2 == 1){
                            cout << "#" ;
                        }else{
                            cout << "." ;
                        }
                    }
                            cout << endl ;
                }else{
                    for(int j = 1 ; j <= W ; j++){
                        if(j % 2 == 1){
                            cout << "." ;
                        }else{
                            cout << "#" ;
                        }
                    }
                            cout << endl ;
                }
            }
                            cout << endl ;
        }
    }while((H > 0)||(W > 0));
    
    
    
}


Measured memory_bytes: 3100
/*
   DP*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
const long long MaxN = 1e5;

int main()
{
	char s[5];
	int n,vis[5];
	while(~scanf("%s",s))
	{
		memset(vis,0,sizeof(vis));
		n = strlen(s);
		for(int i = 0;i < n;i++)
		{
			if(s[i]=='a') vis[1] = 1;
			else if(s[i]=='b') vis[2] = 1;
			else if(s[i]=='c') vis[3] = 1;
		}
		for(int i = 1;i <= 3;i++)
		{
			if(vis[i]!=1) vis[4] = 1;
		}
		if(vis[4]==1) printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

 int a,b;
 scanf("%d%d", &a,&b);

 if (a < b) {
   printf("a < b\n");

 } else if (a > b) {
   printf("a > b\n");

 } else {
   printf("a == b\n");
 }
   
 

 
  
  
  return 0;
}




Measured memory_bytes: 2072
n, m, k = map(int, input().split())

mod = 998244353

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
for i in range(2, n):
    fac.append(fac[-1] * i % mod)
    inv.append(-inv[mod%i] * (mod // i) % mod)
    finv.append(finv[-1] * inv[-1] % mod)

ans = 0
for i in range(n-k-1, n):
    com = fac[n-1] * finv[i] * finv[n-i-1] % mod
    res = m
    e = m - 1
    while i > 0:
        if i & 1:
            res = res * e % mod
        e = e * e % mod
        i >>= 1
    res = res * com % mod
    ans = (ans + res) % mod

print(ans)

Measured memory_bytes: 113808
//ABの全探索->結果の絞り込み->結果とCの全探索の解法
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int K = sc.nextInt();
		long A[] = new long[X];
		long B[] = new long[Y];
		long C[] = new long[Z];
		for(int i=0;i<X;i++)A[i]=sc.nextLong();
		for(int i=0;i<Y;i++)B[i]=sc.nextLong();
		for(int i=0;i<Z;i++)C[i]=sc.nextLong();
		sc.close();
		
		long tmp[] = new long[X*Y];
 
		int cnt = 0;
		for(int i=0;i<X;i++) {
			for(int j=0;j<Y;j++) {
					tmp[cnt]=A[i]+B[j];
					cnt++;
			}
		}
		rsort(tmp);
		
		long ans[] = new long[Math.min(K,X*Y)*Z]; 
		int cnt2 = 0;
		for(int i=0;i<Math.min(K,X*Y);i++) {
			for(int j=0;j<Z;j++) {
					ans[cnt2]=tmp[i]+C[j];
					cnt2++;
			}
		}
		
		
		rsort(ans);
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<K;i++) {
			sb.append(ans[i]+"\n");
		}
		System.out.println(sb.toString());
	}

	//long型を逆順にソートするメソッド
	static void rsort(long[] a) {
		Arrays.sort(a);
		int len = a.length;
		for (int i = 0; i < (len + 1) / 2; i++) {
			long tmp = a[i];
			a[i] = a[len - i - 1];
			a[len - i - 1] = tmp;
		}
	}
}


Measured memory_bytes: 60928
#include <iostream>

using namespace std;

int main () {
  int x, y;
  cin >> x >> y;
  if (y % 2) {
     cout << "No";
     return 0;
  }
  y /= 2;
  if (x > y || 2 * x < y) cout << "No";
  else cout << "Yes";
  return 0; 
}

Measured memory_bytes: 3636
X,N=map(int,input().split())
if N==0:
    print(X)
else:
    w=input()
    w=w.split()
    t=list(w)
    b=list(range(-150,151))
    tt=[int(a) for a in t]

    ttt=set(tt)
    bb=set(b)

    c=bb^ttt

    cc=list(c)

    u=1000


    for s in cc:
        if abs(s-X)<u:
            u=abs(s-X)

    if (X-u) in cc:
            print(X-u)
    else :
            print(X+u)

Measured memory_bytes: 9128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int a[5],s,i,b[5],k=0;
    for(i=0; i<5; i++)
        scanf("%d",&a[i]);
    for(i=0; i<5; i++)
    {
        if(a[i]%10!=0)
        {
            b[k++]=10-a[i]%10;
        }
    }
    sort(b,b+k);
    s=0;
    for(i=0; i<5; i++)
    {
        s=a[i]+s;
    }
    for(i=0; i<k-1; i++)
    {
            s+=b[i];
    }
    printf("%d",s);
    return 0;
}


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

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

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), T = in.ni();
        int[] t = in.ni(n);
        long ans = T;
        for (int i = 0; i < n-1; i++) {
            ans += Math.min(T, t[i + 1] - t[i]);
        }
        out.println(ans);
    }

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

Measured memory_bytes: 47132
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		long a,b;
		a = sc.nextLong();
		b = sc.nextLong();
		System.out.printf("%d %d %.6f\n",a/b,a%b,(double)a/(double)b);
		
	}
}

Measured memory_bytes: 26620
import numpy as np


def main():
    N = int(input())
    Hs = list(map(int, input().split()))
    ans = True
    for i in range(N-1, 0, -1):
        if Hs[i-1] == Hs[i] + 1:
            Hs[i-1] -= 1
        elif Hs[i-1] > Hs[i] + 1:
            ans = False
            break
        elif Hs[i-1] <= Hs[i]:
            pass

    if ans == True:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 2e5 + 2;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue
#define getsz(x) (int) log10(x)

int n;
ll a[maxn], x[maxn], y[maxn], ans;
int main(){
    cin >> n;
    ans = n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        x[i] = a[i];
        y[i] = a[i];
    }
    for(int i = 2; i <= n; i++){
        x[i] ^= x[i - 1];
        y[i] += y[i - 1];
    }
    for(int i = 1; i <= n; i++){
        int l = i, r = n;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if((x[mid] ^ x[i - 1]) == y[mid] - y[i - 1]){
                l = mid;
            }
            else {
                r = mid;
            }
        }
        if((x[r] ^ x[i - 1]) == y[r] - y[i - 1]){
            ans += (r - i);
        }
        else {
            ans += (l - i);
        }
    }
    cout << ans;
}


Measured memory_bytes: 4992
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  arr = [];
  for (i = 0; i < 52; i++) {
    switch (Math.floor(i / 13)) {
      case 0:
        arr.push("S " + (i + 1));
        break;
      case 1:
        arr.push("H " + (i % 13 + 1));
        break;
      case 2:
        arr.push("C " + (i % 13 + 1));
        break;
      case 3:
        arr.push("D " + (i % 13 + 1));
        break;
    }
  }

  
  input = input.split("\n");
  i = 1
  while (input[i] != 0) {
    for (j = 0; j < arr.length; j++) {
      if (arr[j] == input[i]) {
        arr.splice(j, 1);
      }
    }
    i++;
  }
  if (arr.length > 0) {
    console.log(arr.join("\n"));
  }
});

Measured memory_bytes: 7640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	vi jud(n,0);
	vi cnt(n,0);
	REP(i,m){
		int p;
		string s;
		cin>>p>>s;
		
		if(s=="AC"){
			jud[p-1]=1;
		}else{
			if(jud[p-1]){}
			else cnt[p-1]++;
		}
	}
	
	int ac=0,wa=0;
	REP(i,n){
		if(jud[i]){
			ac++;
			wa+=cnt[i];
		}
	}
	
	cout<<ac<<' '<<wa<<endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

struct Solver {
  Solver(int n) : n(n) {}
  const int n;
  vector<int> v;
  void solve(){
    solve(n, 0);
  }
  void solve(int mv, int t){
    if (t == n) show(v, Out<int>);
    if (t >= n) return;
    for (int i = mv; i > 0; i--){
      v.push_back(i);
      solve(i, t + i);
      v.pop_back();
    }
  }
};

int main()
{
  int n;
  while (n = in()){
    Solver s(n);
    s.solve();
  }

  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1228
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();

        final int[][] table = new int[h][w];
        for (int i = 0; i < h; i++) {
            final String s = scanner.next();
            for (int j = 0; j < w; j++) {
                table[i][j] = s.charAt(j) == '#' ? 1 : Integer.MAX_VALUE - 1;
            }
        }

        for (int i = 1; i < h; i++) {
            for (int j = 0; j < w; j++) {
                table[i][j] = Math.min(table[i][j], table[i - 1][j] + 1);
            }
        }

        for (int i = h - 2; i >= 0; i--) {
            for (int j = 0; j < w; j++) {
                table[i][j] = Math.min(table[i][j], table[i + 1][j] + 1);
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 1; j < w; j++) {
                table[i][j] = Math.min(table[i][j], table[i][j - 1] + 1);
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = w - 2; j >= 0; j--) {
                table[i][j] = Math.min(table[i][j], table[i][j + 1] + 1);
            }
        }

        final int answer = Arrays.stream(table)
                .flatMapToInt(Arrays::stream)
                .max()
                .getAsInt() - 1;

        System.out.println(answer);
    }
}


Measured memory_bytes: 37288
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;

struct SegmentTree {
  private:
    int n;
    vector<ll> node;

  public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while(n < sz)
            n *= 2;
        node.resize(2 * n - 1, INF);
        for(int i = 0; i < sz; i++)
            node[i + n - 1] = v[i];
        for(int i = n - 2; i >= 0; i--)
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int x, ll val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2 * x + 1], node[2 * x + 2]);
        }
    }

    ll getmin(int a, int b, int k = 0, ll l = 0, ll r = -1) {
        if(r < 0)
            r = n;
        if(r <= a || b <= l)
            return INF;
        if(a <= l && r <= b)
            return node[k];

        ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

int main() {
    ll N;
    cin >> N;
    vector<pll> A(N);
    rep(i, N) {
        ll l, r;
        cin >> l >> r;
        A[i] = make_pair(l, r);
    }
    sort(All(A));
    ll res = 0;
    vector<ll> v(N);
    SegmentTree st(v);
    rep(i, N) st.update(i, A[i].second);
    for(int i = 1; i < N; i++) {
        ll a1 = 0, a2 = 0;
        if(st.getmin(0, i) - A[i - 1].first >= 0)
            a1 = max(st.getmin(0, i) - A[i - 1].first + 1LL, 0LL);
        if(st.getmin(i, N) - A[N - 1].first >= 0)
            a2 = max(st.getmin(i, N) - A[N - 1].first + 1LL, 0LL);
        res = max(res, a1 + a2);
    }
    for(int i = 0; i < N; i++) {
        ll a1 = 0, a2 = 0;
        a1 = A[i].second - A[i].first + 1;
        a2 = max(min(st.getmin(i + 1, N), st.getmin(0, i)) - A[N - 1].first +
                     1LL,
                 0LL);
        res = max(res, a1 + a2);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#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
#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 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; }

#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;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  if(s == "RRR"){
    cout << 3 << "\n";
  }else if(s == "RRS" || s == "SRR"){
    cout << 2 << "\n";
  }else if(s == "SSS"){
    cout << 0 << "\n";
  }else{
    cout << 1 << "\n";
  }

  return 0;
}


Measured memory_bytes: 3652
/*
ye mera template hai
apna khud likho bc :P
*/

/*
Author : Sarvagya Agarwal
*/

#include<bits/stdc++.h>
using namespace std;

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int32_t main()
{
    fast;
    int n ; 
    string s ; 
    cin >> n >> s ; 
    int x = 0 , ans = 0 ; 
    rep(i,0,n-1) {
        ans = max(ans , x) ; 
        if(s[i] == 'I') x++;
        else x-- ;
        ans = max(ans , x) ; 
    }
    cout << ans ; 
    return 0;
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
sx,sy=0,0
for j in range(n):
    
    if A[j][2]==1 and sx<A[j][0]:
        sx=A[j][0]

    if A[j][2]==2 and w>A[j][0]:
        w=A[j][0]

    if A[j][2]==3 and sy<A[j][1]:
        sy=A[j][1]

    if A[j][2]==4 and h>A[j][1]:
        h=A[j][1]

if (w-sx)<0 or (h-sy)<0 :
    print(0)
else:
    print((w-sx)*(h-sy))

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

int main() {
  int x;
  cin >> x;
  
  int a = x / 100;
  int b = x % 100;
  
  bool ok = false;
  for (int i = 0; i <= 5*a; i++) {
    if (i == b) ok = true;
  }
  if (ok)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  int n,ans=0;
  cin >> n;
   REP2(i,n){
     if(i%3!=0&&i%5!=0)
       ans += i;
   }
   cout << ans;
}

Measured memory_bytes: 3632
import sys
s=input()
n=len(s)
s1=s[0:(n-1)//2]
s2=s[(n+1)//2:n]
if s1!=s2:
  print("No")
  sys.exit()
for i in range(0,len(s1)//2+1):
  if s1[i]!=s1[-i-1]:
    print("No: "+s1[i]+","+s1[-i-1])
    sys.exit()
print("Yes")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define bs binary_search
    #define pb push_back
    #define pp pair<ll,ll>
    #define F first 
    #define S second 
    #define lc "\n"
    ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
    ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
    int main() 
    {
        fastio
        map<string,ll>mp;
        ll n; cin>>n; string s;
        while(n--)
        {
            cin>>s;
            mp[s]++;
        }
        cout<<mp.size();
        return 0;
    }

Measured memory_bytes: 19248
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N],i,v,j;
    for(i=0;i<N;i++) cin>>A[i];
    for(i=1;i<N;i++){
        for(int c=0;c<N;c++){
            cout<<A[c];
            if(c!=N-1) cout<<" ";
        }
        cout<<endl;
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
            A[j+1]=v;
        }
    }
    for(int c=0;c<N;c++){
            cout<<A[c];
            if(c!=N-1) cout<<" ";
        }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;
int n,m,s,g;
double d[33][33][33];
vector<pair<int,pair<int,int> > >G[33];
main()
{
	while(cin>>n>>m,n)
	{
		cin>>s>>g;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=30;j++)for(int k=1;k<=n;k++)d[i][j][k]=1e9;
			G[i].clear();
		}
		for(int i=0;i<m;i++)
		{
			int u,v,d,c;
			cin>>u>>v>>d>>c;
			G[u].push_back({v,{d,c}});
			G[v].push_back({u,{d,c}});
		}
		priority_queue<pair<pair<double,int>,pair<int,int> > >P;
		P.push({{0,0},{s,0}});
		d[s][0][0]=0;
		while(!P.empty())
		{
			double c=-P.top().first.first;
			int prev=P.top().first.second;
			int u=P.top().second.first,speed=P.top().second.second;
			P.pop();
			if(d[u][speed][prev]<c)continue;
			for(int i=0;i<G[u].size();i++)
			{
				int v=G[u][i].first,di=G[u][i].second.first,se=G[u][i].second.second;
				if(v==prev)continue;
				for(int j=-1;j<=1;j++)
				{
					if(speed+j<=0||speed+j>se)continue;
					double ne=c+(double)di/(speed+j);
					if(d[v][speed+j][u]>ne)
					{
						d[v][speed+j][u]=ne;
						P.push({{-ne,u},{v,speed+j}});
					}
				}
			}
		}
		double ans=1e9;
		for(int i=1;i<=n;i++)ans=min(ans,d[g][1][i]);
		if(ans<1e9)cout<<fixed<<setprecision(9)<<ans<<endl;
		else cout<<"unreachable"<<endl;
	}
}



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

using namespace std;

const int N = 2005;

vector<int> g[N];

int dist[N][N];

void bfs(int st) {
	queue<int> q;
	dist[st][st] = 0;
	q.push(st);

	while(!q.empty()) {
		int u = q.front(); q.pop();
		for(int v : g[u]) if(dist[st][v] == -1) {
			dist[st][v] = dist[st][u] + 1;
			q.push(v);
		}
	}
}

int ans[N];

int main() {
	memset(dist, -1, sizeof dist);

	int n, x, y;
	cin >> n >> x >> y;
	for(int i = 1; i + 1 <= n; i++) {
		g[i].push_back(i + 1);
		g[i + 1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);

	for(int i = 1; i <= n; i++) bfs(i);

	for(int i = 1; i <= n; i++) for(int j = i + 1; j <= n; j++) ans[ dist[i][j] ]++;

	for(int i = 1; i < n; i++) {
		printf("%d\n", ans[i]);
	}
}


Measured memory_bytes: 19436
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>
#include <cmath>
 
// 許容する誤差ε
#define EPS (1e-10)

//浮動小数点演算の誤差を考慮した比較を行うマクロ
//等しい(=)　!=を使いたい場合は、!EQとすればよい
#define EQ(x,y) (fabs((x) - (y)) < EPS)
//小なり(<)
#define LT(x,y) ((x) - (y) <= -EPS)
//小なりイコール(<=)
#define LE(x,y) ((x) - (y) < EPS)
//大なり(>)
#define GT(x,y) ((x) - (y) >= EPS)
//大なりイコール(<)
#define GE(x,y) ((x) - (y) > -EPS)

// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
// 円周率
#define PI (acos(-1.0))
//　0≦t＜PIの範囲で偏角を求める（通常のarg()は -PI≦t≦PI)
#define POSARG(a) (arg((a)) > 0.0? arg((a)) : 2.0*PI + arg((a)))

using namespace std;
typedef complex<double> P;
 
double ccw(P& p1, P& p2, P& p3)
{
    return ((p2.real() - p1.real())*(p3.imag() - p1.imag()) 
                - (p2.imag() - p1.imag())*(p3.real() - p1.real())) > 0;
}// ccw>0 => ccw, ccw=0 => colinear, ccw<0, cw
 
bool complex_pred(const P& a, const P& b)
{
    if (a.real() != b.real())
        return a.real() < b.real();
    else
        return a.imag() < b.imag();
}
 
vector<P> solve(vector<P> vc)
{
	sort(vc.begin(), vc.end(), complex_pred);

	int k = 0;
	vector<P> vc2(vc.size()*2);
	
	for (int i = 0; i < (int)vc.size(); i++)
	{
		while( k >= 2 && !ccw(vc2[k-1], vc2[k-2], vc[i]))
		{
			k--;
		}
		
		vc2[k]=vc[i];
		k++;
	}

	int t = k;
	
	for (int i = vc.size()-1; i >= 0; i--)
	{
		while ( k > t && !ccw(vc2[k-1], vc2[k-2], vc[i]))
		{
			k--;
		}
		
		vc2[k]=vc[i];
		k++;
	}
	
	vc2.resize(k-1);
	return vc2;
}

 
int main()
{
    int n;
     
    while(cin >> n, n)
    {
        vector<P> vc;
        vc.clear();
         
        for(int i = 0; i < n; i++)
        {
            char c;
            double a, b;
            cin >> a;
            cin >> c;
            cin >> b;
            vc.push_back(P(a, b));
        }
         
        vector<P> vc2 = solve(vc);
        cout << int(n - vc2.size()) << endl;
    }
     
    return 0;
}

Measured memory_bytes: 1244
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for i in range(M):
	x, y, c = map(int, input().split())
	if a[x-1] + b[y-1] - c < ans:
		ans = a[x-1] + b[y-1] - c
print(ans)

Measured memory_bytes: 70252
#include<bits/stdc++.h>
using namespace std;
int main(){
	while(1){
		int a, b =0,c;
		cin>>a;
		if(a == 0)break;
		for (int i = 1; i < 10 ;i++){
			cin>>c;
			b += c;
		}

		cout<<a - b<<endl;
	}
	return 0;
}



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

int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    sort(v.begin(), v.end());
    ll  k=v[n-1];
    if(k%2!=0){
        auto itr=lower_bound(v.begin(), v.begin()+n-1, (k+1)/2);
        ll a=*(itr-1);
        ll b=*itr;
        ll x=abs(a-(k+1)/2);
        ll y=abs(b-(k+1)/2);
        if(x>y) cout<<k<<" "<<b<<endl;
        else cout<<k<<" "<<a<<endl;
    } 
    else {
        auto itr=lower_bound(v.begin(), v.begin()+(n-1), k/2);
        ll a=*(itr-1);
        ll b=*itr;
        ll x=abs(a-k/2);
        ll y=abs(b-k/2);
        if(x>y) cout<<k<<" "<<b<<endl;
        else cout<<k<<" "<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n'
#define pi 3.1415926535897932384626433832
#define ll long long
using namespace std;
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / __gcd(a, b); }
bool isPrime(int n) {if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;}



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin>>a;
    vector<int> tba(a,0);
    int ans;
    for(int i=1;;i++){
        if(i*i*6>a){
            break;
        }
        for (int j = i;; j++) {
            if(i*i+j*j*3+i*j*2>a){
                break;
            }
            for (int l = j;; l++) {
                ans = i * i + j * j + l * l + i * l + i * j + j * l;
                if (ans > a) {
                    break;
                }
                if (i==l) {
                    tba[ans-1]++;
                } else if (j==l || j==i) {
                    tba[ans-1] += 3;
                } else tba[ans-1] += 6;

            }
        }
    }
    for(auto po:tba){
        cout<<po<<endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define P pair<ll, ll>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    ll n, q;
    cin >> n >> q;
    vector<pair<ll, P> > p;
    rep(i, n) {
        ll s, t, x;
        cin >> s >> t >> x;
        pair<ll, P> s_, t_;
        s_.first = s - x;
        s_.second.first = 1;
        s_.second.second = x;
        t_.first = t - x;
        t_.second.first = -1;
        t_.second.second = x;
        p.push_back(s_);
        p.push_back(t_);
    }
    sort(p.begin(), p.end());
    ll d[q];
    rep(i, q) cin >> d[i];
    set<ll> se;
    ll idx = 0;
    ll t = 0;
    rep(i, p.size()){
        while(p[i].first > d[idx]){
            if(se.size() == 0) cout << -1 << endl;
            else{
                cout << *se.begin() << endl;
            }
            idx++;
            if(idx == q) break;
        }
        if(p[i].second.first == 1){
            se.insert(p[i].second.second);
        }else{
            se.erase(p[i].second.second);
        }
        if(idx == q) break;
    }
    while(idx < q){
        cout << -1 << endl;
        idx++;
    }
}

Measured memory_bytes: 23504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  else if(s == "MON") cout << 6 << endl;
  else if(s == "TUE") cout << 5 << endl;
  else if(s == "WED") cout << 4 << endl;
  else if(s == "THU") cout << 3 << endl;
  else if(s == "FRI") cout << 2 << endl;
  else if(s == "SAT") cout << 1 << endl;
}  

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
	int N, m=0,s=0;

	scanf("%d", &N);
	for (int i=0; i<N; i++)
	{
		int t;
		scanf("%d",&t);
		s+=t;
		if (t>m) m=t;
	}
	if (s-m>m) 
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double[] temp = Array.ConvertAll(input.Trim().Split(' '), double.Parse);

                double ax1 = temp[0], ay1 = temp[1];
                double ax2 = temp[2], ay2 = temp[3];
                double bx1 = temp[4], by1 = temp[5];
                double bx2 = temp[6], by2 = temp[7];

                bool isCollid = ax1 <= bx2 && ay1 <= by2 && ax2 >= bx1 && ay2 >= by1;

                sb.AppendLine(isCollid ? "YES" : "NO");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9288
#include <cstdio>
#define rep(i,n) for(int i=0;i<n;i++)

int n,m,ans,a[5000],b[5000];

int main(){
	scanf("%d%d", &n, &m);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,m) scanf("%d",&b[i]);
	rep(i,m){
		int cnt=0;
		rep(j,n){
			if(i+cnt>=m)break;
			if(a[j]==b[i+cnt])cnt++;			
		}
		if(cnt>ans)ans=cnt;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1064