akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
a = list(map(int, input().split()))

K = len(list(set(a)))

if K <= k:
    print(0)
else:
    rewrite = K - k
    ans = 0
    cnt = [0] *(max(a) + 1)

    for i in range(n):
        cnt[a[i]] += 1
    cnt.sort()
    # print(cnt)
    for c in cnt:
        if 0 < c:
            ans += c
            rewrite -= 1
            if rewrite == 0:
                print(ans)
                exit()

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


int main() {
    ll n;
    cin >> n;
    ll a[n+1];
    for(ll i = 1 ; i <= n ; i++)
    cin >>a[i];
    ll p[n+1];
    p[0] = 0;
    for(ll i = 1 ;i <= n ; i++)
    p[i] = p[i-1]+a[i];

    ll dp[n+1][n+1];

    for(ll i = 0 ; i <=  n ; i++)
    {
        for(ll j  = 0 ; j <= n ; j++)
        dp[i][j] = 1e18;
    }

    for(ll i = 1 ; i < n; i++)
    {
        dp[i][i+1] = a[i]+a[i+1];
        dp[i][i] = 0;
    }

    dp[n][n] = 0;

    


    for(ll k = 2 ; k< n ; k++)
    {
        for(ll j =  1 ; j <= n-k ; j++)
        {
            ll l = j , r = j+k;
            for(ll i = l ; i < r ; i++)
            {
                ll cost = dp[l][i]+dp[i+1][r] + p[i]-p[l-1] + p[r]-p[i];
                dp[l][r] = min(dp[l][r] , cost); 
            }
        }
    }


    cout << dp[1][n] ;

}


Measured memory_bytes: 4796
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    int c;
    
    cin >> a >> b >> c;
    
    if (a <= b ){
        
        if(a <= c){
            
           if(b <= c){
               cout << a << " " << b << " " << c <<endl;
           }
        
           else {
               cout << a << " " << c << " " << b <<endl;
           }
           
        }
        
        else {
            cout << c << " " << a << " " << b <<endl;
        }
        
    }
    else {
        
        if(a <= c){
            cout << b << " " << a << " " << c <<endl;
        }
        
        else{
            
            if(c <= b){
                cout << c << " " << b << " " << a <<endl;
            }
            
            else{
                cout << b << " " << c << " " << a <<endl;
            }
            
        } 
        
    }
    
    return 0;    
    
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int a,b,c,d; cin >> a >> b >> c >> d;
  if( a+b > c+d){ cout<< "Left" << endl;}
  else if( a+b == c+d){ cout << "Balanced" << endl;}
  else{ cout << "Right" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
    int main(){
        int m = 0, f = 0, r = 0, data[50], i = 0;
        do{
            scanf("%d %d %d", &m, &f, &r);
            if (m == -1 && f == -1 && r == -1){
                break;
            }
            if (m == -1 || f == -1){
                printf("F\n");
            }
            if (m + f >= 80 && m != -1 && f != -1){
                printf("A\n");
            }else if (m + f >= 65 && m + f < 80 && m != -1 && f != -1){
                printf("B\n");
            }else if (m + f >= 50 && m + f < 65 && m != -1 && f != -1){
                printf("C\n");
            }else if (m + f >= 30 && m + f < 50 && m != -1 && f != -1){
                if (r >= 50){
                    printf("C\n");
                }else{   
                    printf("D\n");
                }
            }else if (m + f < 30 && m != -1 && f != -1){
                printf("F\n");
            }
        } while (m != -1 || f != -1 || r != -1);
        return 0;
    }


Measured memory_bytes: 2028
#include <iostream>
#include <string>
#include <vector> 
#include <cstring>
#include <map>

using namespace std;

const long long MODP = 1000000007;

long long n, m;
vector<long long> pN;
map<long long, long long> result_map;

long long calc(long long pn) {
    long long pp[100045];
    memset(pp, 0, sizeof(pp));
    
    for (long long i = n; i <= pn + n - 1; i ++) {
        long long p = 2, tmpm = i;
        while (p*p <= tmpm) {
            long long num = 0;
            while (tmpm % p == 0) {
                  pp[p] ++;
                  tmpm /= p;
            }
            p ++;
        }
        if (tmpm > 1) {pp[tmpm] ++; }
    }
    
    for (long long i = 2; i <= pn; i ++) {
        long long p = 2, tmpm = i;
        while (p*p <= tmpm) {
            long long num = 0;
            while (tmpm % p == 0) {
                  pp[p] --;
                  tmpm /= p;
            }
            p ++;
        }
        if (tmpm > 1) pp[tmpm] --;
    }
    
    long long result = 1;
    for (long long i = 1;i <= 100044;i ++) {
        for (int j = 0;j < pp[i];j ++) {
            result = (result * i) % MODP;
        }
    }
    return result;
}

int main() {
    cin >> n >> m;
    
    long long p = 2, tmpm = m, ret = 1;
    while (p*p <= tmpm) {
       long long num = 0;
       while (tmpm % p == 0) {
          num ++;
          tmpm /= p;
       }
       if (num) pN.push_back(num);
       p ++;
    }
    if (tmpm != 1) pN.push_back(1);
    
    for (int i = 0;i < pN.size();i ++) {
        ret = (ret * calc(pN[i])) % MODP;
    }
    cout << ret << endl;
    
    return 0;
} 


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

int main(){
	long A,B,C,K;
	cin >> A >> B >> C >> K;

	for(int i=0; i<=K; i++){
		for(int j=0; j<=K-i; j++){
			long Red = A*pow(2,i);
			long Blue = C*pow(2,j);
			long Green = B*pow(2,K-i-j);
			if(Green>Red && Blue>Green){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3976
import sys
X = int(input())
    
i = X
while True:
    if i == 2:
        print(i)
        sys.exit()
    elif i % 2 != 0:
        y = 3
        while True:
            if i == y:
                print(i)
                sys.exit()
            elif i % y == 0:
                break
            else:
                y += 2
    i += 1
    


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

// 存在チェック
bool exists(std::vector<int> vec, int target){
    return std::find(vec.begin(), vec.end(), target) != vec.end();
}
int main(){
    int X, N = 0;
    cin >> X >> N;
    vector <int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }

    int i = 0;
    int result = X;
    while (true)
    {
        result = X - i;
        if(!exists(p,result)){
            cout << result << endl;
            return 0;
        }

        result = X + i;
        if(!exists(p,result)){
            cout << result << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int a = b; a <= c; a += d)
#define int ll

int n, p;
int cnt[2];
int c[100][100];
int ans0, ans;

main () {
	ios_base::sync_with_stdio(0);
	cin >> n >> p;
	fo(i, 1, n, 1) {
		int x;
		cin >> x;
		++cnt[(x & 1)];
	}
	c[0][0] = 1;
	fo(i, 1, n, 1) {
		c[i][0] = 1;
		c[i][i] = 1;
		fo(j, 1, n, 1) {
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
	}
	fo(i, 0, n, 1) {
		ans0 += c[cnt[0]][i];
	}
	fo(i, p, cnt[1], 2) {
		ans += ans0 * (c[cnt[1]][i]); 
	}
	cout << ans;
	return 0;
}

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

using namespace std;

#define MAX_N 50
#define MAX_X 50

// 入力
int N, A;
int x[MAX_N + 1];

// DPテーブル
long long dp[MAX_N + 1][MAX_N + 1][MAX_N * MAX_X + 1];

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

    for (int j = 0; j <= N; ++j) {
        for (int k = 0; k <= N; ++k) {
            for (int s = 0; s <= N * MAX_X; ++s) {
                if (j == 0 && k == 0 && s == 0) {
                    dp[j][k][s] = 1;
                } else if (j >= 1 && s < x[j]) {
                    dp[j][k][s] = dp[j - 1][k][s];
                } else if (j >= 1 && k >= 1 && s >= x[j]) {
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]];
                } else {
                    dp[j][k][s] = 0;
                }
            }
        }
    }

    long long num = 0;
    for (int k = 1; k <= N; ++k) {
        num += dp[N][k][k * A];
    }

    cout << num << endl;
    return 0;
}


Measured memory_bytes: 51072
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
#define int ll
signed  main(){
    int n;
    while(cin>>n,n){
        vi v;
        map<int,int>mp;
        rep(j,n){
            bool mb=true;
            int a,b,c; cin>>a>>b>>c;
            mp[a]+=b*c;
            rep(i,v.size())if(v[i]==a)mb=false;
            if(mb)v.push_back(a);
        }
        bool flag=false;
        rep(i,v.size())if(mp[v[i]]>=1000000){cout<<v[i]<<endl;flag=true;}
        if(!flag)cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
 
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	ll n, k; cin >> n >> k;
	ll ans = 0;
	for(ll i = k; i <= n; i++){
		ll mini = i*(i-1)/2;
		ll maxi = n*(n+1)/2 - (n-i)*(n-i+1)/2;
		while(maxi < 0) maxi += MOD; 
		ans = (ans + maxi - mini + 1) % MOD;
	}
	cout << (ans+1) % MOD << '\n';

	return 0;
}

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

C = [float('inf')] * (1 << N)
C[0] = 0
key_v = [float('inf')] * (1 << N)
for j in range(M):
    a, b = map(int, input().split())
    box = list(map(int, input().split()))
    ex_status = 0
    for j in box:
        ex_status += 1 << (j-1)
    key_v[ex_status] = min(a, key_v[ex_status])

for key, val in enumerate(key_v):
    if val == float('inf'):
        continue
    for i in range(1 << N):
        now_status = i
        score = C[now_status] + val
        if score == float("inf"):
            continue

        now_status = i | key

        if C[now_status] > score:
            C[now_status] = score

if C[-1] == float("inf"):
    print(-1)
else:
    print(C[-1])



Measured memory_bytes: 3188
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 2512
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int el[27];
int main() {
    string s;
    cin >> s;
    for(int i = 0 ; i < s.size() ; i++) {
        el[s[i] - 'a']++;
    }
    int Min = 200;
    for(int i = 0 ; i < 26 ; i++) {
        if(!el[i]) continue;
        int Max = 0 , count = 0;
        for(int j = 0 ; j < s.size() ; j++) {
            if(s[j] - 'a' != i) count++;
            else {
                Max = max(Max , count);
                count = 0;
            }
        }
        Max = max(Max , count);
        //cout << char(i + 'a') << ' ' << Max << endl;
        Min = min(Min , Max);
    }
    cout << Min << endl;
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  ll n;
  cin >> n;
  string s, t; 
  cin >> s >> t;
  
  bool can=false;
  int ans=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;i+j<n;j++){
      if(s[i+j] == t[j]) sum++;
    }
    if(sum == n-i){
      can = true;
      ans= s.size()*2-sum;
      break;    
    }
  }
  
  if(can) cout<<ans<<endl;
  else cout<<s.size()*2<<endl;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
ab=[list(map(int,input().split())) for i in range(m)]
cnt=[0]*n

for tmp in ab:
    a,b=tmp
    cnt[a-1]+=1
    cnt[b-1]+=1

for c in cnt:
    if c%2!=0:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 61272
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	ll x, y;
	ll count = 0;
	cin >> x >> y;
	while (x <= y) {
		++count;
		x *=2;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    k = i_input()

    num = 1
    for _ in range(n):
        num = min(num * 2, num + k)

    print(num)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77080
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    int ans = 0;
    
    if((a-2*b) > 0) ans = a-2*b;
    else ans = 0;
    
    cout << ans << ln;
    return 0;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){cout<<"Left"<<endl;}
  else if(a+b<c+d) {cout<<"Right"<<endl;} 
  else{cout<<"Balanced"<<endl;}
}

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

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i=0; i<N; i++){
		cin >> a.at(i);
	}
	int Q;
	cin >> Q;
	vector<int> b(Q), c(Q);
	for(int i=0; i<Q; i++){
		cin >> b.at(i) >> c.at(i);
	}

	map<int,long long> ansA;
	for(int i=0; i<N; i++){
		if( ansA.count(a.at(i)) ){
			ansA[a.at(i)]++;
		}
		else{
			ansA[a.at(i)]=1;
		}
	}

	long long sum=0;
	for(int i=1; i<100001; i++){
		if( ansA.count(i) ){
			sum += i*ansA.at(i);
		}
	}

	for(int i=0; i<Q; i++){
		if( ansA.count(b.at(i))){
			if( ansA.count(c.at(i))){
				sum = sum - b.at(i)*ansA[b.at(i)] + c.at(i)*ansA[b.at(i)];

				ansA[c.at(i)] += ansA.at(b.at(i));
				ansA.erase(b.at(i));
			}
			else{
				sum = sum - b.at(i)*ansA[b.at(i)] + c.at(i)*ansA[b.at(i)];

				ansA[c.at(i)] = ansA.at(b.at(i));
				ansA.erase(b.at(i));
			}
		}

		cout << sum << endl;
	}

}


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

int EX_GCD(int a, int b, int& x, int& y) {
	int d = a;
	if (b != 0) {
		d = EX_GCD(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main()
{
	int a, b, x, y;
	cin >> a >> b;
	EX_GCD(a, b, x, y);
	cout << x << ' ' << y << endl;
	return 0;
}

Measured memory_bytes: 3104
s=gets.chomp
z=s.size
k=gets.to_i
ss=s[0]
r=1
c=0
f=true
g=false
(z-1).times do |i|
  if s[i+1]==ss
    r+=1
  else
    g = true if f && r.odd?
    f=false
    c+=r/2
    r=1
  end
  ss=s[i+1]
end
c+=r/2
if r==z
  p z*k/2
  exit
end
a=c*k
if s[0]==ss && r.odd? && g
  a+=k-1
end
p a


Measured memory_bytes: 1788
/**
 *  author: andychen
 *  created: 09.19.2020 22:57:25
**/

#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    int ans = 0;
    for (int i = 1; i < n; i++){
        int x = ceil(n / i) - ((n % i == 0) ? 1 : 0);
        ans += x;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cmath>
#include <functional>
#include <limits>
#include <map>
#include <bitset>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)
#define digit 100
int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    bitset<digit> sum(0);
    rep1(i,n){
        cin >> a[i];
        bitset<digit> tmp(a[i]);
        sum = (sum ^ tmp);
    }

    rep1(i,n){
        bitset<digit> tmp(a[i]);
        if(i != n){
            cout << (sum ^ tmp).to_ulong() << " ";
        }else{
            cout << (sum ^ tmp).to_ulong() << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4688
#!/usr/bin/env python3
# スペース区切りの整数の入力
a, b, c = map(int, input().split())
# 整数の入力
k = int(input())

for c_i in range(k+1):
    #print(c_i)
    for b_i in range(k-c_i+1):
        t_c = c*(2**c_i)
        t_b = b*(2**b_i)
        t_a = a*(2**(k-b_i-c_i))
        #print("t_c:{}, c_i:{}".format(t_c, c_i))
        #print("t_b:{}, b_i:{}".format(t_b, b_i))
        #print("t_a:{}, a_i:{}".format(t_a, k-b_i-c_i))
        if t_c > t_b > t_a:
            print("Yes")
            exit(0)

print("No")

Measured memory_bytes: 9188
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	(b - a == c - b) ? printf("YES") : printf("NO");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
struct node{
    int mid;
    int l, r;

}arr[100010];

bool cmp(node a, node b){
    return a.mid < b.mid;
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++){
        scanf("%d%d", &arr[i].mid, &arr[i].l);
        arr[i].r = arr[i].l + arr[i].mid;
        arr[i].l = arr[i].mid - arr[i].l;
        //arr[i].l ++;
        //arr[i].r --;
    }
    sort(arr, arr + n, cmp);
    int ans = 0;
    node last;
    last = arr[0];
    ans = 1;
    for(int i = 0; i < n - 1; i ++){
        if(last.r <= arr[i + 1].l){
            last = arr[i + 1];
            ans ++;
        }
        else if(last.r > arr[i + 1].r){
            last = arr[i + 1];
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;
  vector<int> v(6), h(5);
  v[0] = dy;
  v[1] = -dy;
  v[2] = dy + 1;
  v[3] = -1;
  v[4] = -dy - 1;
  v[5] = 1;

  h[0] = dx;
  h[1] = -dx - 1;
  h[2] = dx + 1;
  h[3] = 1;
  h[4] = -dx - 1;
  int vi = 0, hi = 0;

  rep(i, 0, 11) {
    if (i % 2 == 0) {
      rep(j, 0, abs(v[vi])) {
        if (v[vi] > 0)
          cout << "U";
        else
          cout << "D";
      }
      vi++;
    } else {
      rep(j, 0, abs(h[hi])) {
        if (h[hi] > 0)
          cout << "R";
        else
          cout << "L";
      }
      hi++;
    }
  }
  return 0;
}


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


int main()
{
    int n,m;cin >>n>>m;
    vector<vector<int>> G(n, vector<int>(n,0));
    for(int i = 0; i< m;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a][b]++;
        G[b][a]++;
    }
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += G[i][j];
        }
        cout << sum << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
task_count = gets.to_i

a = task_count.times.map do
  gets.split.map(&:to_i)
end.sort_by{|task| task[1]}

time = 0
res = true

a.each do |task|
  time += task[0]
  
  res = false if time > task[1]
end

puts (res ? "Yes" : "No")

Measured memory_bytes: 22928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		String S = scanner.next();
		String t = "";

		for (int i = 0; i < S.length(); i++) {
			char a = S.charAt(i);
			a += N;
			
			if ('Z' < a) {
				a -= 26;
			}
			t += (char) a;
		}
		System.out.println(t);
	}

}


Measured memory_bytes: 147540
#include<stdio.h>

int main(void){

  int a,b,c,i;

  int count;

  scanf("%d %d %d\n",&a,&b,&c);

  for(i=a,count=0;i<=b;i++){

    if(c%i==0)count ++;

  }

  printf("%d\n",count);

return 0;

}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int h,w;
char ss[10]="snuke";
char s[30][30][10];
scanf("%d %d",&h,&w);
for(int count=0;count<h;count++){
    for(int count2=0;count2<w;count2++){
        scanf("%s",s[count][count2]);
    }
}

for(int count=0;count<h;count++){
    for(int count2=0;count2<w;count2++){
        if(strcmp(s[count][count2],ss)==0){printf("%c%d",count2+'A',count+1);return 0;}
    }
}
}

Measured memory_bytes: 128
n = int(input())
l = [0 for i in range(n+2)]
for i in range(n):
  [a,b] = list(map(int,input().split()))
  if a <= n+1:
    l[a] += 1
    if b+1 <= n+1:
      l[b+1] -= 1
ans = 0
for i in range(n+2):
  if i != 0:
    l[i] = l[i-1] + l[i]
  if l[i] >= i-1:
    ans = i-1
print(ans)

Measured memory_bytes: 11636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    ll n;
    cin>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    vll csum(n+1);
    csum[0]=0;
    for(ll i=1;i<n+1;i++){
        csum[i]=csum[i-1]+a[i-1];
    }
    ll ans=INF;
    ll sum=csum[n];
    for(ll i=1;i<n;i++){
        ll left=csum[i]-csum[0];
        ll right=sum-(csum[i]-csum[0]);
        ans=min(ans,abs(right-left));
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, 0, n - 1)cin >> a[i];
	ll x = 0;
	rep(i, 0, n - 1)
	{
		if (i % 2)x -= a[i];
		else x += a[i];
	}
	x /= 2;
	vector<ll> ans(n);
	ans[0] = x;
	rep(i, 1, n - 1)
	{
		ans[i] = a[i - 1] - ans[i - 1];
	}
	rep(i, 0, n - 1)
	{
		cout << ans[i] * 2 << " ";
	}
	cout << "" << endl;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>

int main(){
    char s1[10], s2[10];
    

    int c;
    int count1=0,count2=0;
    scanf("%d",&c);

    for(int x=1;x<=c;x++){
        
    scanf("%s %s", s1, s2);
    if ( strcmp(s1, s2) == 0 ){
//        printf("s1 == s2\n");
        count1+=1;
        count2+=1;

    }    else if ( strcmp(s1, s2) > 0 ){
     //printf("s1 > s2\n");
        count1+=3;
    }
    else if ( strcmp(s1, s2) < 0 ){
        count2+=3;
    }
    }

    printf("%d %d\n",count1,count2);
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define PB push_back
#define MP make_pair
#define F first
#define S second

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


int main(){
	string s;
	cin >>s;
	int n=s.length();
	int tmp;
	string o[3];
	REP(bit,1<<(n-1)){
		tmp=s[0]-'0';
		REP(i,n-1){
			if(bit&(1<<i)){
				tmp-=s[i+1]-'0';
				o[i]='-';
			}
			else{
				tmp+=s[i+1]-'0';
				o[i]='+';
			}
		}
		if(tmp==7)break;
	}
	REP(i,3){
		cout <<s[i]<<o[i];
	}
	cout << s[3]<<'='<<7<<endl;
}


Measured memory_bytes: 256
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set ; 
const int N = 1e5+7;  
/*  
    time : 12 : 14    
    date : 19.01.2020
*/    
// int L,R,mid,target,idx ;
char grid[1003][1003] ;
ll dp[1003][1003] ;
int tests() 
{	
	int i,j ; 
	int h,w ; 
	const int M =  1e9+7 ; 
	cin >> h  >> w ; 
	forn(i,0,h)
		forn(j,0,w)
			cin >> grid[i][j] ;  
	forn(i,0,w)
		if(grid[0][i] == '.')
			dp[0][i] = 1 ;
		else 
			break ; 
	forn(i,0,h)
		if(grid[i][0] == '.')
			dp[i][0] = 1 ;
		else 
			break ; 
	forn(i,1,h)
		forn(j,1,w)
			if(grid[i][j] == '.')
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%M;
	
	cout << dp[h-1][w-1] << '\n' ;			 		
	return 0 ; 	
}
int main(){
    I__O ;   
    int cases = 1 ; 
 	// cin >> cases;  
    while(cases--)
	    tests(); 
	return 0 ; 
}

Measured memory_bytes: 9088
N=int(input())
a=list(map(int, input().split()))
c=[0]*9
for i in range(N):
  c[min(a[i]//400, 8)]+=1
  
temp=[1 for i in range(8) if c[i]>0]
x=len(temp)
y=x+c[8]
 
print(max(x, 1), y)

Measured memory_bytes: 3064
H, W = map(int, input().split())  # H行W列のgridgraph
N = int(input())  # N色に塗り分ける
A = list(map(int, input().split()))  # 色iのマス数はA[i]

# W個ごとにループを反対にする
ans = [[-1]*W for _ in range(H)]
colors = []
for i in range(len(A)):
    colors.extend([i+1]*A[i])
pointa = 0
for i in range(H):
    # print(i)
    if i % 2 == 0:
        for j in range(W):
            ans[i][j] = colors[pointa]
            pointa += 1
    else:
        for j in reversed(range(W)):
            ans[i][j] = colors[pointa]
            pointa += 1
for a in ans:
    print(*a)


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

#define fi first
#define se second
#define mkp std::make_pair

typedef std::pair <int, int> pii;

const int kN = 805, kInf = 0x3f3f3f3f;

int H, W, K, step[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, d[kN][kN], d2[kN][kN], stx, sty;
char g[kN][kN];
std::queue <pii> que;

void Bfs() {
	que.push(mkp(stx, sty));
	while(!que.empty()) {
		pii cur = que.front(); que.pop();
	//	printf("VIS: %d %d\n", cur.fi, cur.se);
		for(int i = 0; i < 4; ++i) {
			int nx = cur.fi + step[i][0], ny = cur.se + step[i][1], nd;
			if(nx <= 0 || ny <= 0 || nx > H || ny > W) continue;
			nd = d[cur.fi][cur.se] + 1;
			if(d[nx][ny] >= kInf && g[nx][ny] == '.' && nd <= K) {
				d[nx][ny] = nd;
				que.push(mkp(nx, ny));
			}
		}
	}
}
void Bfs2() {
	for(int i = 1; i <= H; ++i)
		for(int j = 1; j <= W; ++j)
			if(d[i][j] <= K) {
				que.push(mkp(i, j)); d2[i][j] = 0;
		//		printf("%d %d\n", i, j);
			//	vis[i][j] = true;
			}
//	printf("siz = %d\n", que.size());
	while(!que.empty()) {
		pii cur = que.front(); que.pop();
		for(int i = 0; i < 4; ++i) {
			int nx = cur.fi + step[i][0], ny = cur.se + step[i][1], nd;
			if(nx <= 0 || ny <= 0 || nx > H || ny > W) continue;
			nd = d2[cur.fi][cur.se] + 1;
			if(d2[nx][ny] >= kInf) {
				d2[nx][ny] = nd;
		//		printf("VIS: %d %d => %d %d, %d + 1 => %d\n", cur.fi, cur.se, nx, ny, d2[cur.fi][cur.se], nd);
				que.push(mkp(nx, ny));
			}
		}
	}
}

int main() {
	memset(d2, 0x3f, sizeof(d2));
	memset(d, 0x3f, sizeof(d));
	scanf("%d%d%d", &H, &W, &K);
	for(int i = 1; i <= H; ++i) {
		scanf("%s", g[i] + 1);
	}
	for(int i = 1; i <= H; ++i)
		for(int j = 1; j <= W; ++j)
			if(g[i][j] == 'S') {
				g[i][j] = '.';
				stx = i; sty = j;
				d[i][j] = 0;
			}
	Bfs(); Bfs2();
	int ans = H * W;
	for(int i = 1; i <= H; ++i) {
		for(int j = 1; j <= W; ++j) {
			if(i == 1 || j == 1 || i == H || j == W) {
				if(!d2[i][j]) ans = 1;
				ans = std::min(ans, (d2[i][j] - 1) / K + 2);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14504
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	a := getInt()
	b := getInt()
	h := getInt()

	out((a + b) * h / 2)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	char s[5];
	for(int i=n;i<=999;i++){
		sprintf(s,"%d",i);
		if(s[0]==s[1]&&s[1]==s[2]){
			cout<<i;
			break;
		}
	}
	return 0;
}

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


int main(){
  int n;
  double k;
  cin >> n >> k;
  double tmp = 0;
  double ans = 0;
  double count = 1;

  tmp = 1;

  count = 1.0 / n;

  for(int i = n; i > 0; --i){
    while(i < k){
      k /= 2;
      count /= 2;
    }
    ans += count;
  }

  printf("%.12f\n", ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int b  = number.nextInt();
		int c;

		if(a < b) {
			c = a;
			a = b;
			b = c;
		}
		do {
			c = b;
			b = a % b;
			a = c;
			if(b == 0) {
				b = a;
				break;
			}
		}while(a % b != 0);
		System.out.println(b);
	}
}



Measured memory_bytes: 26252
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		int temp=i+1;
		if(temp%2==0)
		{
			if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
			{
				cout<<"No";
				return 0;
			}
		}
		else if(temp%2==1)
		{
			if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
			{
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  int sum = 0;
  int bb = 1001001001;
  rep(i, n-1){
    int b;
    cin >> b;
    sum += min(b, bb);
    bb = b;
  }
  sum += bb;

  cout << sum << endl;

}


Measured memory_bytes: 256
x = int(input())


gap = 1
while True:
    a, b = 0, -gap
    while True:
        if a ** 5 - b ** 5 == x:
            print(a, b)
            exit()
        elif a ** 5 - b ** 5 > x and a > 0 and b > 0:
            break
        else:
            a += 1
            b += 1
    gap += 1




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

int main(){ 
int n;
cin>>n;
vector<int> h(n);
for(int i=0; i<n; i++){
cin>>h[i];
}
vector<int> ans;
int count=0;
for(int i=0; i<n-1; i++){
if(h[i]<h[i+1]){
ans.push_back(count);
count=0;
}
else{
  count ++;
}
}
ans.push_back(count);
sort(ans.begin(), ans.end()); 
reverse(ans.begin(), ans.end());
cout << ans[0] << endl;

}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int N, K;
    cin >> N >> K;
    vi X(N), Y(N);
    vector<char> C(N);
    rep(i, N) {
        cin >> X[i] >> Y[i] >> C[i];
    }

    // wをbにする
    rep(i, N) {
        if (C[i] == 'W') {
            Y[i] += K;
        }
    }

    // 2Kを取り除く
    rep(i, N) {
        X[i] %= (2 * K);
        Y[i] %= (2 * K);
    }

    vector<vector<int>> sum(2 * K + 1, vector<int>(2 * K + 1));
    rep(i, N) sum[X[i] + 1][Y[i] + 1]++;

    // 2次元累積和
    for (int i = 1; i < 2 * K + 1; i++) {
        for (int j = 1; j < 2 * K + 1; j++) {
            sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
        }
    }

    int ans = 0;
    // Kで全探索
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            // (i,j)が左上の頂点の場合

//             if (i == 1 && j == 1) {
//                 int x = sum[K][K] + sum[2 * K][2 * K] - sum[2 * K][K] - sum[K][2 * K] + sum[K][K];
//                 // 反転させた数
//                 int y = N - x;
//                 ans = max(ans, max(x, y));
// // cout << "i: " << i << ", j: " << j << ", x: " << x << ", y: " << y << endl;
//             } else if (i == 1) {
//                 int x = sum[i + K - 1][j + K - 1] - sum[i - 1][j + K - 1];
//                 x += sum[i - 1][2 * K] - sum[i - 1][j + K - 1];
//                 x += sum[2 * K][2 * K] - sum[i + K - 1][2 * K] - sum[2 * K][j + K - 1] + sum[i + K - 1][j + K - 1];
//                 int y = N - x;
//                 ans = max(ans, max(x, y));
// // cout << "i: " << i << ", j: " << j << ", x: " << x << ", y: " << y << endl;
//             } else if (j == 1) {
//                 int x = sum[i + K - 1][j + K - 1] - sum[i + K - 1][j - 1];
//                 x += sum[2 * K][j - 1] - sum[i + K - 1][j - 1];
//                 x += sum[2 * K][2 * K] - sum[i + K - 1][2 * K] - sum[2 * K][j + K - 1] + sum[i + K - 1][j + K - 1];
//                 int y = N - x;
//                 ans = max(ans, max(x, y));
// // cout << "i: " << i << ", j: " << j << ", x: " << x << ", y: " << y << endl;
//             } else {
                int x = sum[2 * K][2 * K] + sum[i + K - 1][j + K - 1] - sum[2 * K][j + K - 1] - sum[i + K - 1][2 * K];
                x += sum[i + K - 1][j + K - 1] + sum[i - 1][j - 1] - sum[i - 1][j + K - 1] - sum[i + K - 1][j - 1];
                x += sum[i - 1][j - 1];
                x += sum[2 * K][j - 1] - sum[i + K - 1][j - 1];
                x += sum[i - 1][2 * K] - sum[i - 1][j + K - 1];
                int y = N - x;
                ans = max(ans, max(x, y));
// cout << "i: " << i << ", j: " << j << ", x: " << x << ", y: " << y << endl;
            // }

        }
    }

    // rep(i, 2 * K + 1) {
    //     rep(j, 2 * K + 1) {
    //         cout << sum[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << ans << endl;

}

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

int main() {
  int n,m,lmax=0,rmin=9999999,x;
  cin >> n >> m;
  int l[m],r[m];
  for(int i=0;i<m;i++){
    cin >> l[i] >> r[i];
    if(l[i]>lmax) lmax = l[i];
    if(r[i]<rmin) rmin = r[i];
  }
  x= rmin - lmax;
  if(x>=0) cout << x+1 << endl;
  else cout << 0 << endl;
  
}

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

int main(){
	string s;
	int ans = 0;

while (1){
	cin >> s;
	if (s == "0"){ break; }
	for (int i = 0; i < s.size(); i++){
		ans += s[i] - 48;
	}
	cout << ans << endl;
	ans = 0;
}

	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long 
    #define ull unsigned long long 
    #define ld long double
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    ll mod=1e9+7;
 
     ll a[200005];
       ll b[200005];
 
     ll idx[100005][2];
    // ll cnt[200005];
     ll pre[200005];
    // ll end[200005];
     map<ll,ll> m;
 
    bool comp(const pair<ll,ll>& a, const pair<ll,ll>& b){
      return (a.fi-a.se)>(b.fi-b.se);
    }
 
    bool revcomp(const pair<ll,ll>& a, const pair<ll,ll>& b){
      return (a.fi)>(b.fi);
    }
 
 
    ll ceil1(ll a, ll b){
      if(a%b!=0)return a/b+1;
      else return a/b;
    }
    ll power(ll a,ll b,ll n){ll ans=1;while(b>0){if(b%2==1)ans=(ans*a)%n;a=(a*a)%n;b/=2;}return ans;}
 
    ll count1=0;
 
 
    ll gcd(ll a, ll b){
      //if(a<b)swap(a,b);
      if(b==0)return a;
      return gcd(b,a%b);
    }
 
  ll primepos(ll fact, ll p) 
  { 
      ll res = 0; 
      while (fact > 0) {         
          res += fact / p; 
          fact /= p;  
      } 
    
      return res; 
  } 
 
  // void dfs(ll n, ll p){
  //   if(vis[n]!=0){
  //     return;
  //   }
  //   else{
  //     vis[n]=1;
  //     b[n]=p;
  //     for(int i=0;i<v[n].size();i++){
  //       dfs(v[n][i],p);
  //     }
  //   }
  // }

   int main(){

      ios::sync_with_stdio(0);\
      int n;
      cin>>n;
      int a[n+1];
      int b[n+1];
      int c[n+1];
      for(int i=0;i<n;i++){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
      }
      int dp[n+1][3];
      memset(dp,0,sizeof dp);
      for(int i=0;i<n;i++){
        if(i==0){
          dp[i][0]=a[0];
          dp[i][1]=b[0];
          dp[i][2]=c[0];
          continue;
        }
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
      }
      cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
      return 0;
}

Measured memory_bytes: 2560
import sys
# sys.stdin = open('input.txt')

import math

n,m = map(int, input().split())
def c(n):
    return int(math.factorial(n) / math.factorial(n-2) / math.factorial(2))

if n == 1 and m == 1:
    print(0)
elif n <= 1:
    print(c(m))
elif m <= 1:
    print(c(n))
else:
    print(c(n)+c(m))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  long long x, s = 100;
  cin >> x;

  int i;
  for (i = 0; s < x; i++) {
       s = (long long)(s * 1.01);
  }
  cout << i << endl;
       
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
	unsigned long long A;
	char B[5];
	char C[4];
	int t;
	
	scanf("%lld", &A);
	scanf("%s", B);
	
	C[0] = B[0];
	C[1] = B[2];
	C[2] = B[3];
	C[3] = B[4];
		
	t = atoi(C);
	
	printf("%lld\n", (long long)((A * t)/ 100));
	
	return 0;
}


Measured memory_bytes: 1724
import java.math.BigInteger;
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0054
public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNextInt()) {
			int a = sc.nextInt(), b = sc.nextInt(), n = sc.nextInt();
			String c = new Double((double)a / b).toString();
			int[] f = new int[200];
			int idx = c.indexOf(".");
			f[0] = new Integer(c.substring(idx - 1, idx));
			for (int i = 1; i < min(200, c.substring(idx + 1).length() + 1); i++) {
				f[i] = new Integer(c.substring(idx + i, idx + i + 1));
			}

			int res = 0;
			for (int i = 1; i <= n; i++)
				res += f[i];
			System.out.println(res);
		}
	}	
}

Measured memory_bytes: 0
cdiv m n = ceiling $ (fromIntegral m) / (fromIntegral n)

ans' (a:[]) = []
ans' (a1:a2:as) = ((a2-a1-1)`cdiv`2):(ans' (a2:as))

ans [[n,m],a@(a1:as)] = maximum $ (a1-1):(ans' (a++[n+(n-al)]))
  where
    al = last a

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  print o



Measured memory_bytes: 23276
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;
#define M 1000000007
#define pb push_back
#define rep(i, a, b) for(int i = a; i <= b; i++)
ll mod = 998244353;


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t; t = 1;
	// cin >> t;
	while(t--)
	{
		ll n, k;
		cin >> n >> k;
		ll a[n+1];ll vis[n+1] = {};
		for(int i = 1; i <= n; i++)
			cin >> a[i];
		ll findes = 1;
		if(k <= n)
		{
			while(k)
			{
				findes = a[findes];
				k--;
			}
		}
		else
		{
			int h = 1;
			ll req = 1;
			vis[1] = 1;
			ll cc = 1;
			while(h)
			{
				findes = a[findes];
				cc++;
				k--;
				if(vis[findes] == 0) vis[findes] = cc;
				else
				{
					// cout << findes << endl;
					// cout << cc << endl;
					//findes = a[findes];
					req = cc - vis[findes];
					break;
				}

			}
			ll rem = k%req;
			// cout << req << endl;
			// cout << findes << " !!!" << endl;
			while(rem)
			{
				// cout << findes << " " << rem << endl;
				findes = a[findes];
				rem--;			
			}
		}
		cout << findes;

	}
		
}  

Measured memory_bytes: 6780
#include<iostream>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    double N, T, A;
    cin >> N >> T >> A;
    double d = 10000;
    int e = 0;
    int x;
    double gap;
    rep(i, N){
        cin >> x;
        gap = abs(T-A-0.006*x);
        if(d>gap){
            d = gap;
            e = i+1;
        }
    }
    cout << e;
}


Measured memory_bytes: 256