akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (998244353)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
const int max_n = 200000+10;
Int p2[max_n];

template<typename T> class BIT {
    private:
        vector<T> bit;
        int n;
    public:
        BIT(int N) : n(N), bit(N+1) {
        }

        void add(int i, T x=1) {
            for(i++;i <= n;i += i&-i)
                bit[i] += x;
        }

        T sum(int x) {
            T ans = 0;
            for(x++;x > 0;x -= x&-x) {
                ans += bit[x];
            }

            return ans;
        }
};

Int f(int a,int b,int c,int d) {
    Int res = 0;
    vector<int> num = {a,b,c,d};
    vector<Int> o(4),ox(4);

    for(int i = 0;i < 4;i++) {
        ox[i] = p2[num[i]];
        o[i] = (MOD + ox[i] - 1) % MOD;
    }

    res = (res + ((o[0]*o[3]%MOD)*(ox[1]*ox[2]%MOD)%MOD))%MOD;
    res = (res + ((ox[0]*ox[3]%MOD)*(o[1]*o[2]%MOD)%MOD))%MOD;
    res = (res + MOD - ((o[0]*o[1]%MOD)*(o[2]*o[3]%MOD)%MOD)) % MOD;

    res = (res+((ox[0]*ox[1])%MOD)*((ox[2]*ox[3])%MOD))%MOD;

    return res;
}

int main(void) {
    cin>>N;

    p2[0] = 1;
    for(int i = 1;i <= N;i++) {
        p2[i] = p2[i-1]*2%MOD;
    }

    vector<pair<int,int> > p(N);

    for(int i = 0;i < N;i++) {
        cin>>p[i].first>>p[i].second;
    }

    {
        map<int,int> m;
        for(int i = 0;i < N;i++) {
            m[p[i].first] = 0;
        }
        int y = 0;
        for(auto &&x: m) x.second=y++;
        for(int i = 0;i < N;i++) {
            p[i].first = m[p[i].first];
        }
    }
    {
        map<int,int> m;
        for(int i= 0;i < N;i++) {
            m[p[i].second] = 0;
        }
        int y = 0;
        for(auto &&x: m) x.second=y++;
        for(int i = 0;i < N;i++) {
            p[i].second = m[p[i].second];
        }
    }

    sort(p.begin(),p.end());

    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    vector<int> d(N);
    for(int i = 0;i < 2;i++) {
        BIT<Int> bit(N);
        for(int j = 0;j < N;j++) {
            a[j] = bit.sum(p[j].second);
            b[j] = j-a[j];
            bit.add(p[j].second);
        }

        reverse(p.begin(),p.end());
        swap(a,c);
        swap(b,d);
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        reverse(c.begin(),c.end());
        reverse(d.begin(),d.end());
    }

    Int ans = 0;
    for(int i = 0;i < N;i++) {
        ans = (ans+f(a[i],b[i],c[i],d[i]))%MOD;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 12800
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}



Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#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 pi acos(-1)
#define mod 998244353 //1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100005
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int main(){
    int ca=0,k,i,j,K = 0, m, n;
    ll s;
    scanf("%lld", &s);
    m = sqrt(s);
    if(1LL * m * m < s)m++;
    ll x1 = m, y2 = m;
    s = x1 * y2 - s;
    ll x2 = s, y1 = 1;
    printf("0 0 %lld %lld %lld %lld\n", x1, y1, x2, y2);
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  char s[3];
  int a = 0,b = 0,c = 0,i;
  scanf("%s",s);
  
  for(i = 0; i < 3; i++)
  {
    if(s[i] =='a')
      a++;
    else if(s[i] == 'b')
      b++;
    else if(s[i] == 'c')
      c++;
    else
      printf("error\n");
  }  
  if(a == 1 && b ==1 && c == 1)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
require 'matrix'

$stdin = DATA if $stdin.eof?

n, m, _ = gets.split.map(&:to_i)

a = n.times.map do
      gets.split.map(&:to_i)
    end

b = m.times.map do
      gets.split.map(&:to_i)
    end

ma = Matrix.rows(a)
mb = Matrix.rows(b)
mc = ma * mb

mc.row_vectors.each{|row| puts row.to_a.join("\s")}


Measured memory_bytes: 9160
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int gcd(int a, int b) {
  return a%b==0?b:gcd(b,a%b);
}

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

  int n,x; cin>>n>>x;
  int ans = 0;
  cin>>ans;
  ans=abs(ans-x);
  for (int i = 1; i < n; i++) {
    int y; cin>>y;
    ans = gcd(ans, abs(y-x));
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 2);
  a[0] = 0;
  a[n + 1] = 0;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum += abs(a[i] - a[i - 1]);
  }
  sum += abs(a[n + 1] - a[n]);
  for (int i = 1; i <= n; ++i) {
    const int ans = sum + abs(a[i + 1] - a[i - 1]) - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
typedef long long int lli;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define JUGAD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define N 1000001
using namespace std;

int main(){
    FAST;
    int n,c=0;bool ok=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b;cin>>a>>b;
        if(a==b){
            c++;
            if(c>2){ok=1;}
        }
        else{
            c=0;
        }
    }
    if(ok){cout<<"Yes\n";}
    else{cout<<"No\n";}
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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


Measured memory_bytes: 256
import sys
fin = sys.stdin.readline


# def dfs(a_list, used, start, strategy):
#     # DFSで更新後のa_listとusedを返す。
#     # 難しいのは移動先の選び方。移動先は奇数と偶数なら奇数を優先してほしい。
#     odds = []
#     y, x = start
#     #for dy, dx in ((-1, 0), (0, 1), (0, -1), (1, 0)):
#     for dy, dx in ((-1, 0), (0, 1)):
#         if y+dy < 0 or y+dy >= H or x+dx < 0 or x+dx >= W:
#             continue
#         elif used[y+dy][x+dx]:
#             continue
#         else:
#             # 奇数なら終わり
#             if a_list[y+dy][x+dx] % 2 == 1:
#                 a_list[y][x] -= 1
#                 a_list[y+dy][x+dx] += 1
#                 used[y][x] = True
#                 strategy.append((y, x, y+dy, x+dx))
#                 return a_list, used, strategy
#             else:
#                 odds.append((dy, dx))
#     # 偶数0なら移動
#     else:
#         try:
#             dy, dx = odds[0]
#         except:
#             return a_list, used, strategy
#         a_list[y][x] -= 1
#         a_list[y+dy][x+dx] += 1
#         used[y][x] = True
#         strategy.append((y, x, y+dy, x+dx))
#         a_list, used, strategy = dfs(a_list, used, (y+dy,x+dx), strategy)
#         return a_list, used, strategy


# H, W = [int(elem) for elem in input().split(' ')]
# a_list = [[int(elem) for elem in fin().split(' ')] for _ in range(H)]
# assert len(a_list) == H
# assert len(a_list[0]) == W


# # 近いところに行き着き次第終わるというDFSでいけるのでは？
# used = [[False] * W for _ in range(H)]
# strategy = []
# for y in range(H):
#     for x in range(W):
#         if a_list[y][x] % 2 != 0:
#             a_list, used, strategy = dfs(a_list, used, (y, x), strategy)

# print(len(strategy))
# for s in strategy:
#     print(' '.join([str(elem + 1) for elem in s]))


H, W = [int(elem) for elem in input().split(' ')]
a_list = [[int(elem) for elem in fin().split(' ')] for _ in range(H)]
assert len(a_list) == H
assert len(a_list[0]) == W

strategy = []
used = [[False] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if a_list[i][j] % 2 == 1 and (not used[i][j]):
            a_list[i][j] -= 1
            if j < W - 1:
                a_list[i][j+1] += 1
                strategy.append((i+1, j+1, i+1, j+2))
                used[i][j] = True
            elif i < H - 1:
                a_list[i+1][j] += 1
                strategy.append((i+1, j+1, i+2, j+1))
                used[i][j] = True
            else:
                continue

print(len(strategy))
for tup in strategy:
    print(' '.join([str(elem) for elem in tup]))


Measured memory_bytes: 27944
# coding: utf-8
from collections import deque

n = int(input().rstrip())
num = deque()
for loop in range(n):
    l = input().rstrip().split()
    if l[0] == "deleteFirst":
        num.popleft()
    elif l[0] == "deleteLast":
        num.pop()
    else:
        if l[0] == "insert":
            num.appendleft(l[1])
        else:
            try:
                num.remove(l[1])
            except ValueError:
                pass

print(' '.join(num))


Measured memory_bytes: 69740
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n / 2 * ((n + 1) / 2);
}


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

using namespace std;

int main(){
  int a,b,c,d,e,f,g,h,i;
  cin >>a>>b>>c>>d>>e>>f>>g>>h>>i;
  if(b-a==e-d && e-d==h-g && c-a==f-d && f-d==i-g){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		BigInteger dogs = new BigInteger(String.valueOf(sc.next()));
		BigInteger[] results;
		StringBuilder result = new StringBuilder("");

		results = dogs.divideAndRemainder(new BigInteger("1"));
		while(results[0].compareTo(new BigInteger("0")) != 0) {
			dogs = dogs.subtract(new BigInteger("1"));
			results = dogs.divideAndRemainder(new BigInteger("26"));
			dogs = results[0];
			result.insert(0,(char)('a' + (char)results[1].intValue()));
		}

		System.out.println(result.toString());

	}

}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

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

    std::priority_queue<ll> l;
    std::priority_queue<ll, std::vector<ll>, std::greater<ll>> r;
    ll lsum = 0, rsum = 0, bsum = 0;

    std::cin >> q;

    for (int i = 0; i < q; ++i) {
        int n;
        std::cin >> n;

        if (n == 1) {
            ll a, b;

            std::cin >> a >> b;

            bsum += b;

            if (l.empty()) {
                l.push(a);
                lsum += a;
            }
            else {
                if (l.size() == r.size()) {
                    if (!r.empty()) {
                        auto p = r.top();
                        if (a > p) {
                            r.pop();
                            r.push(a);
                            rsum += a - p;
                            a = p;
                        }
                    }
                    l.push(a);
                    lsum += a;
                }
                else {
                    if (!l.empty()) {
                        auto p = l.top();
                        if (a < p) {
                            l.pop();
                            l.push(a);
                            lsum += a - p;
                            a = p;
                        }
                    }
                    r.push(a);
                    rsum += a;
                }
            }

        }
        else {
            auto p = l.top();
            auto ans = (p * (ll)l.size() - lsum) + (rsum - p * (ll)r.size()) + bsum;
            std::cout << p << " " << ans << std::endl;
        }
    }

    return 0;
}


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

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

}






Measured memory_bytes: 3580
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	int N, R;
	cin >> N >> R;
	if (N >= 10) {
		cout << R;
	}
	else {
		cout << R + 100 * (10 - N);
	}
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")



#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <memory>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <ctime>
#include <sstream>  
#include <deque>
#include <unordered_set>
#include <stack>
#include <functional>
#include <memory.h>
#include <bitset>
#include <numeric>

using namespace std;

//#define int long long

signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector <int> v(n);
    unordered_multiset <int> sss;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sss.insert(v[i]);

    }
    sort(v.rbegin(), v.rend());
    int ans = 0;
    for (auto it : v) {
        if (sss.find(it) != sss.end()) {
            sss.erase(sss.find(it));
        }
        else {
            continue;
        }
        long long cur = 1073741824;
        while (cur) {
            auto gg = sss.find(cur - it);
            if (gg != sss.end()) {
                ans++;
                sss.erase(gg);
                break;
            }
            cur /= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11336
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;
 
void solve(){
	long double a, b, h, m;
	cin >> a >> b >> h >> m;
	long double x = h * 30 + m * 0.5;
	long double y = m * 6.0;
	long double z = abs(x - y);
	if (z > 180)
		z = 360.0 - z;
	assert(z >= 0);
	long double ans = sqrtl(a * a + b * b - a * b * 2.0 * cos((z * acos((long double)-1.0)) / 180.0));
	cout << ans;
}

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


Measured memory_bytes: 4184
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M=map(int, input().split())
B=[tuple(map(int, input().split())) for _ in range(M)]

P=list(range(N+1))
C=[1 for _ in range(N+1)]
C[0] = 0

def root(x):
    if P[x]==x: return x
    P[x] = root(P[x])
    return P[x]

def unite(a,b):
    ra = root(a)
    rb = root(b)
    if count(ra) < count(rb): ra,rb = rb,ra
    C[ra] += C[rb]
    C[rb] = 0
    P[rb] = ra

def same(a,b):
    return root(a) == root(b)

def count(x):
    return C[root(x)]

ans=[0]*(M+1)
ans[M] = N * (N-1) // 2

for i in range(M-1,-1,-1):
    a,b = B[i]
    if same(a,b):
        ans[i] = ans[i+1]
        continue
    ans[i] = ans[i+1] - count(a) * count(b)
    unite(a,b)

for i in range(1,M+1):
    print(ans[i])

Measured memory_bytes: 100444
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
  string s; cin >> s;
  string::size_type idx = s.find('C', 0);
  if (idx == string::npos) {
    cout << "No" << endl;
    return 0;
  }

  idx = s.find('F', idx);
  if (idx == string::npos) {
    cout << "No" << endl;
    return 0;
  }

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

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 int a,b,c;
 scanf("%d %d %d",&a,&b,&c);
 if(a==b){
   printf("%d",c);
 }
 if(a==c){
   printf("%d",b);
 }
 if(c==b){
   printf("%d",a);
 }
  return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n = int(input())
    s,t = input().split()

    ans = ''
    for i in range(n):
        ans += s[i] + t[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_N 100001

int N;
int K;
long int x[MAX_N];

int main(){
    cin >> N >> K;
    bool flag = true;
    for (int i = 0; i < N; i++){
        long int element;
        cin >> element;
        // if ((element > 0) && (flag)){
            // flag = false;
            // x[i] = 0;
            // i ++;
        // }
        x[i] = element;
    }
    // for (int i = 0; i <= N; i++){
    //     cout << x[i] << endl;
    // }
    int left = 0;
    int right = K - 1;
    long int distance = 10000000001;
    if (x[0] >= 0){
        distance = x[K - 1];
    }
    else if (x[N - 1] <= 0){
        distance = - x[N - K];
    }
    else{
        while (right < N){
            if ((x[right] >= 0) && (x[left] <= 0)){
                distance = min(min(2 * x[right] - x[left], x[right] - 2 * x[left]), distance);
            }
            left ++;
            right ++;
        }
    }
    cout << distance << endl;

    return 0;
}

Measured memory_bytes: 1024
import math

def read():
    N = int(input().strip())
    return N, 

def solve(N):
    pairs = []
    n = math.ceil(math.sqrt(N)) + 1
    for i in range(1, n):
        j = N // i
        if i * j == N:
            pairs.append((i, j))
    min_moves = 1000000000000
    for pair in pairs:
        min_moves = min((pair[0] - 1) + (pair[1] - 1), min_moves)
    return min_moves

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 39280
import math

if __name__ == "__main__":
    n = input()
    X = [int(i) for i in input().split(" ")]
    X.sort()
    
    left = X[0]
    right = X[-1]
    right_p_before = 0
    left_p_before  = 0
    while True:
        left_p  = 0
        right_p = 0
        for i in X:
            left_p  += (i - left )**2
        for i in X:
            right_p += (i - right)**2
        
        if right_p == right_p_before and left_p == left_p_before:
            if right_p > left_p:
                print(left_p_before)
            else:
                print(right_p_before)
            break
        else:
            right_p_before = right_p
            left_p_before  = left_p
            if left_p < right_p:
                right = math.floor(right - (right-left)/2)
            else:
                left  = math.floor(left  + (right-left)/2)

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void){
    
    int K;
    scanf("%d",&K);
    long long int a[K];
    for(int i=0;i<K;i++)scanf("%lld",&a[i]);
    long long int min=2;
    long long int max=3;
    if(a[K-1]!=2){printf("-1");return 0;}
    for(int i=K-2;i>=0;i--){
        long long int maemin=min;
        long long int maemax=max;
        long long int po=max/a[i];
        max=po*a[i]+(a[i]-1);
        po=(min+a[i]-1)/a[i];
        min=po*a[i];
        if(min>max||maemax<min||maemin>max){printf("-1");return 0;}
    }
    printf("%lld %lld",min,max);
    return 0;
}


Measured memory_bytes: 896
n = int(input())
v = list(sorted(map(int, input().split())))
v.append(2000)
total = n*(n-1)*(n-2) / 6



def bs(left, s):
    right = n+1
    while left < right-1:
        m = (right+left)//2

        if v[m]>=s:
            right = m
        else:
            left = m
    return left+1






for i, x in enumerate(v[:-2]):
    for j, y in enumerate(v[i+1:-1]):
        k = bs(j+1, y+x)
        total -= (n-k)

print(int(total))

Measured memory_bytes: 47068
/**
 * author:    Ziel
 * created:   23.04.2020 20:19:46
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
    int n, W, V = 0;
    cin >> n >> W;
    vector<int> w(n + 1), v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
        V += v[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(V + 1));
    for (int i = 0; i <= n; i++) {
        fill(all(dp[i]), INF);
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i][v[i]] = w[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= V; j++) {
            if (j >= v[i]) {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
                if (j == 100 && dp[i][j] == 8) {
                    cout << "found " << i << "\n";
                    cout << dp[i - 1][j] << " " << dp[i - 1][j - v[i]] << "\n\n";
                }
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    for (int i = V; i >= 0; i--) {
        if (dp[n][i] <= W) {
            return !(cout << i);
        }
    }
    
	return 0;
}

/*
	Raise your standard.
*/


Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
long long ma[200005];
long long q[200005];
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%lld", &q[i]);
		ma[q[i]]++;
	}
	long long an = 0;
	for (int i = 0; i <= n; i++)
		an += (ma[i])*(ma[i]-1) / (long long)2;
	for (int i = 0; i < n; i++){
		printf("%lld\n", an - max((long long)0, (ma[q[i]] - 1)));
	}
	return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

    public int findChange(int amount) {
        int n = 0;
        while (n < amount) {
            n = n + 1000;
        }
        return n - amount;
    }

    public static void main(String args[]) {
        Main p = new Main();
        Scanner sc = new Scanner(System.in);
        int amount = sc.nextInt();
        System.out.println(p.findChange(amount));
    }
}

Measured memory_bytes: 35608
#include<stdio.h>
#include<stdlib.h>
#define df 0


int main(){
  int l,r;
  scanf("%d%d",&l,&r);
  
  if(r-l>=673){
    printf("%d",0);
    return 0;
  }
  long int i,j,mini,minj;
  long int min=2019,s;
  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      s=(i*j)%2019;
      if(s<min){
	min=s;
	mini=i;minj=j;
      }
    }
  }
  printf("%ld\n",min);
  if(df)printf("%ld %ld",mini,minj);
}


/// confirm df==0 ///


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  string s, ans;
  cin>>s;
  int n=s.size();
  int m[26];
  for(char i='a'; i<='z'; ++i) m[i-'a']=0;
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout<<-1<<endl;
    return 0;
  }

  if(n<26){
    REP(i, n) ++m[s[i]-'a'];
    for(char i='a'; i<='z'; ++i){
      if(m[i-'a']==0) {
        ans = s + i;
        break;
      }
    }
  }
  else{
    int j;
    for(int i=24; i>-1; --i){
      if(s[i]<s[i+1]) {
        j=i;
        break;
      }
    }
    char t='z';
    for(int i=25; i>j; --i){
      if(s[i]>s[j]) t=min(t, s[i]);
    }
    if(j==0) ans=t;
    else ans = s.substr(0, j) + t;
  }

  ECHO(ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
const ll INF = 1e13;
const ll N = 200001;
const ll mod=998244353;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
void solve()
{
  ll n,W;
  cin>>n>>W;
  ll w[n], v[n];
  loop(i,0,n) cin>>w[i]>>v[i];
  ll dp[n+1][W+1];
  loop(i,0,n+1)
  {
  	loop(j,0,W+1)
  	{
  		if(i==0 || j==0) dp[i][j]=0;
  		else if(w[i-1]<=j) dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
  		else dp[i][j] = dp[i-1][j];
	}
  }
  cout<<dp[n][W];
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 80768
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

// vector set 等
#include <map>
#include <set>
#include <vector>

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#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--)
#define FORA(i, I) for (const auto& i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(x.begin(), x.end())
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m, a_index, b_index, temp, temp_max;
  ll k;
  k = 0;
  a_index = -1;
  b_index = 0;

  cin >> n >> m >> k;
  vector<ll> booksA(n), booksB(m);
  REP(i, n) { cin >> booksA[i]; }
  REP(i, n) {
    if (k >= booksA[i]) {
      k -= booksA[i];
      a_index = a_index + 1;
    } else
      break;
  }

  temp = a_index + 1;

  REP(i, m) { cin >> booksB[i]; }

  FOR(j, b_index, m - 1) {
    if (k >= booksB[j]) {
      k -= booksB[j];
      b_index++;
      temp += 1;
    } else
      break;
  }
  temp_max = temp;

  FORD(i, a_index, 0) {
    k += booksA[i];
    temp -= 1;
    FOR(j, b_index, m - 1) {
      if (k >= booksB[j]) {
        k -= booksB[j];
        b_index++;
        temp += 1;
      } else
        break;
    }
    temp_max = max(temp_max, temp);
  }

  cout << temp_max << endl;

  return 0;
}

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

int main(){
	int n;
	int d[55];
	cin >> n;
	int sum = 0;
	rep(i,n){
		cin >> d[i];
	}
	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
		sum += d[i]*d[j];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct Dijkstra {
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<int> path;
    
    Dijkstra() {}
    Dijkstra(int n) {
        graph.resize(n);
        dist.resize(n);
        prev.resize(n);
    }
    
    void add_edge(int from, int to, T cost) {
        graph[from].emplace_back(to, cost);
    }
    
    void get_distance(int from) {
        priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
        fill(dist.begin(), dist.end(), inf);
        fill(prev.begin(), prev.end(), -1);
        dist[from] = 0;
        pq.push(make_pair(0, from));
        while(!pq.empty()) {
            pair<T, int> p = pq.top(); pq.pop();
            if (dist[p.second] < p.first) continue;
            for (auto e : graph[p.second]) {
                if (dist[e.first] > (dist[p.second] + e.second)) {
                    dist[e.first] = dist[p.second] + e.second;
                    prev[e.first] = p.second;
                    pq.push(make_pair(dist[e.first], e.first));
                }
            }
        }
    }
    
    void get_path(int to) {
        path = vector<int>(0);
        for (; to != -1; to = prev[to]) {
            path.push_back(to);
        }
        reverse(path.begin(), path.end());
    }
    
private:
    vector<vector<pair<int, T>>> graph;
    vector<T> prev;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll v, e, r;
    cin >> v >> e >> r;
    Dijkstra<ll> dij(v);
    rep(i, e) {
        ll s, t, d;
        cin >> s >> t >> d;
        dij.add_edge(s, t, d);
    }
    dij.get_distance(r);
    rep(i, v) {
        if (dij.dist[i] == dij.inf) cout << "INF" << endl;
        else cout << dij.dist[i] << endl;
    }
    return 0;
}



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

using namespace std;
typedef long long llong;

int n, m;
int A[100001];
llong M[200002];
llong B[200002];
llong ans[100001];

void add(int p, int x) {
    int c = (x - p + m) % m;
    M[x + m + 1 - c] -= 1;
    M[x + m + 1] += 1;
    B[x + m + 1 - c] += x + m + 1;
    B[x + m + 1] -= x + m + 1;

    B[x + 1] += c;
    B[x + m + 1 - c] -= c;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    int p;
    cin >> p;
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        add(p, x);
        p = x;
    }
    for (int i = 1; i <= m + m; ++i) {
        M[i] += M[i - 1];
        B[i] += B[i - 1];
        ans[i > m ? i - m : i] += M[i] * i + B[i];
    }
    llong ret = ans[1];
    for (int i = 2; i <= m; ++i) ret = min(ret, ans[i]);
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n;
      string s;
      int ans[5]={};
      
      cin>>n;
      for(int i=0;i<n;i++){
        cin>>s;
        if(s=="AC") ans[0]++;
        if(s=="WA") ans[1]++;
        if(s=="TLE") ans[2]++;
        if(s=="RE") ans[3]++;
      }
      
      cout<<"AC x "<<ans[0]<<endl;
      cout<<"WA x "<<ans[1]<<endl;
      cout<<"TLE x "<<ans[2]<<endl;
      cout<<"RE x "<<ans[3]<<endl;
      return 0;
    }

Measured memory_bytes: 3608
using System;

namespace atcorder
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var m = n % 10;

            if(m == 3)
            {
                Console.WriteLine("bon");
            }
            else if(m == 0 || m == 1 || m == 6 || m == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }
        }
    }
}



Measured memory_bytes: 27488
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int h,a;
	cin >> h >> a;
    cout <<  (h + a - 1) / a;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define eb emplace_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
// vll a(100005, -1);
ll power(ll a, ll b)
{
    ll ans = 1;
    while (b > 0)
    {
        if (b % 2)
        {
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        b /= 2;
    }
    return ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, n, k, ans = 0;
    cin >> n >> k;
    vll p(k + 1);
    for (i = k; i >= 1; i--)
    {
        p[i] = power(k / i, n);
        for (j = 2 * i; j <= k; j += i)
        {
            p[i] -= p[j];
        }
    }
    fr(i, 1, k + 1)
    {
        ans = (ans + i * p[i]) % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4000
def number():
    return int(input())


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


N, K = space()
H = space()

dp = [0] * N

for i in range(1, N):
    dp[i] = min([dp[j] + abs(H[j] - H[i]) for j in range(max(0, i - K), i)])

print(dp[-1])



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

#define MAX 105
#define INFTY 10000000

int n, M[MAX][MAX];
int d[MAX];

void bfs(int s){
    //最短距離を初期化
    for(int u=1; u<=n; u++){
        d[u] = INFTY;
    }
    queue<int> Q;
    d[s] = 0;
    Q.push(s);

    while(!(Q.empty())){
        int v = Q.front();
        for(int u=1; u<=n; u++){
            if(M[v][u] == 1  &&  d[u] == INFTY){
                d[u] = d[v]+1;
                Q.push(u);
            }
        }
        Q.pop();
    }

    //出力
    for(int u=1; u<=n; u++){
        if(d[u] == INFTY) printf("%d -1\n", u);
        else printf("%d %d\n", u, d[u]);
    }
}

//グラフの幅優先探索(stackを用いる)
int main(){
    cin >> n;
    //隣接リスト表現→隣接行列表現への変換
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            M[i][j] = 0;
        }
    }
    for(int i=1; i<=n; i++){
        int u, k;
        cin >> u >> k;
        for(int j=1; j<=k; j++){
            int v;
            cin >> v;
            M[u][v] = 1;
        }
    }

    bfs(1);

    return 0;
}


Measured memory_bytes: 3224
n=int(input())
L=[]
for i in range(n):
      a,b=input().split()
      L.append((i,a,int(b)))
L.sort(key=lambda x:x[2],reverse=True)
L.sort(key=lambda x:x[1])

for i in range(n):
      print(L[i][0]+1)

Measured memory_bytes: 3064
c=input()
d=c.split()
d=[int(i)for i in d]
p=d[0]
q=d[1]
r=d[2]
count=0
if p+q<r:
    count+=p+q+q+1
elif p+q>=r:
    count+=r+q
print(count)
    
    
    
    


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
	int n;
	int t;
	int i;
	int start;
	int stop;
	int time = 0;
	while(scanf("%d", &t) != 0){
		if(t == 0) break;
		scanf("%d", &n);
		for(i = 0; i < n; i++){
			scanf("%d%d", &start, &stop);
			time += stop - start;
		}
		if(t <= time){
			printf("OK\n");
		}else{
			printf("%d\n", t - time);
		}
		time = 0;
	}
	return 0;
}

Measured memory_bytes: 612
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ll> vll;
typedef std::vector<vll> vvll;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int ab, bc, ca;
  scan(ab, bc, ca);
  print(ab * bc / 2);
  return 0;
}


Measured memory_bytes: 760
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <set>
using namespace std;
typedef pair<string,int> P;
int main() {
	string str;
	while(cin>>str,str!="0") {
		queue<P> Q;
		Q.push(P(str,0));
		set<string> S;
		S.insert(str);
		bool NA=true;
		while(!Q.empty()) {
			P p=Q.front(); Q.pop();
			bool Flag=true;
			for(int i=0;i<p.first.size()-1;i++) {
				if(p.first[i]!=p.first[i+1]) {Flag=false;break;}
			}
			if(Flag) {printf("%d\n",p.second);NA=false;break;}
			for(int i=0;i<p.first.size()-1;i++) {
				string tmp=p.first;
				if((tmp[i]=='r' && tmp[i+1]=='g') || (tmp[i+1]=='r' && tmp[i]=='g')) {
					tmp[i]=tmp[i+1]='b';
				}else if((tmp[i]=='r' && tmp[i+1]=='b') || (tmp[i+1]=='r' && tmp[i]=='b')) {
					tmp[i]=tmp[i+1]='g';
				}else if((tmp[i]=='b' && tmp[i+1]=='g') || (tmp[i+1]=='b' && tmp[i]=='g')) {
					tmp[i]=tmp[i+1]='r';
				}else continue;
				if(S.find(tmp)==S.end()) {
					S.insert(tmp);
					Q.push(P(tmp,p.second+1));
				}
			}
		}
		if(NA) printf("NA\n");
	}
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans;
  ans = n * (n+1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std ; 
const int N=2e3+2,Mod= 1e9+7;
long long int dp[ N]; 
int s ; 
long long calc(long long  sum){
       //cout<<1;
        if(sum==s)return 1; 
        if(sum>s)return 0 ; 
        long long &ret = dp[sum];
        if(ret!=-1)return ret ; 
        ret =0 ; 
        bool z =0 ,n =0 ; 
        for(int i =3;i<=s;i++){
                
               ret+=calc(sum+i)%Mod;
                ret %=Mod ; 
        }return ret %= Mod; 
}
int main(){ 
  cin >> s ; 
  memset(dp, -1, sizeof dp);
  cout<<calc(0);
        //cout<<2;
}
  

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

using namespace std;

int main()
{
    while (1){
        double pt[8];
        for (int i = 0; i < 8; i++){
            if (scanf("%lf", pt + i) != 1) return (0);
        }
        
        double xAB = pt[2] - pt[0], yAB = pt[3] - pt[1],
               xCD = pt[6] - pt[4], yCD = pt[7] - pt[5];
        
        printf("%s\n", fabs(xAB * xCD + yAB * yCD) <= 1e-10 ? "YES" : "NO");
    }
    
    return (-1);
}

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

int main(){
  uint64_t A,B,C,D;
  cin >> A >> B >> C >> D;

  uint64_t tmp_C,tmp_D;
  tmp_C = C; tmp_D = D;
  uint64_t x = tmp_C*tmp_D;
  uint64_t r,tmp;
  if(tmp_C<tmp_D){
    tmp = tmp_C;
    tmp_C = tmp_D;
    tmp_D = tmp;
  }

  r = tmp_C % tmp_D;
  while(r!=0){
    tmp_C = tmp_D;
    tmp_D = r;
    r = tmp_C % tmp_D;
  }
  uint64_t lcm = x/tmp_D;
  uint64_t sum = B-A+1;
  sum -= (B/C)-((A-1)/C);
  sum -= (B/D)-((A-1)/D);
  sum += (B/lcm)-((A-1)/lcm);
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x = sc.nextInt();
    
    long ans = 0;
    int prev = sc.nextInt();
    if (prev > x) {
      int diff = prev - x;
      ans += diff;
      prev -= diff;
    }
    for (int i = 2; i <= N; i++) {
      int a = sc.nextInt();
      if (prev+a >= x) {
        int diff = prev+a - x;
        ans += diff;
        prev = a - diff;
      } else {
        prev = a;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 50512