akhauriyash/Code-Regression huggingface dataset:
from math import ceil

N = int(input())
D = ceil(N/2)
A = [0] + [int(i) for i in input().split()]

boxes = [0] * (N+1) # 1-indexed

for i in range(D, N+1):
    boxes[i] = A[i]

for i in range(N-D, 0, -1):
    c = 0
    for j in range(i+i, N+1, i):
        if boxes[j]:
            c ^= 1
    if c==A[i]:
        boxes[i]=0
    else:
        boxes[i]=1

res = set()
for i in range(1, N+1):
    if boxes[i]:
        res.add(i)

print(len(res))
print(*res)

Measured memory_bytes: 17192
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc;
LL ar[500][500];
LL br[500][500];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m>>p>>q>>r;
        k=(m*r);
        l=p+(q*r);
        s=p-(q*r);
        if(abs(n-l)<=k && abs(n-s)<=k )
        {
            Y;
        }
        else
        {
            N;
        }

    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
int N,W,H,L;
vector<int> es;
vector<P> vc,now;
int mn[2010];
int A;
int inf=1e8;
void solve(int e){
//	show(e);
	now.clear();
	for(P p_:vc){
		P p=p_;
		while(p.fs<e) p.fs+=L;
		while(p.fs>p.sc) p.sc+=L;
		p.fs-=e,p.sc-=e;
		if(p.fs==0||(p.fs<=L&&L<=p.sc)) continue;
		now.pb(p);
	}
	vector<int> ash;
	ash.pb(0);
	for(P p:now) ash.pb(p.fs),ash.pb(p.sc);
	sort(all(ash));
	ash.erase(unique(all(ash)),ash.end());
	int M=ash.size();
	for(P& p:now) p.fs=lower_bound(all(ash),p.fs)-ash.begin(),p.sc=lower_bound(all(ash),p.sc)-ash.begin();
//	show(M);
//	for(P p:now) cout<<p.fs<<" "<<p.sc<<endl;
	rep(i,M+1) mn[i]=inf;
	for(P p:now) chmin(mn[p.fs],p.sc);
	for(int i=M-2;i>=0;i--) chmin(mn[i],mn[i+1]);
	int x=0,ans=0;
	while(x<inf){
		x=mn[x+1];
		ans++;
	}
//	show(ans);
	chmin(A,ans);
}
int main(){
	cin>>N>>W>>H;
	L=2*(W+H);
	rep(i,N){
		int x,y;
		char c;
		cin>>x>>y>>c;
		int t[4]={x+y+H,y-x+2*W+H,-y-x+3*H+2*W,x-y+H};
		rep(i,4) t[i]%=L;
		if(c=='E') vc.pb(P(t[0],t[1]));
		if(c=='N') vc.pb(P(t[1],t[2]));
		if(c=='W') vc.pb(P(t[2],t[3]));
		if(c=='S') vc.pb(P(t[3],t[0]));
	}
	rep(i,N) es.pb(vc[i].fs),es.pb(vc[i].sc);
//	rep(i,N) printf("(%d,%d)\n",vc[i].fs,vc[i].sc);
	A=inf;
	for(int e:es) solve(e);
//	solve(14);
	cout<<A<<endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

typedef long long ll;

int main() {
	int N;
	cin>>N;
	vector<ll> T(N),A(N),S(N);
	rep(i,N)cin>>T[i]>>A[i];
	ll t, a, k;
	rep(i,N-1){
		if(T[i+1]>=T[i])t = 1;
		if(A[i+1]>=A[i])a = 1;
		if(T[i+1]<T[i]){
			if(T[i]%T[i+1] == 0)
				t = T[i]/T[i+1];
			else
				t = T[i]/T[i+1] + 1;
		}
		if(A[i+1]<A[i]){
			if(A[i]%A[i+1] == 0)
				a = A[i]/A[i+1];
			else
				a = A[i]/A[i+1] + 1;
		}
		k = max(t,a);
		T[i+1] *= k;
		A[i+1] *= k;
	}
	ll ans = T[N-1] + A[N-1];
	print(T);print(A);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
class ABC091_d {
    public static void Main() {
        var N = int.Parse(Console.ReadLine());
        var A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var B = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        long ans = 0;
        for (var i = 0; i < 29; i++) {
            var mA = new int[N];
            var mB = new int[N];
            var mask = (1 << i + 1) - 1;
            for (var j = 0; j < N; j++) {
                mA[j] = A[j] & mask;
                mB[j] = B[j] & mask;
            }
            Array.Sort(mB);
            long count = 0;
            var T = 1 << i;
            for (var j = 0; j < N; j++) {
                var n1 = LowerBound(mB,     T - mA[j]);
                var n2 = LowerBound(mB, 2 * T - mA[j]);
                var n3 = LowerBound(mB, 3 * T - mA[j]);
                count += (n2 - n1) + (N - n3);
            }
            ans |= (count & 1) << i;
        }
        Console.WriteLine(ans);
    }
    private static int LowerBound(int[] arr, int val) {
        int left = 0, right = arr.Length - 1, center;
        while (left <= right) {
            center = (left + right) >> 1;
            if (val > arr[center]) left = center + 1;
            else right = center - 1;
        }
        return left;
    }
}


Measured memory_bytes: 56960
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a<=b){
            if(b<=c){
                System.out.println(a+" "+b+" "+c);
            }else if(c<=b){
                if(a<=c){
                    System.out.println(a+" "+c+" "+b);
                }else{
                    System.out.println(c+" "+a+" "+b);
                }
            }
        }else if(b<=a){
            if(a<=c){
                System.out.println(b+" "+a+" "+c);
            }else if(c<=a){
                if(b<=c){
                    System.out.println(b+" "+c+" "+a);
                }else if(c<=b){
                    System.out.println(c+" "+b+" "+a);
                }
            }
        }

    }
}


Measured memory_bytes: 26352
def II(): return int(input())
N=II()
N-=1
i=1
while N>=(26**i):
  N-=26**i
  i+=1
ans=''
for j in range(i):
  q,mod=divmod(N,26)
  ans=ans+chr(mod+ord('a'))
  N=q
ans=ans[::-1]
print(ans)

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

int main() {
  char s;
  cin >> s;
  
  if(s=='a'||s=='i'||s=='u'||s=='e'||s=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" <<endl;
   }
}

Measured memory_bytes: 256
/*
Where is frankenstein??
▒▒▒▒▒▒▐███████▌
▒▒▒▒▒▒▐░▀░▀░▀░▌
▒▒▒▒▒▒▐▄▄▄▄▄▄▄▌
▄▀▀▀█▒▐░▀▀▄▀▀░▌▒█▀▀▀▄
▌▌▌▌▐▒▄▌░▄▄▄░▐▄▒▌▐▐▐▐

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <random>
#include <valarray>
//#include <fstream>
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

int main()
{
    int l;
    cin>>l;
    
    printf("%.12f\n",(double)l*l*l/27);
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
def run():
    N,M,K = map(int, sysread().split())
    to = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, sysread().split())
        to[a].append(b)
        to[b].append(a)

    seen = [False] * (N+1)
    groups = [[]]
    belongs = [-1] * (N+1)
    def dfs(node, g = 0 ,parent=None):
        seen[node] = True
        groups[g].append(node)
        belongs[node] = g
        for next in to[node]:
            if not seen[next]:
                dfs(next, g=g, parent=node)

    g = 0
    for idx in range(1, N+1):
        if not seen[idx]:
            dfs(idx, g)
            g += 1
            groups.append([])

    block = [[] for _ in range(N+1)]
    for _ in range(K):
        c,d = map(int, sysread().split())
        if belongs[c] == belongs[d]:
            block[c].append(d)
            block[d].append(c)

    for i in range(1, N+1):
        tmp_g = belongs[i]
        print(len(groups[tmp_g]) - len(to[i]) - len(block[i]) - 1, end=' ')



if __name__ == "__main__":
    run()

Measured memory_bytes: 63632
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int par[100000];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	par[x] = y;
}
int main() {
	int n, q;
	while (cin >> n >> q, n) {
		init(n); int par0[100000] = {}; int marked[100000] = {}; marked[0] = 1;
		int t;
		rep(i, n-1) {
			cin >> t; t--;
			par0[i + 1] = t;
		}
		vector<pair<char,int>> p;
		char a; int b;
		rep(i, q) {
			cin >> a >> b; b--;
			if (a == 'M')marked[b] += 1;
			p.push_back({ a,b });
		}
		rep(i, n) {
			if (marked[i]==0) {
				unite(i, par0[i]);
			}
		}
		ll out = 0;
		for (int i = q - 1; i >= 0; i--) {
			if (p[i].first == 'M') {
				marked[p[i].second]--;
				if (marked[p[i].second] == 0) {
					unite(p[i].second, par0[p[i].second]);
				}
			}
			else {
				out += (ll)(find(p[i].second)+1);
			}
		}
		cout << out << endl;
	}
	return 0;
}


Measured memory_bytes: 5720
#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()
#define int long long
typedef pair<int,int> P;

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

vector<int> fact;

bool check(int n){
    REP(i,fact.size()){
        if(fact[i]*fact[i]>n) break;
        if(n%fact[i]==0) return false;
    }
    return true;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    fact.push_back(6);
    for(int i=7;i<300000;i+=7){
        if(check(i+1)) fact.push_back(i+1);
        if(check(i+6)) fact.push_back(i+6);
    }

    while(true){
        int n; cin>>n;
        if(n==1) break;
        
        cout<<n<<":";
        REP(i,fact.size()){
            if(n%fact[i]==0) cout<<" "<<fact[i];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3344
import java.lang.Math.min

fun main(args:Array<String>?): Unit {
    val classes = readLine()!!.trim().split(' ').drop(1).map(String::toTimeRange)
    val n = readLine()!!.trim().toInt()
    val teachers = Array(n){readLine()!!.trim().split(' ').drop(1).map(String::toTimeRange)}
    val m = readLine()!!.trim().toInt()
    val students = Array(m){readLine()!!.trim().split(' ').drop(1).map(String::toTimeRange)}

    println(classes.map{c ->
        val t = teachers.count{it.any{r -> c.from in r && c.to in r}}
        val s = students.count{it.any{r -> c.from in r && c.to in r}}
        min(t, s)
    }.sum())
}
fun String.toTime(): Time {
    val (hour, minute) = this.split(':').map(String::toInt)
    return Time(hour, minute)
}
fun String.toTimeRange(): TimeRange {
    val (from, to) = this.split('-').map(String::toTime)
    return from .. to
}
data class Time(val hour: Int, val minute: Int) {
    operator fun rangeTo(that: Time): TimeRange = TimeRange(this, that)
}
data class TimeRange(val from: Time, val to: Time) {
    operator fun contains(time: Time): Boolean {
        return from <= time && time <= to
    }
    companion object {
        private operator fun Time.compareTo(that: Time): Int {
            return if (this.hour == that.hour) this.minute.compareTo(that.minute) else this.hour.compareTo(that.hour)
        }
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int H,W,N;
	static int X[200010],Y[200010];
	scanf("%d%d%d",&H,&W,&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d%d",&X[i],&Y[i]);
	}
	
	static vector<int> vec[200010];
	for(int i = 1 ; i <= N ; i ++){
		vec[X[i]].push_back(Y[i]);
	}
	
	static bitset<200010> B;
	for(int i = 0 ; i < 200010 ; i ++){
		B[i] = false;
	}
	B[1] = true;
	for(int i = 2 ; i <= H ; i ++){
		for(int y: vec[i]){
			if(B[y]){
				cout << i-1 << endl;
				return 0;
			}
		}
		B |= B<<1;
		for(int y: vec[i]){
			B[y] = false;
		}
	}
	cout << H << endl;
}


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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    ll X,K,D; cin >> X >> K >> D;
    if(X<0) X*=-1;
    ll cnt=X/D;
    ll ans;
    if(cnt>=K){
        ans=X-K*D;
    }else{
        if((K-cnt)%2==0){
            ans=X-cnt*D;
        }else{
            ans=D*(cnt+1)-X;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000000   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}


void solve(){
    int d, n;
    cin >> d >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x;
    }
    if(d < sum) cout << -1 << endl;
    else cout << d - sum << endl;
}

signed main(){  
//  freopen("ii.txt", "w", stdin);
    // flash;
    int t = 1;
    // cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    // goog(tc);
        solve();
    }
}

Measured memory_bytes: 3676
//#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
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,m,k,ans=0; cin>>n>>m>>k;
    vector<ll> a(n,0),b(m,0),suma(n+1,0);
    vector<pair<ll,ll>> sumb(m+2,mk(0,0));
    sumb.back()=mk(INF,m+1);
    rep(i,n){
        cin>>a[i]; suma[i+1]=suma[i]+a[i];
    }
    rep(i,m){
        cin>>b[i];
        sumb[i+1]=mk(sumb[i].first+b[i],i+1);
    }
    rep(i,n+1){
        if(suma[i]>k) break;
        ll K=k-suma[i],cnt=i;
        cnt+=(*upper_bound(al(sumb),mk(K,INF))).second-1;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 11180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int a, p;
  cin >> a >> p;
  int val = (3*a + p)/2;
  int ans = max(0, val);
  cout << ans << endl;
  return 0;
}

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

namespace ABC117
{
    class A
    {
        static void Main(string[] args)
        {
            int[] aa = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int T = aa[0], X = aa[1];


            double r = T / (double)X;
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
a = list(map(int, input().split()))
Nodd = len([x for x in a if x%2 == 1])
Neven = len([x for x in a if x%2 == 0])
Nfour = len([x for x in a if x%4 == 0])
if Nodd <= Nfour or (Nodd+Nfour==N and Nodd-Nfour==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in a:
    ans += b[i - 1]
for i in range(n-1):
    if a[i + 1] - a[i] == 1:
        ans += c[a[i + 1] - 2]
print(ans)


Measured memory_bytes: 3064
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'

ld path(vector<ii>&p, vector<int>perm){
  ld sum=0;

  for(int i=1;i<perm.size();i++){

    ii p1 = p[perm[i]];
    ii p2 = p[perm[i-1]];

    sum+=hypot(p1.x-p2.x, p1.y-p2.y);
  }

  return sum;
}



int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
  
  int n;
  cin>>n;
  vector<ii> p(n);
  fa(pp, p)cin>>pp.x>>pp.y;

  vector<int> perm(n);

  for(int i=0;i<n;i++)perm[i]=i;

  int k=0;
  ld sum=0;
  do{
    k++;
    sum+=path(p,perm);
  }while(next_permutation(all(perm)));
  
  cout<<setprecision(20);
  cout<<sum/(ld)k<<endl;

}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);
        if(a<b&&b<c)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

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

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

const ll MAX=30;
const ll INF=0x3f3f3f3f3f3f3f;
ll p,q,mux[MAX][MAX],tmp[MAX];
ll find_mux(ll a,ll b){
    int tmp[MAX];
    if(mux[a][b]==-1){
        mux[a][b]=0;
        for(ll i=0;i<MAX;i++) tmp[i]=0;
        for(ll i=2;i<=a;i+=2) tmp[find_mux(a-i,b+i/2)]=1;
        for(ll i=2;i<=b;i+=2) tmp[find_mux(a+i/2,b-i)]=1;
        for(ll i=0;i<MAX;i++){
            if(!tmp[i]) break;
            mux[a][b]++;
        }
    }
    return mux[a][b];
}
int main(){
    scanf("%lld%lld",&p,&q);
    if(abs(p-q)<=1) printf("Brown\n");
    else printf("Alice\n");
}


Measured memory_bytes: 256
#include <cstdio>
long long a,b,s;

bool check(long long x){
    
    if(x*x < s) return true;
    return false;
}

int main(int argc, const char * argv[]) {
   
    int q;
    
    scanf("%d",&q);
    
    for(int i=0;i<q;i++){
        
        scanf("%lld %lld",&a,&b);
        
        s = a*b;
        long long ans = 0;
        if(a<b){ //a가 작은경우
            ans += 2*(a-1);
        }else if(a==b){
            printf("%lld\n",2*(b-1));
            continue;
        }else{
            ans += 2*(b-1);
            long long tmp = a;
            a=b;
            b=tmp;
            
        }
        
        if(a+1 != b){
            
            
            long long l = a+1;
            long long r = b-1;
            long long val = 0;
            while(l<=r){
                
                long long mid = (l+r)/2;
                
                if(check(mid)){
                    l = mid+1;
                    val = mid;
                }else{
                    r = mid-1;
                }
            }
            
            if(val!=0){
                
                if(val *(val+1) < s){
                    ans += 2*(val-a);
                }else{
                
                
                    if(val * val < s) val--;
                    ans += 2*(val-a);
                    if(val *val < s) ans++;
                }
            }
            ans++;
            
        }
        
        printf("%lld\n",ans);
    }
    

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  long long int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)
string A,B,C;
char calu(char o){
    if(o=='a'){
        if(A.size()==0)return 'A';
        char w = A.front();
        A.erase(A.begin());
        calu(w);
    }
    if(o=='b'){
        if(B.size()==0)return 'B';
        char w = B.front();
        B.erase(B.begin());
        calu(w);
    }
    if(o=='c'){
        if(C.size()==0)return 'C';
        char w = C.front();
        C.erase(C.begin());
        calu(w);
    }
}
int main(){
    cin>>A>>B>>C;
    COUT(calu('a'));
    return 0;
}


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

using namespace std;

int cmp(int x, int y){
	return x > y;
}

int main(){
    int n, k;
    cin >> n >> k;
    
    long long all[n];
    
    for(int i = 0; i < n; ++i){
    	cin >> all[i];
	}
	
	sort(all, all + n, cmp);
	
	long long sol = 0;
	
	for(int i = k; i < n; ++i){
		sol += all[i];
	}
	
	cout << sol;

	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod = 1e9 + 7;
const int MX = 1e5+10;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
  int L,R,d;
  cin>>L>>R>>d;
  int ans=0;
  for(int i=L;i<=R;i++)if(i%d==0)ans++;
  cout<<ans<<endl;
   
   return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  puts((b-a==c-b)?"YES":"NO");
  return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL<<31;
constexpr static int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    llong n;
    cin >> n;
    priority_queue<llong, vector<llong>, greater<llong> > divisers;
    for (llong i = 1; i * i <= n; ++i) {
        if (n % i == 0) divisers.push(i), divisers.push(n / i);
    }

    llong ans = 0;
    while(! divisers.empty()){
        llong cur = divisers.top();
        llong m = (n / cur) - 1;
        if (m) {
            if ((n / m) == (n % m)) ans += m;
        }
        divisers.pop();
    }

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

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,m,b,a,flg[100001],h[100001],cnt;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)	flg[i]=1;
	for(i=1;i<=n;i++)	scanf("%d",&h[i]);
	for(i=0;i<m;i++)	{
		scanf("%d %d",&a,&b);
		if(h[a]>h[b])	flg[b]=0;
		else if(h[a]<h[b])	flg[a]=0;
		else {
			flg[b]=0;	flg[a]=0;
		}
	}
	cnt=0;
	for(i=1;i<=n;i++)	cnt+=flg[i];
	printf("%d\n",cnt);	
	return 0;
}

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

int read(){
	int a = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){a = a * 10 + c - 48; c = getchar();}
	return a;
}

const int _ = 2e5 + 7;
struct Edge{int end , upEd;}Ed[_ << 1];
int head[_] , cntEd , N , M , cnt[3];
void addEd(int a , int b){Ed[++cntEd] = (Edge){b , head[a]}; head[a] = cntEd;}

int col[_];
bool dfs(int x , int c){
	col[x] = c; bool flg = 1;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(col[Ed[i].end] == -1) flg &= dfs(Ed[i].end , c ^ 1);
		else if(col[Ed[i].end] == c) flg = 0;
	return flg;
}

int main(){
	N = read(); M = read();	memset(col , -1 , sizeof(col));
	for(int i = 1 ; i <= M ; ++i){int p = read() , q = read(); addEd(p , q); addEd(q , p);}
	for(int i = 1 ; i <= N ; ++i) if(head[i] == 0) ++cnt[2]; else if(col[i] == -1) ++cnt[dfs(i , 0)];
	printf("%lld\n" , 1ll * N * N - 1ll * (N - cnt[2]) * (N - cnt[2]) + 1ll * (cnt[0] + cnt[1]) * (cnt[0] + cnt[1]) + 1ll * cnt[1] * cnt[1]);
	return 0;
}


Measured memory_bytes: 7296
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
    T = ""
    for j in range(w):
        if s[i][j] == ".":
            count = 0
            if i < h - 1:
                if s[i + 1][j] == "#":
                    count += 1
                if j < w - 1:
                    if s[i + 1][j + 1] == "#":
                        count += 1
                if j > 0:
                    if s[i + 1][j - 1] == "#":
                        count += 1
            if i > 0:
                if s[i - 1][j] == "#":
                    count += 1
                if j < w - 1:
                    if s[i - 1][j + 1] == "#":
                        count += 1
                if j > 0:
                    if s[i - 1][j - 1] == "#":
                        count += 1
            if j < w - 1:
                if s[i][j + 1] == "#":
                    count += 1
            if j > 0:
                if s[i][j - 1] == "#":
                    count += 1
            T += str(count)
        else:
            T += "#"
    print(T)

Measured memory_bytes: 3064
#include <stdio.h>
int main (){
	int darah;
	int damage;
	int total;
	int bagi;
	scanf ("%d %d", &darah, &damage);
	total = darah % damage;
	bagi = darah / damage;
	total > 0 ? printf ("%d", bagi + 1) : printf ("%d", bagi);
	return 0;
}

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;
int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}

const int inv2 = (mod + 1) / 2;

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int ans = 0;
	for(int i = k; i <= n + 1; i++) {
		ll lo = 1LL * i * (i - 1) / 2;
		ll hi = 1LL * (n + n - i + 1) * i / 2;
		ans = (ans + (hi - lo + 1)) % mod;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define ll long long
#define N 200123
#define endl '\n'

using namespace std;

ll v[N], foward[N], ans, n;

int main() {
    ios_base::sync_with_stdio(0);
    
    cin >> n;

    for(int i=1; i <= n; ++i) {
        cin >> v[i];
    }

    for(int i=1; i <= n; ++i) {
        if(i + v[i] <= n) foward[i + v[i]]++;
    }

    for(int i=n; i >= 1; --i) {
        if(i - v[i] > 0) {
            ans += foward[i - v[i]];
        }
    }
    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 6712
s = input()
elements = ["0", "1"]
black_start = [elements[x % 2] for x in range(len(s))]
white_start = [elements[(x+1) % 2] for x in range(len(s))]

ans_white = 0
ans_black = 0
for i in range(len(s)):
    if black_start[i] != s[i]:
        ans_black += 1
    if white_start[i] != s[i]:
        ans_white += 1
print(min(ans_black, ans_white))


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string a,b,c;cin>>a>>b>>c;
  ans2(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]);
  

  return 0;
}

Measured memory_bytes: 256
#97c
s = list(str(input()))
K = int(input())

char_place_dict = dict()

#key:文字、value:出てくる座標なdictを作る
for i in range(len(s)):
    if s[i] not in char_place_dict:
        char_place_dict[s[i]] = [i]
    else:
        char_place_dict[s[i]].append(i)
        
all_alphabet = list([chr(i) for i in range(97, 97+26)])

substrings_set = set()
break_flag = 0

s = ''.join(map(str,s))

for char in all_alphabet:
    if char in char_place_dict:
        substrings_set.add(char)
        #print(char)
        
        for place in char_place_dict[char]:
            for i in range(1,6):
                substrings_set.add(s[place:place+i])
                #print(s[place:place+i])
                
        if len(substrings_set)>=K:
            break_flag = 1
            break
        
    if break_flag == 1:
            break
            

substrings_list = list(substrings_set)
substrings_list.sort(reverse=False)
#print(substrings_list)
print(substrings_list[K-1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1002;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b;
	cin>>a>>b;
	if(b==100)b++;
	cout<<b;
	FOR(i,0,a){
		cout<<"00";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<set>
#include<list>
#define int long long
using namespace std;

signed main() {
	int ans = LLONG_MIN / 3;
	int MIN = LLONG_MAX / 3;
	int a; cin >> a;
	for (int i = 0; i < a; i++) {
		int b; cin >> b;
		ans = max(ans,b - MIN);
		MIN = min(MIN, b);
	}
	cout << ans << endl;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main(){
    int H,W,K;
    cin>>H>>W>>K;
    vector<string> v(H);
    rep(i,H) cin>>v[i];
    ll ans = 0LL;
    rep(i,(1<<H)){
        rep(j,(1<<W)){
            int cnt = 0;
            rep(k,H){
                rep(l,W){
                    if(v[k][l]=='#'&&!(i&(1<<k))&&!(j&(1<<l)))cnt++;
                }
            }
            if(cnt == K)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
n=int(input())
vertex=[(1+n-i)*(n-i)//2 for i in range(n)]
side=[0]*(n-1)
for i in range(n-1):
    l,r=list(map(int,input().split()))
    if l>r:
        l,r=r,l
    side[i]=l*(n-r+1)
print(sum(vertex)-sum(side))

Measured memory_bytes: 24896
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ll n,m;
    cin>>n>>m;
    if(n>m)swap(n,m);
    if(m==1)
    {
        return cout<<1,0;
    }
    else if(n==1)
    {
        return cout<<m-2,0;
    }
    else if(n==2)
    {
        return cout<<0,0;
    }
    cout<<(n*m)-n*2-(m-2)*2;
    return 0;
}


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

int main(void){
  int n,m,x_max,y_min;
  cin >> n >> m >> x_max >> y_min;
  
  for(int i = 0; i < n ; i++){
    int x;
    cin >> x;
    x_max = x_max > x ? x_max : x;
  }
  
  for(int i = 0; i < m ; i++){
    int y;
    cin >> y;
    y_min = y_min < y ? y_min : y;
  }
  if(x_max < y_min){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf= 1e9+7;

int main(){
  int n;
  scanf("%d",&n);
  long long int arr[n];
  for(int a=0;a<n;a++)
    scanf("%lld", &arr[a]);
  long long int prefix[n];
  prefix[0]=arr[0];
  for(int a=1;a<n;a++)
  prefix[a]=(prefix[a-1]+arr[a])%inf;
  long long int ans=0;
  for(int a=0;a<n;a++)
  ans=(ans+arr[a]*(prefix[n-1]-prefix[a])+inf)%inf;
  printf("%lld", ans);
}

Measured memory_bytes: 6884
N, A, B = map(int, input().split())
S = input()
internal = 0
external = 0
res = []
for s in S:
    if s == 'a':
        internal += 1
        res.append('Yes')
    elif s == 'b':
        if external == B:
            res.append('No')
            continue
        external += 1
        res.append('Yes')
    else:
        res.append('No')
    if internal + external == A + B:
        break
res += ['No' for _ in range(N - len(res))]
print(*res, sep='\n')



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

int main() {
  int n, r;

  while(cin >> n >> r, n+r) {
    vector<int> card(n);
    for(int i = 0; i < n; i++) card[i] = n-i;
    for(int i = 0; i < r; i++) {
      int p, c;
      cin >> p >> c;
      vector<int> tmp(p-1);
      for(int j = 0; j < p-1; j++) tmp[j] = card[j];
      for(int j = 0; j < c; j++) card[j] = card[j+p-1];
      for(int j = 0; j < p-1; j++) card[j+c] = tmp[j];
    }
    cout << card[0] << endl;
  }  
}

Measured memory_bytes: 1192
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

struct Dice {
	int label[6];

	void toN() {
		swap(label[0], label[1]);
		swap(label[1], label[5]);
		swap(label[5], label[4]);
	}

	void toS() {
		swap(label[0], label[4]);
		swap(label[4], label[5]);
		swap(label[5], label[1]);
	}

	void toE() {
		swap(label[0], label[3]);
		swap(label[3], label[5]);
		swap(label[5], label[2]);
	}

	void toW() {
		swap(label[0], label[2]);
		swap(label[2], label[5]);
		swap(label[5], label[3]);
	}

	int top() const {
		return label[0];
	}
};

istream& operator>>(istream& in, Dice& dice) {
	in >> dice.label[0] >> dice.label[1] >> dice.label[2]
		>> dice.label[3] >> dice.label[4] >> dice.label[5];
	return in;
}

int main() {

	Dice dice;
	cin >> dice;
	cin.ignore();

	string cmd;
	getline(cin, cmd);

	for (char& c : cmd) {
		switch (c) {
		case 'N': dice.toN(); break;
		case 'S': dice.toS(); break;
		case 'E': dice.toE(); break;
		case 'W': dice.toW(); break;
		}
	}

	cout << dice.top() << endl;

	return 0;
}



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

int main() {
  string N;
  cin >> N;
  string res;
  if(N.at(0)==N.at(1) && N.at(2) == N.at(3) && N.at(1) !=  N.at(2))res = "Yes";
  else if(N.at(0)==N.at(2) && N.at(1) == N.at(3) && N.at(0) !=  N.at(1))res = "Yes";
  else if(N.at(0)==N.at(3) && N.at(1) == N.at(2) && N.at(0) !=  N.at(1))res = "Yes";
  else res = "No";
  cout << res << endl;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

ll cnt[100100];

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

    int N;
    ll K;
    std::cin >> N >> K;

    for(int i=0;i<N;++i){
        int a, b;
        std::cin >> a >> b;

        cnt[a] += b;
    }

    // for(int i=0;i<10;++i){
    //     std::cout << i << ", " << cnt[i] << std::endl;
    // }

    int i = 0;
    ll sum = 0;
    while(cnt[i] + sum < K){sum += cnt[i]; i++;}

    std::cout << i << std::endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) ( (n % k) + k ) % k
#define isOn(S, j) (S & (1 << j) )
#define setBit(S, j) (S | (1 << j ) )
#define LSB(S) (S & (-S))

vector<ll> cub(300);
ll n, res = 0;
string s;

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

    cin >> s;
    n = s.size();

    for (int i = 0; i < n; i++)
        cub[s[i]]++;

    for (int i = 'a'; i <= 'z'; i++) {
        n -= cub[i];
        res += cub[i] * n;
    }

    cout << res + 1 << endl;

    return 0;
}  

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  cin >> n;
  ll res = 1;
  vector<int> v(n+1,1);
  for(int i = 2;i <= n;i++){
    for(ll j = 1;j*i <= n;j++)v[j*i]++;
    res += 1ll*i*v[i];
  }
  cout << res << endl;
  




  return 0;
}

Measured memory_bytes: 42324
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		if (X%2==0||Y%2==0) {
			System.out.println("Even");
			return ;
		}
		System.out.println("Odd");
	}
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n;
    cin >> n;

    LL ans = 0;
    for(LL i = 1; i <= n; i++){
        LL l, r;
        cin >> l >> r;

        ans += (r - l + 1);
    }

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
 int main()
{	
lli i,j,n,k,mx=0;
cin >> n ;
lli a[n][3];
	for(i=0;i<n;i++){
	for(j=0;j<3;j++){
		cin >> a[i][j];
	}
	}
	for(i=1;i<n;i++){
		for(j=0;j<3;j++){
			a[i][j]=a[i][j]+max(a[i-1][(j+1)%3],a[i-1][(j+2)%3]);
		}
	}
	for(i=n-1,j=0;j<3;j++){
		mx=max(mx,a[i][j]);
	}
	cout << mx << '\n';
return 0;}


Measured memory_bytes: 2560
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

bonus = 0

for i in range(n-1):
    if a[i]+1 == a[i+1]:
        bonus += c[a[i]-1]

print(sum(b)+bonus)


Measured memory_bytes: 3060
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n;
    cin>>n;
    cout<<n*n*n<<endl;

}
//Alhamdulillah
















Measured memory_bytes: 3604
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    int n,m;

    cin >> n;
    string c[n];

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

    cin >> m;
    string d[m];

    for(int i=0;i<m;i++){
        cin >> d[i];
    }
    
    int ans = 0;
    for(int i=0;i<n;i++){
        int tmp = 0;
        for(int ii=0;ii<n;ii++){
            if(c[i] == c[ii]){tmp++;}
        }
        for(int j=0;j<m;j++){
            if(c[i] == d[j]){
                tmp--;
            }
        }
        ans = max(ans, tmp);
    }
       
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

n, d = map(int, input().split())
x = [list(map(int,input().split())) for i in range(n)]

def good_distance(x, y):
  return (sum(map(lambda a, b: (a-b)**2, x, y))) ** 0.5

ans = 0

for i in itertools.combinations(list(range(n)), 2):
  a, b = x[int(i[0])], x[int(i[1])]
  if str(good_distance(a, b))[-1] == "0":
    ans += 1

print(ans)

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



int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n+1); a[0]=0;
  vector<ll> b(m+1); b[0]=0;
  ll ai=0, bj=0;
  rep(i,n){
    ll tmp;
    cin >> tmp;
    ai += tmp;
    a[i+1]=ai;
  }
  rep(j,m){
    ll tmp;
    cin >> tmp;
    bj += tmp;
    b[j+1]=bj;
  }
  ll ans=0, j=m;
  rep(i, n+1){
    if(a[i] > k) break;
    while(b[j] > k-a[i]) j -= 1;
    ans = max(ans, i+j);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6404
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto s = readln.chomp;
    do {
        s = s[0..$-2];
    } while (!zip(s[0..$/2], s[$/2..$]).all!(z => z[0] == z[1]));
    s.length.writeln;
}



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



int main(){
    int n,cnt;
    int num[10000],i=0;
    for(int a=0;a<10;a++)
        for(int b=0;b<10;b++)
            for(int c=0;c<10;c++)
                for(int d=0;d<10;d++){
                    num[i]=a+b+c+d;
                    i++;
                }
    
    while(cin >> n){
        cnt = 0;
        for(int j=0;j<10000;j++){
            if(n==num[j]) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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


int main(void)
{
	int n,k=0;
	char s;
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){scanf("%c",&s);if(s=='Y'){k=1;}}
	
	
	
	
	
	if(k==1){printf("Four\n");}else{printf("Three\n");}
	
	return 0;
}




Measured memory_bytes: 128