akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    rep(i, N+1) { 
        cin >> A[i];
    }
    vector<ll> B(N);
    rep(i, N) { 
        cin >> B[i];
    }
    ll cnt = 0;
    ll rem = 0;
    rep(i, N) {
        if (A[i] < B[i] + rem) {
            cnt += A[i];
            rem = B[i] + rem - A[i];
            rem = min(rem, B[i]);
        } else {
            cnt += B[i] + rem;
            rem = 0;
        }
    }
    if (A[N] < rem) {
        cnt += A[N];
    } else {
        cnt += rem;
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 1792
#python3
from heapq import heappop, heappush

def main():
    n, m = map(int, input().split())
    hq = [] 
    for i in input().split():
        heappush(hq, (-int(i), 1))
    for _ in range(m):
        b, c = map(int, input().split())
        heappush(hq, (-c, b))
    ans = 0
    for i in range(n):
        v, u = heappop(hq)
        u = u - 1
        if u >= 1:
            heappush(hq, (v, u))
        v = - v 
        ans = ans + v
    print(ans)
main()


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string ans;
  for(int i=0; i<c-a; i++) ans+='R';
  for(int i=0; i<d-b; i++) ans+='U';
  for(int i=0; i<c-a; i++) ans+='L';
  for(int i=0; i<d-b; i++) ans+='D';
  ans+='D';
  for(int i=0; i<1+c-a; i++) ans+='R';
  for(int i=0; i<1+d-b; i++) ans+='U';
  ans+='L';
  ans+='U';
  for(int i=0; i<1+c-a; i++) ans+='L';
  for(int i=0; i<1+d-b; i++) ans+='D';
  ans+='R';
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#define LEN 100005

// using namespace std;

//問題に出てくるプロセスを表す構造体
typedef struct pp
{
    char name[100];
    int t;
} P;

/*
通常の構造体宣言は以下
struct pp {
    char name[100];
    int t;
};
このときは次のように宣言する
struct pp Q[LEN];
*/
/*
ここで
typedef struct pp{
    char name[100];
    int t;
}P;
のようにtypedefを使い、最後にPのように別名を設定することで
構造体の宣言を
P Q[LEN]
のように簡単にできる
*/

P Q[LEN];
int head, tail, n;

void initialize()
{
    head = 0;
    tail = 0;
}

bool isFull()
{
    return head == (tail + 1) % LEN;
}

void enqueue(P x)
{
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue()
{
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

//min関数実装
/*
a<b ? a:b;  ?は二項演算子という
a<b == Trueならa,Falseならbを返す
なお、if文とちがって値しか返せなかったような気がする
int min(int a,int b){return a<b ? a:b;}
minをわざわざ定義する必要もないと思うが、intだけなのももったいないので
defineで」書こうと思ったらコンパイル時にごたごたするのでdefineはやめろという記事があった
参考：https://blog.myon.info/entry/2015/12/18/avoid-defining-macros/
そこで関数templateというものがあったので使ってみる
参考：https://qiita.com/hal1437/items/b6deb22a88c76eeaf90c
templateはおまじないを唱えることで同じ処理ならオーバーロードが要らなくなるものらしい
*/
//なお、namespace stdをusingしていると案の定minが衝突するみたいなのでusingをはずしてある　
template <typename T>
T min(T a, T b)
{
    return a < b ? a : b;
}
//こうしてtemplateの呪文を置くことで、Tは任意の型を表す
//また次のようにすることで特定の型の処理のみを変えるテンプレートの特殊化が可能(らしいけど下記のものはエラーがでる)
// template <>
// void min(char a, char b)
// {
//     return ;
// }

int main()
{
    //総経過時間 elaps
    //1回ずつの処理時間 c
    int elaps = 0, c;
    int i, q;
    P u;
    //プロセス数n
    //最大処理量q
    scanf("%d %d", &n, &q);

    //すべてのプロセスをキューに順番に追加する
    for (i = 1; i <= n; i++)
    {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n + 1;

    while (head != tail)
    {
        u = dequeue();   //先頭のプロセスを持ってくる
        c = min(q, u.t); //処理時間決定,u.tがqより大きければqだけ処理
        u.t -= c;        //処理時間を減算
        elaps += c;      //経過時間加算
        if (u.t > 0)
            enqueue(u);
        else
        {
            printf("%s %d\n", u.name, elaps);
        }
    }

    return 0;
}



Measured memory_bytes: 13244
# https://atcoder.jp/contests/abc079/tasks/abc079_c
import random
import sys

str = input()


def retop():
    if(random.uniform(0, 1) > 0.5):
        return "+"
    return "-"


for i in range(100):
    formula = (str[0] + retop() + str[1] + retop() + str[2] + retop() + str[3])
    if eval(formula) == 7:
        print(formula + "=7")
        sys.exit()


Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <climits>
#include <cassert>
#include <iterator>

using namespace std;
using ll = long long;

int main(){
    int tests;
    // cin >> tests;
    tests = 1;
    while(tests--){
        string s;
        cin >> s;
        if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S'){
            cout << "0" << endl;
            continue;
        }
        if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
            cout << "3" << endl;
            continue;
        }
        if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')){
            cout << "2" << endl;
            continue;
        }
        cout << "1" << endl;
    }
    return 0;
}

Measured memory_bytes: 3036
// In the name of god
#include <bits/stdc++.h>
//#pragma GCC optimze("02")
using namespace std;
using ll=long long;
const ll maxn=2e5+5,inf=1e18+18;
long double a,b,h,m,a1,a2,x,y,z,mi=1,ans;
const long double pi = acos(-1.0);
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cout<<fixed<<setprecision(10);
	cin>>a>>b>>h>>m;
	mi/=2;
	a1=30*h+mi*m;
	a2=m*6;
	x=(a*a);
	y=(b*b);
	a1-=a2;
	z=2*b*a*(cos(a1*pi/180));
	ans=x+y-z;
	ans=sqrt(ans);
	cout<<ans;
}


Measured memory_bytes: 4184
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; ++i) {
			H[i] = sc.nextInt();
		}
		Arrays.sort(H);
		long ans = 1;
		int pos = 0;
		for (int i = 1;; ++i) {
			while (pos < N && H[pos] < i) {
				++pos;
			}
			if (pos == N) break;
			ans += Math.min(N - pos, 4 * i);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int x = sc.nextInt();
    int dis = 0;
    int ans = 1;

    while (sc.hasNext()) {
      dis += sc.nextInt();
      if (dis > x) {
        break;
      } else {
        ans++;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35920
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n, m, q = map(int, readline().split())

a = [0 for i in range(50)]
b = [0 for i in range(50)]
c = [0 for i in range(50)]
d = [0 for i in range(50)]

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, readline().split())


A = [0 for i in range(n)]
A[0] = 1

ans = 0
def dfs(length):
    if length == n:
        #process
        # print(A)
        total = 0
        global ans
        for i in range(q):
            if A[b[i] - 1] - A[a[i] - 1] == c[i]:
                total += d[i]
        ans = max(total, ans)
        return

    lastItem = A[length - 1]
    while lastItem <= m:
        A[length] = lastItem
        dfs(length + 1)
        lastItem += 1
dfs(1)
print(ans)

Measured memory_bytes: 27192
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int count = 0, x;

	while (1) {

		count++;
		cin >> x;
		if (x == 0)break;
		else printf("Case %d: %d\n", count, x);

	}

	return 0;
}

Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    public static void Main()
    {
        int N = NextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) A[i] = NextInt();
        List<int> B = A.ToList();
        B.Sort();
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            int index = BinarySearch(B, A[i]);
            if ((index + i) % 2 == 1) ans += 1;
        }
        Console.WriteLine(ans / 2);
    }

    public static int BinarySearch(List<int> list, int x)
    {
        int r = 0, l = list.Count() - 1;
        if (list.Last() == x) return l;
        while (l - r != 1)
        {
            int m = (r + l) / 2;
            if (list[m] <= x) { r = m; }
            else { l = m; }
        }
        return r;
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 16080
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}
//cout << fixed << setprecision(10);

int main(){
  ll n;
  double sum=0,cnt=0;
  cin>>n;
  vector<vector<double>>v(n,vector<double>(2,0));
  rep(i,n) cin>>v[i][0]>>v[i][1];
  rep(i,n-1){
    for(ll k=i+1;k<n;k++){
      sum+=sqrt(pow(v[i][0]-v[k][0],2)+pow(v[i][1]-v[k][1],2));
      cnt+=1.0;
    }
  }
  
  cout<< fixed << setprecision(8) << sum/cnt*(n-1) <<endl;
}

Measured memory_bytes: 256
from itertools import combinations
import copy

h, w, k = map(int,input().split())
c = [list(input()) for _ in range(h)]

black = 0
for i in range(h):
    black += c[i].count('#')

cc = copy.deepcopy(c)

ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        paint_h = [-1] * h
        paint_w = [-1] * w
        for s in range(h):
            if ((i >> s) & 1):
                paint_h[h - 1 - s] = 1
        for s in range(w):
            if ((j >> s) & 1):
                paint_w[w - 1 - s] = 1
        #print(paint_h,paint_w)

        painted = 0
        for s in range(h):
            if paint_h[s] == 1:
                for t in range(w):
                    if c[s][t] == '#':
                        c[s][t] = '.'
                        painted += 1
        for s in range(w):
            if paint_w[s] == 1:
                for t in range(h):
                    if c[t][s] == '#':
                        c[t][s] == '.'
                        painted += 1

        if black - painted == k:
            ans += 1

        c = copy.deepcopy(cc)

print(ans)

Measured memory_bytes: 9308
s=input()
n=len(s)
for j in range(n): 
    s=s[:-1]
    c=0
    if len(s)%2==0:
        for i in range(int(len(s)/2)):
            if s[i]==s[int(len(s)/2)+i]:
                c+=1
                continue
            else:
                break 
        if c==int(len(s)/2):
            print(len(s))
            break           


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cstdlib>

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


const long long INF = 1LL << 60;


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

    vector<long> dp(100010);
    vector<long> h(100010); //高さの保存

    for(int i = 0; i < N; i++) cin >> h.at(i);

    for(int i = 0; i < N; i++) dp.at(i) = INF;

    dp.at(0) = 0; // 初期化

    for(int i = 1; i < N; i++){
        chmax(dp.at(i),(dp.at(i-1) + abs(h.at(i) - h.at(i-1))));
        if(i > 1)  chmax(dp.at(i), dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
    }



    cout << dp.at(N-1) << endl;

    return 0;
}

Measured memory_bytes: 1792
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: Vec<usize> = (0..3).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    if a.iter().filter(|x| **x == 5).count() == 2
        && a.iter().filter(|x| **x == 7).count() == 1 {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}


Measured memory_bytes: 2076
ans = 0

N = int(input())

s = input()
t = input()

now = N
ans = 0

for i in range(N):
    #print (s[-1 * now:] , t[:now])
    if s[-1 * now:] == t[:now]:
    
        ans = max(ans,now)
    now -= 1

print (len(s) + len(t) - ans)


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

int main(void) {
	char a_aS[11];
	char a_aT[12];
	int iLen;
	int	j;
	//文字列を入力
	scanf("%s", a_aS);
	scanf("%s", a_aT);
	//文字列Sの長さを計る
	iLen = strlen(a_aS);
	//2つの文字列を比較する
	for (j = 0;j < iLen;j++) {
		if (a_aS[j] != a_aT[j]) {
			printf("No\n");
			break;
		}
		else {}
	}
	if (j == iLen) {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1588
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =1e5+5;
    
     int mod= 1e9+7,INF=1e17;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
     
   
     
     void solve(){
		 int n;
		 cin>>n;
		 
		 vi v(n,0);
		 
		 rep(i,0,n)
		  cin>>v[i];
		 
		 sort(all(v));
		 int maxi=0;
			
		 rep(i,0,n){
			 
			 if(i+1<sz(v) && v[i+1]!=v[i]){
				 if(i+1 == sz(v)-1-i)
				   maxi=max(maxi,v[i+1]-v[i]);			   
			 }
		 }
		 
		 
		 cout<<maxi<<endl; 
	   
       
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


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

using namespace std;

int get(int a, int k){
	while(a % k != 0){
		int c = a / k + 1;
		int l = a / k * k;
		a -= (a - l + c - 1) / c * c;
	}
	return a / k;
}

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

	int res = 0;

	for(int i=0; i<n; i++){
		int a, k;
		cin >> a >> k;

		int key = get(a,k);
		//cout << key << endl;
		res ^= key;
	}

	if(res == 0){
		cout << "Aoki" << endl;
	}else{
		cout << "Takahashi" << endl;
	}

	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<vi> adj(n);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vi dep(n,-1);
    queue<int> que;
    dep[0] = 0;
    que.push(0);
    while(que.size()){
        int v = que.front(); que.pop();
        for(auto u:adj[v]){
            if (dep[u]!=-1) continue;
            dep[u] = dep[v]+1;
            que.push(u);
        }
    }
    cout<<"Yes\n";
    vi ans(n);
    FOR(i,1,n-1){
        for(auto u:adj[i]){
            if (dep[u]==dep[i]-1){
                cout<<u+1<<"\n";
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 10684
#include<bits/stdc++.h>
using namespace std;
map<int, int> add;
void dfs(vector<vector<int>> &side, vector<int> &tree, int x, int v, int p, int z) {
  if(add.count(v)) x += add.at(v);
  tree.at(v) += x;
  for(int i = 0; i < side.at(v).size(); i++) {
    int u = side.at(v).at(i);
    if(u == p) continue;
    dfs(side, tree, x, u, v, z);
  }
}

int main() {
  int N, Q; cin >> N >> Q;
  vector<vector<int>> side(N, vector<int> (0));
  vector<int> tree(N, 0);
  for(int i = 0; i < N - 1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    side.at(a).push_back(b);
    side.at(b).push_back(a);
  }
  for(int i = 0; i < Q; i++) {
    int z, x; cin >> z >> x; z--;
    if(add.count(z)) add.at(z) += x;
    else add[z] = x;
  }
  dfs(side, tree, 0, 0, -1, 0);
  for(int i = 0; i < N; i++) {
    cout << tree.at(i) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 41984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
char s[105],t[105];
int main()
{
	scanf("%d\n%s%s",&n,s,t);
	for(int i=1;i<=n;++i)
		printf("%c%c",s[i-1],t[i-1]);
	return 0;
}

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

int main(){
    string s;
    int n;
    while(cin >>s && s != "-"){
        cin >>n;
        for(int i=0;i<n;i++){
            int a;
            cin >>a;
            string t = s.substr(0, a);
            s.erase(0, a);
            s+=t;
        }
        cout << s << endl;
    }
}


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

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i,N){
        cin >> X[i];
    }
    ll cost = 0;
    rep(i,N-1){
        ll dist = X[i+1]-X[i];
        cost += min(dist*A,B);
    }
    cout << cost << endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys

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

SC = []
for m in range(M):
    [s, c] = [int(i) for i in input().split()]
    SC.append((s, c))

ans_str = ['-1'] * N

for (s, c) in SC:
    if ans_str[s - 1] != '-1' and ans_str[s - 1] != str(c):
        print(-1)
        sys.exit()
    if s == 1 and c == 0 and N != 1:
        print(-1)
        sys.exit()
        
    ans_str[s - 1] = str(c)

if N == 1:
    if ans_str[0] == '-1':
        ans_str[0] = '0'
else:
    for i in range(len(ans_str)):
        if ans_str[i] == '-1':
            if i == 0:
                ans_str[i] = '1'
            else:
                ans_str[i] = '0'

ans = ''.join(ans_str)
print(int(ans))

Measured memory_bytes: 3064
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int k;
int w[N];
int v[N];
long long mem[111][N];

long long go(int idx , int lft){
        if(idx == n + 1)
            return 0;
        if(~mem[idx][lft])
            return mem[idx][lft];
        long long best = 0;
        best = max(best , go(idx + 1 , lft));
        if(lft >= w[idx])
            best = max(best , go(idx + 1 , lft - w[idx]) + v[idx]);
        return mem[idx][lft] = best;
}

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d%d" , &w[i] , &v[i]);
    }
    memset(mem , -1 , sizeof mem);
    printf("%lld\n" , go(1 , k));


}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
n, m, q = [int(item) for item in input().split(" ")]
# n, m, q = [int(item) for item in lines[0].split(" ")]

end = np.zeros((m,2),dtype=int)
query = np.zeros((q,2),dtype=int)
for i in range(m):
    end[i] = [int(item) for item in input().split(" ")]
#     end[i] = [int(item) for item in lines[1+i].split(" ")]

for i in range(q):
    query[i] = [int(item) for item in input().split(" ")]
#     query[i] = [int(item) for item in lines[1+m+i].split(" ")]

a = np.zeros((n,n), dtype=int)
np.add.at(a, [end[:,0]-1,end[:,1]-1], 1)
b = np.cumsum(a[::-1,:], axis=0)[::-1,:]
c = np.cumsum(b, axis=1)
for item in query:
    print(c[item[0]-1, item[1]-1])
    # print(np.sum(a[(item[0]-1):, :item[1]]))

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

fn main(){
    let mut array = [0; 3];
    for i in 0..3 {
        let a: u32 = read();
        array[i] = a;
    }
    array.sort();
    let mut ans = 0;
    ans += array[1] - array[0];
    ans += array[2] - array[1];
    println!("{}", ans);
}

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")
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
int x,i,j,k;
	char a[101],b[101],c[202];

	scanf("%s",a );
	scanf("%s",b );
	sprintf(c,"%s%s",a,a );

	if(strstr(c,b)!=NULL)printf("Yes\n" );
	else printf("No\n" );

	return 0;
}

Measured memory_bytes: 560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		a --;
		int b = 0;
		for(int i = 1; i < a + 1; i++){
			b += a / i;
		} 
		System.out.println(b);
		
		
	}
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int x,y,z,sv[200007];
long long ans,a[200007],b[200007],c[200007],pre[200007],suf[200007];
priority_queue < long long , vector <long long> , greater <long long> > pr;
int ss(int j,int k){
    return ((b[j]-a[j])>(b[k]-a[k]) || (b[j]-a[j]==b[k]-a[k] && j<k));
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>x>>y>>z;
	for(int i=1;i<=x+y+z;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]-=c[i];
        b[i]-=c[i];
        ans+=c[i];
        sv[i]=i;
	}
	sort(sv+1,sv+1+x+y+z,ss);
	for(int i=1;i<=y;i++){
        int id=sv[i];
        pr.push(b[id]);
        pre[y]+=b[id];
	}
	for(int i=y+1;i<=y+z+1;i++){
        int id=sv[i];
        long long val=pr.top();
        pre[i]=pre[i-1];
        if(b[id]>val){
            pr.pop();
            pr.push(b[id]);
            pre[i]+=b[id]-val;
        }
	}
	while(!pr.empty()) pr.pop();
	for(int i=x+y+z;i>=y+z+1;i--){
        int id=sv[i];
        pr.push(a[id]);
        suf[y+z+1]+=a[id];
	}
	for(int i=y+z;i>=y;i--){
        int id=sv[i];
        long long val=pr.top();
        suf[i]=suf[i+1];
        if(a[id]>val){
            pr.pop();
            pr.push(a[id]);
            suf[i]+=a[id]-val;
        }
	}
	long long ret=-1e14;
	for(int i=y;i<y+z+1;i++){
        ret=max(ret,pre[i]+suf[i+1]);
	}
	cout<<ret+ans;
}


Measured memory_bytes: 8184
#include <algorithm>
#include <cmath>
#include <cstdint>
#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))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll K;
    cin >> K;
    ll mod = 0;
    for(int i = 0; i < 10000000; i++) {
        mod *= 10;
        mod += 7;
        mod %= K;
        if(mod == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

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

using ll = long long;

//p[r] - p[l - 1] == r - l + 1 + k

//p[r] - r == p[l - 1] - l + 1

int main() {
    ios::sync_with_stdio(false);

    int n, k; cin >> n >> k;
    if(k == 1) {
        cout << "0\n";
        exit(0);
    }

    vector<ll> a;
    a.push_back(0);
    for(int i = 0; i<n; ++i) {
        ll x; cin >> x;
        a.push_back(x);
    }


    vector<ll> pref(n + 1);
    map<ll, int> occ;

    ll ans = 0;

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


    for(int i = 0; i <= n; i++) {

        occ[(pref[i] - i) % k]--;
        ans += occ[(pref[i] - i) % k];

        if(i + k <= n) occ[(pref[i + k] - i - k) % k]++;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 15856
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef unordered_map<long long,int> hashmap;

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


long long topos(int x, int y) {
    return (((long long) x ) << 32) + y;
}


int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    int W, H; cin >> H >> W;
    int N; cin >> N;

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

    hashmap postoind;

    vector<bool[3][3]> checked(N);

    REP(n,0,N) {
        int x,y; cin >> y >> x;
        x--;y--;
        pos[n] = {x,y};

        postoind.insert({topos(x,y),n});
        REP(x,0,3) {
            REP(y,0,3) {
                checked[n][x][y] = false;
            }
        }
    }

    vector<long long> nums(10,0);

    int ind[5][5];

    REP(n,0,N) {
        auto tpos = pos[n];

        REP(y,0,5) {
            REP(x,0,5) {
                auto elem = postoind.find(topos(tpos.first-2+x,tpos.second-2+y));
                if (elem == postoind.end()) {
                    ind[y][x] = -1;
                } else {
//                    cout << "found" << endl;
                    ind[y][x] = elem->second;
                }
            }
        }

        REP(sy,0,3) {
            REP(sx,0,3) {
                if (checked[n][sy][sx])
                    continue;
                if (pos[n].first - 2 + sx < 0 || pos[n].first + sx >= W || pos[n].second - 2 + sy < 0 || pos[n].second + sy >= H)
                    continue;

                int num = 0;
                REP(x,0,3) {
                    REP(y,0,3) {
                        if (ind[sy + y][sx + x] == -1)
                            continue;
//                        cout << "checking " << x << " " << y << endl;
                        checked[ind[sy + y][sx + x]][2-y][2-x] = true;
                        num++;
                    }
                }
                nums[num]++;

//                cout << "Checking: " << pos[n].first << " " << pos[n].second << ": " << sx << " " << sy << " (num " << num << ")" << endl;
            }
        }
    }

    nums[0] = (long long)(W - 2) * (H - 2);
    REP(i,1, 10) {
        nums[0] -= nums[i];
    }
    REP(i,0,10) {
        cout << nums[i] << endl;
    }
	return 0;
}


Measured memory_bytes: 6180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int T;
   cin >> T;
   for(int i = 0 ; i < T;i++){
      int N;
      cin >> N;
      long long ans=0;
      vector<pair<int,int>> Ls;
      vector<pair<int,int>> Rs;
      for(int i = 0 ; i < N ; i++){
         int K,L,R;
         cin >> K >> L >> R;
         if(L>R){
            Ls.push_back(make_pair(K,L-R));
            ans+=L;
         }
         if(R>=L){
            Rs.push_back(make_pair(N-K,R-L));
            ans+=R;
         }
      }
      sort(Ls.begin(),Ls.end());
      sort(Rs.begin(),Rs.end());
      int Lsize=Ls.size();
      priority_queue<int> Lq;
      int Rsize=Rs.size();
      priority_queue<int> Rq;
      int ind = 0;
      for(int i = 0 ; i <= N; i++){
         //cout << "l" << i << endl;
         while(ind<Lsize&&Ls[ind].first<=i){
            //cout << Ls[ind].second << endl;
            Lq.push(-Ls[ind].second);
            ind++;
         }  
         while(Lq.size()>i){
            int t = Lq.top();
            ans += t;
            Lq.pop();
         }
      }
      ind =0;
      for(int i = 0 ; i <= N; i++){
         //cout << "r"<<  i << endl;
         while(ind<Rsize&&Rs[ind].first<=i){
            //cout << Rs[ind].second << endl;
            Rq.push(-Rs[ind].second);
            ind++;
         }  
         while(Rq.size()>i){
            int t = Rq.top();
            ans += t;
            Rq.pop();
         }
      }

      cout << ans << endl;

   }

   return 0;
}


Measured memory_bytes: 6112
class Bus
    attr_accessor :start_time, :num, :max_num, :th_time
    def initialize max_num, th_time
        @max_num = max_num
        @th_time = th_time
        init_state
    end

    def init_state
        @num = 0
        @start_time = nil
    end

    def get_on(time)
        if @num == 0
            @start_time = time + @th_time
        end
        @num += 1
    end

    def leave?(time)
        (!@start_time.nil? && @start_time < time) || @num==@max_num
    end

    def leave
        init_state
    end

    def empty?
        @num==0
    end
end
N,c,k = gets.split.map(&:to_i)
T = []
N.times{T<<gets.to_i}
T.sort!
ans = 0
bus=Bus.new(c,k)
T.each do |t|
    if bus.leave?(t)
        bus.leave
        ans+=1
    end
    bus.get_on t
end
ans+=1 unless bus.empty?
puts ans

Measured memory_bytes: 16336
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200005;
int n,L,T,p=0,res[N];
int main(){
	cin >> n >> L >> T;
	for (int i=0,x,w;i<n;i++){
		cin >> x >> w;
		if (w==1)
			res[i]=(x+T)%L,p=(p+(T+x)/L%n+n)%n;
		else
			res[i]=((x-T)%L+L)%L,p=(p-(T+L-x-1)/L%n+n)%n;
	}
	sort(res,res+n);
	for (int i=0;i<n;i++,p=(p+1)%n)
		printf("%d\n",res[p]);
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int t[] = new int[10];
        t[0] = scan.nextInt();
        t[1] = scan.nextInt();
        t[2] = scan.nextInt();
        t[3] = scan.nextInt();
        t[4] = scan.nextInt();
        t[5] = scan.nextInt();
        t[6] = scan.nextInt();
        t[7] = scan.nextInt();
        t[8] = scan.nextInt();
        t[9] = scan.nextInt();

        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9 - i; j++) {
                if (t[j] < t[j + 1]) {
                    int temp = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < 3; i++) {
            System.out.println(t[i]);
        }
    }
}



Measured memory_bytes: 26136
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int MAX = 555555;
  vector<bool> is_prime(MAX, 1);
  is_prime[0] = 0, is_prime[1] = 0;
  for (int i = 2; i < MAX; ++i) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j < MAX; j += i) is_prime[j] = 0;
  }
  int n;
  cin >> n;
  int cnt = 0;

  for (int i = 0; i < 555555; i++) {
    if (is_prime[i]) {
      if (i % 5 == 1) {
        cout << i << " ";
        cnt++;
        if (cnt == n) break;
      }
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
function main (s) {
    s=s.split(" ");
	for(var i=0;i<3;i++)s[i]=parseInt(s[i]);
	var mx=Math.max(s[0],s[1],s[2]);
	var sum=s[0]+s[1]+s[2];
	console.log((mx*2==sum)?"Yes":"No");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define INF 1001001001
#define MAX 1e18

const int mod = 998244353;

int main() {
  int n, q;
  cin >> n >> q;
  ll ans = (ll)(n-2)*(n-2);
  vector<int> rm_row(n), rm_col(n);
  int rend = n-1, cend = n-1;
  rep(i,q) {
    int c, x;
    cin >> c >> x; x--;
    if (c == 1) {
      if (x>rend) {
        ans -= rm_row[x];
        rm_row[x] = 0;
      } else {
        ans -= cend-1;
        for (int j = x+1; j < rend; j++) {
          rm_row[j] = cend-1;
        }
        rend = x;
      }
    } else {
      if (x>cend) {
        ans -= rm_col[x];
        rm_col[x] = 0;
      } else {
        ans -= rend-1;
        for (int j = x+1; j < cend; j++) {
          rm_col[j] = rend-1;
        }
        cend = x;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
int f[101][11],p[101][12],flag=0,c[110];
int main()
{
    int n,i,j,k,v,sum;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<10;j++){
            scanf("%d",&f[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<11;j++){
            scanf("%d",&p[i][j]);
        }
    }
    for(i=1;i<1024;i++){
        int x=i;
        memset(c,0,sizeof c);
        for(k=0;k<10;k++){
            for(j=0;j<n;j++){
                if(f[j][k]){
                    if((x>>k)&1)
                        c[j]++;
                }
            }
        }
        sum=0;
        for(j=0;j<n;j++){
            sum+=p[j][c[j]];
        }
        if(!flag){
            flag=1;
            v=sum;
        }
        if(sum>v)v=sum;

    }
    printf("%d\n",v);

}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  char b;
  scanf("%s",&b);
  if(b=='A'){
    printf("T");
  }else if(b=='T'){
      printf("A");
  }else if(b=='G'){
      printf("C");
  }else if(b=='C'){
       printf("G");
     }
      return 0;
    }

Measured memory_bytes: 128
n=int(input())
s=sorted([''.join(sorted(input())) for i in range(n)])

c=[]
i=0
while i<n-1:
  cnt=0
  while i<n-1 and s[i]==s[i+1]:
    cnt+=1
    i+=1
  c+=[cnt+1]
  i+=1
ans=0
for i in c:
  if i>1:
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 11408
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    T = list(input())
    ans = 0
    if S[0]==T[0]:
        ans+=1
    if S[1]==T[1]:
        ans+=1
    if S[2]==T[2]:
        ans+=1
    print(ans)

if __name__ == '__main__':
    main()

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

def gcd_(a, b):
    if a < b:    a, b = b, a
    if b == 0:    return a
    return gcd_(b, a % b)

left = [0 for _ in range(N + 1)]
right = [0 for _ in range(N + 1)]

for i in range(1, N + 1):
    left[i] = gcd_(left[i - 1], A[i - 1])
for i in reversed(range(N)):
    right[i] = gcd_(right[i + 1], A[i])

ans = -1
for i in range(N):
    ans = max(gcd_(left[i], right[i + 1]), ans)
print(ans)

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, k;
  std::cin >> n >> k;

  std::cout << (((n + 1) / 2 >= k) ? "YES" : "NO") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n); ++i)
int main() {
    int N;
    cin >> N;
    double v;
    rep(i,N) {
        int a;
        cin >> a;
        v+=1.0/a;//1.0とすることでdouble型で演算
    }
    double ans = 1/v;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a[10005];
ll dp[20005]={0};
int main()
{
    for(int i=0;i<20003;i++){
        dp[i]=999999999;
    }
    dp[0]=0;
    int h,n;
    cin >> h >> n;
    for(int i=0;i<n;i++){
        int num1,num2;
        cin >> num1 >> num2;
        for(int i=1;i<2*h;i++){
            dp[i]=min(dp[max(0,i-num1)]+num2,dp[i]);
        }
    }
    cout << dp[h] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			1000000007

#define MAX 		200005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int dp[MAX];

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

	REP(i,N){
		int tmp;
		cin>>tmp;
		//cout << endl << dp[tmp-1];
		dp[tmp] = dp[tmp-1]+1;
	}
	//cout << endl;
	int ans = 1;
	REPS(i,1,N+1)ans = max(ans,dp[i]);
	cout << (N - ans) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323

map<ll,ll>modcnt;

void solve()
{
       ll n,m;
       cin>>n>>m;
       ll a[n];
       ll sum=0, ans=0;
       modcnt[0]=1;
       for(ll i=0; i<n; i++) cin>>a[i];
       for(ll i=0; i<n; i++)
       {
              sum+=a[i];
              ll k = sum % m;
              ans += modcnt[k];
              modcnt[k]++;
       }
       cout<<ans;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int L[n];
  int sum=0;
  for(int i=0; i<n; i++){
    cin>>L[i];
    sum+=L[i];
  }
  sort(L,L+n);
  if(L[n-1]<sum-L[n-1])cout<<"Yes";
  else cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  string S;cin>>S;
  int ans=1;
  string prev=S.substr(0,1);
  REP(i,1,S.size()){
    if(i==S.size()-1){
      if(prev==S.substr(i,1)){
        br;
      }
    }
    if(S.substr(i,1)==prev){
      prev=S.substr(i,2);
      i++;
    }
    else{
      prev=S.substr(i,1);
    }
    //print(prev);
    ans++;
  }
  print(ans);



}


Measured memory_bytes: 720
N = int(input())
ans_list = [0] * (N+1)
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c
for i in range(N):
    if i == 0:
        continue
    else:
        if i %popcnt(i) == 0 :
            ans_list[i] = 1
        else:
            ans_list[i] = ans_list[i%popcnt(i)] + 1
S = input()
count = 0
for i in range(N):
    if S[i] == "1":
        count += 1
if count == 1:
    high_total = 0
    low_total = 0
    for i in range(N):
        if S[i] == "1":
            high_total += pow(2,N-1-i,count+1)
            high_total %= (count+1)
    for i in range(N):
        if S[i] == "1":
            print(0)
        if S[i] == "0":
            total = (high_total + pow(2,N-1-i,count+1)) % (count+1)
            print(ans_list[total]+1)
else:
    high_total = 0
    low_total = 0
    for i in range(N):
        if S[i] == "1":
            high_total += pow(2,N-1-i,count+1)
            high_total %= (count+1)
            low_total +=  pow(2,N-1-i,count-1)
            low_total %= (count-1)
    for i in range(N):
        if S[i] == "1":
            total = (low_total - pow(2,N-1-i,count-1)) % (count-1)
            print(ans_list[total]+1)
        if S[i] == "0":
            total = (high_total + pow(2,N-1-i,count+1)) % (count+1)
            print(ans_list[total]+1)


Measured memory_bytes: 76276
#include<iostream>
#include<string>
using namespace std;
#define int long long
int a,b,c,k,sum=0;

signed main(){
	cin>>a>>b>>c>>k;
	if(a>k){cout<<k<<endl;return 0;
	}sum=a;k-=a;
	if(b>k){cout<<sum<<endl;return 0;
	} k-=b;
	cout<<sum-k<<endl;
	
	}

Measured memory_bytes: 3640