akhauriyash/Code-Regression huggingface dataset:
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

from collections import deque
dist_f=[-1]*n
dist_f[0]=0
q=deque()
q.append(0)
while q:
    cur=q.popleft()
    for nx in G[cur]:
        if dist_f[nx]==-1:
            dist_f[nx]=dist_f[cur]+1
            q.append(nx)

dist_s=[-1]*n
dist_s[n-1]=0
q=deque()
q.append(n-1)
while q:
    cur=q.popleft()
    for nx in G[cur]:
        if dist_s[nx]==-1:
            dist_s[nx]=dist_s[cur]+1
            q.append(nx)
fenec,sunuke=0,0
for i in range(n):
    if dist_f[i]<=dist_s[i]:
        fenec+=1
    else:
        sunuke+=1
print("Fennec") if fenec>sunuke else print("Snuke")

Measured memory_bytes: 29552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[] ts, as;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        ts = new int[n];
        as = new int[n];
        for (int i = 0; i < n; i++) {
            ts[i] = sc.nextInt();
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        long tVote = ts[0];
        long aVote = as[0];
        for (int i = 1; i < n; i++) {
            long tRatio = (tVote % ts[i] == 0) ? tVote / ts[i] : tVote / ts[i] + 1;
            long aRatio = (aVote % as[i] == 0) ? aVote / as[i] : aVote / as[i] + 1;
            long k = Math.max(tRatio, aRatio);
            long newTVote = ts[i];
            long newAVote = as[i];
            newTVote *= k;
            newAVote *= k;
            tVote = newTVote;
            aVote = newAVote;
        }
        System.out.println(tVote + aVote);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <math.h>
#define N_MAX 10001 /* ツ妥ィツ暗督つゥツづァa[10001]ツづ慊づ参ツ湘つウツづェツつ、ツづゥ */

int main(void){
	char a[N_MAX+1]; int i, j, N, count;
	
	/* eratosthenes */
	a[0]=0, a[1]=0;
	for(i=2; i<=N_MAX; i++) a[i]=1;
	
	for(i=2; i<=(int)sqrt(N_MAX); i++)
		if(a[i])
			for(j=2*i; j<=N_MAX; j+=i) a[j]=0;
	
	/* main */
	while(~scanf("%d",&N)){
		count=0;
	
		for(i=1; i<=N; i++)
			if(a[i]==1 && a[N-i+1]) count++;
		
		printf("%d\n",count);
	}
	
	return 0;
}

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

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

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    string str;
    cin >> str;
    int len = str.length();
    bool valid = true;
    int curidx = len;
    string strs[4] = {"dream", "dreamer", "erase", "eraser"};
    while(true){
    	bool found = false;
    	FOR(i,4){
    		int nxtidx = curidx - (int) strs[i].size();
    		// cout << nxtidx << endl;
    		if(nxtidx >= 0){
    			// cout << str.substr(nxtidx, (int)strs[i].size()) << endl;
    			if(str.substr(nxtidx, (int)strs[i].size()) == strs[i]){
    				found = true;
    				curidx -= strs[i].size();
    				break;
    			}
    		}
    	}
    	if(found && curidx == 0)break;
    	if(!found){
    		valid = false;
    		break;
    	}

    }

    printf("%s", valid ? "YES" : "NO");


    return 0;
}




Measured memory_bytes: 512
use std::io::{stdin, Read};
use std::str::FromStr;

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

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let vv = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    use std::collections::HashMap;
    let mut odds: HashMap<usize, i32> = HashMap::new();
    let mut evens: HashMap<usize, i32> = HashMap::new();

    for i in 0..n {
        let v = vv[i];
        if i % 2 == 0 {
            let &c = evens.get(&v).or(Some(&0)).unwrap();
            evens.insert(v, c + 1);
        } else {
            let &c = odds.get(&v).or(Some(&0)).unwrap();
            odds.insert(v, c + 1);
        }
    }

    let mut ve = evens.iter().map(|(&k, &v)| (v, k)).collect::<Vec<_>>();
    ve.sort();

    let mut vo = odds.iter().map(|(&k, &v)| (v, k)).collect::<Vec<_>>();
    vo.sort();

    let e_len = ve.len();
    let o_len = vo.len();
    let (c1, v1) = ve[e_len - 1];
    let (c3, v3) = vo[o_len - 1];

    let a: i32 = vo.iter().map(|&(c, v)| c).sum();
    let b: i32 = ve.iter().map(|&(c, v)| c).sum();

    if v1 != v3 {
        let (e1, _) = ve[e_len - 1];
        let (o1, _) = vo[o_len - 1];
        println!("{}", a + b - e1 - o1);
    } else {
        let (e1, _) = ve[e_len - 1];
        let (o1, _) = vo[o_len - 1];

        if e_len == 1 && o_len == 1 {
            println!("{}", n / 2);
        } else if e_len == 1 {
            let (o2, _) = vo[o_len - 2];
            println!("{}", a + b - e1 - o2);
        } else if o_len == 1 {
            let (e2, _) = ve[e_len - 2];
            println!("{}", a + b - e2 - o1);
        } else {
            let (e2, _) = ve[e_len - 2];
            let (o2, _) = vo[o_len - 2];
            use std::cmp::min;
            let ans = min(a + b - e1 - o2, a + b - e2 - o1);
            println!("{}", ans);
        }
    }
}


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

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            char[] cs = s.ToCharArray();
            cs[3] = '8';
            Console. WriteLine(cs);
            Console.ReadKey();

        }
    }
}


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

int main(){
    int x,a;cin>>x>>a;
    if(x<a) cout<<0;
    else cout<<10;
    return 0;
}

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

int n,m;
bool g[510][510];

int main()
{
#ifdef h10
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
	int i,j;
	char c;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	for (j=1;j<=m;j++)
	{
		c=getchar();
		while (c!='.'&&c!='#') c=getchar();
		g[i][j]=c=='#';
	}

	for (i=1;i<=n;i++)
	{
		for (j=1;j<=m;j++)
			putchar(j!=m&&(j==1||g[i][j]||(i&1))?'#':'.');
		puts("");
	}

	puts("");

	for (i=1;i<=n;i++)
	{
		for (j=1;j<=m;j++)
			putchar(j!=1&&(j==m||g[i][j]||(!(i&1)))?'#':'.');
		puts("");
	}
}


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

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

    int count = 0;

    for (int i = 0; i < N-2; i++){
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            count++;
            i += 2;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  unordered_map<int,int> mp;
  REP(i,n){
    int a;
    cin >> a;
    mp[a]++;
  }
  int ans=0;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    if(itr->second % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll res = 0;
  if(n == 1 && a != b)res = 0;
  else if(a > b){
    res = 0;
  }
  else{
    res = b * (n - 1) + a - (a * (n - 1) + b) + 1;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG




int main() {
  long double L;
  cin >> L;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));

  long double E = L / 3.0;
  long double ans = E*E*E;

  
  cout << setprecision(18) << ans << endl;

  return 0;
}


Measured memory_bytes: 3788
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


# Nの素因数分解を辞書で返す
def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def combination_mod_initialize(n, MOD=10**9+7):
    fac = [1]*(n+1)
    inv = [1]*(n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = inv[i-1] * pow(i, MOD-2, MOD) % MOD
    return fac, inv

# 二項係数　高速
def combination_mod(n, r, fac, inv, mod=10**9+7):
    return fac[n] * inv[r] * inv[n-r]


def main():
    N, M = NMI()
    PD = prime_fact(M)
    ans = 1
    fac, inv = combination_mod_initialize(10**6, MOD)

    for x in list(PD.values()):
        ans = ans * combination_mod(N+x-1, N-1, fac, inv) % MOD

    print(ans)



if __name__ == "__main__":
    main()

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

int main(){
  int n, k;
  cin >> n >> k;
  double ret=0;
  for(int i=1; i<=n; i++){
    int p=i;
    double prob=1.0/n;
    while(p<k){
      p*=2;
      prob/=2.0;
    }
    ret+=prob;
  }
  cout << setprecision(14) << ret;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s[n];
    int t[n];
    for(int i=0; i<n; i++){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    int i = 0;
    for(;i<n; i++){
        if(s[i] == x) break;
    }
    i++;
    int ans = 0;
    for(; i< n; i++){
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A, B) << "\n";
}

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

N=int(input())
S=input()
S=list(S)
East_number=0
East=[]
for i in S:
  if i=='E':
    East_number+=1
  East.append(East_number)
number=0
ans=[]
for i in range(N):
  if i >0:
    number+=i-East[i-1]
  number+=East[N-1]-East[i]
  ans.append(number)
  number=0
print(min(ans))

Measured memory_bytes: 29260
f::[Int]->[Int]->[Int]->Int
f [] ys zs = 0
f [x] ys zs = ys!!(x-1)
f [x,y] ys zs = if x+1 == y then ys!!(x-1)+ys!!(y-1) + zs!!(x-1)  else ys!!(x-1) + ys!!(y-1) 
f (x:y:xs) ys zs = if x+1 == y then ys!!(x-1)  + zs!!(x-1) + f(y:xs) ys zs else ys!!(x-1)  + f(y:xs) ys zs
main = do
    getLine
    a<- map read.words<$>getLine
    b<- map read.words<$>getLine
    c<-map read.words<$>getLine
    print $ f a b c

Measured memory_bytes: 764
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
998244353 99824435
'''


def MAIN():
  # T_IN()
  A()


def A():
  a, b = IN_L_I()
  if (a + b) % 2 != 0:
    print("IMPOSSIBLE")
    exit()

  d = (a + b) // 2
  print(d)

  return None


def B():
  return None


def C():
  return None


MAIN()


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) { 
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/
ll dp[101][200001];
vll a;

ll count(ll k, ll n){ //k*k*n algo
    if(k<0 or n<=0) return 0;
    if(dp[n][k]>=0) return dp[n][k];
    dp[n][k]=0;
    int i;
    fo(i,a[n]+1){
        dp[n][k] = (dp[n][k] + count(k-i,n-1))%mod;
    }
    dp[n][k]%=mod;
    return dp[n][k];
}

int main(){
    _cin;
    // cout << setprecision(22);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n >> k;
    a.assign(n,0);
    fo(i,n) cin >> a[i];
    sort(all(a));
    vll dp(k+1), pr(k+1);
    pr[0]=dp[0]=1;
    repa(i,1,k+1) pr[i] = (pr[i-1]+dp[i])%mod;
    fo(i,n){
        repb(j,k,1){
            // repa(l,1,a[i]+1){
            //    if(j-l>=0) dp[j] = (dp[j]+dp[j-l]) %mod;
            // }
          if(j-a[i]-1>=0)  dp[j] = (dp[j] + (mod+pr[j-1]-pr[j-a[i]-1])%mod)%mod;
          else dp[j] = (dp[j] + pr[j-1])%mod;
        }
        pr[0]=1;
        repa(j,1,k+1) pr[j] = (pr[j-1]+dp[j])%mod;
        // fo(j,k+1) cout << dp[j] << ' ';
        // cout << endl;
    }
    cout << dp[k];
}
 return 0;      
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int a, i, cnt;
    int A[1000];
    
    scanf("%d", &a);
    
    for(i = 0; i < a; i++){
        scanf("%d", &A[i]);
        //printf("%d\n", A[i]);
    }
    
    cnt = 1;
    
    for(i = 0; i < a; i++){
        if(A[i]%2 == 0){
            if(!(A[i]%3 == 0 || A[i]%5 == 0)){
                cnt = cnt - 1;
                //printf("  %d\n", cnt);
            }
        }
    }
    
    if(cnt <= 0){
        printf("DENIED");
    }else{
        printf("APPROVED");
    }
    
}


Measured memory_bytes: 1700
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void die() {
  cout << "-1\n";
  exit(0);
}

void solve() {
  int n;
  cin >> n;
  vector<int> v;
  v.push_back(0);
  for(int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    v.push_back(t);
  }
  vector<int> ret;
  for(int turn = n; turn > 0; turn--) {
    bool found = false;
    for(int i = turn; !found && i >= 1; i--) {
      if(v[i] == i) {
        ret.push_back(i);
        v.erase(v.begin() + i);
        found = true;
      }
    }
    if(!found) die();
  }
  reverse(ret.begin(), ret.end());
  for(int out: ret) cout << out << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


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

if __name__ == "__main__":
    n, a, b = map(int, input().split())

    val = 0
    for i in range(1, n+1):
        dum = 0
        for j in str(i):
            dum += int(j)

        if a <= dum <= b:
            val += i

    print(val)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, A[CMax], B[CMax], C[CMax], ib, ic;
long long ats, BC[CMax];

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    sort(A, A+n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &B[i]);
    }
    sort(B, B+n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &C[i]);
    }
    sort(C, C+n);

    ic = 0;
    for (int i = 0; i < n; i++) {
        while (ic < n && B[i] >= C[ic]) ic++;
        BC[i] = (long long)n - ic;
    }

    for (int i = n-2; i >= 0; i--) {
        BC[i] += BC[i+1];
    }

    ib = 0;
    for (int i = 0; i < n; i++) {
        while (ib < n && A[i] >= B[ib]) ib++;
        ats += BC[ib];
    }

    printf("%lld\n", ats);
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    cin >> K;
    ll a = K/2;
    ll b = (K+1)/2;
    
    cout << a*b << endl;
    return 0;
}

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

using namespace std;

int main() {

    int n;
    cin >> n;

    int a[4],sum;
    a[0] = n/1000;
    a[1] = (n%1000)/100;
    a[2] = (n%100)/10;
    a[3] = n % 10;

    bool op[3] = {false};
    int m[8] = {1,1,1,1,0,0,0,0};
    int p[8] = {1,1,0,0,1,1,0,0};
    int o[8] = {1,0,1,0,1,0,1,0};

    for(int i = 0;i < 8;i++){
        sum = a[0];
        op[0] = false;
        op[1] = false;
        op[2] = false;
        if(m[i] == 1) op[0] = true;
        if(p[i] == 1) op[1] = true;
        if(o[i] == 1) op[2] = true;
        for(int l = 0;l < 3;l++){
            if(op[l]) sum += a[l+1];
            else sum -= a[l+1];
        }
        if (sum == 7) goto END;       
        
    }
    END:

    cout << a[0];

    for(int i = 0;i < 3;i++){
        if(op[i]) cout << "+";
        else cout << "-";
        cout << a[i+1];
    }

    cout << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
typedef  long long int lli;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inf (1000*1000*1000+5)
const int NODE =1e4+9;

const int mod=1e9+7;
const lli num=1e5+5;

void init(){

}


int main()
{
   boost;
   int t=1;
   //cin>>t;
   init();
   while(t--){
      int n,k;
      cin>>n>>k;
      int a[n];
      for(int i=0;i<n;i++)cin>>a[i];
      int dp[k+1];
      memset(dp,false,sizeof(dp));
      for(int i=0;i<=k;i++){
         for(auto x:a){
            if(i>=x && !dp[i-x])dp[i]=true;
         }
      }
      if(dp[k])cout<<"First\n";
      else cout<<"Second\n";
      
   }
   return 0;
}


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

char s[128],p[128];
int l_s,l_p,count=0;

void check(int num){
	int i;
	count=0;
	for(i=0;i<l_p;i++){
		if(num==l_s){
			num=0;
		}
		if(p[i]==s[num]){
			//printf("%c\n",s[num]);
			count++;
		}else{
			break;
		}
		num++;
	}
}

int main(){
	int i,j;
	
	fgets(s,sizeof s,stdin);
	fgets(p,sizeof p,stdin);
	
	l_p=strlen(p);
	l_s=strlen(s);
	
	//\0???????????°????????????
	l_p--;
	l_s--;
	
	for(i=0;i<l_s;i++){
		if(p[0]==s[i]){
			check(i);
			if(count==l_p){
				break;
			}
		}
	}
	if(count==l_p){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 2628
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll cost;
};


///////////////////////////

vector <vector<edge>> g;

vector<ll> tar;

vector<ll> see;

vector<ll> ans;

ll dfs(ll v) {
	ll ret = tar[v];

	see[v] = 1;
	
	for (edge e : g[v]) {
		if (see[e.to] == 0) {
			ll t=dfs(e.to);
			ans[e.ind] = t;
			ret += t;
		}
	}

	return ret;

}

int main() {

	
	ll N, M;
	cin >> N >> M;

	vector<pair<ll, ll>> bomb(N + 1, { 0,0 });

	repn(i, N) cin >> bomb[i].first >> bomb[i].second;

	sort(bomb.begin(), bomb.end());


	vector<ll> L(M + 1), R(M + 1);

	repn(i, M) cin >> L[i] >> R[i];

	vector<ll> cdon(M + 1), cdof(M + 1);

	vector<ll> bomf(N + 1);
	repn(i, N) bomf[i] = bomb[i].first;
	
	repn(i, M) {
		auto itr = lower_bound(bomf.begin(), bomf.end(), L[i]);
		cdon[i] = distance(bomf.begin(), itr);

		itr = upper_bound(bomf.begin(), bomf.end(), R[i]);
		cdof[i] = distance(bomf.begin(), itr);
	}

	

	

	g.resize(N + 2);

	repn(i, M) {
		if (cdon[i] == cdof[i]) { continue; }
		g[cdon[i]].push_back({ i,cdon[i],cdof[i],0 });
		g[cdof[i]].push_back({ i,cdof[i],cdon[i],0 });
	}

	tar.assign(N + 2, 0);

	repn(i, N) {
		if (bomb[i].second != bomb[i - 1].second) { tar[i] = 1; }
	}

	tar[N + 1] = bomb[N].second;

	see.assign(N + 2, 0);

	ans.assign(M + 1, 0);

	ll b = 1;

	repn(i, N+1) {
		if (see[i] == 1) { continue; }

		ll x = dfs(i);
		if (x % 2 == 1) { b = 0; }
	}

	if (b == 0) { cout << -1; }

	else {
		ll k = 0;
		vector<ll> c;

		repn(i, M) {
			if (ans[i] % 2 == 1) {
				k++;
				c.push_back(i);
			}
		}

		cout << k <<endl;
		rep(i, k) { cout << c[i] << " "; }
	}


	system("PAUSE");

	

}


Measured memory_bytes: 37628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

ll l[123456],r[123456];
vector<P> lv,rv;

bool comp(P a, P b){
	return a.first > b.first;
}

priority_queue<P> pql,pqr;
bool used[100100];

int main(void){
	int n,i;
	P p;
	ll l,r,ans=-INFLL,tmp=0ll;
	bool flag=false;
	fill(used,used+100100,false);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> l >> r;
		pql.push(P(l,i));
		pqr.push(P(-r,i));
	}
	while(true){
		while(true){
			if(pql.empty()){
				flag = true;
				break;
			}
			p = pql.top();
			if(used[p.second]){
				pql.pop();
				continue;
			}
			l = p.first;
			used[p.second] = true;
			pql.pop();
			ans = max(ans,tmp+l);
			break;
		}
		while(true){
			if(pqr.empty()){
				flag = true;
				break;
			}
			p = pqr.top();
			if(used[p.second]){
				pqr.pop();
				continue;
			}
			r = p.first;
			used[p.second] = true;
			pqr.pop();
			ans = max(ans,tmp+r);
			break;
		}
		if(flag){
			break;
		}
		tmp += (l+r);
		ans = max(ans,tmp);
	}
	cout << (ans*2) << endl;
	return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a[9]={111,222,333,444,555,666,777,888,999};
    int N; cin>>N;
    cout<<*lower_bound(a,a+9,N)<<endl;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
hlist = list(map(int, input().split()))
oklist=[1]*n
for i in range(m):
    a, b = map(int,input().split())
    a-=1
    b-=1
    if hlist[a]==hlist[b]:
        oklist[a]=0
        oklist[b]=0
    elif hlist[a]>hlist[b]:
        oklist[b]=0
    else:
        oklist[a]=0

print(sum(oklist))

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

int main()
{
  ll n; cin >> n;
  ll m; cin >> m;
  vector<ll> s(m);
  vector<ll> c(m);
  for (int i=0; i<m; i++){
    cin >> s[i];
    cin >> c[i];
    s[i]--;
  }
  vector<ll> d(n, -1);
  rep(i, m) {
    if (d[s[i]] == -1) {
      d[s[i]] = c[i];
    } else if (d[s[i]] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n>1) {
    if (d[0]==0) {
      cout << -1 << endl;
      return 0;
    }
    ll ans = 0;
    rep(i, n) {
      if (d[i]==-1) {
        if (i==0) d[i]=1;
        else d[i]=0;
      }
      ans = ans*10 + d[i];
    }
    cout << ans << endl;
  } else {
    cout << max(0LL, d[0]) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#define MAXSIZE 101
#define PI 3.141592653589
using namespace std;

class Dice{
public:
  Dice(){}
  int face[7];
  void move(char s){
    if(s=='S'){
      int tmp;
      tmp=face[1];
      face[1]=face[5];
      face[5]=face[6];
      face[6]=face[2];
      face[2]=tmp;
    }else if(s=='E'){
      int tmp;
      tmp=face[1];
      face[1]=face[4];
      face[4]=face[6];
      face[6]=face[3];
      face[3]=tmp;
    }else if(s=='N'){
      int tmp;
      tmp=face[1];
      face[1]=face[2];
      face[2]=face[6];
      face[6]=face[5];
      face[5]=tmp;
    }else if(s=='W'){
      int tmp;
      tmp=face[1];
      face[1]=face[3];
      face[3]=face[6];
      face[6]=face[4];
      face[4]=tmp;
    }
  }
};

int main(){
    Dice dice1;
    for(int i=1;i<=6;i++){
      std::cin >> dice1.face[i];
    }
    char c[100];
    std::cin >> c;
    for(int i=0;;i++){
      if(c[i]=='S'||c[i]=='E'||c[i]=='N'||c[i]=='W'){
        dice1.move(c[i]);
      }else{
        break;
      }
    }

    std::cout << dice1.face[1] << '\n';


}

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

int main(){
  int n; cin >> n;
  int a[n+1]; a[0] = 0;
  for(int i=0; i<n; i++){
    int x; cin >> x;
    a[x] = i+1;
  }

  for(int i=1; i<=n; i++){
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int main(){
    int a, b, c;
    int cnt = 0;

    cin >> a >> b >> c;

    if(a == b && b == c && c == a) {
        cout << 1 << endl;
        return 0;
    }else if ((a == b && a == c) || (b == c && b == a) || (c == a && c == b)){
        cout << 2 << endl;
        return 0;
    }else if (a == b || b == c || c == a){
        cout << 2 << endl;
        return 0;
    }
    

    cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    a=int(input())
    b=int(input())
    c=int(input())
    d=int(input())
    e=int(input())
    print(-(-n//min(a,b,c,d,e))+4)

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}
#define N_MAX 200
#define W_MAX 200000
ll dp[N_MAX][W_MAX];

int main() {
  ll N, W; cin >> N >> W;
  vector<ll> w(N+1), v(N+1);
  for(int i=1; i<=N; ++i) cin >> w[i] >> v[i];
  for(int i=1; i<=N; ++i) {
    for(int j=0; j<w[i]; ++j) {
      chmax(dp[i][j], dp[i-1][j]);
    }
    for(int j=w[i]; j<=W; ++j) {
      chmax(dp[i][j], dp[i-1][j-w[i]]+v[i]);
      chmax(dp[i][j], dp[i-1][j]);
    }
  }
  ll ans=0;
  // Output DP table
//  rep(i,N+1) {
//    rep(j,W+1) {
//      cout << dp[i][j] << " ";
//    }
//    cout << endl;
//  }
  rep(i, N+1) chmax(ans, dp[i][W]);
  cout << ans << endl;
}


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

template <class T>
inline bool read(T &ret)
{
    char c;
    int sgn;
    if (c = getchar(), c == EOF)
    {
        return 0;
    }
    while (c != '-' && (c < '0' || c > '9'))
    {
        c = getchar();
    }
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0');
    }
    ret *= sgn;
    return 1;
}

template <class T>
inline void write(T x)
{
    if (x > 9)
    {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}

const int MAXN=100010;
int a[MAXN];
int n;

int main()
{
    cin>>n;
    int l=1;
    int ans=-1;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    while(l<=n)
    {
        int r=l;
        for(r;r<=n;r++)
        {
            if(a[r]<a[r+1])
                break;
        }
        if(r>n)
            r=n;
        ans=max(ans,r-l);
        l=r+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	long f(long x) {
		if (x == 0) {
			return 0;
		}
		return 1 + f(x / 2) * 2;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long H = sc.nextLong();

		sc.close();

		out.println(f(H));

	}

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


Measured memory_bytes: 22740
#include<stdio.h>
#define M 100000000
int main(){
  int n,m,min,mi,i,j,k,s;
  int d[10][10];
  while(scanf("%d",&n),n){
    min=M;
    for(i=m=0;i<100;i++)d[i/10][i%10]=M;
    while(n--){
      scanf("%d %d %d",&i,&j,&k);
      d[i][j]=d[j][i]=k;
      d[i][i]=d[j][j]=0;
      if(m<i)m=i;
      if(m<j)m=j;
    }
    m++;
    for(k=0;k<m;k++){
      for(i=0;i<m;i++){
	for(j=0;j<m;j++){
	  if(d[i][j]>d[i][k]+d[k][j])d[i][j]=d[i][k]+d[k][j];
	}
      }
    }
    for(i=0;i<m;i++){
      for(j=s=0;j<m;j++){
	if(d[i][j]==M)continue;
	s+=d[i][j];
      }
      if(min>s){
	min=s;
	mi=i;
      }
    }
    printf("%d %d\n",mi,min);
  }
  return 0;
}

Measured memory_bytes: 600
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize x:i64)(list:[i64]));
    let mut list = list;
    list.sort();
    let mut x = x;
    let mut count = 0;
    let mut zeroc = 0;
    for i in list {
        if i <= x {
            x -= i;
            count += 1;
        } else {
            zeroc += 1;
        }
    }
    if x != 0 && count != 0 && zeroc == 0 {
        count -= 1;
    }
    count.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 70\n20 30 10" => "2",
    test2: "3 10\n20 30 10" => "1",
    test3: "4 1111\n1 10 100 1000" => "4",
    test4: "2 10\n20 20" => "0",
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=400010;
int X;
int main()
{
	X=gi();
	for(int a=-500;a<=500;a++)
		for(int b=-500;b<=500;b++)
			if(1ll*a*a*a*a*a-1ll*b*b*b*b*b==X)
				return printf("%d %d\n",a,b),0;
	return 0;
}


Measured memory_bytes: 3764
n=input()[::-1]
ans=0
flag=0
for i in range(len(n)):
    a=int(n[i])
    a+=flag
    if a==5 and i+1<len(n) and int(n[i+1])>=5:
        ans+=10-a
        flag=1
    elif a<=5:
        ans+=a
        flag=0
    else:
        ans+=10-a
        flag=1
ans+=flag
print(ans)

Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int k,a,b;cin>>k>>a>>b;
  if(b-a<=2 || k+1<=a){
    cout<<k+1<<endl;
    return 0;
  }
  
  //int ans=0;
  k-=(a-1);
  cout<<a+(b-a)*(k/2)+(k%2)<<endl;
  
  return 0;
}


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

int main() {
  int N;
  double sum=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=(double)1/A.at(i);
  }
  cout << fixed << setprecision(10) << 1/sum << endl;
} 

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (s); i < (e); ++i)
#define per(i,s,e) for(int i = (s)-1; i >= e; --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<typename T, size_t N, typename U>
void Fill(T (&a)[N], const U&v){
    std::fill((U*)a,(U*)(a+N),v);
}

int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(auto&e : v){
    cin >> e;
  }
  sort(v.begin(),v.end());
  ll ans = 0;
  per(i,n,0){    
    int a = v[i];
    per(j,i,0){
      int b = v[j];
      int ks = lower_bound(v.begin(), v.end(), a-b+1) - v.begin();
      if(ks >= j)break;
      rep(k,ks,j){
	ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b;
    a = sc.nextInt();
    b = sc.nextInt();

    if(a < b){
      System.out.println("a < b");
    }else if(a > b){
      System.out.println("a > b");
    }else{
      System.out.println("a == b");
    }
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int main(){
  int N,b=1,count=0;  
  cin >> N;
  vector<int>vec(N);
  for(int i=0; i<N ;i++){
    cin >> vec.at(i);}
  
  for(;;){
    b = vec.at(b-1);    //b番目のボタン＝b番目のボタンに書いてある番号
    count++;
    
    if( b == 2 ){
      cout << count << endl;
      break;}
    
    if( count > N ){
      cout << "-1" << endl;
      break;}
  }
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    M = [0]*(N+1)
    for i in range(1,N+1):
        for j in range(i, N+1, i):
            M[j] += 1
    ans = 0
    for i in range(1, N+1):
        ans += i * M[i]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 151540
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Arrays;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s =sc.next();
		
		if(s.charAt(s.length()-1)=='s') {
			System.out.println(s+"es");
		}else {
			System.out.println(s+'s');
		}
	}

}

Measured memory_bytes: 26996
ABC = list(map(int, input().split()))

ans = 0
while True:
    ABC.sort()
    diff = ABC[2] - ABC[0]
    if diff >= 2:
        ABC[0] += 2
    elif diff == 1:
        ABC[2] -= 1
    else:
        break
    ans += 1

print(ans)


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<ll> p, q, r;

	rep(i,a){
		int t;cin >> t;
		p.push(t);
	}
	rep(i,b){
		int t;cin >> t;
		q.push(t);
	}
	rep(i,c){
		int t;cin >> t;
		r.push(t);
	}

	ll ans = 0;
	rep(i,x){
		ll t = p.top();p.pop();
		r.push(t);
	}
	rep(i,y){
		ll t = q.top();q.pop(); 
		r.push(t);
	}
	rep(i,x+y){
		ans += r.top();r.pop();
	}

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


Measured memory_bytes: 8048
#include<stdio.h>
int main(){
	int n,hitcount=0,outcount=0,point=0;
	char s[8];
	scanf("%d",&n);
	while(1){
		scanf("%s",&s);
		if(s[1]=='U')outcount++;
		if(outcount==3){
			printf("%d\n",point);
			point=0;
			n--;
			outcount=0;
			hitcount=0;
		}
		if(!n)break;
		if(s[1]=='I')hitcount++;
		if(hitcount==4){
			point++;
			hitcount=3;
		}
		if(s[1]=='O'){
			point+=hitcount;
			hitcount=0;
			point++;
		}
	}
	return 0;
}

Measured memory_bytes: 596
module Main where

import Debug.Trace

main :: IO ()
main = do
  [s, c] <- map read . words <$> getLine
  print $ solve s c


solve :: Int -> Int -> Int
solve 0 0 = 0
solve s c = --(s, c) `traceShow`
  if s * 2 > c then c `div` 2 else s + solve ((c - s * 2) `div` 4) ((c - s * 2) `div` 2)


Measured memory_bytes: 508
def solve():
    from sys import stdin
    f_i = stdin
    
    while True:
        H, W = map(int, f_i.readline().split())
        if H == 0:
            break
        
        mp = ['X'] * (W + 2)
        for i in range(H):
            mp += list('X' + f_i.readline().rstrip() + 'X')
        mp += ['X'] * (W + 2)
        
        direction = (W + 2, -W - 2, -1, 1)
        ans = 0
        for i in range(W + 3, (W + 2) * (H + 1), W + 2):
            for j in range(i, i + W):
                f = mp[j]
                if f != 'X':
                    mp[j] = 'X'
                    parcel = [j]
                    while parcel:
                        p = parcel.pop()
                        for d in direction:
                            adj = p + d
                            if mp[adj] == f:
                                parcel.append(adj)
                                mp[adj] = 'X'
                    ans += 1
        print(ans)

solve()


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

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;

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

    int n, m;
    cin >> n >> m;
    vector<vi> prev(n + 1), next(n + 1);
    vi in(n + 1), dist(n + 1);
    int ans = 0, u, v;
    
    for (int i = 0; i < m; ++i) {
        cin >> u >> v;
        prev[v].push_back(u);
        next[u].push_back(v);
        ++in[v];
    }

    queue<int> q;
    for (int i = 1; i <= n; ++i) {
        if (in[i] == 0) {
            q.push(i);
        }
    }

    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int vp : prev[v]) {
            dist[v] = max(dist[v], dist[vp] + 1);
        }
        ans = max(ans, dist[v]);
        for (int vn : next[v]) {
            --in[vn];
            if (in[vn] == 0) {
                q.push(vn);
            }
        }
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

vi to[200005];
ll ans[200005];

void dfs(int u=0, int k=-1) {
  for (int v: to[u]) {
    if (v == k) continue;
    ans[v] += ans[u];
    dfs(v, u);
  }
}
int main() {
  int n,q; cin >> n >> q;
  rep(i,n-1) {
    int a,b; cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,q) {
    int p,x; cin >> p >> x;
    p--; ans[p]+=x;
  }
  dfs();
  rep(i,n) printf("%lld%c", ans[i], i==n-1?'\n':' ');
  return 0;
}

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

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

  int longs ;
  longs = s.length();

  int j = 0;

  rep(i, longs / 2){
    if(s.at(i) != s.at(longs - (i + 1))) j++;
  }

  //if(longs % 2 == 0){
    //rep(i, longs / 2){
      //if(s.at(i) != s.at(longs / 2 - i)) j++;
    //}
  //}
  //else{
    //rep(s.at())
  //}
//}

cout << j << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int prime(int n)
{
 for(int i=2;i*i<=n;i++)
      {
          if(n%i==0)
          return 0;
      }
      return 1;
}
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
        string s;
        int n;
        cin>>n;
        std::map<string,int>m;
        for(int i=0;i<n;i++)
        {
            cin>>s;
            m[s]++;
            
        }
        int max=0;
        for(const auto&x:m)
        {
            int v=x.second;
            if(v>max)
            max=v;
        }
        for(auto x1:m)
        {
            if(x1.second==max)
            {
                cout<<x1.first<<"\n";
            }
        }
    }
    
}
// 🍪 🍪 🍪


Measured memory_bytes: 19260