akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 3010;

int n, m;
string s, t;
int f[N][N];

int dp(int x, int y) {
	if(f[x][y] != -1) {
		return f[x][y];
	}
	if(x == 0 or y == 0) {
		return (f[x][y] = 0);
	}
	if(s[x - 1] == t[y - 1]) {
		return (f[x][y] = max(f[x][y], 1 + dp(x - 1, y - 1)));
	} else {
		return (f[x][y] = max(f[x][y], max(dp(x - 1, y), dp(x, y - 1))));
	}
}

string reconstruct(int x, int y) {
	if(x == 0 or y == 0) return "";
	if(s[x - 1] == t[y - 1]) {
		return s[x - 1] + reconstruct(x - 1, y - 1);
	}
	if(f[x - 1][y] > f[x][y - 1]) {
		return reconstruct(x - 1, y);
	}
	return reconstruct(x, y - 1);
}

int main() {
	for(int i = 0 ; i < N ; i++) {
		for(int j = 0 ; j < N ; j++) {
			f[i][j] = -1;
		}
	}
	cin >> s >> t;
	n = s.size(), m = t.size();
	dp(n, m);
	string lcs = reconstruct(n, m);
	reverse(lcs.begin(), lcs.end());
	cout << lcs;
}


Measured memory_bytes: 36224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
    int m,n,sum=0,a[110]={0};
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    if(4*m*a[n-m]<sum)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
G = {i:[] for i in range(1, n+1)}
for _ in range(n):
    ukv = list(map(int, input().split()))
    u = ukv[0]
    k = ukv[1]
    for i in range(2, 2+k):
        G[u].append(ukv[i])
        
stack = [1]
dist = [-1]*(n+1)
dist[1] = 0

while stack:
    target = stack.pop(0)
    for target_i in G[target]:
        if dist[target_i]==-1:
            dist[target_i] = dist[target]+1
            stack.append(target_i)
            
for i, dist_i in enumerate(dist[1:], 1):
    print(i, dist_i)


Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b, k; cin >> a >> b >> k;
    
    int acc = 0;
    
    for(int i = 100; i > 0; i--)
    {
        if(a % i == 0 && b % i == 0)
            acc += 1;
        if(acc == k)
        {
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}


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

int main() {
	int S;
	int K;
	int count = 0;
	scanf("%d%d",&K,&S);
	for(int a=0;a<=K;a++){
		for(int b=0;b<=K;b++){
			if(S-a-b<=K&&S-a-b>=0) count++;
		}
	}
	printf("%d",count);
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string op;
		cin >> op;
		int a, b;
		cin >> a >> b;
		if (op == "print") {
			cout << s.substr(a, b - a + 1) << endl;
		}
		if (op == "reverse") {
			reverse(s.begin() + a, s.begin() + b + 1);
		}
		if (op == "replace") {
			string p;
			cin >> p;
			s.replace(s.begin() + a, s.begin() + b + 1, p);
		}
	}
}



Measured memory_bytes: 3228
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> sum(N + 1);
    ll res = LINF;
    rep(i, N) { sum[i + 1] = A[i] + sum[i]; }
    for(int i = 0; i <= N; i++) {
        int lb = 0, ub = i;
        while(ub - lb > 1) {
            int mid = (ub + lb) / 2;
            if(sum[mid] > sum[i] - sum[mid]) {
                ub = mid;
            } else {
                lb = mid;
            }
        }
        ll P1 = sum[lb];
        ll P2 = sum[ub];
        ll Q1 = sum[i] - sum[lb];
        ll Q2 = sum[i] - sum[ub];
        lb = i, ub = N;
        while(ub - lb > 1) {
            int mid = (ub + lb) / 2;
            if(sum[mid] - sum[i] > sum[N] - sum[mid]) {
                ub = mid;
            } else {
                lb = mid;
            }
        }
        ll R1 = sum[lb] - sum[i];
        ll R2 = sum[ub] - sum[i];
        ll S1 = sum[N] - sum[lb];
        ll S2 = sum[N] - sum[ub];
        ll tmp = LINF;
        tmp = min(tmp, abs(max(P1, max(Q1, max(R1, S1))) -
                           min(P1, min(Q1, min(R1, S1)))));
        tmp = min(tmp, abs(max(P1, max(Q1, max(R2, S2))) -
                           min(P1, min(Q1, min(R2, S2)))));
        tmp = min(tmp, abs(max(P2, max(Q2, max(R1, S1))) -
                           min(P2, min(Q2, min(R1, S1)))));
        tmp = min(tmp, abs(max(P2, max(Q2, max(R2, S2))) -
                           min(P2, min(Q2, min(R2, S2)))));
        res = min(tmp, res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3328
# import numpy as np


def solve():
    H, W, K = map(int, input().split())
    C = [[] for _ in range(H)]
    for i in range(H):
        tmp = input()
        C[i] = list(tmp)
    # C = np.array(C)
    # print(C)
    ans = 0
    for i in range(2 ** (H + W)):
        cnt = 0
        h_i = []
        w_i = []
        for j in range(H + W):
            if (i >> j) & 1:
                if j < H:
                    h_i.append(j)
                else:
                    w_i.append(j - H)
        for k in range(H):
            for l in range(W):
                if k not in h_i and l not in w_i and C[k][l] == '#':
                    cnt += 1

        if cnt == K:
            ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9208
N, K = list(map(int,input().split()))
A  = list(map(int,input().split()))

M = max(A)

L = [0] * (M+1)

for i in A:
    L[i] += 1

D = []    
for i in range(M+1):
    if L[i] > 0:
        D.append(L[i])

D.sort()

nn = len(D)

if nn <= K:
    print(0)

else:
    print(sum(D[:nn-K]))

Measured memory_bytes: 25644
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
  ll N; cin >> N;
  ll s = pow(N,0.5);
  
  while(N%s!=0){s--;}
  ll t = N/s;
  
  int c=1;
  while(t>=10){t = t/10; c++;}
  
  cout << c;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <string> 
#include <sstream>  
#include <vector> 
#include <time.h>
#include <algorithm>
using namespace std;

int main(){
    int P;
    while(cin >> P){
        if(P == 0)break;
        int Money  = 0,answer = 0;
        int M,N;
        for(int i = 1;12 >= i;i++){cin >> M >> N;Money += M - N;if(Money >= P and answer == 0){answer = i;}}
        if(answer == 0){
            cout << "NA" << endl;
        }else{
            cout << answer << endl;
        }
    }
}  

Measured memory_bytes: 1160
n = int(input())
edges = [set() for _ in range(n)]
matched = [-1] * n
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(n)]
for j, (c, d) in enumerate(cd):
    for i, (a, b) in enumerate(ab):
        if a < c and b < d:
            edges[i].add(j)


def dfs(v, visited):
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False


print(sum(dfs(s, set()) for s in range(n)))


Measured memory_bytes: 3188
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 998244353;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
int main() {
    ll n,a,b,k;
    COMinit();
    std::cin >> n>>a>>b>>k;
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        if((k-a*i)%b==0&&(k-a*i)>=0){
            ll j = (k-a*i)/b;
            ans += COM(n,i)*COM(n,j)%MOD;
            ans %= MOD;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 12160
h, w = map(int, input().split())
A = [str(input()) for _  in range(h)]

q_ = 0
for i in range(h):
    flag = 0
    for j in range(w):
        if A[i][j] == '#' and flag == 0:
            p = j
            q = j
            flag = 1
        elif A[i][j] == '#' and flag == 1:
            q = j
        else:
            pass
    if p < q_:
        print('Impossible')
        exit()
    else:
        q_ = q
else:
    print('Possible')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define INF 1e9

using ll = long long;

int main(){
  int H,N;
  cin >> H >> N;
  vector< pair<int,int> > magic(N+1);
  rep(i,N){cin >> magic[i].first >> magic[i].second;}
  // first = damage , second = cost

  
  int max_damage = 0;
  // 1回の攻撃で与えられる最大幅(HPを0未満にすればいい)
  rep(i,N){max_damage = max(max_damage, magic[i].first);}


  vector<int> min_MP(H+20000,INF);
  // HPをi削るまでの最小消費MP
  min_MP[0] = 0;
  for(int i=0;i<H+max_damage;i++){
    for(int j=0;j<N;j++){ // 魔法選択
      min_MP[i+magic[j].first]
        = min(min_MP[i + magic[j].first] // 撃つ
          , min_MP[i] + magic[j].second ); // 撃たない
    }
      //cout << min_MP[i] << endl;
  }


  int min_cost = INF;
  for(int i=0;i<max_damage+1;i++){
    min_cost = min(min_cost, min_MP[H+i]);
  }

  cout << min_cost << endl;
}

/*
DP配列の幅を10000から10万にくっそ広げたらドロボから拾ってきたコーナーケース例が通った………なんで？？？
足し算の時にオーバーしたときの配列分も確保できるようにdamage(Ai)最大値=10000の幅も確保しておいたのに…

と思ったがデバッグしてみたらわかった
これHp超えた後の超過計算時のときにも最大ダメージ超えが起きるから幅は最悪、最大値の2倍の2万撮っておく必要があったのか～～～！！！
*/

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long ans = 0;
		
		for(int i=0; Math.pow(i,2)<=n; i++){
		    ans = (long)Math.pow(i,2);
		}
		
      	System.out.println(ans);
    }
}

Measured memory_bytes: 35708
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
 
N, K = map(int, input().split())

for i in range(1,K+1):
  if N-K+1 < i:
    print(0)
    continue
  blue = cmb(K-1, i-1)
  red = cmb(N-K+1, i)
  print((blue * red) % (10**9+7))


Measured memory_bytes: 3944
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;
    
    if(N % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    // cout << S.substr(0,N/2) << " " << S.substr(N/2, N/2) << endl;
    if(S.substr(0,N/2) == S.substr(N/2, N/2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y:
            print(" ".join(map(str, [i, j, n-i-j])))
            sys.exit()
else:
    print("-1 -1 -1")

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

typedef long long ll;
const int len = 1e5+5;
int a[len], b[len];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d %d", &a[i], &b[i]);

    ll cur = 0;
    for (int i = n; i >= 1; i--)
        if ((cur+a[i])%b[i] != 0)
            cur += b[i] - ((cur+a[i])%b[i]);

    printf("%lld\n", cur);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>

class Compare {
public:
    bool operator()(std::pair<int, char> a, std::pair<int, char> b) {
        return (a.first < b.first);
    }
};

int main()
{
    char menu[] = {'A', 'B', 'C'};
    std::priority_queue<std::pair<int, char>, std::vector<std::pair<int, char>>, Compare> pq;
    int tmp;
    for (int i = 0; i < 3; i++) {
        std::cin >> tmp;
        pq.push(std::make_pair(tmp, menu[i]));
    }
    std::cout << pq.top().second << std::endl;
    return 0;
}



Measured memory_bytes: 3136
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
a,b=n1()

if b-a>=2019:
    print(0)
else:
    c=[]
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            c.append(i*j)
    c=[i%2019 for i in c]
    print(min(c))

Measured memory_bytes: 171984
D,G = map(int,(input().split()))
p = [0]*D
c = [0]*D
for i in range(D):
    p[i],c[i] = map(int,(input().split()))

ans = []
K = 2 #選択肢の数
N = D #問題の個数
for i in range(K**N):
    TF=[0]*N

    for j in range(N):
        TF[N-j-1] = i % K
        i //= K

    sc = 0
    for j in range(D):
        sc += (100*(j+1)*p[j] + c[j]) *TF[j]

    m = 0
    for j in range(D):
        m += p[j] *TF[j]
    
    g = G-sc
    if g <= 0:
        ans.append(m)
    else:
        for j in range(D)[::-1]:
            if TF[j] == 0:
                break
        for _ in range(p[j]):
            g -= 100*(j+1)
            m += 1
            if g <= 0:
                break
        else:
            m = 100000
        
        ans.append(m)
    
print(min(ans))

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

using namespace std;

int main(){
  string a, b, c; cin >> a >> b >> c;
  int count = 1;

  if(a != b){
    count++;
    if(b != c && a != c){
      count++;
    }
  }
  else {
    if(b != c) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x[] = new int[5];

        // Enter x[0] - x[4]
        for(int i = 0; i < x.length; i++) {
            x[i] = scan.nextInt();
        }

        // Output x[i] if its value is 0
        for(int i = 0; i < x.length; i++) {
            if(x[i] == 0) {
                System.out.println(i + 1);
            }
        }

        scan.close();
    }
}

Measured memory_bytes: 35772
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    ans = 0
    already = set()
    already.add((A, B, C))
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        tmp_a = B // 2 + C // 2
        tmp_b = A // 2 + C // 2
        tmp_c = B // 2 + A // 2
        A = tmp_a
        B = tmp_b
        C = tmp_c
        ans += 1

        res = (A, B, C)
        if res in already:
            ans = -1
            break
        already.add(res)

    ans = ans if ans else 0
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;
    int ar[n+1];
    bool aFlag = false;
    ar[0] = 0;
    for(int i = 0; i < n; i++){
        if(aFlag && s[i] == 'C'){
            ar[i+1] = 1+ar[i];
        }else{
            ar[i+1] = ar[i];
        }
        aFlag = false;
        if(s[i] == 'A'){
            aFlag = true;
        }
    }

    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << ar[r] - ar[l] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1472
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<cstring>
#define MAX_N 200000
using namespace std;

long long N;
string S[MAX_N];
set<string>gift;



int main()
{
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> S[i];
        gift.insert(S[i]);
    }
    cout << gift.size();
    

    
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define INF 100000000

int main()
{
	int N;
	cin >> N;
	vi seq(N);
	for (int n = 0; n < N; n++)
		cin >> seq[n];

	int sum = 0;
	for (int n = 0; n < N; n++)
		sum += seq[n] - 1;
	cout << sum << endl;
}



Measured memory_bytes: 3620
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    int N;
    cin >> N;
    vl a(N);
    int count = 0;
    rep(i, 0, N) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            ++count;
        }
    }
    int res = 0;
    bool flag = false;
    rep(i, 0, N) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 == 0) {
                res++;
                continue;
            }

            if (a[i] % 5 == 0) {
                res++;
                continue;
            }
        }
    }
    if (count == res) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int32_t N;
	scanf("%d", &N);

	vector<int32_t> H(N);
	for (int32_t i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}

	vector<int32_t> d(N);
	d[N - 1] = 0;
	int32_t res = 0;
	for (int32_t i = N - 2; i >= 0; i--) {
		d[i] = (H[i] < H[i + 1]) ? 0 : (d[i + 1] + 1);
		res = max(res, d[i]);
	}

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

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, M;
    cin >> A >> B >> M;
    vector<ll> a(A), b(B);
    for(ll i = 0; i < A; i++) {
        cin >> a[i];
    }
    for(ll i = 0; i < B; i++) {
        cin >> b[i];
    }
    ll ans = LLINF;
    chmin(ans, *min_element(ALL(a)) + *min_element(ALL(b)));
    for(int i = 0; i < M; i++) {
        ll x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        chmin(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

const int N = 2002;
int H, W, ans, U[N][N], R[N][N], D[N][N], L[N][N];
char S[N][N];

int main() {
    cin >> H >> W;
    rep1(i, H) cin >> S[i] + 1;

    rep1(i, H) rep1(j, W) {
        if (S[i][j] == '.') {
            L[i][j] = L[i][j-1] + 1;
            U[i][j] = U[i-1][j] + 1;
        }
    }
    for (int i = H; i > 0; i--) for (int j = W; j > 0; j--) {
        if (S[i][j] == '.') {
            R[i][j] = R[i][j+1] + 1;
            D[i][j] = D[i+1][j] + 1;
        }
    }
    rep1(i, H) rep1(j, W) {
        if (S[i][j] == '.') ans = max(ans, U[i][j] + R[i][j] + D[i][j] + L[i][j] - 3);
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;

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

  int N;
  cin>>N;
  cin>>S;
  if(N%2==1||S.substr(0,N/2)!=S.substr(N/2,N/2)){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 5e5+1;
int n, m;
ll a[N], b[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setF(N*2);
  cin >> n >> m;
  m -= n;
  a[0] = 1;
  FOR(i, 1, n+1){
     a[i] = (a[i-1]*m + b[i-1]*(i-1)) % MOD;
     b[i] = (a[i-1]*(m+1) + b[i-1]*(i-1)) % MOD;
  }
  cout << a[n]*Fac[n+m]%MOD*Rac[m]%MOD << endl;
}


Measured memory_bytes: 26640
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;


int main() {
	int h, n;
	cin >> h >> n;
	int a[100000];
	rep(i, n) {
		cin >> a[i];
	}
	int sum(0);
	rep(i, n) {
		sum += a[i];
	}
	if (sum >= h) {
		cout << "Yes";;
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF (1<<30);

int main() {
  string T;
  cin >> T;

  rep(i, T.length()) {
    if (T[i] == '?') cout << 'D';
    else cout << T[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

using Position = pair<int, int>;

int main()
{
  int N, M;

  cin >> N >> M;

  if (N == 0) N = 1;
  if (M == 0) M = 1;

  cout << (N * (N - 1)) / 2 + (M * (M - 1)) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
input = [input() for i in range(2)]
n = int(input[0])
s = input[1]

if(n % 2 != 0):
  print('No')
elif(n != len(list(s))):  
  print('No')
else:  
  s_list = list(s)
  num = n/2
  s1 = s_list[:int(num)]
  s2 = s_list[int(num):]

  if(len(s1) != len(s2)):
    print('No')    
  else:  
    flag = True  
    for index in range(len(s1)):
      if(s1[index] != s2[index]):
        flag = False

    if(flag):
      print('Yes')
    else:
      print('No')    

Measured memory_bytes: 3064
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int[] XN = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int X = XN[0], N = XN[1];
        if (N == 0) {
            Console.WriteLine(X);
            return;
        }
        int[] p = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).OrderBy(i => i).ToArray();

        bool[] table = Enumerable.Repeat(true, 102).ToArray();
        foreach (int i in p)
            table[i] = false;

        for (int i = 0; ; i++) {
            if (table[X - i]) {
                Console.WriteLine(X - i);
                return;
            } else if (table[X + i]) {
                Console.WriteLine(X + i);
                return;
            }
        }
    }
}

Measured memory_bytes: 28340
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s, t;
    cin >> s >> t;
    int n1 = s.length(), n2 = t.length();
    int pos = -1;
    for(int i = 0; i + n2 <= n1; ++i){
        if(s[i] == '?' || s[i] == t[0]){
            bool flag = true;
            for(int j = i + 1; j - i < n2; ++j){
                if(s[j] == '?' || s[j] == t[j - i]) ;
                else{
                    flag = false;
                    break;
                }
            }
            if(flag)    pos = i;
        }
    }
    if(pos == -1){
        cout << "UNRESTORABLE\n";
        return 0;
    }
    int now = 0;
    while(now < n1){
        if(now == pos){
            for(int i = now; i - now < n2; ++i){
                s[i] = t[i - now];
            }
            now += n2;
        }
        else if(s[now] == '?'){
            s[now++] = 'a';
        }
        else    ++now;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#coding:UTF-8
def GCD(x,y):
    d=0
    if x < y:
        d=y
        y=x
        x=d
    if y==0:
        print(x)
    else:
        GCD(y,x%y)
if __name__=="__main__":
    a=input()
    x=int(a.split(" ")[0])
    y=int(a.split(" ")[1])
    GCD(x,y)

Measured memory_bytes: 7720
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair 
# define all(x) x.begin(),x.end()                                                      
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;

ll power(ll x,ll y,ll m){            //power(x,y)=x^y  %m;
	if(y==0)return 1;
	int ll a=power(x,y/2,m);
	if(y%2){
		return (a*((a*x)%m))%m;
	}
	else{
		return (a*a)%m;
	}
}
ll mod_inverse(ll x,ll m){
	return power(x,m-2,m);
}
ll fact(ll n,ll m){
	if(n<=1)return 1;
	return (fact(n-1,m)*n)%m;
}
ll ncr(ll n,ll r,ll m){
	ll n1=1,d1=1,d2=1;
	n1=fact(n,m);d1=fact(r,m);d2=fact(n-r,m);
	ll ans=mod_inverse((d1*d2)%m,m);
	ans=(ans*n1)%m;
	return ans;
}
int main()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll r=0,g=0,b=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R')r++;
		else if(s[i]=='G')g++;
		else b++;
	}
	ll cnt=0;
	for(int i=1;i<=n;i++){
		char a=s[i-1];
		int d=1;
		for(int j=i+d,k=i+2*d;j<=n&&k<=n;j=i+d,k=i+2*d){
			char b=s[j-1],c=s[k-1];
			if(a!=b&&b!=c&&c!=a)
			cnt++;
			d++;
		}
	}
	ll ans=r*g*b;
	ans=ans-cnt;
	cout<<ans<<'\n';
}




Measured memory_bytes: 3596
#include<stdio.h>
#define len 110

int main(){
	int n,i=0;
	int L[len];
	scanf("%d",&n);
	for(;i<n;++i)
		scanf("%d",L+i);
	while(i>0)
		if(i>1)
			printf("%d ",L[--i]);
		else printf("%d\n",L[--i]);

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <set>

using namespace std;

int main() {
	int k;
	cin >> k;
	
	int x = 7 % k;
	set<int> s;
	
	for (int i = 1; i <= k; ++i) {
		if (!x) {
			cout << i << '\n';
			return 0;
		}
		
		x = (x * 10 + 7) % k;
	} 
	
	cout << -1 << '\n';
	
	return 0;
}

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

int r;
string s;

void input() {
    cin >> r >> s;
}

void solve() {
    int length = s.length();
    string former = s.substr(0, length/2);
    string latter = s.substr(length/2, s.length()-former.length());
    //cout << former << endl;
    //cout << latter << endl;
    if(former == latter) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}
int main() {
    input();
    solve();
}


Measured memory_bytes: 256
#include<stdio.h>
int a[11111],dp[11111];
int main()
{
    long long m,n;
    scanf("%lld%lld",&m,&n);
    for(int i=1;i<=m;i++)scanf("%d",&a[i]);
    long long ans=0;
    for(int i=1;i<=m;i++)
    {
        if(a[i]==n) ans=(ans+i*(m-i+1)%998244353)%998244353;
        else if(n>a[i])ans=(ans+dp[n-a[i]]*(m-i+1)%998244353)%998244353;
        for(int j=n;j>=a[i];j--) dp[j]=(dp[j]+dp[j-a[i]])%998244353;
        dp[a[i]]=(dp[a[i]]+i)%998244353;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 128
n = int(input())
a = [int(input()) for _ in range(n)]

sum_a = sum(a)

if sum_a % 10 == 0:
	can_nums = filter(lambda x: x%10 != 0, set(a))
	if len(list(can_nums)) == 0:
		print(0)
	else:
		print(sum_a - min(can_nums))
else:
	print(sum_a)

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

using namespace std;

long long a[10000004];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    long long ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j += i)
        {
            a[j] += j;
        }
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 81732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, int>Pair;
#define MAX 1e9
struct edge { int to, cost; };
typedef pair<int, int>P;
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  if(N%2ll==1ll){cout<<0<<endl;return 0;}
  N/=2ll;
  ll cnt=0ll;
  while(true){
    cnt+=(N/5ll);
    N/=5ll;
    if(N<5ll){break;}
  }
  cout<<cnt;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin >> n;
  ll abc[n][3];
  REP(i,n){
      REP(j,3){
          cin >> abc[i][j];
      }
  }

  ll dp[n][3];
  REP(i,n){
      REP(j,3){
          dp[i][j] = 0;
      }
  }
  REP(j,3){
      dp[0][j] = abc[0][j];
  }

  REP(i,n-1){
      REP(j,3){
          REP(k,3){
              if(j==k) continue;
              dp[i+1][k] = max(dp[i+1][k],dp[i][j] + abc[i+1][k]);
          }
      }
  }
  ll ans = 0;
  REP(i,3){
      ans = max(dp[n-1][i], ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
float a,b,c,d,e,f,x,y;
while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=-1)
{
y=((f*a)-(d*c))/((e*a)-(d*b));
x=(c-(b*y))/a;
printf("%.3f %.3f\n",x,y);
}
return 0;
}

Measured memory_bytes: 648
def main():
    N = int(input())
    A = list(map(int, input().split()))
    temp = A[0]
    su = 0
    for i in range(1, N):
        if A[i - 1] > A[i]:
            su += A[i - 1] - A[i]
            A[i] = A[i - 1]
    print(su)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32384
d,n = map(int,input().split())
if d == 0:
    if n != 100:
        print(n)
    else:
        print(101)
elif d == 1:
    if n != 100:
        print(n*100)
    else:
        print(10100)
else:
    if n != 100:
        print(n*100**2)
    else:
        print(1010000)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <tuple>
#include <algorithm>
#include <iomanip>
using namespace std;

double distance(tuple<double, double, double> const& t1, tuple<double, double, double> const& t2) {
    return pow(get<0>(t1) - get<0>(t2), 2) + pow(get<1>(t1) - get<1>(t2), 2) + pow(get<2>(t1) - get<2>(t2), 2);
}

double solve(int i, int rest, vector<bool>& used, vector<vector<double>> const& dist) {
    if(rest == 0 || rest > used.size() - i) {
        return 0;
    }

    used[i] = true;
    double ret = 0;
    for(int j=0; j<dist.size(); ++j) {
        if(used[j]) {
            ret += dist[i][j];
        }
    }
    ret += solve(i+1, rest-1, used, dist);
    
    used[i] = false;
    ret = max(ret, solve(i+1, rest, used, dist));

    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<tuple<double, double, double>> v(N);
    vector<vector<double>> dist(N, vector<double>(N, 0.0));
    for(int i=0; i<N; ++i) {
        double L, a, b;
        cin >> L >> a >> b;
        v[i] = make_tuple(L, a, b);
    }
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            dist[i][j] = distance(v[i], v[j]);
        }
    }
    vector<bool> used(N, false);
    cout << fixed << setprecision(20) << solve(0, M, used, dist) << endl;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int sum = 0;
    int sugar = 0;
    int up = 0;
    int down = 1;
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 30; j++) {
            for (int t = 0; t <= f; t++) {
                if (i + j != 0) {
                    int w = (a * i + b * j) * e;
                    if (w - c * t >= 0) {
                        int l = min((w - c * t) / d, (f - (100 * (a * i + b * j) + c * t)) / d);
                        if ((c * t + d * l) * down >= up * w && 100 * (a * i + b * j) + c * t + d * l <= f) {
                            up = c * t + d * l;
                            down = w;
                            sum = 100 * (a * i + b * j) + c * t + d * l;
                            sugar = c * t + d * l;
                        }
                    }
                }
            }
        }
    }
    cout << sum << " " << sugar << endl;
    return 0;
}

Measured memory_bytes: 256
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[]) . show

solver [a,b] = 
  if b `mod` a == 0 then a + b else b - a

Measured memory_bytes: 508
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define nl "\n"
#define fout(x) fixed<<setprecision(x)
#define one(x) __builtin_popcountll(x)
#define F first
#define S second
#define or_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(), order_of_key()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << fout(10)<<x;}
void __print(double x) {cerr << fout(10)<<x;}
void __print(long double x) {cerr << fout(10)<<x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod=1e9+7;
const double eps=1e-9;
const double PI=acos(-1.0);

ll qpow(ll n,ll k){ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


// ****************************************************



int main()
{
    int n;
    cin>>n;
    double ans=2*PI*n;//<<endl;
    printf("%.10f\n", ans);
    return 0;
}


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

int main() {
  int H, N;
  int sum = 0;
  cin >> H >> N;
  
  vector<int> vec(N);
  
  rep(i, N) {
    cin >> vec.at(i);
  }
  
  rep(i, N) {
    sum += vec.at(i);
  }
  
  if (H <= sum) {
   cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

struct node{
    int u,v;
}a[maxn];
ll ans[maxn];
ll num[maxn];
int pre[maxn];
int _find(int x){
    return x==pre[x]?x:pre[x]=_find(pre[x]);
}
int uni(int x,int y){
    int fax=_find(x);
    int fay=_find(y);
    if(fax!=fay){
        ll temp=num[fax];
        num[fax]+=num[fay];
        pre[fay]=fax;
        return temp*num[fay];
    }
    return 0;
}
int main(){
    int n,m,T;
    cin>>n>>m;
    ll sum=1ll*n*(n-1)/2;
    rep(i,1,n+1){
        pre[i]=i;
        num[i]=1;
    }
    rep(i,0,m){
        cin>>a[i].u>>a[i].v;
    }
    per(i,0,m){

        //cout<<"------------"<<temp<<" "<<i+1<<" "<<sum<<endl;
        ans[i+1]=sum;
        ll temp=uni(a[i].u,a[i].v);
        sum-=temp;
    }
    rep(i,1,m+1){
        cout<<ans[i]<<endl;
    }



    return 0;
}



Measured memory_bytes: 5120
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std ;

int n ;
int a[233333];

int main ()
{
	int i ;
	int res=0;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
	for ( i=1 ; i<=n ; i++ ) res+=a[i]-1;
	printf("%d",res);
	return 0 ;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> s1(n);
  rep(i, n) { s1[i] = s[i] - '0'; }

  vector<int> s2 = s1;
  int cnt1 = 0;
  int cnt2 = 0;
  rep(i, n - 1) {
    if (s1[i] == s1[i + 1]) {
      s1[i + 1] = 1 - s1[i + 1];
      cnt1++;
    }
    if (s2[n - i - 1] == s2[n - i - 2]) {
      s2[n - i - 2] = 1 - s2[n - i - 2];
      cnt2++;
    }
  }

  cout << min(cnt1, cnt2) << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else if ((a > b && b != 1) || a == 1) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

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

using namespace std;

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

	vector<int> l(n);
	int max = 0, p = -1;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		if (max < l[i]) {
			max = l[i];
			p = i;
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (i != p) {
			sum += l[i];
		}
	}

	if (sum > max) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

ll n,m,x,sum;

int main()
{
    cin >> n >> m;
    for (int i=0;i<m;i++)
    {
        cin >> x;
        sum+=x;
    }
    if (sum>n)cout << -1 << endl;
    else cout << n-sum << endl;
    return 0;
}


Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

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

use std::cmp::{max, min};
use std::collections::VecDeque;

fn bfs(map: &Vec<Vec<usize>>, status: &mut Vec<usize>) {
    let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    q.push_front((1, 0));

    while !q.is_empty() {
        let cn = q.pop_front().unwrap();
        // println!("cn:{:?}", cn);
        if status[cn.0] != 0 {
            continue;
        }
        status[cn.0] = cn.1;

        for i in 0..map[cn.0].len() {
            let mi = map[cn.0][i];
            if status[mi] != 0 {
                continue;
            }
            q.push_back((mi, cn.0));
        }
    }
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut map: Vec<Vec<usize>> = vec![vec![]; n + 1];

    for _ in 0..m {
        let a: usize = read();
        let b: usize = read();
        map[a].push(b);
        map[b].push(a);
    }
    let mut anss: Vec<usize> = vec![0; n + 1];
    bfs(&map, &mut anss);
    // println!("{:?}", anss);
    println!("Yes");
    for i in 2..n + 1 {
        println!("{}", anss[i]);
    }
}


Measured memory_bytes: 14884