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

int main()
{
    //freopen("A.data", "r", stdin);
    int N;
    scanf("%d",&N);
    int left = N%10;
    if(left == 2 || left == 4 || left == 5 || left == 7 || left == 9){
        printf("hon\n");
    }else if(left == 0 || left == 1 || left == 6 || left ==8){
        printf("pon\n");
    }else if(left == 3){
        printf("bon\n");
    }
    return 0;
}

Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String a = Integer.toString(in.nextInt());
            String b = Integer.toString(in.nextInt());
            String aa = "";
            String bb = "";

            int b_count = Integer.parseInt(b);
            while (b_count-- > 0)
            {
                aa += a;
            }

            int a_count = Integer.parseInt(a);
            while (a_count-- > 0)
            {
                bb += b;
            }
            if (aa.compareTo(bb) < 0)
            {
                out.print(aa);
            } else
            {
                out.print(bb);
            }

        }

    }
}



Measured memory_bytes: 21844
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define MAXN 10010

int N, W;
int w[110], v[110];
ll dp[110][MAXN];

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

	cin >> N >> W;	
	for (int i = 1; i <= N; i++)
		cin >> w[i] >> v[i];

	for (int i = 1; i <= N; i++)
		for (int j = W; j >= 0; j--)
			if (j-w[i] >= 0)
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
			else
				dp[i][j] = dp[i-1][j];

	cout << dp[N][W] << endl;
	
	return 0;
}


Measured memory_bytes: 8832
from math import floor, ceil

A, B = list(map(int, input().split()))

pa1 = ceil(A * 100 / 8.0)
pa2 = floor((A * 100 + 100) / 8.0)
pb1 = ceil(B * 100 / 10.0)
pb2 = floor((B * 100 + 100) / 10.0)

p1 = max(pa1, pb1)
if p1 >= pa2 or p1 >= pb2:
    print(-1)
else:
    print(p1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int bound = 100010;
vector<int> graph[bound];
vector<int> h(bound);

bool check( int now ){
	bool res = true;
	for( auto next : graph[now] ){
		if( h[next] >= h[now] ) res = false;
	}
	return res;
}

int main(){
	int n, m; cin >> n >> m;
	for( int i = 0; i < n; ++i ) cin >> h[i];
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y; --x; --y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	int cnt = 0;
	for( int i = 0; i < n; ++i ){
		if( check(i) ) ++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 8740
//テンプレ
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
//
signed main (){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int N,K;
   cin >> N >> K;
   if( K % 2 ==0)
   {
       int cnt1 = N/K;
       int cnt2 = (N+K/2)/K;
       cout << cnt1 * cnt1 * cnt1 + cnt2 * cnt2 * cnt2 << endl;
       return 0;
   }
   else {
       
       int cnt1 = N/K;
       cout << cnt1 * cnt1 * cnt1 << endl;
       return 0;
   }
   //方程式　a+b = Kl ....を解くと
   /*k/2 |a,b,c (kは偶数)　k|a,b,c (k:odd)
   のどちらかであることが必要。そして奇数の時は必要十分条件である。
   偶数についてはmodで考えればよい。a、b,c === 0 or k/2 (mod K)となる。
   0の場合は奇数と同様に数えることができる*/
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

W_count = [0]*(N)#左から累積を数えていく
E_count = [0]*(N)#右からｒｙ

for i in range(1,N,1):
    W_count[i]=W_count[i-1]
    if S[i-1]=="W":
        W_count[i]+=1

for i in range(N-2,-1,-1):
    E_count[i]=E_count[i+1]
    if S[i+1]=="E":
        E_count[i]+=1

ans = [0]*(N)
for i in range(0,N,1):
    ans[i]=W_count[i]+E_count[i]

print(min(ans))

Measured memory_bytes: 93220
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


def main():
    class UnionFind:
        def __init__(self, n):
            # 負  : 根であることを示す。絶対値はランクを示す
            # 非負: 根でないことを示す。値は親を示す
            self.table = [-1] * n
            self.size = [1] * n
            self.group_num = n

        def root(self, x):
            if self.table[x] < 0:
                return x
            else:
                self.table[x] = self.root(self.table[x])
                return self.table[x]

        def is_same(self, x, y):
            return self.root(x) == self.root(y)

        def get_size(self, x):
            r = self.root(x)
            return self.size[r]

        def union(self, x, y):
            r1 = self.root(x)
            r2 = self.root(y)
            if r1 == r2:
                return
            # ランクの取得
            d1 = self.table[r1]
            d2 = self.table[r2]
            if d1 <= d2:
                self.table[r2] = r1
                self.size[r1] += self.size[r2]
                if d1 == d2:
                    self.table[r1] -= 1
            else:
                self.table[r1] = r2
                self.size[r2] += self.size[r1]
            self.group_num -= 1


    n = I()
    A = LI()
    B = LI()
    a_sort = sorted([(a, i) for i, a in enumerate(A)])
    b_sort = sorted([(b, i) for i, b in enumerate(B)])
    U = UnionFind(n)
    for i in range(n):
        if a_sort[i][0] > b_sort[i][0]:
            return 'No'
    for j in range(n):
        if j != 0 and a_sort[j][0] <= b_sort[j - 1][0]:
            return 'Yes'
    b_ind_to_a_ind = {}
    for i in range(n):
        b_ind_to_a_ind[b_sort[i][1]] = a_sort[i][1]
    for j in range(n):
        U.union(j, b_ind_to_a_ind[j])
    if U.group_num == 1:
        return 'No'
    else:
        return 'Yes'



print(main())



Measured memory_bytes: 96508
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;


double sunuke(ll x)
{
	int s=0;
	ll y;

	for(y=x;y>0;y/=10)
	{
		s+=y%10;
	}
	return (double)x/s;
}


int main(void)
{
	int k;

	while(scanf("%d", &k)==1)
	{
		ll add=1;
		ll t=1;

		for(int i=0;i<k;i++)
		{
			printf("%lld\n", t, add);
			ll tn=t+add;
			if(sunuke(tn)>sunuke(tn+add))
			{
				add*=10;
				tn=t+add;
			}
			t=tn;
		}
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
/* AtCoder Beginner Contest 106 (๑•﹏•๑｀) */

int main(){
	string str;
	integer K;
	getline(cin,str);
	SCLLD(K);

	int len = str.length();

	for(integer i = 0;i < str.length();i++){
		if (str[i] != '1'){
			printf("%c\n",str[i]);
			return 0;
		}

		if (i == K-1){
			printf("%c\n",str[i]);
			return 0;
		}

	}

}

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

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

    cout<<(n*(n-1))/2<<endl;

}

Measured memory_bytes: 256
program main;
var
	N, M, i, sum, count : integer;
    A : array[1..100] of integer;
begin
	readln(N, M);
    sum := 0 ;
    count := 0;
    for i := 1 to N do begin
    	read(A[i]);
        sum := sum + A[i];
    end;
    
    for i := 1 to N do begin
    	if A[i] >= sum / (4 * M)
        then count := count + 1;
   	end;
    
    if count >= M
    then writeln('Yes')
    else writeln('No');
end.

Measured memory_bytes: 1368
x=range(int(input()))
f=lambda a,d,b,c : a*d - b*c 
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=f(P[j][0],P[j+1][1],P[j][1],P[j+1][0])
print(_*0.5)

Measured memory_bytes: 7716
n = int(input())
ls_h = list(map(int,input().split()))
ls_cos = [0]*n
ls_cos[1] = abs(ls_h[1]-ls_h[0])
for i in range(2,n):
    ls_cos[i] = min(ls_cos[i-2]+abs(ls_h[i]-ls_h[i-2]) , ls_cos[i-1]+abs(ls_h[i]-ls_h[i-1]))

print(ls_cos[-1])



Measured memory_bytes: 52208
N, M = map(int, input().split())

edges =[set() for _ in range(N + 1)]
one = set()
for _ in range(M):
    fr, to = map(int, input().split())
    edges[fr].add(to)
    edges[to].add(fr)
    if fr == 1:
        one.add(to)
    if to == 1:
        one.add(fr)

for fr in one:
    if N in edges[fr]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')


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

pointList = [0]
for i in range(len(L)):
  x = pointList[i]+L[i]
  pointList.append(x)
    
num = 0
    
for i in range(len(pointList)):
  if pointList[i]<=X:
    num += 1

print(num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> counter(n);
    for(int i=1;i<n;i++){
        cin >> a[i];
        counter[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
       cout << counter[i] << endl;
    }

}


Measured memory_bytes: 4844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int a[100005];
int b[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1; i<=n; ++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1; i<=h; ++i)
        {
            if(i&1)
            {
                for(int j=1; j<=w; ++j)
                {
                    if(a[cnt]>0)
                    {
                        b[i][j]=cnt;
                        --a[cnt];
                    }
                    else if(a[cnt]==0)
                    {
                        ++cnt;
                        b[i][j]=cnt;
                        --a[cnt];
                    }
                }
            }
            else
            {
                for(int j=w; j>=1; --j)
                {
                    if(a[cnt]>0)
                    {
                        b[i][j]=cnt;
                        --a[cnt];
                    }
                    else if(a[cnt]==0)
                    {
                        ++cnt;
                        b[i][j]=cnt;
                        --a[cnt];
                    }
                }
            }
        }
        for(int i=1; i<=h; ++i)
        {
            for(int j=1; j<=w; ++j)
            {
                if(j!=w) printf("%d ",b[i][j]);
                else printf("%d\n",b[i][j]);
            }
        }
    }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for (int i = a; i < b; i++)
const int mod = 1e9 + 7;


int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n,m;
	cin >> n >> m;
	ll total = 0;
	std::vector<int> a(n);
	FOR(i,0,n){
		cin >> a[i];
		total+=a[i];
	}
	ll count = 0;
	FOR(i,0,n){
		if(a[i]*m*4 >= total) count++;
	}
	if(count >=m){
		cout << "Yes" << "\n";
	}else{
		cout << "No" << "\n";
	}
	return 0;
}

Measured memory_bytes: 3516
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n){
		if(n==-1) return;
		int ans=1150;
		n=max(0,n-10);
		if(n){
			ans+=min(10,n)*125;
			n=max(0,n-10);
		}
		if(n){
			ans+=min(10,n)*140;
			n=max(0,n-10);
		}
		ans+=n*160;
		cout<<4280-ans<<endl;
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0);
  	cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[4][2010][2010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[2010];
    rep(i, H) cin >> S[i];

    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '.') {
                if (j - 1 >= 0)
                    dp[0][i][j] += dp[0][i][j - 1] + 1;
                else 
                    dp[0][i][j] = 1;
            } else {
                dp[0][i][j] = 0;
            }
        }
    }
    rep(i, H) {
        rrep(j, W - 1) {
            if (S[i][j] == '.') {
                if (j - 1 >= 0)
                    dp[1][i][j] += dp[1][i][j + 1] + 1;
                else 
                    dp[1][i][j] = 1;
            } else {
                dp[1][i][j] = 0;
            }
        }
    }
    rep(j, W) {
        rep(i, H) {
            if (S[i][j] == '.') {
                if (i - 1 >= 0)
                    dp[2][i][j] += dp[2][i - 1][j] + 1;
                else 
                    dp[2][i][j] = 1;
            } else {
                dp[2][i][j] = 0;
            }
        }
    }
    rep(j, W) {
        rrep(i, H - 1) {
            if (S[i][j] == '.') {
                if (i - 1 >= 0)
                    dp[3][i][j] += dp[3][i + 1][j] + 1;
                else 
                    dp[3][i][j] = 1;
            } else {
                dp[3][i][j] = 0;
            }
        }
    }
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') continue;
            int tmp = 0;
            rep(k, 4) tmp += dp[k][i][j];
            ans = max(ans, tmp - 3);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 67584
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//遅延セグメント木
// ref:https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename Monoid, typename OperatorMonoid = Monoid>
struct segment_tree_lazy {
    using F = function<Monoid(Monoid, Monoid)>;
    using G = function<Monoid(Monoid, OperatorMonoid)>;
    using H = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
    int sz, height;
    vector<Monoid> data;
    vector<OperatorMonoid> lazy;
    const F f;
    const G g;
    const H h;
    const Monoid e;
    const OperatorMonoid id;
    segment_tree_lazy(int _sz, const F _f, const G _g, const H _h,
                      const Monoid& _e, const OperatorMonoid _id)
        : f(_f), g(_g), h(_h), e(_e), id(_id) {
        sz = 1, height = 0;
        while (sz < _sz) sz <<= 1, height++;
        data.assign(2 * sz, e);
        lazy.assign(2 * sz, id);
    }
    void set(const int k, const Monoid& x) {
        data[k + sz] = x;
    }
    Monoid operator[](const int& k) {
        return query(k, k + 1);
    }
    void build() {
        for (int i = sz - 1; i > 0; i--)
            data[i] = f(data[i * 2], data[i * 2] + 1);
    }
    Monoid reflect(int k) {
        return lazy[k] == id ? data[k] : g(data[k], lazy[k]);
    }
    void propagate(int k) {
        if (lazy[k] != id) {
            lazy[2 * k] = h(lazy[2 * k], lazy[k]);
            lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
            data[k] = reflect(k);
            lazy[k] = id;
        }
    }
    void recalc(int k) {
        while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //自分より上にあるやつ全てに対して上から順にpropagate
    void thrust(int k) {
        for (int i = height; i > 0; i--) propagate(k >> i);
    }
    // a~bにxを作用させる
    void update(int a, int b, const OperatorMonoid& x) {
        thrust(a += sz), thrust(b += sz - 1);
        for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
            if (l & 1) lazy[l] = h(lazy[l], x), l++;
            if (r & 1) r--, lazy[r] = h(lazy[r], x);
        }
        recalc(a), recalc(b);
    }
    Monoid query(int a, int b) {
        thrust(a += sz), thrust(b += sz - 1);
        Monoid L = e, R = e;
        for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
            if (l & 1) L = f(L, reflect(l++));
            if (r & 1) L = f(reflect(--r), R);
        }
        return f(L, R);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    segment_tree_lazy<int> seg(
        n, [](int a, int b) { return min(a, b); },
        [](int a, int b) { return b == INT_MAX ? a : b; },
        [](int a, int b) { return b == INT_MAX ? a : b; }, INT_MAX, INT_MAX);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t) {
            int k;
            cin >> k;
            cout << seg.query(k, k + 1) << endl;
        } else {
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t + 1, x);
        }
    }
}


Measured memory_bytes: 4936
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> factors(n + 1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j += i)
        {
            factors[j]++;
        }
    }
    ll ans = 0;
    for (int i = 0; i < factors.size(); i++)
    {
        ans += i * factors[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81408
#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
    if(x>y)swap(x,y);
    for(int i=x; i >= 1; i--){
        if(i == 1)return 1;
        else if( x % i  == 0 && y % i == 0)return i;
        //最大公約数、lcm = x*y/gcd 僕のVSCではgcd関数が使えませんでした(泣)だれか教えてください。
    }
}
typedef long long ll;

int main(){ 
    int n,a,b;
    cin >> n>> a >> b;
    if((b-a) % 2 == 1 ) cout << "Borys"<<endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 256
program answer
  implicit none

  integer :: N, i, count, sum
  character(len=100000) :: S, p, q

  read(*,*) S

  N = len_trim(S)
  count = 0


  do i = 1, N, 2
     p(i:i) = '0'
     q(i:i) = '1'
  end do

  do i = 2, N, 2
     p(i:i) = '1'
     q(i:i) = '0'
  end do
 do i = 1, N
     if(S(i:i)/=p(i:i)) then
        count = count + 1
     end if
  end do

  sum = 0
  do i = 1, N
     if(S(i:i)/=q(i:i)) then
        sum = sum + 1
     end if
  end do

  if(count>=sum) then
     write(*,*) sum
  else
     write(*,*) count
  end if

  stop
 end program answer


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

#define INF 100000000

int main(){
    float N;
    float ans = INF;
    cin >> N;
    float start = floor(N/1.08);
    while(true){
        float n = floor(start*1.08);
        if(n == N) {ans = start; break;}
        else if(n < N) start++;
        else break;
    }
    if (ans == INF) cout << ":(" << endl;
    else cout << int(ans) << endl;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int N, M;

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

    vector<int> a(M), b(M);
    for (size_t i = 0; i < M / 2; i++)
    {
        int sum = (M / 2) * 2 + 2;
        a[i] = i + 1;
        b[i] = sum - a[i];
    }
    for (size_t i = M / 2; i < M; i++)
    {
        int init = (M / 2) * 2 + 2;
        int sum = ((M + 1) / 2) * 2 + 1 + (init - 1) * 2;
        a[i] = init + i - M / 2;
        b[i] = sum - a[i];
    }

    for (size_t i = 0; i < M; i++)
    {
        cout << a[i] << " " << b[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <cstring>

#define MAX 20

using namespace std;

int main() {
	char str[MAX];
	cin >> str;

	int len = strlen(str);
	for (int i = len - 1; i >= 0; i--) {
		cout << str[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3008
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class18
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int height_first = 0;
            int height_last = 0;
            int height = 0;
            int height_max = 0;

            for(int i = 0; i < N; i++)
            {
                if (S[i] == '(')
                    height++;
                else
                    height--;
                height_max = Math.Min(height_max, height);
            }
            if (height_max<0)
            {
                for (int i = height_max; i < 0; i++)
                    S = S.Insert(0, "(");
            }
            if (height > height_max)
            {
                for (int i = height-height_max; i > 0; i--)
                    S += ")";
            }
            Console.WriteLine(S);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;
const ll mod = 1000000007;
typedef pair<int, int> P;

int n;
string s;

void solve() {
	cin >> s;
	vector<int> v(n+1);
	{
		int cur = 0;
		rep(i, n) {
			if (s[i] == 'u') {
				cur = 0;
			}
			else {
				int t = s[i] - '0';
				if (cur&(1 << t)) {
					cout << "UNSAFE" << endl; return;
				}
				cur ^= (1 << t);
			}
			v[i+1] = cur;
		}
	}
	vector<int> a[10];
	rep(i, n) {
		if (s[i] != 'u') {
			int t = s[i] - '0';
			a[t].push_back(v[i]);
		}
	}
	rep(i, 10) {
		sort(a[i].begin(), a[i].end());
		a[i].erase(unique(a[i].begin(), a[i].end()), a[i].end());
	}
	rep(i, 1024) {
		vector<int> c;
		rep(j, 10) {
			if (i&(1 << j))c.push_back(j);
		}
		if (c.size() < 2)continue;
		int ss = 0;
		rep(j, c.size())ss ^= (1 << c[j]);
		bitset<1024> dp=0;
		dp[0] = true;
		rep(j, c.size()) {
			int id = c[j];
			rep(l, 1024) {
				if (!dp[l])continue;
				rep(k, a[id].size()) {
					if (l&a[id][k])continue;
					dp[l + a[id][k]] = true;
					if (((l + a[id][k])&ss) == ss) {
						cout << "UNSAFE" << endl; return;
					}
				}
			}
		}
	}
	cout << "SAFE" << endl; return;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> n, n) {
		solve();
	}
	//stop
	return 0;
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if((N % 500) <= A){
  	cout << "Yes" << endl; 
  }
  
   else if((N % 500) > A){
  	cout << "No" << endl; 
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long LL; 
const LL inf=1e18;
int n;
int a[20];
LL f[20][20][1<<18];
LL F(int l,int r,int xl,int xr,int s)
{
	if(l+1==r)
	{
		return 0;
	}
	if(f[l][r][s]!=-1)
	{
		return f[l][r][s];
	}
	LL &re=f[l][r][s]=inf;
	for(int i=l+1;i<r;++i)
	{
		re=min(re,F(l,i,xl,xl+xr,s<<1)+F(i,r,xl+xr,xr,s<<1|1)+(LL)(xl+xr)*a[i]);
	}
	return re;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
	}
	memset(f,-1,sizeof(f));
	printf("%lld\n",F(1,n,1,1,1)+a[1]+a[n]);
	return 0;
}

Measured memory_bytes: 820088
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;


  ll fun(pair<ll,ll> p1,pair<ll,ll> p2)
  {
    if(p1.ss!=p2.ss)
      return p1.ss>p2.ss;
    else 
      return p1.ff>p2.ff;
  }

int main()
{ 
fast;

    ll n,m;
    cin>>n>>m;
set<ll> s;
for(ll i=1;i<=m;i++)
s.insert(i);


    pair<ll,ll> v[n];

    for(ll i=0;i<n;i++)
      cin>>v[i].ff>>v[i].ss;


    sort(v,v+n,fun);
    

    ll ans=0;
    for(ll i=0;i<n;i++)
    {
      auto it=s.upper_bound(m+1-v[i].ff);
      if(s.empty() or it==s.begin())
        continue;
      else
      {
        ans+=v[i].ss;
       
        it--;
        s.erase(it);
      }

    }

  cout<<ans<<endl;
  }

Measured memory_bytes: 6528
use proconio::input;

fn main() {
    input! {
        n: isize,
        m: isize,
        k: isize,
    }

    let div = 998244353;
    let max = 510000;

    let mut fac = vec![0; max];
    let mut finv = vec![0; max];
    let mut inv = vec![0; max];

    com_init(&mut fac, &mut finv, &mut inv, max, div);
    let mut ans = 0;

    let mut tmp = m;
    for _ in 0..n - k - 1 {
        tmp = tmp * (m - 1) % div;
    }

    for i in (0..=k).rev() {
        ans = (ans + com((n - 1) as usize, i as usize, &fac, &finv, div) * tmp % div) % div;
        tmp = tmp * (m - 1) % div;
    }
    println!("{}", ans);
}

fn com_init(
    fac: &mut Vec<isize>,
    finv: &mut Vec<isize>,
    inv: &mut Vec<isize>,
    max: usize,
    m: isize,
) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[0] = 0;
    inv[1] = 1;

    let mut i = 2;
    while i < max {
        fac[i] = fac[i - 1] * i as isize % m;
        inv[i] = m as isize - inv[m as usize % i] * (m / i as isize) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
        i += 1;
    }
}

fn com(n: usize, k: usize, fac: &Vec<isize>, finv: &Vec<isize>, m: isize) -> isize {
    if n < k {
        return 0;
    }
    fac[n] * (finv[k] * finv[n - k] % m) % m
}


Measured memory_bytes: 13952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		double result = 0.0;

		if (n % 2 == 0) {
			result = 0.5;
		} else {
			result = (double) ((n + 1) / 2) / n;
		}
		System.out.println(result);
		sc.close();
	}

}


Measured memory_bytes: 23252
fun main(arr:Array<String>) {
    val ballCount = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val ballList = readLine()!!.split(" ").map { it.toInt() }
    val ans = ballList.map { Math.min(Math.abs(k-it), it)*2 }.sum()
    println(ans)
}




Measured memory_bytes: 37872
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define inf 0xffffff
using namespace std;


int main()
{
    int r;
    while(~scanf("%d",&r))
    {
         if(r<1200)
            printf("ABC\n");
         else if(r<2800)
            printf("ARC\n");
         else
            printf("AGC\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
    fast();
    int n,m;
    cin>>n>>m;
    int a[n];
    int s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s = s+a[i];
    }
    double l = s/(4.00*m);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]<l)
        {
            continue;
        }
        else
        {
            cnt++;
        }
        if(cnt==m)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split(" "))
d = []
a = []
get_flag = [0 for i in range(n)]
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
#print(d)
#print(a)

for i in range(k):
    for j in range(d[i]):
        for m in range(n):
            if a[i][j] == m+1:
                get_flag[m] = 1
#print(get_flag)
count = 0
for i in range(len(get_flag)):
    if get_flag[i] == 0:
        count += 1
print(count)

Measured memory_bytes: 9064
#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 <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

int a[100010];
int main() {
	ll kei[2] = {};
		int n, ptr = 0, g = 0;
		cin >> n;
		for (int i = 0; i < n; i++)cin >> a[i];

		sort(a, a + n);
		reverse(a, a + n);

		while (ptr < n) {
			int x = a[ptr], res = 0;
			while (ptr < n && a[ptr] == x) {
				ptr++;
				res++;
			}
			if (res >= 4 && g == 0) {
				kei[0] = x;
				kei[1] = x;
				break;
			}
			else if (res >= 2) {
				kei[g] = x;
				g++;
			}
			if (g >= 2)break;
		}

		cout << (ll)kei[0] * kei[1] << endl;


	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(int i = 0; i < x; i++)
typedef long long ll;
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<pair<ll, ll>> all(n+m);
    vector<pair<ll, ll>> a(n);
    rep(i,n) {
        ll temp;
        scanf("%llu",&temp);
        a[i] = make_pair(temp,1);
        all[i] = a[i];
    }
    vector<pair<ll, ll>> bc(m);
    rep(i,m) {
        ll t1,t2;
        scanf("%llu%llu",&t1,&t2);
        bc[i] = make_pair(t2,t1);
        all[n+i] = bc[i];
    }

    sort(all.begin(), all.end());
    // rep(i,all.size()) cout << all[i].first << " " << all[i].second << endl;
    vector<ll> ans;
    int i = 0;
    while(ans.size() < n){
        rep(j,all[n+m-i-1].second){
            ans.push_back(all[n+m-i-1].first);
        }
        i++;
    }
    
    ll sum = 0;
    rep(i,n) sum += ans[i];
    cout << sum << endl;
    // sort(a.begin(),a.end());
}

Measured memory_bytes: 8692
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;
int n, k;
int arr[100005];
int dp[100005];

int fun(int ind)
{
    if (ind == n - 1)
    {
        return 0;
    }
    if (dp[ind] != -1)
        return dp[ind];
    int mini = 1e9 + 5;
    for (int i = ind + 1; i <= min(n, ind + k); i++)
    {
        mini = min(mini, abs(arr[i] - arr[ind]) + fun(i));
    }
    return dp[ind] = mini;
}

int main()
{

    cin >> n >> k;

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

    memset(dp, -1, sizeof(dp));
    cout << fun(0) << "\n";
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long MOD  = 1e9+7;


signed main(){
    fast;
    int n; cin >> n;
    int ans[n] = {};
    for(int i=0 ; i<n-1 ; i++){
        int x; cin >> x;
        if(i==0)
            ans[i] = ans[i+1] = x;
        else{
            if(x > ans[i]){
                ans[i+1] = x;
            }
            else{
                ans[i] = ans[i+1] = x;
            }
            
        }
    }

    int sum = 0;
    for(int i=0  ;i<n ; i++){
        sum += ans[i];
    }
    cout << sum << endl;
    cerr << endl;
}

Measured memory_bytes: 384
import numpy as np

s = input()
l = s.split()

n = int(l[0])
d = int(l[1])

X = []
for i in range(n):
    s = input()
    x = s.split()
    Xi = [int(xi) for xi in x]
    X.append(Xi)

X = np.array(X)

cnt = 0
for i, xi in enumerate(X):
    for j, xj in enumerate(X[i+1:]):
        if np.linalg.norm(xi-xj, ord=2) % 1.0 == 0:
            cnt += 1

print(cnt)


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

using namespace std;

int sx, sy, tx, ty;


int main() {
	cin >> sx >> sy >> tx >> ty;

	//一往復目
	for (int i = 0;i < tx - sx;i++) {
		cout << "R";
	}
	for (int i = 0;i < ty - sy;i++) {
		cout << "U";
	}
	for (int i = 0;i < tx - sx;i++) {
		cout << "L";
	}
	for (int i = 0;i < ty - sy;i++) {
		cout << "D";
	}
	//二往復目
	cout << "L";
	for (int i = 0;i < ty - sy + 1;i++) {
		cout << "U";
	}
	for (int i = 0;i < tx - sx + 1;i++) {
		cout << "R";
	}
	cout << "D";
	cout << "R";
	for (int i = 0;i < ty - sy + 1;i++) {
		cout << "D";
	}
	for (int i = 0;i < tx - sx + 1;i++) {
		cout << "L";
	}
	cout << "U";
	cout << endl;
	return 0;

}

Measured memory_bytes: 256
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)


Measured memory_bytes: 2940
n,k = map(int,input().split())

mod = 10**9+7

m = 10**5 * 4 +10 
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

ans = 0
for i in range(min(n,k+1)):
    ans += comb(n,i)*comb(n-1,i)
    ans %= mod
print(ans)

Measured memory_bytes: 50476
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

vector<vector<P>> G;
int res[100010];

void dfs(int node,int c){
  res[node] = c;
  for(P e : G[node]){
    int next,w;
    tie(next,w) = e;
    if(res[next] == -1){
      if(w % 2 == 0){
        dfs(next,c);
      }else{
        dfs(next, !c);
      }
    }
  }
}

int main(void){
  int n;
  cin >> n;
  G = vector<vector<P>>(n);
  for(int i = 0;i < n-1;++i){
    int u,v,w;
    cin >> u >> v >> w;
    --u;--v;
    G[u].push_back(P(v,w));
    G[v].push_back(P(u,w));
  }
  fill(res, res+100010, -1);
  dfs(0,0);
  for(int i = 0;i < n;++i){
    printf("%d\n", res[i]);
  }
  return 0;
}


Measured memory_bytes: 8832
def search_dfs(A, n):
    def __inner(i, sum_v, goal):
        if sum_v == goal:
            return True
        if sum_v > goal or i >= n:
            return False
        if sum_v + sum(A[i:]) < goal:
            return False
            
        return __inner(i+1, sum_v, goal) or __inner(i+1, sum_v+A[i], goal)
    
    return __inner


n = int(input())
A = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]

dfs = search_dfs(A, n)

for goal in M:
    print('yes') if dfs(0, 0, goal) else print('no')





Measured memory_bytes: 5624
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3512
N,K,Q=map(int,input().split())
hito=[]
points=[]
for _ in range(Q):
    hito.append(int(input()))
for _ in range(N):
    points.append(K-Q)
for i in hito:
    points[i-1]+=1
for j in points:
    if j>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11776
#include<stdio.h>
int main(void)
{
  int x,y,a,b,i,num[1000],t;
  
  scanf("%d",&y);
  scanf("%d",&x);
  
  for(i=0;i<y;i++)
    {
      num[i]=i+1;
    }
  
  for(i=0;i<x;i++)
    {
      scanf("%d,%d",&a,&b);
      t=num[a-1];
      num[a-1]=num[b-1];
      num[b-1]=t;
    }
  
  for(i=0;i<y;i++)
    {
      printf("%d\n",num[i]);
    }
  
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
long long int dp[100040] = {};
int main() {
	int n;
	cin >> n;
	vector<int>a;
	vector<int>b;
	vector<int>c;
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		a.push_back(in);
	}
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		b.push_back(in);
	}
	for (int i = 0; i < n - 1; i++) {
		int in;
		cin >> in;
		c.push_back(in);
	}
	int ans = 0;
	ans = ans + b[a[0]-1];
	for (int i = 1; i < a.size(); i++) {
		ans = ans + b[a[i] - 1];
		if (a[i] - a[i - 1] == 1) {
			ans = ans + c[a[i - 1]-1];
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
chomp($s=<>);

$flg=0;
while($flg==0){
	chop($s);
    if(length($s)%2 == 0){
    	$head = substr($s,0,length($s)/2);
        $tail = substr($s,length($s)/2);
        if($head eq $tail){
        	$ans = length($s);
            $flg = 1;
        }
    }
}
print $ans;


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

int main(){

	int a, b, c;
	cin >> a >> b >> c;

	if(a > b) swap(a, b);
	if(b > c) swap(b, c);
	if(a > b) swap(a, b);

	cout << a << " " << b << " " << c <<endl;

	return 0;

}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int x1,x2,y1,y2,x3,x4,y3,y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3 = x2 + y1 - y2;
  y3 = x2 - x1 + y2;
  x4 = x1 + y1 - y2;
  y4 = x2 - x1 + y1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()

if S == 'hi' or S == 'hihi' or S == 'hihihi' or S == 'hihihihi' or S == 'hihihihihi':
  print('Yes')
else:
  print('No')
"""
if len(S) == 1:
  print('No')
elif len(S) == 2:
  if S == 'hi':
    print('Yes')
  else:
    print('No')
else:
  flag = 0
  i = 0
  while i < len(S)-1:
    if S[i:i+2] == 'hi':
      flag = 1
    else:
      flag = 0
      break
    i += 2
  if flag == 1:
    print('Yes')
  else:
    print('No')
"""

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string(); 
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);

    lli n;
    cin>>n;
    lli a[n+1];
    for(lli i=1;i<=n;i++)cin>>a[i];
    lli ans=INT_MAX;
    for(lli t=1;t<n;t++){
    	lli sum1=0,sum2=0;
    	for(lli i=1;i<=t;i++)sum1+=a[i];
    	for(lli i=t+1;i<=n;i++)sum2+=a[i];
    	ans=min(ans,abs(sum1-sum2));
    	//cout<<abs(sum1-sum2)<<endl;
    }
    cout<<ans;

    
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	scanf("%d%d%d",&a,&b,&c);
	if(a*a==b*b+c*c || b*b==c*c+a*a || c*c==b*b+a*a)printf("YES\n");
	else printf("NO\n");
	}

return 0;
}

Measured memory_bytes: 580
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int f[N];
int main(){
	int n , k , raod = 0 , Q;
	cin >> n >> k >> Q;
	while(Q --){
		int x;
		cin >> x;
		f[x] ++;
		raod ++;
	}
	for(int i = 1; i <= n; i ++)
		cout << ((k - (raod - f[i]) > 0) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 1024
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

template <typename T>
inline T Abs(T a) {
    if (0 <= a) {
        return a;
    } else {
        return -a;
    }
}

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

    int n, X;
    cin >> n >> X;
    int x, ans;
    cin >> x;
    ans = Abs(X - x);
    for (int i = 1; i < n; i++) {
        cin >> x;
        ans = Gcd(Abs(X - x), ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
const fi='rbgcard.inp';
        fo='rbgcard.out';
var s1,s2,s3,kq:longint;
procedure nhap;
begin
        read(s1,s2,s3);
        kq:=s1*100+s2*10+s3;
end;

procedure xuly;
begin
        if  kq mod 4 =0 then write('YES')
        else write('NO');
end;

begin
        nhap;
        xuly;

end.

Measured memory_bytes: 128