akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ACantWaitForHoliday {
public:
	void solve(std::istream& in, std::ostream& out) {
        string t;
        in >> t;
        vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == t) {
                out << 7-i << endl;
                return ;
            }
        }
    }
};


int main() {
	ACantWaitForHoliday solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    char S[3],T[3];
    int ans;
    scanf("%s%s",S,T);
    for (int i = 0; i<3; i++) {
        if (S[i] == T[i]) {
            ans++;
        }
    }
    printf("%d",ans);
    
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n;
    double sub=0,b=0,ans=0;
    
    while(1){
    int s[1000]={};
    double ave=0,cnt=0;
    
    cin>>n;
    if(n==0) break;
    
    for(int i=0;i<n;i++){
        cin>>s[i];
        ave+=s[i];
    }
    ave/=n;
    
    for(int i=0;i<n;i++){
        sub=s[i]-ave;
        b=sub*sub;
        cnt+=b;
    }
    cnt=cnt/n;
    ans=sqrt(cnt);
    cout<<fixed<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    int d[c][c];
    REP(i, c)REP(j, c) cin >> d[i][j];

    int color_cnt[3][c];
    REP(i, 3)REP(j, c) color_cnt[i][j] = 0;
    REP(i, n)REP(j, n) {
        int color;
        cin >> color;
        color_cnt[(i + j) % 3][color - 1]++;
    }
    
    ll ans = 1001001001001001001;
    REP(i, c)REP(j, c)if(i != j)REP(k, c)if(i != k and j != k) {
        int c_map[3];
        c_map[0] = i;
        c_map[1] = j;
        c_map[2] = k;
        ll d_sum =0;
        REP(mod, 3)REP(color, c)
            d_sum += color_cnt[mod][color] * d[color][c_map[mod]];
        ans = min(ans, d_sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
import numpy as np

H, W = map(int, input().split())
c = [input() for _ in range(H)]
si = sj =0

dist = [[-1] * W for _ in range(H)]
dist[0][0] = 0
queue = deque()
queue.append((0,0))
move = [(1, 0), (0, 1)]#,(-1,0),(0,-1)]
while queue:
    i, j = queue.popleft()
    for di, dj in move:
        ni, nj = i+di, j+dj
        if 0 <= ni < H and 0 <= nj < W and dist[ni][nj] == -1:
            if c[ni][nj] == c[i][j]:
                dist[ni][nj] =dist[i][j]
                queue.appendleft((ni,nj))
            else:
                dist[ni][nj] =dist[i][j] +1
                queue.append((ni,nj))

if dist[-1][-1]%2==1:
  ans=dist[-1][-1]//2+1
else:
  if c[0][0]==".":
    ans=dist[-1][-1]//2
  else:
    ans=dist[-1][-1]//2+1

print(ans)


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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  for(int i =100; i > 0; i--){
    if(A % i == 0 && B % i == 0){
      K--;
      if(K == 0){
        cout << i << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = 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 fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using vi = vector<int>;

vi in(){
    int w;
    cin >>w;

    vi p(3);
    iota(all(p),0);

    rep(i,w){
        int a;
        cin >>a;
        swap(p[a],p[a+1]);
    }

    return p;
}

bool solve(){
    vi p(3);
    iota(all(p),0);

    vector<vi> v;
    map<vi,int> m;
    do{
        m[p] = v.size();
        v.pb(p);
    }while(next_permutation(all(p)));

    int n;
    cin >>n;

    int ct[6]={};
    int loop[6]={1,2,2,3,3,2};
    rep(i,n){
        vi amida = in();
        ++ct[m[amida]];
    }

    rep(i,6){
        if(ct[i]>=loop[i]) return true;
    }

    vi x;
    rep(i,6)rep(j,ct[i]) x.pb(i);
    int X = x.size();

    vi E(3);
    iota(all(E),0);

    do{
        vi t(3);
        iota(all(t),0);

        rep(i,X){
            vi nt(3);
            vi f = v[x[i]];
            rep(j,3) nt[j] = t[f[j]];
            t = nt;
            if(t==E) return true;
        }
    }while(next_permutation(all(x)));

    return false;
}

int main(){
    cout << (solve()?"yes":"no") << endl;
    return 0;
}



Measured memory_bytes: 3172
n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
s.sort()


def num_cmb(a, b):
    enum = 1
    denom = 1
    for i in range(b):
        enum *= (a - i)
        denom *= (b - i)
    return enum // denom


sum = 0
count = 1
prev = s[0]
for s_i in s[1::]:
    if prev == s_i:
        count += 1
    else:
        sum += num_cmb(count, 2)
        count = 1
        prev = s_i
if 0 < count:
    sum += num_cmb(count, 2)
print(sum)


Measured memory_bytes: 10988
# AOJ 0013 Switching Railroad Cars
# Python3 2018.6.9 bal4u

class Stack:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return self.items == []

    def push(self, item):
        self.items.append(item)

    def pop(self):
        return self.items.pop()

    def peek(self):
        return self.items[len(self.items)-1]

    def size(self):
        return len(self.items)

s = Stack()
while True:
    try:
        a = int(input())
        if a > 0:
            s.push(a)
        else:	
            print(s.pop())
    except EOFError:
        break


Measured memory_bytes: 5592
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
answer = [1]*N

for i in range(M):
	if H[AB[i][0]-1] > H[AB[i][1]-1]:
		answer[AB[i][1]-1] = 0
	elif H[AB[i][0]-1] == H[AB[i][1]-1]:
		answer[AB[i][1]-1] = 0
		answer[AB[i][0]-1] = 0
	else:
		answer[AB[i][0]-1] = 0

print(sum(answer))

Measured memory_bytes: 96492
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BCollectingBallsEasyVersion {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, k;
	    in >> n >> k;
	    vector<int> x(n);
	    for(int i=0; i<n; i++){
	        in >> x[i];
	    }

	    for(int i=0; i<n; i++){
	        if(abs(k-x[i]) < x[i]) x[i] = abs(k-x[i]);
	    }
	    ll res = 0;
	    for(int i=0; i<n; i++){
	        res += x[i];
	    }

	    out << res*2 << endl;
	}
};


int main() {
	BCollectingBallsEasyVersion solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

void solve()
{
    int n;
    string s;
    cin >> n >> s;
    int x = 0, ans = 0;
    rep(i, n)
    {
        if (s[i] == 'I')
            x++;
        else
            x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    printf("%lf",acos(-1)*read()*2);
    output();
    return 0;
}

Measured memory_bytes: 3764
MOD = 10**9+7
# dp[i][j] := Sの後ろからi桁を13で割った余りがjとなるようなものの個数
S = input()
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
mul = 1
l = len(S)
for i in range(len(S)):
    x = S[-(i+1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= MOD
    else:
        k = int(x) # これしか選ぶ余地なし
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= MOD
    mul = mul * 10 % 13
print(dp[len(S)][5])


Measured memory_bytes: 62300
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	nums := map[int]int{}
	for i := range as {
		nums[as[i]]++
	}
	combiNum := 0
	for _, v := range nums {
		combiNum += v * (v - 1) >> 1
	}
	for _, v := range as {
		num := nums[v]
		fmt.Println(combiNum - (num - 1))
	}
	return
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 14472
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll k=n%10;
    if(k==0 || k==1 ||k==6 || k==8)
    {

        cout<<"pon"<<endl;
    }
    else if(k==3)
    {
        cout<<"bon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }



}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

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

Measured memory_bytes: 768
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var h = cin.nextLong();
            var w = cin.nextLong();

            if(w == 1 || h == 1)
            {
                Console.WriteLine(1);
                return;
            }

            var ww = (w + 1) / 2;
            var ww2 = w / 2;
            var hh = (h + 1) / 2;
            var hh2 = h / 2;            
            
            Console.WriteLine(ww * hh + ww2 * hh2);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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

const ll MOD = 2019;


int main(int argc, char* argv[]) {
	
	string s;
	cin >> s;

	vector<int> dp(s.length() + 1);

	int p10 = 1;
	for (int i = s.length() - 1; i >= 0; i--) {
		dp[i] = (dp[i + 1] + p10 * (s[i] - '0')) % MOD;
		p10 = (p10 * 10) % MOD;
	}

	map<int, int> m;
	for (int d : dp) {
		m[d]++;
	}

	int ans = 0;
	for (int i = 0; i < MOD; i++) {
		ans += (m[i] * (m[i] - 1)) / 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4432
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		long H = nl();
		long tmp = 1;
		long result = 0;
		while(H >= 1) {
			result += tmp;
			H /= 2;
			tmp *= 2;
		}
		System.out.println(result);
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

using namespace std;

int main() {
	int n;
	long long k;
	cin >> n >> k;
	map<int, long long> cnt;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a] += b;
	}
	long long num = 0;
	for (auto&& i : cnt) {
		num += i.second;
		if (k <= num) {
			cout << i.first << "\n";
			return 0;
		}
	}
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    bool one = false;
    rep(i, n) {
        char c;
        cin >> c;
        a[i] = c - '0';
        a[i]--;
        if (a[i]%2==1) one = true;
    }
    if (!one) {
        rep(i, n) a[i] /= 2;
    }
    int ans = 0;
    int nt = n - 1;
    vi tb;
    while (nt) {
        tb.push_back(nt%2);
        nt /= 2;
    }
    for (int i=0; i<n; i++) {
        int it = i;
        int tmp = 1;
        for (int tf : tb) {
            if (tf==0&&it%2==1) {
                tmp *= 0;
                break;
            }
            tmp *= 1;
            it /= 2;
        }
        ans = (ans + tmp * a[i]) % 2;
    }
    if (!one) ans *= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
    int a, b, c;
    char line[256];

    memset(line, 0, sizeof(line));
    if (!fgets(line, sizeof(line), stdin)) {
        fprintf(stderr, "error input val\n");
        return -1;
    }

    if (sscanf(line, "%d %d %d", &a, &b, &c) != 3) {
        fprintf(stderr, "error input format\n");
        return -1;
    }
    printf("%s\n", (a<b && b<c) ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 588
A =input().split()
r = int(A[0])
D = int(A[1])
x_2000 = int(A[2])

#def x(i+1):
#    global x_2000
#    x(2000) = x_2000
#    x = r*x(i) - D
#    return(x)
ans = list()
ans.append(x_2000)
for i in range(1,11):
    ans.append(r*ans[i-1] - D)

for i in range(1,len(ans)):
    print(ans[i])

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

#define MAX_V 100010

bool used[MAX_V] = {false};
int ord[MAX_V], lowlink[MAX_V];
vector<int> g[MAX_V];
vector<int> ans;

int dfs(int u, int p, int k) {
	used[u] = true;
	ord[u] = lowlink[u] = k++;

	bool is_articulation = false;
	int child_cnt = 0;

	for (auto v : g[u]) { // u -> v
		if (not used[v]) {
			child_cnt++;
			dfs(v, u, k);
			lowlink[u] = min(lowlink[u], lowlink[v]);
			if (p != -1 and ord[u] <= lowlink[v]) is_articulation = true;
		} else if (v != p) {
			lowlink[u] = min(lowlink[u], ord[v]);
		}
	}

	if (p == -1 and child_cnt > 1) is_articulation = true;
	if (is_articulation) ans.push_back(u);
}

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x, y; cin >> x >> y;
		g[x].push_back(y), g[y].push_back(x);
	}
	for (int i = 0; i < n; ++i) {
		if (not used[i]) dfs(i, -1, 0);
	}
	sort(ans.begin(), ans.end());
	for (auto u : ans) cout << u << endl;
	return 0;
}



Measured memory_bytes: 6968
<?php

fscanf(STDIN, "%d %d", $n, $x);
$a = [];
$a[0] = 1;
$p = [];
$p[0] = 1;
for ($i = 1; $i < 51; ++$i) {
    $a[$i] = $a[$i - 1] * 2 + 3;
    $p[$i] = $p[$i - 1] * 2 + 1;
}

function search($n, $x) {
    global $a, $p;
    if ($n == 0) { 
        if ($x == 0) return 0;
        if ($x == 1) return 1;
    }

    if ($x == 1) return 0;
    if ($x < $a[$n - 1] + 2) return search($n - 1, $x - 1);
    if ($x == $a[$n - 1] + 2) return $p[$n - 1] + 1;
    if ($x < 2 * $a[$n - 1] + 3) return $p[$n - 1] + 1 + search($n - 1, $x - ($a[$n - 1] + 2));
    if ($x == 2 * $a[$n - 1] + 3) return 2 * $p[$n - 1] + 1;
}

echo search($n, $x), PHP_EOL;


Measured memory_bytes: 16268
# https://atcoder.jp/contests/abc107/tasks/arc101_a
# C - Candles

n, k = list(map(int, input().split()))
x_list = list(map(int, input().split()))
x_list = sorted(x_list)
min_l = float('inf')

minus_list = [x for x in x_list if x < 0]
plus_index = len(minus_list)

for i, x in enumerate(x_list):
    left, right = x_list[i], x_list[i+k-1]
    # 最左端に行ってから、最右端に行く
    a = abs(left) + abs(left-right)
    # 最右端に行ってから、最左端に行く
    b = abs(right) + abs(right - left)
    l = min(a, b)

    if l < min_l:
        min_l = l

    if i + k > n - 1:
        break

print(min_l)


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

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

  int res10000 = -1, res5000 = -1, res1000 = -1;
  for (int a = 0; a <= N; a++) {
    for (int b = 0; b + a <= N; b++) {
      int c = N - a - b;
      int total = 10000*a + 5000*b + 1000*c;
      if (total == Y) {
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }
  
  cout << res10000 << ' ' << res5000 << ' ' << res1000 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, h[max];
    int hiest, ans=1;
    
    scanf("%d", &n);
    rep(i, n){
        scanf("%d", &h[i]);
    }
    
    hiest=h[0];
    for (int i=1; i<n; i++) {
        if (hiest<=h[i]) {
            ans++;
            hiest=h[i];
        }
    }
    
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 1732
object Main {
  def main(args: Array[String]): Unit = {
    var nums = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    if(nums(1)%nums(0) == 0) {
      println(nums(0) + nums(1))
    }
    else {
      println(nums(1) - nums(0))
    }
  }
}

Measured memory_bytes: 25424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


const int inf = 1000000000;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s.at(i);
	int cnt = 0, num = inf;
	rep(i,h){
		rep(j,w){
			if(s[i][j] == '.') cnt++;
		}
	}
	queue<pair<pii,int>> q;
	q.push(mp(mp(0,0),1));
	while(!q.empty()){
		pii cur = q.front().first;
		int k = q.front().second;
		q.pop();
		if(cur.first + 1 == h && cur.second + 1 == w){
			num = min(num, k);
		}
		rep(i,4){
			int nexty = cur.first + dy[i], nextx = cur.second + dx[i];
			if(inside(nexty, nextx, h, w) && s[nexty][nextx] == '.'){
				q.push(mp(mp(nexty, nextx), k + 1));
				s[nexty][nextx] = '#';
			}
		}
	}
	if(num == inf) cout << -1 << endl;
	else cout << cnt - num << endl;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int N,M;
vector<pair<int,int>> adj[100001];
pair<int,int> cond[100001];

void solve(){
	
	fill(all(cond),mkp(-1,0));
	queue<int> que;
	int l = 0;
	int u = INF_32;
	que.push(1);
	cond[1] = {1,0};
	bool fix = 0;
	while(!fix && !que.empty()){
		int v = que.front();
		que.pop();
		for(auto e : adj[v]){
			int t = e.fir;
			int s = e.sec;
			if(cond[t].fir >= 0){
				if(cond[t].fir == cond[v].fir){
					if(cond[t].fir){
						int d = s - cond[v].sec - cond[t].sec;
						if(d & 1 || d <= 0 || l >= d/2 || u <= d/2){
							cout<<0<<endl;
							return;
						}else{
							l = d/2 - 1;
							u = d/2 + 1;
							fix = 1;
							break;
						}
					}else{
						int d = cond[v].sec + cond[t].sec - s;
						if(d & 1 || d <= 0 || l >= d/2 || u <= d/2){
							cout<<0<<endl;
							return;
						}else{
							l = d/2 - 1;
							u = d/2 + 1;
							fix = 1;
							break;
						}
					}
				}else{
					if(cond[t].sec != s - cond[v].sec){
						cout<<0<<endl;
						return;
					}
				}
			}else{
				if(cond[v].fir){
					u = min(u,s-cond[v].sec);
					if(u <= 1){
						cout<<0<<endl;
						return;
					}
					cond[t] = {0,s-cond[v].sec};
				}else{
					l = max(l,cond[v].sec-s);
					cond[t] = {1,s-cond[v].sec};
				}
				que.push(t);
			}
		}
		
	}
	
	if(!fix){ cout<<u-l-1<<endl; return; }
	
	int val[100001] = {};
	queue<int> que2;
	que2.push(1);
	val[1] = l+1;
	while(!que2.empty()){
		int v = que2.front();
		que2.pop();
		for(auto e : adj[v]){
			int t = e.fir;
			int s = e.sec;
			if(val[t]){
				if(val[v] + val[t] != s){ cout<<0<<endl; return; }
			}else{
				if(s - val[v] <= 0){ cout<<0<<endl; return; }
				val[t] = s - val[v];
				que2.push(t);
			}
		}
	}
	
	cout<<1<<endl;
	
	return;
}

void input(){
	
	cin>>N>>M;
	int u,v,s;
	rep(i,M){
		cin>>u>>v>>s;
		adj[u].pub({v,s});
		adj[v].pub({u,s});
	}
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





Measured memory_bytes: 8064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, mm;
	cin >> nn >> mm;
	char tmp;
	bool aa[nn][nn], bb[mm][mm], flag = false;
	for(int64 ii = 0;ii < nn;ii++)
	{
		for(int64 jj = 0;jj < nn;jj++)
		{
			cin >> tmp;
			if(tmp == '#')
			{
				aa[ii][jj] = true;
			}
			else
			{
				aa[ii][jj] = false;
			}
		}
	}
	for(int64 ii = 0;ii < mm;ii++)
	{
		for(int64 jj = 0;jj < mm;jj++)
		{
			cin >> tmp;
			if(tmp == '#')
			{
				bb[ii][jj] = true;
			}
			else
			{
				bb[ii][jj] = false;
			}
		}
	}
	for(int64 ii = 0;ii <= (nn - mm);ii++)
	{
		for(int64 jj = 0;jj <= (nn - mm);jj++)
		{
			flag = true;
			for(int64 kk = 0;kk < mm;kk++)
			{
				for(int64 ll = 0;ll < mm;ll++)
				{
					if(aa[ii + kk][jj + ll] != bb[kk][ll])
					{
						flag = false;
					}
				}
			}
			if(flag)
			{
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 3612
N, K = map(int,input().split()) # 複数の数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

result = []
num = 0

for i in range(K):
    num += List[i]

result.append(num)
    
for i in range(N-K):
    num = num - List[i] + List[K+i]
    result.append(num)

print(max(result) / 2 + 0.5*K)

Measured memory_bytes: 24548
#include <iostream>
#include <fstream>
#include <list>
using namespace std;

class game{
	int length;
	int cur;
	int *r,*l;
	int r_score,l_score;
public:
	game(int _l){
		length = _l;
		r = new int [length];
		l = new int [length];
		r_score = 0;
		l_score = 0;
		cur = 0;
	}
	~game(){
		delete [] r;
		delete [] l;
	}
	void run();
	void insert(int,int);
};

void game::run(){
	for(int i = 0;i < length;i++){
		if(r[i] < l[i]){
			l_score += r[i] + l[i];
		}else if(r[i] > l[i]){
			r_score += r[i] + l[i];
		}else{
			l_score += l[i];
			r_score += r[i];
		}
	}
	cout<<l_score<<" "<<r_score<<endl;
}

void game::insert(int l_card,int r_card){
	r[cur] = r_card;
	l[cur] = l_card;
	cur++;
}

int main(){
	list<game*> lst;
	while(1){
		int read;
		cin>>read;
		if(read == 0){
			break;
		}
		game *g = new game(read);
		for(int i = 0; i < read;i++){
			int r_card,l_card;
			cin>>l_card>>r_card;
			//cout<<l_card<<","<<r_card<<endl;
			g->insert(l_card,r_card);
		}
		lst.push_back(g);
	}

	for(auto it = lst.begin();it != lst.end();it++){
		(*it)->run();
		delete (*it);
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
inline int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

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

    int n, k;
    cin >> n >> k;
    
    vector<bool> v(n+1);

    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            v[a] = true;
        }
    }

    int res = 0;

    reps(i,n){
        if(!v[i]) ++res;
    }

    cout << res << '\n';    

    return 0;
}

Measured memory_bytes: 3628
def main():
    N, K = map(int, input().split(' '))
    d = [0] * N
    total = 0
    for i in range(K):
        A = input()
        B = list(map(int, input().split(' ')))
        for j in B:
            d[j - 1] = 1
    for j in range(N):
        if d[j] == 0:
            total += 1
    print(total)
main()

Measured memory_bytes: 9176
#include <stdio.h>

int main (void)
{
int n , i , max = 0,maxi, ans = 0;
scanf("%d",&n);

int  a[n];

for(i = 0; i < n;i ++){
  scanf("%d",&a[i]);
   if(max < a[i]){
         max = a[i];
         maxi = i;
}}
for(i = 0;i < n;i++){
   if(i != maxi){
     ans += a[i];
}}


if(ans > max)
  printf("Yes\n");
else
   printf("No\n");

return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define IN(n) int n; cin>>n;
#define ARR(arr,i,n) int arr[n]; REP(i,0,n){cin>>arr[i];}
#define MOD 1000000007

using namespace std;

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

    // code comes here
    int a,b,c;
    cin>>a>>b>>c;
    if(b+c-a<0){
        cout<<"0"<<endl;
    }
    else{
        cout<<b+c-a<<endl;
    }


    return 0;
}






Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

ll a[120000];
int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	a[0] = 0;
	ll sum = 0;
	for (int i = 0; i <= n; ++i)
		sum += abs(a[i] - a[i + 1]);
	for (int i = 1; i <= n; ++i) {
		cout << sum - abs(a[i] - a[i + 1]) - abs(a[i] - a[i - 1]) + abs(a[i - 1] - a[i + 1]) << " ";
	}
	cout << "\n";
	return 0;
}




Measured memory_bytes: 2048
N,M,X = gets.split.map(&:to_i)
A = gets.strip.split.map(&:to_i)
a = 0
b = 0
for i in 0..X
    if A.include?(i)
        a += 1
    end
end
for i in X..N
    if A.include?(i)
        b += 1
    end
end

puts [a,b].min

Measured memory_bytes: 1788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        k: usize,
        mut h: [i32; n]
    }
    
    h.sort();
    
    let mut ans = 1e9 as i32;
    
    for i in 0..h.len() - k + 1 {
        ans = std::cmp::min(ans, h[i + k - 1] - h[i]);
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 6396
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("%s = %s\n", #x, to_string(x).data())
#define dbg_al(s, x) for(auto e:x)s+=to_string(e)+" "
#define dbg_rt(x) string s="[ ";dbg_al(s,x);s+="]";return s;
#define dbg_fd1 template<typename T>string to_string
#define dbg_fd2 template<typename U, typename V>string to_string
#define dbg_d1(c) dbg_fd1(c<T>);
#define dbg_d2(c) dbg_fd2(c<U, V>);
#define dbg_f1(c) dbg_fd1(c<T> v){dbg_rt(v);}
#define dbg_f2(c) dbg_fd2(c<U, V> v){dbg_rt(v);}
string to_string (char s) { return "\'"+string(1, s)+"\'"; }
string to_string (string s) { return "\"" + s + "\""; }
dbg_d1(vector) dbg_d1(set) dbg_d2(map)
dbg_fd2(pair<U, V> p) { return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
dbg_f1(vector) dbg_f1(set) dbg_f2(map)
/* ==================== */ 
const int N = 110;
int n, s[N];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", s + i);
	int sm = 0, mn = N, ans;
	for (int i = 0; i < n; i++) sm += s[i];
	if (sm % 10) ans = sm; 
	else {
		for (int i = 0; i < n; i++) if (s[i] % 10)
			mn = min(mn, s[i]);
		if (mn == N) ans = 0;
		else ans = sm - mn;
	}
	printf("%d\n", ans);
}


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

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

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

int main()
{
    int k, s;
    int result = 0;
    cin >> k >> s;
    for(int x = 0; x <= k; ++x)
    {
        for(int y = 0; y <= x; ++y)
        {
            for(int z = 0; z <= y; ++z)
            {
                if(x + y + z == s)
                {
                    if(x == y && y == z)
                    {
                        result += 1;
                    }
                    else if(x == y || y == z)
                    {
                        result += 3;
                    }
                    else
                    {
                        result += 6;
                    }
                }
            }
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main() {

	int A, i;
	int total = 0;

	cin >> A;

	for (i = 0; A >= 500; i++) {

		A = A - 500;

	}
	total = total + 1000 * i;
	for (i = 0; A >= 5; i++) {

		A = A - 5;

	}
	total = total + 5 * i;

	cout << total;

	return 0;
}

Measured memory_bytes: 256
module B
  sub Main(byval args() as string)
    dim arr() as string = split(console.readline())
    dim n,k,i as integer
  	n=arr(0):k=arr(1)
    i=1
    while n>=k
      n=math.floor(n/k)
      i+=1
    end while
    console.writeline(i)
  end sub
end module

Measured memory_bytes: 11484
n,p=map(int,input().split())
a=list(map(int,input().split()))
e=o=0
def c(a,b):
	w=1
	for i in range(a-b+1,a+1):
		w*=i
	for i in range(b):
		w//=(i+1)
	return w
for i in range(n):
	if a[i]%2==0:
		e+=1
	else:
		o+=1
if p==0:
	ans=2**e
	q=0
	for i in range(o//2+1):
		q+=c(o,2*i)
	print(ans*q)
else:
	ans=2**e
	q=0
	for i in range((o+1)//2):
		q+=c(o,2*i+1)
	print(ans*q)





Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
 
 int main() {
	 
	 int a, b;
	 cin >> a >> b;
	 
	 for (int i=0; i<=1000000; i++) {
		 if (i * 8 / 100 == a) {
			 if (i * 10 / 100 == b) {
				cout << i << endl;
				exit(0); 
			 }
		 }
	 }
	 
	 cout << -1 << endl;
	 
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = (a); i <= (b); ++i)
#define ll long long

main() {
    while(1) {
        string s;
        cin >> s;
        string t;
        cin >> t;
        if(cin.eof()) break;
        auto f = [](string s) {
            string res;
            vector<string> a;
            rep(i, s.size()) {
                if(s[i] == '\"') {
                    i++;
                    a.emplace_back(string());
                    while(s[i] != '\"') { a.back().push_back(s[i++]); }
                    res.push_back('"');
                } else
                    res.push_back(s[i]);
            }
            return make_pair(res, a);
        };
        vector<string> ss, tt;
        string S, T;
        tie(S, ss) = f(s);
        tie(T, tt) = f(t);
        if(S == T and ss == tt) {
            cout << "IDENTICAL\n";
            continue;
        }
        bool flag = true;
        if(S == T) {
            int cnt = 0;
            if(ss.size() != tt.size())
                flag = false;
            else {
                rep(i, ss.size()) cnt += ss[i] != tt[i];
                flag = cnt < 2;
            }
        } else
            flag = false;
        cout << (flag ? "CLOSE\n" : "DIFFERENT\n");
    }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll T,N,A,B,C,D;
map<ll,ll> mp;
ll dfs(ll n){
    if(mp.count(n)){
        return mp[n];
    }
    if(n==0){
        return 0;
    }
    if(n==1){
        return D;
    }
    ll res = 1e18;
    if(n < 1e18/D){
        cmin(res, D*n);
    }
    //cout << n << endl;
    ll q = n/2;
    ll r = n%2;
    cmin(res, dfs(n/2) + r*D + A);
    cmin(res, dfs((n+2-1)/2) + (2-r)*D + A);
    q = n/3;
    r = n%3;
    cmin(res, dfs(n/3) + r*D + B);
    cmin(res, dfs((n+3-1)/3) + (3-r)*D + B);
    q = n/5;
    r = n%5;
    cmin(res, dfs(n/5) + r*D + C);
    cmin(res, dfs((n+5-1)/5) + (5-r)*D + C);
    mp[n] = res;
    return res; 

}


int main(){
    cin >> T;
    rep(i,T){
        mp.clear();
        cin >> N >> A >> B >> C >> D;
        cout << dfs(N) << endl;
    }
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    ll a, v, b, w, t;
    cin>>a>>v;
    cin >> b >> w;
    cin >> t;
    if(abs(a - b) <= (v - w) * t){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll N;
    cin>>N;
    rep(i,3500)for(int j=i;j<3500;j++){
        ll h=i+1,n=j+1;
        ll a=4*h*n-N*h-N*n,b=N*h*n;
        if(a>0&&b%a==0){
            cout<<h<<" "<<n<<" "<<b/a<<"\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	long long sum = 0;
	for (int i = 0; i < N; ++ i) {
		cin >> A[i];
		A[i] += N-i;
		sum += A[i];
	}
	sort(A.begin(), A.end());
	long long b = 0;
	long long res = sum;
	long long minus = 0;
	for (int i = 0; i < N; ) {
		int m = i;
		auto d = A[i] - b;
		b = A[i];
		int n = i;
		++ i;
		while (i < N && A[i] == A[i-1]) ++ i;
		n = i - n;
		minus += d * m;
		sum -= n * d;
		sum -= (N-i) * d;
		res = min(res, sum + minus);
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u) {
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if ( u == NIL ) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if ( u == NIL ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main() {
  int i, v, l, r, root;

  scanf("%d", &n);
  for( i = 0; i < n; i++ )
    T[i].p = NIL;

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}


Measured memory_bytes: 2100