akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#include <iostream>
#include <vector>
using namespace std;

struct WeightedUnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> size;
  vector<int> diff_weight;
  
  WeightedUnionFind(int N) : par(N), rank(N), size(N), diff_weight(N) {
    for (int i = 0; i < N; i++) {
      par[i]  = i;
      rank[i] = 0;
      size[i] = 1;
      diff_weight[i] = 0;
    }
  }

  int find(int x) {
    if (par[x] == x) return x;
    else {
      int r = find(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }
  
  bool unite(int x, int y, int w) {
    w += weight(x); w -= weight(y); 
    x = find(x); y = find(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;    
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x; 
    diff_weight[y] = w; 
    return true;
  }

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

  int weight(int x) {
    find(x);
    return diff_weight[x];
  }

  int diff(int x, int y) {
    if (find(x) != find(y)) return -1;
    return weight(y) - weight(x);
  }
  
  int get_size(int x) {
    int rx = find(x);
    return size[rx];
  }
  
};


int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  int L, R, D;

  cin >> N >> M;

  WeightedUnionFind wuf = WeightedUnionFind(N);
  for (int i = 0; i < M; i++) {
    cin >> L >> R >> D;
    L--; R--;

    if (!wuf.same(L, R)) wuf.unite(L, R, D);
    else {
      int d = wuf.diff(L, R);
      if (d != D) {
	cout << "No" << endl;
	return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


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

#define ll long long int
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define nl '\n'
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define all(a) a.begin(),a.end()
#define F first
#define S second
const ll N=3e3+9;
const ll mod=1e9+7;

ll a[N][N];

void solve()
{
	string s,t;
	cin>>s>>t;
	ll n= s.size();
	ll m= t.size();

	rep(i,1,n)
	{
		rep(j,1,m)
		{
			if(s[i-1]==t[j-1])
			{
				a[i][j] = a[i-1][j-1] + 1 ;
			}
			else
				a[i][j] = max( a[i][j-1], a[i-1][j] ) ;
			//cout<<a[i][j]<<" ";
		}
		//cout<<nl;
	}

	string ss=".";
	ll r=n,c=m;
	while(1)
	{
		if(s[r-1]==t[c-1])
		{
			ss+=s[r-1];
			r--;
			c--;
		}
		else
		{
			if(a[r-1][c]>a[r][c-1])
			{
				r--;
			}
			else c--;
		}
		//cout<<r<<" "<<c<<" "<<ss<<nl;
		if(r<1 || c<1)break;
	}
	//cout<<ss.size();
	for(ll i=ss.size()-1; i>0 ; i--)cout<<ss[i];

}



int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    //if(t^1)exit(0);
    while(t--)
       solve();
}

Measured memory_bytes: 70784
import java.util.*;

public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int c[] = new int[3];
        c[0] = sc.nextInt();
        c[1] = sc.nextInt();
        c[2] = sc.nextInt();
        Arrays.sort(c);
        System.out.println(c[1] - c[0] + c[2] - c[1]);
    }
}

Measured memory_bytes: 21844
sizes = list(map(int, input().split()))
a, b, c = [], [], []
for i in range(sizes[0]):
    a.append(list(map(int, input().split())))
for i in range(sizes[1]):
    b.append(list(map(int, input().split())))
for i in range(sizes[0]):
    c.append([])
    for j in range(sizes[2]):
        t = 0
        for k in range(sizes[1]):
            t += a[i][k] * b[k][j]
        c[i].append(t)
for i in range(sizes[0]):
    for j in range(sizes[2]):
        if j < sizes[2]-1:
            print(c[i][j], end = ' ')
        else:
            print(c[i][j])  


Measured memory_bytes: 7056
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

typedef struct _fruit{
        string name;
        double e;   //??????
} fruit;



int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;

        vector<fruit> array(n);

        for(int i = 0; i < n; i++){
            string L; cin >> L;
            array[i].name = L;
            int P, A, B, C, D, E, F, S, M; cin >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            int t1 = A + B + C + D + E;
            int t2 = D + E;
            double ue = (F*S*M) - P;
            double sita = t1 + (M-1)*t2;
            array[i].e = ue/sita;
        }

        bool flag = true;

        //???????????????
        while(flag){
            flag = false;
            for(int i = 0; i < n - 1; i++){
                if(array[i].name > array[i + 1].name){
                    fruit temp;
                    temp = array[i];
                    array[i] = array[i + 1];
                    array[i + 1] = temp;
                    flag = true;
                }
            }
        }

        flag = true;
        //???????????????
        while(flag){
            flag = false;
            for(int i = 0; i < n - 1; i++){
                if(array[i].e < array[i + 1].e){
                    fruit temp;
                    temp = array[i];
                    array[i] = array[i + 1];
                    array[i + 1] = temp;
                    flag = true;
                }
            }
        }


        for(int i = 0; i < n; i++){
            cout << array[i].name << endl;
        }
        
        cout << "#" << endl;

    }

    return 0;
}

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

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  int ret = 0, out = 0;
  for(int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    ret += max(0, (B - A) / 2);
    out = max(out, (B - A) / 2);
  }
  cout << ret - out << endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <cstdlib>
#include <vector>
#define MIN -1000000000

void min (std::vector<int> R, int n) {
    int maxv = MIN;
    int minv = R[0];
    int dif;

    for (int j = 1; j < n; j++) {
        dif = R[j] - minv;
        if (dif > maxv) {
            maxv = dif;
        }
        if (R[j] < minv) {
            minv = R[j];
        }
    }
    std::cout << maxv << std::endl;
    return;
}

int main(void) {
    int n;
    std::cin >> n;
    std::vector<int> R(n);
    for (int i = 0; i < n; i++) {
        std::cin >> R[i];
    }
    min(R, n);
    return EXIT_SUCCESS;
}

Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

// 現在いる頂点vを色cで塗る
// vの親はpである
void dfs(int v, int p, int c, vector<vector<pair<int, int>>> &G, vector<int> &result){
    
    result[v] = c; // 現在いる頂点vを色cで塗る
    
    // 周囲を探索する
    for (auto e : G[v]){
        
        // 親への逆流を防止する
        if (e.first == p) continue;
        
        if (e.second % 2 == 1) dfs(e.first,v,1-c,G,result);
        else dfs(e.first,v,c,G,result);
    }
}

int main(void){
    
    int n;
    cin >> n;
    
    // 木の構造を保存するための配列である
    vector<vector<pair<int, int>>> G(n, vector<pair<int,int>>());
    
    for (int i = 0; i < n-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        
        // 0-indexにする
        u--, v--;
        G[u].push_back(pair<int,int>(v,w));
        G[v].push_back(pair<int,int>(u,w));
    }
    
    // 各頂点の色の塗り方を記録する配列である
    vector<int> result(n);
    // DFSにより木構造を探索する
    dfs(0, -1, 1, G,result);
    
    // resultの中身を出力すれば良い
    for (auto p : result) cout << p << endl;
    
    return 0;
    
}


Measured memory_bytes: 9728
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

K=int(input())
c=9
cb=0
r_list=[1,2,3,4,5,6,7,8,9]
while(c<K):
    tmp=[]
    for i in r_list:
        if(i%10==0):
            tmp.append(i*10)
            tmp.append(i*10+1)
        elif(i%10==9):
            tmp.append(i*10+8)
            tmp.append(i*10+9)
        else:
            tmp.append(i*10+i%10-1)
            tmp.append(i*10+i%10)
            tmp.append(i*10+i%10+1)
    cb=c
    r_list=tmp
    c+=len(r_list)

    
r_list.sort()
ans=r_list[K-cb-1]
print(ans)


Measured memory_bytes: 10720
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    long long N;
    cin >> N;
    vi digits;
    do {
        N -= 1;
        long long digit = N % 26;
        digits.push_back(digit);
        N /= 26;
    } while (N != 0);
    for (int i = digits.size() - 1; i >= 0; --i) {
        int digit = digits[i];
        char c = 'a' + digit;
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
A, B, C, D, E, F = map(int, input().split())
a, b = [], []

for i in range(3001):
    for j in range(3001):
        v = 100*A*i+100*B*j
        if v <= F:
            a.append(v)
        else:
            break

for i in range(3001):
    for j in range(3001):
        v = C*i+D*j
        if v <= F:
            b.append(v)
        else:
            break

a.sort()
b.sort()

c = -1
ans = [0, 0]
for ai in a:
    for bi in b:
        t = ai+bi
        if t > 0 and t <= F and (E*ai//100) >= bi:
            tc = 100*bi/(ai+bi)
            if c < tc:
                c = tc
                ans = [t, bi]

print(*ans)


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

int main() {
  int n;
  cin >> n;
  vector<float> a(n);
  float sum=0.0;
  rep(i,n){
    cin >> a.at(i);
    sum += (1/a.at(i));
  }
  cout << 1/sum << endl;
}


Measured memory_bytes: 764
#include <stdio.h>

int main() {
	int n, a[100];
	int count = 0;

	scanf("%d",&n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
			count++;
	}
	printf("%d",count);
	
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

ll l[200020],r[200020];

int main(){
  ll n;
  cin >> n;
  ll ans=-n;
  while(ans<0){
    ans+=1000;
  }
  cout << ans%1000 << endl;
return 0;}

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

int a[26];

int main() {

    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
        a[s[i]-'a']++;
    
    for (int i = 0; i < 26; i++) {
        if (a[i] == 0) {
            cout << char('a'+i);
            return 0;
        }
    }
    
    cout << "None";
        
    
    return 0;
}


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

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

  string ans;
  while (n) {
    n--;
    ans += 'a'+ n%26;
    n /= 26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}

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

int main()
{
	int n;
	cin>>n;
	int A=0,B=0,C=0,x;
	while(n--)
	{
		cin>>x;
		if(x%2==0&&x%4==0)A++;
		else if(x%2==0)B++;
		else C++;
	}
	if(A>=C)cout<<"Yes";
	else if(B==0&&C-A==1)cout<<"Yes";
	else cout<<"No";
	//system("pause");
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int W = scanner.nextInt();
        String[] a = new String[H];

        for (int i = 0; i < H; i++) {
            a[i] = scanner.next();
        }
        for (int i = 0; i < W+2; i++) {
            System.out.print("#");
        }
        System.out.println("");
        for (int i = 0; i < H; i++) {
            System.out.print("#");
            System.out.print(a[i]);
            System.out.print("#");
            System.out.println("");
        }
        for (int i = 0; i < W+2; i++) {
            System.out.print("#");
        }
        System.out.println("");
    }
}

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

typedef long long ll;


int main() {
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        int t = ceil(n/1000.0) * 1000;
        cout<<t - n;    
    }
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i,N;
  bool p=false, w=false, g=false, y=false;
  cin >> N;
  for (i=0; i<N; i++) {
    string s;
    cin >> s;
    if (s == "P") p = true;
    else if (s == "W") w = true;
    else if (s == "G") g = true;
    else y = true;
  }
  if (p && w && g && y) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [b-1 for b in a]
imos = [0 for _ in range(m+1)]
base = 0
for i in range(n-1):
	x, y = a[i], a[i+1]
	if y-x == 1 or x+1-m == y:
		continue
	z, w = (x+2)%m, (y+1)%m
	if w == 0:
		w = m
	if z < w:
		imos[z] += 1
		imos[w] -= w-z+1
		if w < m:
			imos[w+1] += w-z
	else:
		imos[z] += 1
		imos[m] -= m-z+1
		imos[0] += 1
		base += m-z
		imos[w] -= m+w-z+1
		if w < m:
			imos[w+1] += m+w-z
#print(imos)
#print(base)
for i in range(m):
	imos[i+1] += imos[i]
imos[0] += base
for i in range(m):
	imos[i+1] += imos[i]
res = max(imos[:m])
ans = 0
for i in range(n-1):
	if a[i+1] > a[i]:
		ans += a[i+1] - a[i]
	else:
		ans += a[i+1] + m - a[i]
#print(ans)
ans -= res
print(ans)

Measured memory_bytes: 13812
N = int(input())

s = ""
for i in range(12):
    if 26*(26**i-1)/25 < N and N <= 26*(26**(i+1)-1)/25:
        t = i#桁数-1
        break

#print(t + 1)
N = int(N - 26*(26**t-1)/25 - 1)

a = [0] * (t + 1)

for i in range(t + 1):
    a[t - i] = N%26
    N = N //26

#print(a)

for i in range(0, len(a)):
    a[i] = chr(97+int(a[i]))
    s += a[i]

#s += chr(97+a[len(a)-1])

print(s)


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

int main()
{
    std::ios::sync_with_stdio(false);
    ll a[100005];
    ll n,k,q,a1;
    cin>>n>>k>>q;
    fill(a+1,a+n+1,k);
    for(ll i=1;i<=q;i++){
        cin>>a1;
        a[a1]++;
    }
    for(ll i=1;i<=n;i++){
        if((a[i]-q)<=0){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;

ll i,j,k;


int main(){
   string a,b;
   cin>>a>>b;
   bool jud=false;
   for(int i=1;i*i<=stoi(a+b);i++)if(i*i==stoi(a+b))jud=true;
   if(jud)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


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

int main(){
  int N; cin >> N;
  int A;
  int mx=1,mn=1000000000;
  for(int i=0; i<N; i++){
    cin >> A;
    mx=max(mx,A); mn=min(mn,A);
  }
  cout << mx-mn << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,m,tmp;
    scanf("%d %d",&n,&m);
    int** A = new int*[n];
    for(int i = 0; i < n; i++) A[i] = new int[m];
    int b[m];
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d",&tmp);
            A[i][j] = tmp;
        }
    }
    for(int i = 0; i < m; i++){
        scanf("%d",&tmp);
        b[i] = tmp;
    }
    long long int sum;
    for(int i = 0; i < n; i++){
        sum = 0;
        for(int j = 0; j < m; j++){
            sum += A[i][j] * b[j];
        }
        printf("%lld\n",sum);
    }
 
    for(int i = 0; i < n; i++){
        delete[] A[i];
    }
    delete A;
}


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

int main(){

  int cnt = 0 ; 
  string S ; 
  cin >> S ; 
  int N = S.size() ; 

  
  for(int i = 0 ; i < N ; i++){
    char A = S.at(i) ; 
    //cout << A << endl ; 
    cnt += A - '0' ;

  }
  if((cnt % 9 )== 0){
    cout << "Yes" << endl;
    return 0 ;
  }
  else{
    cout << "No" << endl ; 
  }
}

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

#define fast ios::sync_with_stdio(0); cin.tie(0)

int main(){
  string s, ans="";
  cin>>s;
  for(int i=0; i<s.size(); ++i){
    if(s[i]=='1' | s[i]=='0') 
      ans += s[i];
    else if(s[i]=='B') {
      if(ans.size() > 0){
        ans.pop_back();
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;

int indeg[MAXn], par[MAXn], n, m;
vector<int> g[MAXn], vec;

void del(int v) {
  for (int i = 0; i < g[v].size(); i++) {
  	indeg[g[v][i]]--;
  	if (!indeg[g[v][i]]) {
      par[g[v][i]] = v + 1;
      vec.push_back(g[v][i]);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n - 1 + m; i++) {
    int v, u;
    cin >> v >> u;v--;u--;
    g[v].push_back(u);
    indeg[u]++;
  }
  for (int i = 0; i < n; i++)
    if (!indeg[i]) {
      vec.push_back(i);
      break;
    }
  for (int i = 0; i < vec.size(); i++)
    	del(vec[i]);
  for (int i = 0; i < n; i++)
    	cout << par[i] << '\n';
}

Measured memory_bytes: 7540
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;

ll dp[65][2];

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll now = 0;
    ll ans = 0;
    

    for (int i=60; i>=0; i--){
        ll num = 0;
        rep(j, n) {
            if ((a[j]>>i & 1)==1) num++;
        }
        ll ik = (k>>i) & 1;
        if (ik==0) {
            dp[i][0] = dp[i+1][0] + (num * (1LL<<i));
        }
        else {
            dp[i][0] = dp[i+1][0] + ((n-num) * (1LL<<i));
        }
        if (dp[i+1][1]) {
            dp[i][1] = dp[i+1][1] + (max(num, n-num) * (1LL<<i));
        }
        if (ik==1) {
            dp[i][1] = max(dp[i][1], dp[i+1][0] + (num * (1LL<<i)));
        }
        //debug(dp[i][0]);
        //debug(dp[i][1]);
        /*
        if ((1LL<<i)+now>k) {
            ans += (1LL<<i)*(num);
        }
        else if (num>n/2) {
            now += 1LL<<i;
            ans += (1LL<<i)*num;
        }
        else {
            ans += (1LL<<i)*(n-num);
        }
        */
    }
    ans = max(dp[0][0], dp[0][1]);  
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

lList = [arr[0] for arr in LR]
rList = [arr[1] for arr in LR]

l = max(lList)
r = min(rList)

print(max(r-l+1, 0))

Measured memory_bytes: 29052
#include <iostream>
using namespace std;
int main(void) {
	long long A, B, C;
	cin >> A >> B >> C;
	long long ans = 0;
	long long eaten = min(B, C);
	C -= eaten;
	B -= eaten;
	ans += eaten * 2;
	
	eaten = min(C, A);
	C -= eaten;
	A -= eaten;
	ans += eaten;

	ans += B;

	if (C > 0) ++ans;

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

Measured memory_bytes: 256
R(n,r,p){//rñÌtriffle-shuffleÉæèÊupÌJ[hÍÇÌÊuÖßé©H
	int c,m;
	if(r){
		scanf("%d",&c);
		p=R(n,r-1,p);
		m=n-n/(c*2)*(c*2);//deckCÌ¼[
		if(p<n-m)//c¸Â¬º½ª
			return (1-p/c%2)*(n/2)+(p/c/2*c)+(p%c);
		else if(p<n-m/2)//deckAÌ¼[ª
			return n-(n-m/2-p);
		else//deckBÌ¼[ª
			return n/2-(n-p);
	}else{
		return p;
	}
}
main(){
	int n,r;
	for(;~scanf("%d%d",&n,&r);){
		printf("%d\n",R(n,r,n-1));
	}
}

Measured memory_bytes: 0
N,C=map(int, input().split())
stc=[list(map(int,input().split())) for i in range(N)]
line=[[0]*(10**5+1) for c in range(C+1)]
for s,t,c in stc:
    line[c][s]+=1
    line[c][t]-=1
for c in range(1,C+1):
    for s in range(1,10**5+1):
        if line[c][s]==1:
            line[0][s-1]+=1
        elif line[c][s]==-1:
            line[0][s]-=1
        line[c][s]+=line[c][s-1]
ans=0
for s in range(1,10**5+1):
    line[0][s]+=line[0][s-1]
    ans=max(ans,line[0][s])
print(ans)

Measured memory_bytes: 53728
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := float64(nextInt())

	cnt := 0

	for i := 0; i < n; i++ {
		x, y := nextInt(), nextInt()
		point := math.Sqrt(float64(x * x + y *y))
		if d >= point{
			cnt++
		}
	}
	fmt.Println(cnt)

}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


Measured memory_bytes: 4908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1e9+7;

ll n, m;

const int MAX = 200050;
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vl prime_factorization(ll n) {
    vl ret;
    ll loc = 0;
    while(n%2==0) {
        n /= 2;
        loc++;
    }
    ret.pb(loc);
    for(ll p = 3; p * p <= n; p += 2) {
        loc = 0;
        while(n%p==0) {
            n /= p;
            loc++;
        }
        ret.pb(loc);
    }
    if(n > 1)
        ret.pb(1);
    return ret;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	COMinit();
	cin >> n >> m;
	vl r = prime_factorization(m);
	ll ret = 1;
	rep(i,0,sz(r)) {
		ll x = r[i];
		ret = ret * COM(n+x-1,x) % MOD;
	}
	cout << ret << '\n';
	return 0;
}


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

int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b; cin>>a>>b;
  if(b==1){
    cout<<0<<endl;
    return 0;
  }
  
  ll cnt=(b+a-2)/(a-1);
  if((a-1)*(cnt-1)+1>=b){
    cout<<cnt-1<<endl;
  }else{
    cout<<cnt<<endl;
  }
  
}


Measured memory_bytes: 3628
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut b: [usize; n],
    }
    let mut a = vec![];

    if b[0] != 1 {
        println!("-1");
        return;
    }

    let mut cnt = 0;

    for i in 0..n {
        for j in (0..b.len()).rev() {
            if b[j] == j + 1 {
                a.push(b[j]);
                b.remove(j);
                break;
            }
        }
        if a.len() != i + 1 {
            println!("-1");
            return;
        }
    }
    a.reverse();
    for i in 0..n {
        println!("{}", a[i]);
    }
}


Measured memory_bytes: 4352
local function str2tbl(s)
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        t[i] = char(t[i])
    end
    return t
end

local N, K, _, S = io.read("n", "n", "l", "l")
S = str2tbl(S)
S[K] = string.char(string.byte(S[K]) + 0x20)
print(table.concat(S, ""))

Measured memory_bytes: 1008
n = gets.chomp.to_i
ans = 0

memo = Array.new(10) {Array.new(10, 0)}

1.upto(n) do |i|
  l = i.to_s[0].to_i
  r = i.to_s[-1].to_i
  memo[l][r] += 1
end

ans = 0
1.upto(9) do |i|
  1.upto(9) do |t|
    ans += memo[i][t] * memo[t][i]
  end
end
p ans


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  cin >> n >> m;
  cout << (n + m * 2) / (1 + m * 2) << endl;




  return 0;
}


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



int main() {
    ll n,p; cin >> n >> p;
    bool flag = true;
    ll tmp;
    rep(i,n) {
        cin >> tmp;
        if(tmp%2 == 1) flag = false;
    }
    if(flag && p == 0)printf("%lld",(ll)pow(2,n));
    else if(flag && p == 1)cout << 0;
    else printf("%lld",(ll)pow(2,n-1));

    return 0;
}











Measured memory_bytes: 4160
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int res = a[n - 1] - a[0];
    for (int i = 1; i < n; i++) {
        res = min(res, k - a[i] + a[i - 1]);
    }

    cout << res << endl;
}


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

prev = ans1 = 0
for a in src:
    if prev+a > X:
        eat = prev+a - X
        ans1 += eat
        prev = max(0, a-eat)
    else:
        prev = a

prev = ans2 = 0
for a in src[::-1]:
    if prev+a > X:
        eat = prev+a - X
        ans2 += eat
        prev = max(0, a-eat)
    else:
        prev = a

print(min(ans1,ans2))


Measured memory_bytes: 14052
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
s = input()
#開業されたN個要素を受け付ける
#list = [input() for i in range(N)]

print("2018"+s[4:])


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, max_dec_run = 0, curr_run = 0;
    cin >> n;
    int heights[n];
    for (int i = 0; i < n; i++) {
        cin >> heights[i];
    }
    for (int i = 1; i < n; i++) {
        if (heights[i] <= heights[i - 1]) {
            curr_run++;
        } else {
            max_dec_run = max(max_dec_run, curr_run);
            curr_run = 0;
        }
    }
    max_dec_run = max(max_dec_run, curr_run);
    cout << max_dec_run;
}


Measured memory_bytes: 3964
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	string s;
	cin>>s;int cnt=0;
	for(char c:s)if(c=='1')cnt++;
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,M;
struct node {
    int l,r;
}p[MAXN];
struct seg_tree {
    int l,r;
    int lz,mx;
}tr[MAXN * 4];
void update(int u) {
    tr[u].mx = max(tr[u << 1 | 1].mx,tr[u << 1].mx);
}
void addlz(int u,int v) {
    tr[u].mx += v;tr[u].lz += v;
}
void pushdown(int u) {
    if(tr[u].lz) {
	addlz(u << 1,tr[u].lz);
	addlz(u << 1 | 1,tr[u].lz);
	tr[u].lz = 0;
    }
}
void build(int u,int l,int r) {
    tr[u].l = l;tr[u].r = r;
    if(l == r) {
	tr[u].mx = r;
	return;
    }
    int mid = (l + r) >> 1;
    build(u << 1,l,mid);
    build(u << 1 | 1,mid + 1,r);
    update(u);
}
void Change(int u,int l,int r,int v) {
    if(tr[u].l == l && tr[u].r == r) {addlz(u,v);return;}
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) Change(u << 1,l,r,v);
    else if(l > mid) Change(u << 1 | 1,l,r,v);
    else {Change(u << 1,l,mid,v);Change(u << 1 | 1,mid + 1,r,v);}
    update(u);
}
int Query(int u,int l,int r) {
    if(tr[u].l == l && tr[u].r == r) {return tr[u].mx;}
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) return Query(u << 1,l,r);
    else if(l > mid) return Query(u << 1 | 1,l,r);
    else return max(Query(u << 1,l,mid),Query(u << 1 | 1,mid + 1,r));
}
void Solve() {
    read(N);read(M);
    for(int i = 1 ; i <= N ; ++i) {
	read(p[i].l);read(p[i].r);
    }
    build(1,1,M + 1);
    sort(p + 1,p + N + 1,[](node a,node b){return a.l < b.l || (a.l == b.l && a.r > b.r);});
    int ans = max(0,N - M);
    for(int i = 1 ; i <= N ; ++i) {
	Change(1,p[i].l + 1,p[i].r,1);
	int t = Query(1,p[i].l + 1,M + 1) - M - p[i].l - 1;
	ans = max(ans,t);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 12160
#include<stdio.h>


void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int cnt=0;

int main(){
  
  int innum,i;
  
  scanf("%d",&innum);
  
  int array[innum];
  
  for(i=0;i<innum;i++){
    scanf("%d",&array[i]);
  }
  
  
  
  mergeSort(array,0,innum);
  
  
  
  for(i=0;i<innum;i++){
    if(i==innum-1)printf("%d\n",array[i]);
    else printf("%d ",array[i]);
    
  }  
  printf("%d\n",cnt);
  
  return 0;
}


void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;
  int L[n1],R[n2];
  
  for (i = 0 ;i<=n1-1;i++)
    L[i] = A[left + i];
  for (i = 0;i<=n2-1;i++)
    R[i] = A[mid + i];
  
  L[n1] = 999999999;
  R[n2] = 999999999;
  
  i = 0;
  j = 0;
  for(k = left;k<=right-1;k++){
    cnt++;
    if( L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
	}
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}
void mergeSort(int A[],int left,int right){
  int mid;
  
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
  
}



Measured memory_bytes: 5752
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll counter=0;
    for(ll i=0;i<N;i++){
        if(i<N-1&&S[i]=='R'&&S[i+1]=='R')counter++;
        if(i>0&&S[i]=='L'&&S[i-1]=='L')counter++
    ;}
    cout<<min(N-1,counter+2*K)<<endl;
return 0;
}  



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;
using ull = unsigned long long;

vector<int> v;

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

    int n, d;
    cin >> n >> d;

    int ans = 0;
    int a = 1 + d + d;

    if(n % a == 0){
        ans = n / a;
    }else{
        ans = (n / a) + 1;
    }

    cout << ans << next;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, T, CT):
    ctm = list(filter(lambda x: x[1] <= T, CT))
    if ctm:
        return(min(ctm)[0])
    return 'TLE'


def main():
    N, T = read_int_n()
    CT = [read_int_n() for _ in range(N)]
    print(slv(N, T, CT))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6760
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(void){
	
	int r;
	cin>>r;
	if(r<1200)cout<<"ABC"<<endl;
	else if(r<2800)cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
let rec q()=let a=Array.init 10(fun i->Scanf.scanf"%d,"(fun i->i*2000))in Scanf.scanf"%d,%d
"(fun v w->let t=(Array.fold_left(+)0a)/(v+w) in let rec($)i z=if t*v<=z+a.(i)then q(Printf.printf"%d\n"(i+1))else(i+1)$(z+a.(i))in 0$0);;try q()with _->()

Measured memory_bytes: 2316
program main
  implicit none
  integer :: h, w, k, i, j, t, ptr, res
  character(1000) :: s(10)
  integer, allocatable :: si(:, :), rows(:, :)
  read *, h, w, k
  allocate (si(w, h), rows(w, h))
  do i = 1, h
    read *, s(i)
    do j = 1, w
      read (s(i)(j:j), *) si(j, i)
    end do
  end do

  res = 10 ** 9
  do t = 0, 2 ** (h - 1) - 1  ! それぞれの鉛直分割法を全探索
    rows = 0
    ptr = 1
    do i = 1, h
      rows(:, ptr) = rows(:, ptr) + si(:, i)
      if (btest(t, i - 1)) then  ! iの後ろで分割される
        ptr = ptr + 1
      end if
    end do

    ! rowsのh行のうちptr行が使われた
    res = min(res, hdiv(rows, w, h, k) + ptr - 1)
  end do

  print "(i0)", res

  contains

  integer function hdiv(rows, w, h, k)
    ! Greedyに最小限の水平分割する
    integer, intent(in) :: w, h, k
    integer, intent(in) :: rows(w, h)
    integer :: cnt(h), j
    if (maxval(rows) > k) then
      hdiv = 10 ** 9
      return
    end if
    hdiv = 0
    cnt = 0
    do j = 1, w
      cnt(:) = cnt(:) + rows(j, :)
      if (maxval(cnt) > k) then
        hdiv = hdiv + 1
        cnt(:) = rows(j, :)
      end if
    end do
  end function hdiv
end program main


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

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}


#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}



int main() 
{
    fast();
    string s,t;
    cin>>s>>t;
    for(ll i=0;i<sz(s);i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,ans=0,l[210],i;
  cin >> n;
  n=n*2;
  for(i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l,l+n);
  for(i=0;i<n;i++){
    if(i%2==0){
      ans+=l[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3540
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){

    string s;
    string t;

    cin >> s >> t;

    sort(all(s));
    sort(t.rbegin(), t.rend());
    //reverse(t.begin(), t.end());

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();

		if (K % 2 == 0) {
			System.out.println((int)Math.pow(K / 2, 2));
		} else {
			System.out.println((K / 2 + 1) * (K / 2));
		}
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,t; cin>>n>>t;
    int ans =10000;
    
    for(int i=0;i<n;i++){
        int c,t1; cin>>c>>t1;
        if(ans>c&&t1<=t) ans=c; 
    }
    if(ans!=10000) cout<<ans<<endl;
    else
    cout<<"TLE"<<endl;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;

typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;


vector<ll> bfs(int n){
    queue<ll> q;
    vector<ll> ret;
    int count = 0;
    for(int i = 1; i < 10; i++){
        q.push(i);
        ret.push_back(i);
        count++;
        if(count == n)return ret;
    }
    while(1){
        ll now = q.front(); q.pop();
        // string now = to_string(top);
        // char c = now[now.size()-1];
        for(int i = -1; i < 2; i++){
            ll check = now % 10 + i;
            if(check == -1 or check  == 10)continue;
            q.push(now * 10 + check);
            ret.push_back(now * 10 + check);
            count++;
            if(count == n)return ret;
        }
    }
}
int main(){
    int k; cin >> k;
    vector<ll>v = bfs(k);
    // // for(int i = 0; i < v.size(); i++)cout << v[i] << " ";
    // cout << endl;
    cout << v[k-1] << endl;
}


Measured memory_bytes: 1620
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))

    a.sort(reverse=True)

    A = 0
    B = 0

    for i in range(N):
        if i == 0:
            A = A + a[i]
        elif i % 2 == 0:
            A = A + a[i]
        else:
            B = B + a[i]

    print(A - B)





Measured memory_bytes: 3060
#include <iostream>
#include <bitset>
#include <algorithm>
#include <queue>
#include <functional>
#include <numeric>
#include <map>
using namespace std;

int main(int argc, char *argv[])
{
#ifndef  ONLINE_JUDGE
	//freopen("test.txt", "r", stdin);
	//freopen("result.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	string word = "CODEFESTIVAL2016";
	int len = word.size();
	int count = 0;
	for (int i = 0; i < len; ++i)
	{
		if (s[i] != word[i])
		{
			count++;
		}
	}
	cout << count << endl;
#ifndef  ONLINE_JUDGE
	//fclose(stdin);
	//fclose(stdout);
	//system("result.txt");
#endif
	

	return 0;
}

Measured memory_bytes: 256