akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

#define sf scanf
#define pf printf
#define pb push_back
#define lb lower_bound
#define finc(i,j,k) for(int i=j;i<=k;i++)
#define fpro(i,j,k) for(int i=j;i>=k;i--)

void read(int &input) {
	char word;
	int value=0,sign=1;
	do {
		word=getchar();
		if(word=='-')
			sign=-1;
	} while(word<'0'||word>'9');
	while(word>='0'&&word<='9') {
		value=value*10+word-'0';
		word=getchar();
	}
	input=value*sign;
}
void read(int *input,int begin,int end) {
	finc(i,begin,end)
		read(input[i]);
}

int n,a[205],ans;

int main() {
    read(n);
    finc(i,1,n*2) {
        read(a[i]);
    }
    sort(a+1,a+2*n+1);
    finc(i,1,n) {
        ans+=a[i*2-1];
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <bitset>
#include <cassert>
#include <ctime>  
#include <cmath>  
#include <cstdlib>  
#include <cstring>  
#include <functional>  
#include <iostream>  
#include <deque>  
#include <stack>
#include <queue>  
#include <vector>  
#include <map>  
#include <set>  
#include <string>  
#include <unordered_map>  
#include <unordered_set>  

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 1e18;
const int MAXN = 3e5 + 5;

int N, A[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

	cin >> N;

	cout << A[N-1] << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		if(a==25) {
			System.out.println("Christmas");
		}
		if(a==24) {
			System.out.println("Christmas Eve");
		}
		if(a==23) {
			System.out.println("Christmas Eve Eve");
		}
		if(a==22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}

Measured memory_bytes: 19924
#include<iostream>
using namespace std;
#include<cstdio>
#include<vector>
#include<utility>
#include<queue>

typedef vector<pair<int, int> > adj;

struct current_cost
{
	int index, cost;
	bool operator < (const current_cost &cur) const
	{
		return cost > cur.cost;
	}
};

current_cost init(int i, int c)
{
	current_cost cur;
	cur.index = i, cur.cost = c;
	return cur;
}

int main()
{
	int i, j, k, n, m, next, cost;
	scanf("%d", &n);
	adj *adlist;
	adlist = new adj [n];

	for(k = 0; k < n; k++){
		scanf("%d %d", &i, &m);
		for(j = 0; j < m; j++){
			scanf("%d %d", &next, &cost);
			adlist[i].push_back(make_pair(next, cost));
		}
	}
	
	int *d;
	d = new int [n];
	d[0] = 0;
	for(i = 1; i < n; i++){
		d[i] = 200000;
	}

	priority_queue<current_cost> C;
	current_cost cur = init(0, 0);
	C.push(cur);

	int size;
	bool *check;
	check = new bool [n];
	for(i = 0; i < n; i++){ check[i] = false; }

	while(!C.empty())
	{
		cur = C.top(); C.pop();
		if(check[cur.index]) continue;
		check[cur.index] = true;

		i = cur.index;
		size = adlist[i].size();
		for(j = 0; j < size; j++){
			k = adlist[i][j].first;
			if(d[i] + adlist[i][j].second < d[k]){
				d[k] = d[i] + adlist[i][j].second;
				C.push(init(k, d[k]));
			}
		}
	};
	for(i = 0; i < n; i++){ printf("%d %d\n", i, d[i]); }

	return 0;
}

Measured memory_bytes: 6100
# -*- coding: utf-8 -*-

class UnionFindTree():
    def __init__(self, n):
        self.parent = []
        self.rank = []
        self.number = []
        for i in range(n):
            self.parent.append(i)
            self.rank.append(0)
            self.number.append(1)

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.number[y] += self.number[x]
        else:
            self.parent[y] = x
            self.number[x] += self.number[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def union_number(self, x):
        x = self.find(x)
        return self.number[x]

    def same_union_list(self, x):
        l = []
        for i in range(len(self.parent)):
            if i != x:
                if self.same(x, i):
                    l.append(i)
        
        return l

[N, M, K] = [int(i) for i in input().split()]

AB = []
for m in range(M):
    [a, b] = [int(i) for i in input().split()]
    AB.append((a, b))

CD = []
for k in range(K):
    [c, d] = [int(i) for i in input().split()]
    CD.append((c, d))

uf_tree = UnionFindTree(N)
for (a, b) in AB:
    a -= 1
    b -= 1
    uf_tree.unite(a, b)

candidates = []
for n in range(N):
    candidates.append(uf_tree.union_number(n) - 1)

for (a, b) in AB:
    a -= 1
    b -= 1
    candidates[a] -= 1
    candidates[b] -= 1

for (c, d) in CD:
    c -= 1
    d -= 1
    if uf_tree.same(c, d):
        candidates[c] -= 1
        candidates[d] -= 1

ans = ''
for candidate in candidates:
    ans += str(candidate)
    ans += ' '

print(ans[:len(ans) - 1])

Measured memory_bytes: 41916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

  int n;
  cin >> n;
  cout << 0 << endl;
  string s = "Vacant";
  string sl, sr;
  cin >> sl;
  sr = sl;
  if (sl == s) return 0;
  int left = 0, right = n;
  while (1) {
    int mid = (left + right) / 2;
    if (mid == left) mid++;
    string sm;
    cout << mid << endl;
    cin >> sm;
    if (sm == s) return 0;
    if ((sm == sl && (mid - left) % 2 == 0) || (sm != sl && (mid - left) % 2 == 1)) {
      left = mid;
      sl = sm;
    } else {
      right = mid;
      sr = sm;
    }
  }
  return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

const int MAX = 1e5+5;
int a[MAX];
int n, l, t;

int main() {
    cin >> n >> l >> t;
    int p = 0;
    for (int i = 0; i < n; ++i) {
        int x, w; cin >> x >> w;
        x = x + t*(w == 1 ? 1 : -1);
        p += (x > 0 ? x/l : (x-l+1)/l);
        a[i] = (x%l+l)%l;
    } 
    sort(a, a+n);
    for (int i = 0; i < n; ++i) cout << a[((i+p)%n+n)%n] << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector <pair <int, int> > lx(n);
  REP(i, n) {
	int x, l;
	cin >> x >> l;
	lx[i] = make_pair(x + l, x - l);
  }
  sort(all(lx));
  int l   = -2e9;
  int ans = 0;
  REP(i, n) {
	if (l <= lx[i].second) {
		ans++;
		l = lx[i].first;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a, b, v[50][50];
int dx[] = {0, 0, -1, 1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
string s[50];

int good(int c, int d)
{
    return c >= 0 && c < a && d >= 0 && d < b;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b;
    for (int i = 0; i < a; ++i)
        cin >> s[i];
    for (int i = 0; i < a; ++i)
        for (int j = 0; j < b; ++j)
            if (s[i][j] == '#')
                for (int k = 0; k < 8; ++k)
                {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if (good(x, y))
                        v[x][y]++;
                }
    for (int i = 0; i < a; ++i)
    {
        for (int j = 0; j < b; ++j)
        {
            if (s[i][j] == '#')
                cout << '#';
            else
                cout << v[i][j];
        }
        cout << endl;
    }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    string A;
    cin >> A;
    cout << "#" << A << "#" << endl;
  }
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
    v = [A, B, C]
    ans = []
    if sum(v) == 0:
        return None
    if sum(v) == 1:
        for l, r in s:
            if v[l] + v[r] == 0:
                return None
            if v[l] == 0:
                ans.append(l)
            else:
                ans.append(r)
            v[l], v[r] = v[r], v[l]
        return ans
    if sum(v) > 1:
        for i in range(N):
            l, r = s[i]
            if v[l] + v[r] == 0:
                return None
            if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:
                ans.append(r)
                v[l] -= 1
                v[r] += 1
            else:
                ans.append(l)
                v[l] += 1
                v[r] -= 1
        return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    def s2i(s: str):
        return ord(s[0])-ord('A'), ord(s[1])-ord('A')

    def i2s(i: int):
        return chr(i + ord('A'))

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, A, B, C, s)
    if ans == None:
        print(NO)
    else:
        print(YES)
        print("\n".join(list(map(i2s, ans))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 87284
#include <cstdio>

typedef long long i64;

i64 gcd(i64 a, i64 b) {
  i64 r = a % b;
  while(r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

i64 lcm(i64 a, i64 b) {
  i64 x = gcd(a, b);
  return a / x * b;
}

int main() {
  int n;
  i64 rez, x;
  scanf("%d%lld", &n, &rez);
  for(int i = 1; i < n; ++i) {
    scanf("%lld", &x);
    rez = lcm(rez, x);
  }
  printf("%lld", rez);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
ll facctorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n+1){
        ll temp = i * 1.08;
        if(temp == n){
            ans = i;
            break;
        }
    }
    if(ans == 0){
        cout << ":(" << endl;
    }else{
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    ll n;
    cin >> n;
    print(n/3);
   
  return 0;
}

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

int descending_compare(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int ascending_compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}


int main(void){
    int n;
    long int a[200];
    int i;
    int cnt = 0;
    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%ld", &a[i]);
    }

    while (1){ 
        for (i = 0; i < n; i++){
            if (a[i]%2 == 0){
                a[i] = a[i]/2;
            }else{
                printf("%d\n", cnt);
                return 0;
            }
        }
        cnt++;
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);
  if ( A > 8 || B > 8 )
    printf(":(\n");
  else
    printf("Yay!\n");
  return 0;
}


Measured memory_bytes: 128
from collections import Counter

N, P = list(map(int, input().split()))
S = [int(c) for c in input().rstrip()]


if P in [2, 5]:
    total = 0
    for i, x in enumerate(S):
        if x % P == 0:
            # If P == 2
            # all substring ending here with last digit even
            # If P == 5
            # all substring ending here with last digit 5 or 0
            total += i + 1
    print(total)
else:
    # Note P is relatively prime with 10

    # If S is '1234'
    # Want suffixes:
    # s[4] = 1234
    # s[3] =  234
    # s[2] =   34
    # s[1] =    4
    # s[0] =    0
    #
    # Then s[j] - s[i] gives the value of the number int(S[-j:-i]) * 10**(N -i)
    # Since P doesn't divide 10, if P divides s[j] - s[i] it also divides the number

    CHECK = False
    suf = [0]
    power = 1
    for x in reversed(S):
        suf.append(suf[-1] + x * power)
        power *= 10
        if not CHECK:
            # Don't mod when checking
            suf[-1] %= P
            power %= P
    if CHECK:
        # Check
        N = len(S)
        for i in range(N):
            for j in range(i + 1, N + 1):
                print(
                    i,
                    j,
                    int("".join(map(str, S[N - j : N - i]))) * (10 ** i),
                    suf[j] - suf[i],
                )
        print(suf)

    # Count number of s[j] - s[i] pairs that are 0 mod P
    total = 0
    counts = Counter()
    for x in suf:
        x = x % P
        total += counts[x]
        counts[x] += 1
    print(total)


Measured memory_bytes: 59724
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
        int N;
        cin >> N;

  int A[N], B[N];
        for (int i = 0; i < N; i++){
                cin >> A[i];
                B[i] = A[i] - (i + 1);
        }

        sort(B, B + N);

        int b = (N % 2 == 0)?B[N / 2 - 1]:B[(N + 1) / 2 - 1];

        long long sum = 0;
        for (int i = 0; i < N; i++){
                sum += abs(B[i] - b);
        }

        cout << sum << endl;

        return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  ll a, b;
  scanf("%d%lld%lld", &n, &a, &b);
  vector<ll> f(n + 1, 1ll << 55);
  f[0] = 0;
  for (int _ = 1; _ <= n; _++) {
    int x;
    scanf("%d", &x);
    vector<ll> g(n + 1, 1ll << 55);
    for (int i = 0; i <= n; i++) if (f[i] != 1ll << 55) {
      if (x > i) {
        g[x] = min(g[x], f[i]);
        g[i] = min(g[i], f[i] + a);
      } else {
        g[i] = min(g[i], f[i] + b);
      }
    }
    f = g;
  }
  ll ans = f[0];
  for (int i = 1; i <= n; i++) {
    ans = min(ans, f[i]);
  }
  printf("%lld\n", ans);
}


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

int main(){
    int n;cin>>n;
    int t,a;cin>>t>>a;
    double tem[1000];
    for(int i=0;i<n;i++){
        int h;cin>>h;
        tem[i]=t-h*0.006;
    }

    int ans=0;
    double anst=tem[0];
    for(int i=1;i<n;i++)if(abs(a-anst)>abs(a-tem[i])){
        ans=i;
        anst=tem[i];
    }

    cout<<ans+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#define N 2005

using namespace std;

struct edge{
	int to, nxt;
}e[N * N];

int n, cnt;
int a[N], fir[N], ins[N];
bool vis[N];

vector < int > G[N];

void add(int ,int);
void work();
void dfs(int);

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	sort(a + 1, a + 1 + n);
	for(int i = 1; i <= n; ++i)
		for(int j = n; j; --j)
			if(__gcd(a[i], a[j]) != 1 && i != j)
				add(i, j);
	for(int i = 1; i <= n; ++i)
		if(!vis[i]) dfs(i);
	work();
	return 0;
}

void add(int u,int v){
	e[++cnt].to = v;e[cnt].nxt = fir[u];fir[u] = cnt;
	return ;
}

void dfs(int u){
	vis[u] = true;
	for(int i = fir[u]; i; i = e[i].nxt){
		int v = e[i].to;
		if(vis[v]) continue;
		G[u].push_back(v);
		++ins[v];dfs(v);
	}
	return ;
}

void work(){
	priority_queue < int > Q;
	for(int i = 1; i <= n; ++i)
		if(!ins[i])
			Q.push(i);
	while(!Q.empty()){
		int u = Q.top();Q.pop();
		printf("%d ", a[u]);
		int sz = G[u].size();
		for(int i = 0; i < sz; ++i){
			int v = G[u][i];
			--ins[v];
			if(!ins[v]) Q.push(v);
		}
	}
	return ;
}


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

int main(){
  int L, N;
  cin >> N >> L;
  vector<string> S(N);
  REP(i, 0, N) cin >> S.at(i);
  sort(S.begin(), S.end());
  REP(i, 0, N) cout << S.at(i);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<array>
using namespace std;

int main(){
    int a, b;
    char op;

    cin >> a >> op >> b;

    if(op == '+')
        cout << a + b << endl;
    else if(op == '-')
        cout << a - b << endl;
}


Measured memory_bytes: 256
# D
N,C = map(int, input().split())
st = [[] for _ in range(C)]
for _ in range(N):
    si,ti,ci = map(int, input().split())
    st[ci-1].append((si,ti))
    
T_MAX = int(1e5)
imos = [0]*(T_MAX+1)
for ch in range(C):
    if st[ch]==[]: continue
    st[ch].sort()
    prev_s, prev_t = st[ch][0]
    for si,ti in st[ch][1:]:
        if si!=prev_t:
            imos[prev_s-1] += 1
            imos[prev_t] -= 1
        else:
            imos[prev_s-1] += 1
            imos[prev_t-1] -= 1
        prev_s,prev_t = si,ti
    else:
        imos[prev_s-1] += 1
        imos[prev_t] -= 1
# print(imos)
ans = 1
wa = 0
for imosi in imos:
    wa += imosi
    ans = max(ans, wa)
print(ans)
    

Measured memory_bytes: 18108
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq

class FenwickTree():
    def __init__(self,n):
        self.n = n
        self.tree = [0]*(n+1)
    def add(self,idx,a):#値の更新
        idx+=1
        while idx<=self.n:
            self.tree[idx] +=a
            idx += idx &-idx

    def _sum(self,r):
        ret=0
        r+=1
        while r>0:
            ret+=self.tree[r]
            r-=r&-r
        return ret
    def sum(self,l,r):
        return self._sum(r)-self._sum(l-1)

n,q = ma()
A = lma()
ft = FenwickTree(n)
for i in range(n):
    ft.add(i,A[i])
for i in range(q):
    t,u,v = ma()
    if t==0:
        ft.add(u,v)
    else:
        print(ft.sum(u,v-1))


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

int main() {
    int N,M,s=0,P,X;
    cin >> N;

    vector<int> T(N);
    rep(i,N) {
        cin >> T.at(i);
        s += T.at(i);
    }

    cin >> M;
    rep(i,M) {
        cin >> P >> X;
        cout << s-T.at(P-1)+X << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>

int n;
double a, ansinverse=0;

int main(){
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%lf", &a);
    ansinverse+=1.0/a;
  }
  printf("%f", 1.0/ansinverse);
  return 0;
}


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

int main(){
  int x,y;
  cin >> x >> y;
  if(x==2){
    x=28;
  }else if(x==4||x==6||x==9||x==11){
    x=30;
  }else{
    x=31;
  }
  if(y==2){
    y=28;
  }else if(y==4||y==6||y==9||y==11){
    y=30;
  }else{
    y=31;
  }
  
  if(x==y){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define ll long long
using namespace std;
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int N=6e3+5;
const int M=12005;
int n,P,inv[N],f[N][M];
void Add(int &x,int y){
	x+=y,x-=x>=P?P:0;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),P=read(),inv[1]=1,f[0][n*3]=1;
	for(int i=1;i<=n*3;i++)	f[0][n*3]=1LL*f[0][n*3]*i%P;
	for(int i=2;i<=n*3;i++)	inv[i]=1LL*(P-P/i)*inv[P%i]%P;
	for(int i=0;i<n*3;i++)
		for(int j=-n*3;j<=n*3;j++)
			if(f[i][j+n*3]){
				Add(f[i+1][j+1+n*3],1LL*f[i][j+n*3]*inv[i+1]%P);
				Add(f[i+2][j-1+n*3],1LL*f[i][j+n*3]*inv[i+2]%P);
				Add(f[i+3][j+n*3],1LL*f[i][j+n*3]*inv[i+3]%P);
			}
	int ans=0;
	for(int i=n*3;i<=n*6;i++)	Add(ans,f[n*3][i]);
	cout<<ans<<endl;
	return 0;
}
 


Measured memory_bytes: 279808
/*************************
author : coldbeer
2019-06-02 9:17:38 PM
*************************/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string str;
	cin >> str;
	int n = str.length();
	str = '@' + str;
	string t;
	for (int i = 1; i < n; i++)
	{
		if (str[i] == 'B' && str[i + 1] == 'C')
			t += 'X', i++;
		else
			t += str[i];
	}
	long long curr = 0;
	long long ans = 0;
	for (int i = 0; i < t.length(); i++)
	{
		if (t[i] == 'A')
			curr++;
		else if (t[i] == 'X')
			ans += (curr);
		else
			curr = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 848
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

bool dfs(vector<llong> &A, llong index, llong sum, llong q){
    if(sum==q){
        return true;
    }
    if(index==A.size()){
        return false;
    }
    return dfs(A, index+1, sum+A[index], q) | dfs(A, index+1, sum, q);
}

int main(){
    llong n,q;
    cin >> n;
    vector<llong> A(n,0);
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    cin >> q;
    vector<llong> Query(q,0);
    for(int i=0; i<q; i++){
        cin >> Query[i];
    }
    for(int i=0; i<Query.size(); i++){
        if(dfs(A, 0, 0, Query[i])){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-')f = 1;ch = getchar();}
	while(isdigit(ch)) {x = x * 10 + ch - '0';ch = getchar();}
	return f ? -x : x;
}
const int N = 1e5 + 100;
int main() {
	int k = read();
	for(int i = 1;i <= k;i++) cout <<"ACL";
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

  private static final int MAX_COUNT = 999;

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int a = scan.nextInt();
    int b = scan.nextInt();

    long total = 0;
    for (int i = 1; i <= n; i++) {
      String value = String.valueOf(i);
      int sum = 0;
      for (int j = 0; j < value.length(); j++) {
        sum += Integer.parseInt(value.substring(j, j + 1));
      }
      if (sum >= a && sum <= b) {
        total += i;
      }
    }
    System.out.println(total);

    scan.close();
  }
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

  unordered_map<int, int> m;
  for (int x : xs) {
    m[x]++;
  }

  int e = 0;
  for (const auto& kv : m) {
    int k, v;
    tie(k, v) = kv;
    if (v >= 2) {
      e += v - 1;
    }
  }
  int ans = n - (e + 1) / 2 * 2;
  cout << ans << endl;
}

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

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0): x((x % mod + mod) % mod) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        return mint(*this) += a;
    }
    mint operator-(const mint a) const {
        return mint(*this) -= a;
    }
    mint operator*(const mint a) const {
        return mint(*this) *= a;
    }
    mint pow(long long t) const {
        if (!t) {
            return 1;
        }
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) {
            a *= *this;
        }
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return *this *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, const mint& a) {
    return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
    return os << a.x;
}

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

    int n;
    cin >> n;
    int zero = 0;
    map<pair<ll, ll>, pair<int, int>> mp;

    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) {
            zero++;
            continue ;
        }
        ll g = gcd(x, y);
        x /= g;
        y /= g;
        if (y < 0) {
            x = -x;
            y = -y;
        }
        if (y == 0 && x < 0) {
            x = -x;
            y = -y;
        }
        bool rot90 = false;
        if (x <= 0)
            rot90 = true;
        if (rot90) {
            ll tmp = x;
            x = y;
            y = -tmp;
        }
        if (rot90)
            mp[{x, y}].first++;
        else
            mp[{x, y}].second++;
    }

    mint ans = 1;
    for (auto p : mp) {
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1; // s, t どちらからも選ばない個数
        now += mint(2).pow(s) - 1;
        now += mint(2).pow(t) - 1;
        ans *= now;
    }

    ans -= 1; // 誰も選ばない通りを引いた
    ans += zero; // 0単体の場合を足す

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 16080
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val tasks = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }.sortedBy { it[1] }
    var currentTime = 0
    for ((x, y) in tasks) {
        currentTime += x
        if (currentTime > y) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 132500
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++){
		cin >> x[i];
	}
	int ans = MOD;
	for (int now = 1; now <= 100; now++){
		int power = 0;
		for (int i = 0; i < n; i++){
			power += (now - x[i])*(now - x[i]);
		}
		ans = min(ans, power);

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

	int n;
	cin >> n;

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

	sort(h.begin(), h.end(), greater<int>());

	long long ans = 1;
	for(int i = 0; i < n; ++i)
		ans += max(0, h[i] - i / 4);

	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int[] N = new int[5];
        int ans = 0;
        for(int i=0; i<5; i++) {
            int n = sc.nextInt();
            if(n == 0) ans = i + 1;
        }
        out.println(ans);

        out.flush();

    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 32996
from collections import deque
N = int(input())
A = deque()
for _ in range(N):
    a,b = list(map(int,input().split()))
    A.append([b,a])
A = list(A)
A.sort()
time = 0
for i in A:
    time += i[1]
    if time > i[0]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 66264
#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 REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll 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 main(void)
{
    vector<vector<int>> a(3, vector<int>(3, 0));
    vector<vector<bool>> hit(3, vector<bool>(3, false));
    REP(i, 3)
    {
        REP(j,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    REP(i,n){
        cin >> b[i];
        REP(j,3){
            REP(k,3){
                if(a[j][k] == b[i]){
                    hit[j][k] = true;
                }
            }
        }
    }

    bool ans = false;
    
    REP(i,3){
        bool flag = true;
        REP(j, 3)
        {
            if(!hit[i][j]){
                flag = false;
            }
        }
        if(flag){
            ans = true;
        }
    }

    REP(i,3){
        bool flag = true;
        REP(j, 3)
        {
            if(!hit[j][i]){
                flag = false;
            }
        }
        if(flag){
            ans = true;
        }
    }

    bool flag = true;
    REP(i, 3)
    {
        if(!hit[i][i]){
            flag = false;
        }
    }
    if(flag){
        ans = true;
    }

    flag = true;
    REP(i, 3)
    {
        if(!hit[i][2 - i]){
            flag = false;
        }
    }
    if(flag){
        ans = true;
    }

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

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashSet;
// use std::collections::VecDeque;
// use std::cmp::max;
// use std::cmp::min;


fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }

    return gcd(b, a % b);
}

fn main() {
    input! {
        N: usize,
        As: [i64; N],
    }

    let pc = String::from("pairwise coprime");
    let sc = String::from("setwise coprime");
    let nc = String::from("not coprime");

    let mut all_gcd = As[0];
    for &a in As.iter() {
        all_gcd = gcd(all_gcd, a);
    }

    // 素数表を持っておく
    let mut is_prime: Vec<bool> = vec![true; 1000_000 + 10];
    let mut primes: Vec<i64> = Vec::new();
    is_prime[0] = false;
    is_prime[1] = false;

    for p in 2..1000 + 10 {
        if !is_prime[p] {
            continue;
        }

        primes.push(p as i64);

        for q in (p + p..1000 + 10).step_by(p) {
            is_prime[q] = false;
        }
    }

    let mut common_primes: HashSet<i64> = HashSet::new();

    let mut is_pc = true;

    // 素因数分解をしよう
    for &a in As.iter() {
        if a == 1 {
            continue;
        }

        let mut a_copy = a;

        for &p in primes.iter() {
            if p > ((a as f64).sqrt() + 10.0) as i64 {
                break;
            }

            if a_copy % p == 0 {
                if common_primes.contains(&p) {
                    is_pc = false;
                    break;
                }

                common_primes.insert(p);

                while a_copy % p == 0 {
                    a_copy /= p;
                }
            }

            if !is_pc {
                break;
            }
        }

        if a_copy > 1 {
            // まだ生き残っていたらそれは素数
            if common_primes.contains(&a_copy) {
                is_pc = false;
                break;
            }

            common_primes.insert(a_copy);
        }
    }

    let ans = if is_pc {
        pc
    } else {
        if all_gcd == 1 { sc } else { nc }
    };
    println!("{}", ans);
}


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

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k; cin >> n >> k;
    vector<int> a(n);
    vector<bool> dp(k + 1);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 1; i < k + 1; i++) for(int j = 0; j < n; j++)
    {
    	if(i - a[j] < 0) break;
    	if(!dp[i - a[j]])
    	{
    		dp[i] = 1;
    		break;
    	}
    }
    cout << (dp[k] ? "First" : "Second");

    return 0;
}

Measured memory_bytes: 256
while (m,f,r = gets.split(" ").map(&:to_i)) != [-1,-1,-1]
    if m + f < 30 or m < 0 or f < 0
        puts "F"
    elsif m + f >= 80
        puts "A"
    elsif m + f >= 65
        puts "B"
    elsif m + f >= 50 or r >=50
        puts "C"
    else
        puts "D"
    end
end




Measured memory_bytes: 6864
#include <bits/stdc++.h>
using namespace std;
int calc(int p, int q, int x, int y) {
    int ret = min(abs(x-p) + abs(y-q) + 1, abs(x-q) + abs(y-p) + 1);
    ret = min(ret, abs(p-q));
    return ret;
}
int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    vector<int> ans(n-1, 0);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int k = calc(i, j, x, y);
            ans[k-1]++;
        }
    }
    for (auto p: ans) cout << p << endl;
    return 0;
}

Measured memory_bytes: 3620
import numpy as np
N, x = map(int, input().split())
a = np.array(list(map(int, input().split())))
a.sort()
s = np.cumsum(a)
b = (s <= x)
if b.all():
  if s[-1] == x:
    c = b.sum()
  else:
    c = b.sum() - 1
elif b.any():
  c = b.sum()
  r = x - s[c-1]
  if (r == a[c:]).any():
    c += 1
else:
  c = 0
print(c)

Measured memory_bytes: 12392
while(n,m=gets.split.map &:to_i)[0]>0
c=(1..n).map{{}}
m.times{a,b,t=gets.split.map &:to_i;c[a][b]=c[b][a]=t}
d=[s=0]
(y,z=d.flat_map{|i|[*c[i].select{|k,v|d-[k]==d}]}.min_by{|k,v|v};s+=z;d<<y)while[*0..n-1]!=d.sort
p s
end

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

int main(){
	int q;
	cin >> q;
	long long int l=0, r=0;
	for(int i=0; i<q; i++){
		int p,n;
		char c;
		cin >> p >> c >> n;
		if(c=='(') l+=n;
		else r+=n;
		
		if(l==r){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}	
	return 0;
}

Measured memory_bytes: 3112
using System;
namespace ITP1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().Split();
            var a = int.Parse(S[0]);
            var b = int.Parse(S[1]);
            if(a < b)
            {
                Console.WriteLine("a < b");
            }
            else if(a > b)
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}


Measured memory_bytes: 17876
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

from itertools import product
N,M = II()
k = [0]*M
p = [0]*M
s = []
for i in range(M):
    a = III()
    k[i] = a[0]
    temp = a[1:]
    temp = list(map(lambda x:x-1,temp))
    s.append(temp)

p = III()

x=list(product([0,1],repeat=N))
count = 0

for i in range(len(x)):
    for j in range(M):
        scount = 0
        for k in s[j]:
            if x[i][k]==1:
                scount += 1
        if scount%2 != p[j]:
            break
        if j==M-1:
            count += 1

print(count)

Measured memory_bytes: 40644
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  string s;
  cin >> s;
  if (s[0] == '9' || s[1] == '9') {
    cout << "Yes" << LF;
  } else {
    cout << "No" << LF;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int n, k, a[100010], ans = INF;

signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	for (int i = 0; i <= n - k; i++) {
		if (a[i + k - 1] <= 0)ans = min(ans, abs(a[i]));
		else if (a[i] >= 0)ans = min(ans, a[i + k - 1]);
		else ans = min(ans, min(abs(a[i]), abs(a[i + k - 1])) + (a[i + k - 1] - a[i]));
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

int main()
{
	int a, b, c, k;
	std::cin >> a >> b >> c >> k;
	
	int max = std::min(a, k);
	k -= a + b;
	if (k > 0) {
		max -= k;
	}
	
	std::cout << max << std::endl;
	
	return 0;
}


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

#define ll long long

using namespace std;

int main() {
	ll n, m, p, v;
	cin >> n >> m >> v >> p;
	vector <ll> a(n);
	for (ll i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	if (v <= p) {
		ll l = 0;
		ll r = n - 1;
		while (l != r) {
			ll med = (l + r) / 2;
			if (a[med] + m >= a[p - 1])
				l = med + 1;
			else
				r = med;
		}
		if (a[n - 1] + m >= a[p - 1])
			cout << n;
		else
			cout << l;
		return 0;
	}
	v -= p - 1;
	ll l = p;
	ll r = n - 1;
	while (l != r) {
		ll med = (l + r) / 2;
		ll copy_v = v;
		ll x = a[med] + m;
		copy_v -= (n - med);
		ll all_v = copy_v * m;
		for (ll i = p - 1; i < med; i++)
			all_v -= min(m, (x - a[i]));
		if (all_v > 0 || x < a[p - 1])
			r = med;
		else
			l = med + 1;
	}
	ll copy_v = v;
	ll x = a[n - 1] + m;
	copy_v--;
	ll all_v = copy_v * m;
	for (ll i = p - 1; i < n - 1; i++)
		all_v -= min(m, (x - a[i]));
	if (all_v <= 0 && a[n - 1] + m >= a[p - 1])
		cout << l + 1;
	else
		cout << l;
	return 0;
}

Measured memory_bytes: 1024
a, b = map(int, input().split())

r = range(min(a, b), max(a, b) + 1)

if 0 in r:
    print("Zero")
else:
    if min(a, b) < 0:
        if (-min(a, b) + min(0, max(a, b)) + 1) % 2 == 0:
            print("Positive")
        else:
            print("Negative")
    else:
        print("Positive")

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static final int BIG_NUM = 2000000000;
    public static final int MOD     = 1000000007;
    
    public static void main(String[] args) {
        int table[] = new int[10001];
        
        for(int i = 0; i <= 10000; i++) {
            table[i] = 1;
        }
        
        int limit = (int) Math.sqrt(10000);
        for(int i = 2; i <= limit; i++) {
            if(table[i] == 1) {
                for(int k = 2 * i ; k < 10000; k += i) {
                    table[k] = 0;
                }
            }
        }
        
        ArrayList<Integer> prime = new ArrayList<Integer>();
        for(int i = 2; i <= 10000; i++) {
            if(table[i] == 1) {
                prime.add(Integer.valueOf(i));
            }
        }
        
        Scanner scanner = new Scanner(System.in);
        
        int N = scanner.nextInt();
        int input, tmp, count = 0;
        boolean FLG;
        
        for(int loop = 0; loop < N; loop++) {
            input = scanner.nextInt();
            
            FLG = false;
            
            for(int i = 0; i < prime.size(); i++) {
                tmp = prime.get(i);
                if(input % tmp == 0 && (input / tmp) > 1) {
                    FLG = true;
                    break;
                }
                if(tmp * tmp > input) break;
            }
            if(!FLG) count++;
        }
        System.out.println(count);
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

struct UF
{
  vector<int> parent_, rank_;

  UF(int N) {
    parent_ = vector<int>(N + 5);
    rank_ = vector<int>(N + 5, 1);
    for (int i = 0; i <= N; ++i) { parent_[i] = i; }
  }

  int find_set(int x)
  {
    if (parent_[x] != x) {
      parent_[x] = find_set(parent_[x]);
    }
    return parent_[x];
  }

  void unite(int x, int y)
  {
    int s1 = find_set(x), s2 = find_set(y);
    if (s1 == s2) { return; }
    if (rank_[s1] > rank_[s2]) { parent_[s2] = s1; }
    else {
      parent_[s1] = s2;
      if (rank_[s1] == rank_[s2]) { ++rank_[s2]; }
    }
  }

  bool is_connected(int x, int y) { return find_set(x) == find_set(y); }
};

int main()
{
  int N; scanf("%d", &N);
  vector<pair<ll, ll>> towns(N, pair<ll, ll>());
  vector<pair<ll, int>> X(N), Y(N);
  for (int i = 0; i < N; ++i) {
    ll x, y;
    scanf("%lld %lld", &x, &y);
    X[i] = {x, i};
    Y[i] = {y, i};
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  vector<pair<ll, pair<int, int>>> edges;
  for (int i = 1; i < N; ++i) {
    edges.push_back({ abs(X[i].first - X[i - 1].first),
        { X[i].second, X[i - 1].second }});
    edges.push_back({ abs(Y[i].first - Y[i - 1].first),
        { Y[i].second, Y[i - 1].second }});
  }
  sort(edges.begin(), edges.end());
  UF uf(N);
  ll ans = 0;
  for (int i = 0; i < (int)edges.size(); ++i) {
    int u = edges[i].second.first, v = edges[i].second.second;
    if (uf.find_set(u) == uf.find_set(v)) { continue; }
    uf.unite(u, v);
    ans += edges[i].first;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 11120