akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n; cin>>n;
	//cout<<(n%1000==0 ? "0\n" : 1000-(n%1000));<<endl;
	
	if(n%1000==0) cout<<"0\n";
	else cout<<1000-(n%1000)<<endl;	
	
	return 0;
}


Measured memory_bytes: 3600
import itertools
INF=10**30
N,M,R=map(int,input().split())
r=list(map(lambda x:int(x)-1,input().split()))

dist=[[INF]*N for i in range(N)]
for i in range(M):
    A,B,C=map(int,input().split())
    A,B=A-1,B-1
    dist[A][B]=C
    dist[B][A]=C
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
ans=INF
for x in itertools.permutations(r):
    res=0
    for i in range(len(x)-1):
        res+=dist[x[i]][x[i+1]]
    ans=min(ans,res)
print(ans)

Measured memory_bytes: 65368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

bool print = false;

int main(){
    ll n,k; cin >> n >> k;
    VL p(3); cin >> p[0] >> p[1] >> p[2];
    string t; cin >> t;

    VVL mod(k);
    rep(i,n){
        ll m = i%k;
        if(t[i]=='r') mod[m].push_back(2);
        else if(t[i]=='s') mod[m].push_back(0);
        else if(t[i]=='p') mod[m].push_back(1);
    }

    if(print){
        rep(m,k){
            for(auto x: mod[m]){
                cout << x << " ";
            }
            cout << endl;
        }
    }

    ll ans = 0;
    rep(m,k){
        ll bef = -1;
        for(auto x : mod[m]){
            if(x==bef){
                bef = -1;
                continue;
            }
            ans += p[x];
            bef = x;
        }
    }

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

Measured memory_bytes: 5120
import sys
input = sys.stdin.readline
import math
def print_ans(input_line):
    """Test Case
    >>> print_ans("4 10")
    3
    >>> print_ans("8 9")
    2
    >>> print_ans("8 8")
    1
    """
    A, B = map(int,input_line.split())
    print(math.ceil((B-1)/(A-1)))

if __name__ == '__main__':
    s = input().rstrip()
    print_ans(s)

Measured memory_bytes: 3060
from sys import stdin

N = int(stdin.readline().rstrip())
S = [stdin.readline().rstrip() for _ in range(N)]
count = {}

for s in S:
    s = ''.join(sorted(s))
    if s not in count:
        count[s] = 1
    else:
        count[s] += 1

ans = 0
for c in count:
    if count[c] > 1:
        ans += count[c] * (count[c] - 1) // 2

print(ans)


Measured memory_bytes: 66012
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();


    if(N % 2 == 0)
        System.out.println(N);
    else
        System.out.println(N * 2);

    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      Int res = sqrt(n) + 1e-10;
      printf("%ld\n", res * res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i,j,k,l,c,n;
  while(scanf("%d", &n) != EOF) {
    c = 0;
  for(i = 0; i <= 9; i++) 
  for(j = 0; j <= 9; j++) 
  for(k = 0; k <= 9; k++) 
  for(l = 0; l <= 9; l++) 
    if(i+j+k+l == n) c++;
  printf("%d\n", c);
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int N=0,a=0,b=0,sum1=2;
	while(1)
	{
		scanf("%d",&N);
		if(N==0){break;}
		a=0;sum1=1;
		
		for(int i=0;i<N;i++)
		{
			scanf("%d",&b);
			if(b==0){}
			else{sum1++;}
			if(b>=2&&a!=1){a=1;}
		}
		if(a!=1){printf("NA\n");}
		else{printf("%d\n",sum1);}
	}
	return 0;
}


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

int main(){
    int N;
    int total=0;
    cin >> N;
    rep(i,N){
        int a,b;
        cin >> a >>b;
        total+=b-a+1;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
vector<ll> v;
queue<ll> que;
void bfs()
{
	while(que.size())
	{
		ll p = que.front();
		que.pop();
		v.pb(p);
		if(p*10>3234566667) continue;
		int x = p%10;
		if(x==0)
		{
			que.push(p*10);
			que.push(p*10+1);
		}
		else if(x==9)
		{
			que.push(p*10+9);
			que.push(p*10+8);
		}
		else
		{
			que.push(p*10+x-1);
			que.push(p*10+x);
			que.push(p*10+x+1);
		}
	}
}
inline void solve()
{

	for(int i=1; i<10; i++) que.push(i);
	bfs();
	sort(v.begin(),v.end());
	int k;
	cin>>k;
	cout<<v[k-1]<<endl;
}
int main()
{
	IOS();
	solve();
	return 0;
}




Measured memory_bytes: 2416
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    int jump;
    cin >> num >> jump;
    vector<int> v;
    int tmp;
    for(int i=0;i<num;i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    for(int i=0;i<=jump+10;i++){
        v.push_back(1000000);
    }
    array<int,110000> ans;
    for(int i=0;i<100010;i++){
        ans[i]=-1;
    }
    ans[0]=0;
    for(int i=0;i<num-1;i++){
        for(int j=1;j<=jump;j++){
            if(ans[i+j]==-1){
                ans[i+j]=ans[i]+abs(v[i+j]-v[i]);
            }else{
                ans[i+j]=min(ans[i+j],ans[i]+abs(v[i+j]-v[i]));
            }
        }
    }
    cout << ans[num-1] << endl;
    return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  string S; cin >> S;
  int N = S.size() + 1;
  vector<int> a(N, 0);
  for(int i = 0; i < N-1; i++) {
    if(S[i] == '<') {
      a[i+1] = max(a[i+1], a[i] + 1);
    }
  }
  for(int i = N-2; i >= 0; i--) {
    if(S[i] == '>') {
      a[i] = max(a[i], a[i+1] + 1);
    }
  }
  ll sum = 0;
  for(int i = 0; i < N; i++) {
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2820
N, K = map(int, input().split())
v = list(map(int, input().split()))

nk = min(N, K)

ans = -1
for a in range(nk+1):
    for b in range(nk+1-a):
        have = v[:a] + v[N-b:]
        have = sorted(have)
        i = 0
        while i < K - a - b and i < a + b:
            if have[i] < 0:
                have[i] = 0
            else:
                break
            i += 1
        ans = max(ans, sum(have))

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int a,b,c;
	string s="No";
	cin >> a >> b >> c;
	if(a+b==c)s="Yes";
	if(a+c==b)s="Yes";
	if(b+c==a)s="Yes";
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>




int t, n, m, k, a[300010], q, l;



int32_t main(){
INIT
cin>>n;

if(n%10==0   || n%10==1 || n%10==8 || n%10==6){
    cout<<"pon"; return 0;
}

if(n%10==3){cout<<"bon"; return 0;}

cout<<"hon";

return 0;
}


Measured memory_bytes: 3652
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime


Q = iin()
lr = [iln() for _ in range(Q)]

max_num = 10**5
c = [0 for _ in range(max_num+1)]

is_primes = sieves_of_e(max_num)

for i in range(1, max_num):
    c[i+1] = c[i]
    if is_primes[i] and is_primes[(i+1)//2]: c[i+1] += 1

for i in range(Q):
    left = lr[i][0]
    right = lr[i][1]
    print(c[right+1]-c[left])




Measured memory_bytes: 32140
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5,mod=100000007,mod2=998244353,MAXN=100000+29;
void files(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int dist(ii a,ii b){
    return abs(a.first-b.first)+abs(a.second-b.second);
}
bool cmp(ii a,ii b){
    int d1 = abs(a.first)+abs(a.second);
    int d2 = abs(b.first)+abs(b.second);
    return d1<d2;
}
bool cmp2(ii a,ii b){
    int d1 = abs(a.first)-abs(a.second);
    int d2 = abs(b.first)-abs(b.second);
    return d1<d2;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    files();
    int n;
    cin >> n;
    vii v(n);
    Forr(i, v)cin >> i.first >> i.second;
    sort(all(v),cmp);
    int ans=dist(v.front(),v.back());
    sort(all(v),cmp2);
    ans=max(ans,dist(v.front(),v.back()));
    
    cout<<ans;

}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
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 a;
    cin >>a ;
    cout << a+a*a+a*a*a <<endl;
    return 0;
}

Measured memory_bytes: 3632
target = input()
num_operations = int(input())

for _ in range(num_operations):
    operation = input().split()
    operation_name = operation[0]
    frm, to = map(int, operation[1:3])
    if operation_name == 'replace':
        new = operation[3]
    
    if operation_name == 'print':
        print(target[frm:to+1])
    elif operation_name == 'reverse':
        reverse_target = target[frm:to+1]
        target = target[:frm] + reverse_target[::-1] + target[to+1:]
    elif operation_name == 'replace':
        target = target[:frm] + new + target[to+1:]
    else :
        raise Exception


Measured memory_bytes: 5616
package main

import "fmt"

func main() {
	var c [4][4]int
	for i := 1; i < 4; i++ {
		for j := 1; j < 4; j++ {
			fmt.Scan(&c[i][j])
		}
	}
	if (c[1][1]-c[2][1] == c[1][2]-c[2][2]) && (c[1][2]-c[2][2] == c[1][3]-c[2][3]) &&
		(c[2][1]-c[3][1] == c[2][2]-c[3][2]) && (c[2][2]-c[3][2] == c[2][3]-c[3][3]) &&
		(c[3][1]-c[1][1] == c[3][2]-c[1][2]) && (c[3][2]-c[1][2] == c[3][3]-c[1][3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);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 YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main(){
	int N;
	cin >> N;
	vi2 A(2,vi(N));
	REP(i,N) cin >> A[0][i];
	REP(i,N) cin >> A[1][i];

	int ans = -1;
	
	REP(i,N){
		int sum = 0;
		for(int j=0; j<=i; j++) sum += A[0][j];
		for(int j=i; j<=N-1; j++) sum += A[1][j];
		ans = max(ans,sum);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    alphabet = ["A", "B", "C", "D", "E", "F","G",
                "H", "I", "J", "K", "L", "M", "N",
                "O", "P", "Q", "R", "S", "T", "U",
                "V", "W", "X", "Y", "Z"]
    res = ""
    for i in s:
        idx = alphabet.index(i)
        target_idx = idx + n
        if target_idx > 25:
            target_idx -= 26
        res += alphabet[target_idx]
    print(res)
if __name__ == "__main__":
    main()

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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (long long i = 0;i < N;i++){
        cin >> A.at(i);
    }

    vector<long long> step(N);
    long long loop_s = 1, loop_e = 1;
    {
        long long i = 0;
        for (long long a = 1;; i++){
            if(step.at(a - 1) == 0){
                step.at(a - 1) = i;
            }else{
                break;
            }
            loop_e = a;
            a = A.at(a - 1);
            loop_s = a;
        }
    }

    long long ans = 1;
    if(K <= step.at(loop_s - 1)){
        long long i = 0;
        for (long long a = 1;i < K;i++){
            a = A.at(a - 1);
            ans = a;
        }
        cout << ans << endl;
        return 0;
    }
    K -= step.at(loop_s - 1);
    long long len = step.at(loop_e - 1) - step.at(loop_s - 1);
    K = K % (len + 1);
    ans = loop_s;
    {
        long long i = 0;
        for (long long a = loop_s;i < K;i++){
            a = A.at(a - 1);
            ans = a;
        }
    }

    cout << ans << endl;
}



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

using namespace std;

int N, A[100000];

bool check(int A_0)
{
  int kind1 = 0;
  for(int i = 0; i < N; i++) {
    if(A[i] == A_0) ++kind1;
  }
  int kind2 = N - kind1;
  if(A_0 < kind1 - 1 + (kind2 != 0)) return (false);
  int sz = A_0 + 1 - kind1;
  while(sz > 0 && kind2 > 1) {
    sz--;
    kind2 -= 2;
  }
  if(sz == 0) return (true);
  return (false);
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  if(abs(A[0] - A[N - 1]) >= 2) cout << "No" << endl;
  else if(check(A[0])) cout << "Yes" << endl;
  else if(count(A, A + N, A[0]) == N && check(A[0] - 1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string.h>
using namespace std;

int main(){
    
    char c;
    cin>>c;
    
    if(c=='A'){
        cout<<'T'<<endl;
    }else if(c=='T'){
        cout<<'A'<<endl;
    }else if(c=='C'){
        cout<<'G'<<endl;
    }else if(c=='G'){
        cout<<'C'<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
      solve();
    }
}

// debuged, long long
void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> b(n);
  rep(i, n) cin >> b[i];

  ll sum = 0;
  rep(i, n) { // bi を ai にするための回数
    if (a[i] > b[i]) sum += a[i] - b[i];
  }

  // sum 分 ai に 2 を足す
  rep(i, n) {
    if (b[i] > a[i]) { // debuged
      ll tmp = min((b[i] - a[i]) / 2, sum);
      sum -= tmp;
      a[i] += tmp;
    }
  }

  if (sum > 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  // 残りは bi >= ai
  // 1 ずつ小さくできる
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <map>
#include <deque>
#include <queue>
#include <set>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n<=999) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl; 
	return 0;
}


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

using namespace std;

int sumList(vector<int> nums) {
    int amount = 0;
    for (int i : nums) {
        amount += i;
    }
    return amount;
}

int main() {
    int p;
    int n, l;
    cin >> n >> l;
    vector<int> apples(n);
    for (int i = 0; i < n; ++i) {
        apples.at(i) += l + i;
    }
    int absMin = 1001001001;
    for (int j : apples) {
        if (absMin > abs(j)) {
            absMin = abs(j);
            p = j;
        }
    }

    cout << sumList(apples) - p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pii pair<ll, ll> 
#define pb push_back
#define mod (1e9+7)
#define debug(x) cerr<< #x << " is " <<x<<endl;
#define debug2(x) cerr<<#x<< " is\n"; for (auto &i:x) {cout<<i<<' '; } cout<<endl;
#define f first
#define s second
using namespace std;

const int inf = 1e9+5;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    for (int i=0; i<n; i++){
    	cin>>a[i];
    }
    vector<int> dp(n+2,inf);
    dp[0]=0;
    for (int i=0; i<n; i++){
    	for (int j: {i+1, i+2}){
    		dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
    	}
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
t1, s1 = 0, 0
for i, x in enumerate(a):
    s1 += x
    if i % 2 == 0:
        if s1 < 1:
            t1 += (1-s1)
            s1 = 1
    else:
        if s1 > -1:
            t1 += (s1+1)
            s1 = -1
t2, s2 = 0, 0
for i, x in enumerate(a):
    s2 += x
    if i % 2 == 0:
        if s2 > -1:
            t2 += (s2+1)
            s2 = -1
    else:
        if s2 < 1:
            t2 += (1-s2)
            s2 = 1
print(min(t1, t2))

Measured memory_bytes: 14332
list_NK = list(map(int, input().split())) 
N = list_NK[0]
K = list_NK[1]

number = N - K*(N//K)
abs_now  = number 
while all:
    abs_past = abs(abs_now - K)
    if(abs_past >= abs_now):
        break
    abs_now = abs_past
print(abs_now)

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<ll> l(n);
	for (auto &v : l) {
		cin >> v;
	}
	sort(begin(l), end(l));

	ll ans = 0;
	for (int a = 0; a < n; a++) {
		for (int b = a + 1; b < n; b++) {
			int r = lower_bound(begin(l), end(l), l[a] + l[b]) - begin(l);
			int s = b + 1;
			ans += r - s;
		}
	}

	// 0 1 2 3
	// b s g r
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n, i;
    cin >> n;
    int a[n];
    double k = 0, d;
    for(i = 0; i < n; i++){
        cin >> d;
        k += 1 / d;
    }
    printf("%.8f\n", 1 / k);

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque

def dfs(v, p):
    global pos
    
    seen[v] = True
    hist.append(v)

    for nv in adj_list[v]:
        if nv==p:
            continue
        
        if seen[nv]:
            pos = nv
            return
        
        dfs(nv, v)
        
        if pos!=-1:
            return
    
    hist.pop()

N = int(input())
adj_list = [[] for _ in range(N)]

for _ in range(N):
    ui, vi = map(int, input().split())
    adj_list[ui-1].append(vi-1)
    adj_list[vi-1].append(ui-1)

seen = [False]*N
hist = deque([])
pos = -1
dfs(0, -1)
cycle = set()

while hist:
    t = hist.pop()
    cycle.add(t)
    
    if t==pos:
        break

Q = int(input())

for _ in range(Q):
    ai, bi = map(int, input().split())
    
    if ai-1 in cycle and bi-1 in cycle:
        print(2)
    else:
        print(1)


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

main()
{
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    long long i,j,k,l,m,n,o,p;
 string s;
 while(cin>>n){
    int x[n];
    map<long long,long long>mp;

    for(i=0;i<n;i++){
        cin>>x[i];

    }
    sort(x,x+n);
   long long a=0,b=0;
   for(i=n-1;i>0;i--){
    if(x[i]==x[i-1]){
        if(a==0)a=x[i];
        else if(b==0)b=x[i];
        else break;
        i--;
    }
   }
   cout<<a*b<<endl;
 }
    return 0;

}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int main(){
  int x;cin >> x;
  int ans = 1;
  for(int b=1;b<=x;b++){
    for(int p=2;p<=x;p++){
      int k = pow(b,p);
      if(k<=x){
        ans = max(ans,k);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int k;
    cin >> n >> k;
    vector<double> p(n);
    vector<double> s(n); //s.at(i)がa.at(0)からa.at(i)までの和
    double ans=0;
    for(int i=0;i<n;i++){
        cin >> p.at(i);
        p.at(i) = (p.at(i)+1)/2; 
        //cout << p.at(i) << endl;
    }
    s.at(0) = p.at(0);
    for(int i=1;i<n;i++){
        s.at(i) = s.at(i-1) + p.at(i);
        //cout <<"s.at("<<i<<")="<<s.at(i)<<endl;
    }
    for(int i=0;i<n-k+1;i++){
        if(i==0){
            double t = s.at(k-1);
            ans = t;
        }else{
            double t = s.at(i+k-1)-s.at(i-1);
            if(t>ans){
                ans = t;
            }
        }
        
    }
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
#define OUT(x) cout << x << endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//エラトステネスの篩
//n以下の素数を列挙
#define MAX_N 100010
int prime[MAX_N];//i番目の素数
bool is_prime[MAX_N + 1];//is_prime[i]がtrueならiは素数
vector<int> c(100010);
//n以下の素数の数を返す
void sieve(int n){
    int p=0;
    for(int i=0; i<=n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j= 2*i; j<= n; j+=i) is_prime[j] = false;
        }
    }
}

int main(){
  int n;
  cin >> n;
  sieve(100000);
  for(int i=3;i<=100000;i++){
    if(is_prime[i] && is_prime[(i+1)/2]) c[i]++;
  }
  for(int i=3;i<=100000;i++) c[i] += c[i-1];
  REP(i,n){
    int l,r;
    cin >> l >> r;
    cout << c[r] - c[l-1] << endl;
  }
}

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

int count753(vector<int> &usenum, int n, int cur){
    int ans = 0;

    if(cur <= n){
        if(usenum[3] >= 1 && usenum[5] >= 1 && usenum[7] >= 1){
            ans++;
        }
    }

    int cketa = 0;
    {
        int cur1 = cur;
        while(cur1 > 0){
            cur1 /= 10;
            cketa++;
        }
    }

    int nketa = 0;
    {
        int n1 = n;
        while(n1 > 0){
            n1 /= 10;
            nketa++;
        }
    }

    switch(nketa-cketa){
        case 1:
        if(cur*10+3 <= n && usenum[5] >= 1 && usenum[7] >= 1){
            ans++;
        }

        if(cur*10+5 <= n && usenum[3] >= 1 && usenum[7] >= 1){
            ans++;
        }

        if(cur*10+7 <= n && usenum[5] >= 1 && usenum[3] >= 1){
            ans++;
        }
        break;

        case 2:
        if(usenum[5] >= 1 || usenum[7] >= 1){
            usenum[3]++;
            ans += count753(usenum, n, cur*10+3);
            usenum[3]--;
        }

        if(usenum[3] >= 1 || usenum[7] >= 1){
            usenum[5]++;
            ans += count753(usenum, n, cur*10+5);
            usenum[5]--;
        }

        if(usenum[5] >= 1 || usenum[3] >= 1){
            usenum[7]++;
            ans += count753(usenum, n, cur*10+7);
            usenum[7]--;
        }
        break;

        default:
        usenum[3]++;
        ans += count753(usenum, n, cur*10+3);
        usenum[3]--;
        usenum[5]++;
        ans += count753(usenum, n, cur*10+5);
        usenum[5]--;
        usenum[7]++;
        ans += count753(usenum, n, cur*10+7);
        usenum[7]--;
    }
    return ans;
}

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

    vector<int> usenum(10, 0);
    cout << count753(usenum, n, 0) << endl;
    return 0;
}

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

int main() {
  long n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  long a1 = (n + (a - 1)) / a;
  long b1 = (n + (b - 1)) / b;
  long c1 = (n + (c - 1)) / c;
  long d1 = (n + (d - 1)) / d;
  long e1 = (n + (e - 1)) / e;
  
  long min = a1;
  if (b1 + 1 <= min) min += 1;
  else min = b1+1;
  if (c1 + 2 <= min) min += 1;
  else min = c1+2;
  if (d1 + 3 <= min) min += 1;
  else min = d1+3;
  if (e1 + 4 <= min) min += 1;
  else min = e1+4;

  cout << min << endl;
  
}

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

int main(){
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool trig=true;
  for(int i=0; i<a; i++)if(s[i]<'0'||'9'<s[i])trig=false;
  if(s[a]!='-')trig=false;
  for(int i=a+1; i<a+b+1; i++)if(s[i]<'0'||'9'<s[i])trig=false;
  cout << (trig ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))

lmax = max(L)
maxidx = L.index(lmax)

suml = 0
for i in range(N):
    if i != maxidx:
        suml += L[i]
        
if lmax < suml:
    print('Yes')
else :
    print('No')       
    

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }


int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        cout<<"x";
    }
    cout<<endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    q=II()
    aa=deque(ord(c) for c in s)
    rev=0
    for _ in range(q):
        t=SI().split()
        if t[0]=="1":rev=1-rev
        else:
            f=int(t[1])-1
            if f^rev:aa.append(ord(t[2]))
            else:aa.appendleft(ord(t[2]))
    if rev:aa.reverse()
    print("".join(chr(a) for a in aa))

main()

Measured memory_bytes: 8684
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int i,j,N,K,tmp1,ans[100]={0};
  scanf("%d %d",&N,&K);
  int *d=(int*)malloc(sizeof(int)*K);
  int **A=(int**)malloc(sizeof(int*)*K);
  for(i=0;i<K;i++)
    A[i]=(int*)malloc(sizeof(int)*N);
  
  
  for(i=0;i<K;i++){
    scanf("%d",&d[i]);
    for(j=0;j<d[i];j++){
      scanf("%d",&tmp1);
      tmp1--;
      A[i][tmp1]=1;
    }
  }
  int cat=0;
  for(i=0;i<K;i++){
    for(j=0;j<N;j++){
      if(1==A[i][j]){
	ans[j]=1;
      }
    }
  }
  for(i=0;i<N;i++){
    if(0==ans[i])
      cat++;
  }
  printf("%d",cat);
  return 0;
}

Measured memory_bytes: 1772
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl
 
using namespace std;
 
typedef long long ll;
 
template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }
 
const int INF = 0x3f3f3f3f;
const int N = 2e3 + 10;
 
char str[N];
int Pos[N][N],Map[N][N],L[N],R[N];
 
inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}
 
struct node {
	int x,y;
} sta[N];
 
int main() {
	int n = read(),m = read();
	if(n < m) {
    	For(i,1,n) {
    		scanf("%s",str + 1);
    		For(j,1,m) Map[i][j] = (str[j] == '#');
    	}
	}
	else {
	    swap(n,m);
    	For(i,1,m) {
    		scanf("%s",str + 1);
    		For(j,1,n) Map[j][i] = (str[j] == '#');
    	}
	}
	For(i,1,n - 1) For(j,1,m - 1) {
		if(Map[i][j] ^ Map[i][j + 1] ^ Map[i + 1][j] ^ Map[i + 1][j + 1]) Pos[i][j] = i;
		else Pos[i][j] = Pos[i - 1][j];
	}
	int ans = 0;
	For(i,1,n - 1) {
		int top = 0;
		sta[top] = (node){0,0};
		For(j,1,m - 1) {
			while(top && sta[top].y >= i - Pos[i][j]) top--;
			L[j] = j - sta[top].x;
			sta[++top] = (node){j,i - Pos[i][j]};
		}
		top = 0;
		sta[top] = (node){m,0};
		Fordown(j,m - 1,1) {
			while(top && sta[top].y >= i - Pos[i][j]) top--;
			R[j] = sta[top].x - j;
			sta[++top] = (node){j,i - Pos[i][j]};
		}
		For(j,1,m - 1) chkmax(ans,(i - Pos[i][j] + 1) * (L[j] + R[j]));
	}
 
	printf("%d\n",ans);
 
	return 0;
}

Measured memory_bytes: 31744
package main
 
import (
  "fmt"
  "strconv"
)
 
func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := "Heisei"
  month, _ := strconv.Atoi(s[5:7])
  if month > 4 {
    ans = "TBD"
  }
  fmt.Printf("%s\n", ans)
}

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

using namespace std;


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

  vector<int> L;

  for(int i = 0; i < N; i++){
    int l;
    cin >> l;

    L.push_back(l);
  }

  int D = 0;

  int bound = 1;

  for(int i = 0; i < N; i++){
    D += L[i];

    if(D <= X) bound++;
    else break;
  }

  cout << bound << endl;

  return 0;
}


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

typedef long long ll;
#define mod 1000000007

int main()
{
    vector<ll> v(4);

    for(ll i = 0; i < 4; i++)
        cin >> v[i];
    
    ll ans = 0;

    ans = max({v[0]*v[2], v[0]*v[3], v[1]*v[2], v[1]*v[3]});

    cout << ans << "\n";
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  double sum=0;
  for(int i=0;i<n;i++){
    double value;
    string money;
    cin>>value;
    cin>>money;
    if(money=="JPY"){
      sum+=value;
    }else{
      sum+=value*380000.0;
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,x;cin >> n >> x;
    vector<int> L(n);
    rep(i,n)cin >> L[i];
    int sum = 0;
    int ans = 1;
    for(int i=0;i<n;i++){
        sum += L[i];
        if(sum <= x)ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    int n;
    cin>>n;
    multiset<ll> left;
    map<ll, int> rit;
    for(int i = 1; i<= n;i++)
    {
        ll x;
        cin>>x;
        left.insert(x + i);
        rit[i-x]++;
    }
    ll ans = 0;
    for(auto it = left.begin(); it != left.end(); it++)
        ans += rit[*it];
    cout<<ans;
    return 0;
}


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

const int N = 303;
char g[N][N];
int n;

int check(int k) {
    int ok = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(g[(i+k)%n][j] != g[(j+k)%n][i])
                ok = 0;
        }
    }
    return ok*n;
}

int32_t main() {
    cin >> n;

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

    int ans = 0;
    for(int i = 0; i < n; i++) ans += check(i);

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    int a, b, c, x, counter = 0;
    cin >> a >> b >> c >> x;
    for (int a_ = 0; a_ <= a; ++a_) {
        for (int b_ = 0; b_ <= b; ++b_) {
            for (int c_ = 0; c_ <= c; ++c_) {
                if (500 * a_ + 100 * b_ + 50 * c_ == x) {
                    counter++;
                }
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
def gi; gets.to_i end
def gs; gets.chomp end
def gli; gets.split(' ').map(&:to_i) end
def d(n); Math.log10(n).to_i + 1 end
class Integer
  # 約数の組み合わせを列挙する
  def divisor_combinations
    (1..Math.sqrt(self).to_i).
      select { |i| self % i == 0 }.
      map { |i| [i, self / i] }
  end
end

N = gi
a_n = gli
puts a_n.each_with_object(Array.new(N)).with_index  { |(a, res), i| res[a - 1] = i + 1 } * ' '


Measured memory_bytes: 12548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll pw(ll n,ll m){
  if(m==0) return 1;
  else if(m%2==0) return pw((n*n)%1000000007,m/2);
  else return (n*pw(n,m-1))%(1000000007);
}

int main(){
  ll n,a[100010];
  cin>>n;
  fr(i,n) cin>>a[i];
  sort(a,a+n);
  for(int i=n-1;i>=0;i-=2) a[i]++;
  bool f=1;
  fr(i,n) if(a[i]!=i+1) f=0;
  cout<<(f?pw(2,n/2):0)<<endl;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()
N=len(S)

# nxt[k][i] := 最初iにいた子が2^k回の移動後にいるマス
nxt=list2d(17, N, -1)
# 初期化
for i in range(N):
    if S[i]=='L':
        nxt[0][i]=i-1
    elif S[i]=='R':
        nxt[0][i]=i+1
# ダブリングのテーブル構築
for k in range(1, 17):
    for i in range(N):
        nxt[k][i]=nxt[k-1][nxt[k-1][i]]

ans=[0]*N
# 10万回移動後を求める(今回はこれで10**100と一致する)
K=10**5
# 元々iにいた子
for i in range(N):
    cur=i
    for k in range(17):
        # ビットが立っている所に合わせて、移動させていく
        if K>>k&1:
            cur=nxt[k][cur]
    ans[cur]+=1
print(*ans)


Measured memory_bytes: 23028
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    ll n, d;
    cin >> n >> d;
    vector<ll> x(n), y(n);
    REP(i, n){
        cin >> x.at(i) >> y.at(i);
    }

    two_sat ts(n);

    REP(i, n){
        for(ll j = i + 1; j < n; ++j){
            // xi, xj
            if(abs(x.at(i) - x.at(j)) < d){
                ts.add_clause(i, true, j, true);
            }
            // xi, yj
            if(abs(x.at(i) - y.at(j)) < d){
                ts.add_clause(i, true, j, false);
            }
            // yi, xj
            if(abs(y.at(i) - x.at(j)) < d){
                ts.add_clause(i, false, j, true);
            }
            // yi, yj;
            if(abs(y.at(i) - y.at(j)) < d){
                ts.add_clause(i, false, j, false);
            }
        }
    }

    if(!ts.satisfiable()){
        cout << NO << endl;
        return 0;
    }
    cout << YES << endl;

    vector<bool> ans = ts.answer();
    REP(i, n){
        if(ans.at(i)){
            cout << y.at(i) << endl;
        }else{
            cout << x.at(i) << endl;
        }
    }
    return 0;
}


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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    map<int64_t, int64_t> hist;
    for (int64_t i = 1; i <= N; i++)
    {
        int M = i;
        int64_t a = 2;
        while (M >= a * a)
        {
            if (M % a == 0)
            {
                hist[a]++;
                M /= a;
            }
            else
                a++;
        }
        hist[M]++;
    }
    int64_t ans = 1;
    for (auto x : hist)
        if (x.first != 1)
            ans = ans * (x.second + 1) % mod;
    cout << ans;
}

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

using  namespace std;

int main() {

    string S;
    cin >> S;
    vector<string> divide = {"dream","dreamer","erase","eraser"};
    for (int i = 0; i < 4; ++i)  reverse(divide[i].begin(),divide[i].end());
    reverse(S.begin(),S.end());
    bool cut;
    bool fin = false;
    for (int j = 0; j < S.size();) {
        cut = false;
        for (string D:divide) {
            if(S.substr(j,D.size()) == D)
            {
                cut = true;
                j += D.size();
            }
        }
        if (cut) fin = true;
        else {
            fin = false;
            break;
        }

    }

    if(fin){
        cout << "YES";
    }else{
        cout << "NO";
    }


    return 0;
}

Measured memory_bytes: 512
n = int(input())

h = list(map(int, input().split()))

dp = [1000000000] * n
dp[0] = 0
for i in range(n):
    for j in [1, 2]:
        if i+j < n:
            dp[i+j] = min(dp[i+j], (dp[i] + abs(h[i] - h[i+j])))

print(dp[n-1])

Measured memory_bytes: 13924
import math

while True:
    n = int(input())
    
    if n==0:
        break
    
    slist = [int(s) for s in input().split()]
    
    m = sum(slist)/n
    
    S = 0
    for i in range(n):
        S += (slist[i]-m)**2
    
    a2 = S/n
    a = math.sqrt(a2)
    print(f'{a:.8f}')


Measured memory_bytes: 5724