akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,m=0,a[100000],r=0;
  vector <int> li;
  cin>>n;
  for(int i=0;i<n;m=max(m,a[i]),i++) cin>>a[i];
  for(int i=1;i<=m;i++) if(__gcd(i,m)==i) li.push_back(i);
  for(int i=0;i<n;i++) r+=*lower_bound(li.begin(),li.end(),a[i])-a[i];
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3528
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		HashMap <String,Integer> p=new HashMap<String,Integer>();
		Deque <String> hoge=new ArrayDeque<String>();
		int N=stdIn.nextInt();
		int a[][]=new int[N][2];
		String s="";
		int z=0,y=0,X=0,Y=0,max=0,k=0;
		while(z<N){
			a[z][0]=stdIn.nextInt();
			a[z][1]=stdIn.nextInt();
			z++;
		}z=0;
		while(z<N){
			while(y<N){
				if(z!=y){
					X=a[z][0]-a[y][0];
					Y=a[z][1]-a[y][1];
					s=X+","+Y;
					if(p.containsKey(s))
						p.put(s,p.get(s)+1);
					else{
						p.put(s,1);
						hoge.add(s);
					}
				}
				y++;
			}y=0;
			z++;
		}z=0;
		k=hoge.size();
		while(z<k){
			s=hoge.poll();
			if(p.get(s)>max){
				max=p.get(s);
			}
			z++;
		}
		if(N-max==0)
			N++;
		System.out.println(N-max);
	}
}

Measured memory_bytes: 23252
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int lis[100010];
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>lis[i];
    }
    sort(lis,lis+N);
    int bef=-1;
    int ans=0;
    for(int i=0;i<N;i++){
        if(lis[i]!=lis[i+1]||i+1==N){
            if(i-bef<lis[i])ans+=(i-bef);
            else ans+=(i-bef)-lis[i];
            bef=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 202;

string str, pre, suf;
int Z[N];

void ZAlgorithm() {
	int L = 0, R = 0, SZ = SZ(str);
	for (int i = 1; i < SZ; i++) {
		if (i > R) {
			L = R = i;
			while (R < SZ && str[R - L] == str[R])
				R++;
			Z[i] = R - L;
			R--;
		} else {
			if (Z[i - L] < R - i + 1)
				Z[i] = Z[i - L];
			else {
				L = i;
				while (R < SZ && str[R - L] == str[R])
					R++;
				Z[i] = R - L;
				R--;
			}
		}
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n;
	cin >> n >> suf >> pre;
	str = pre + suf;
	ZAlgorithm();
	for (int i = 0; i < n; i++) {
		if (Z[n + i] >= (n - i)) {
			cout << n + i << endl;
			return 0;
		}
	}
	cout << 2 * n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
    string a,b;
    cin>>a>>b;
    if(a.size() > b.size()){ 
        cout<<"GREATER"<<endl;
        return 0;
    }
    else if(a.size() < b.size()){ 
        cout<<"LESS"<<endl;
        return 0;
    }else{
        if(a<b) cout<<"LESS"<<endl;
        else if(a==b) cout<<"EQUAL"<<endl;
        else cout<<"GREATER"<<endl;
    }
}

   

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long x, long long a, long long b) {
  if (abs(x - a) < abs(x - b)) {
    cout << "A" << endl;
  } else {
    cout << "B" << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long b;
  long long a;
  long long x;
  cin >> x;
  cin >> a;
  cin >> b;
  solve(x, a, b);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static final long mod = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        // 猿/犬/猿/犬... or 犬/猿/犬/猿 ...
        int maxNum = Math.max(N, M);
        int minNum = Math.min(N, M);

        long ans = 0;
        if (maxNum - minNum > 1) {
            ans = 0;
        } else if (maxNum == minNum) {
            // 猿/犬...と犬/猿の組み合わせがある
            ans = factorial(N);
            ans = (ans * factorial(M)) % mod;
            ans = (ans * 2) % mod;
        } else {
            ans = factorial(N);
            ans = (ans * factorial(M)) % mod;
        }

        out.println(ans);
    }

    static long factorial(long n){
        return recfact(1, n);
    }

    // http://www.luschny.de/math/factorial/FastFactorialFunctions.htm
    static long recfact(long start, long n) {
        long i;
        if (n <= 16) {
            long r = start;
            for (i = start + 1; i < start + n; i++) {
                r = r * i % mod;
            }
            return r;
        }
        i = n / 2;
        return (recfact(start, i) * recfact(start + i, n - i)) %  mod;
    }
}

Measured memory_bytes: 24912
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string w; cin >> w;
    int a[26]; REP(i,26) a[i] = 0;
    for(char s : w) a[s-'a']++;
    REP(i,26){
        if(a[i]%2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
INF = 10**20

N, M, S = map(int, input().split())
adj = [[] for _ in range(N)]
for m in range(M):
    u,v,a,b = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append((v,a,b))
    adj[v].append((u,a,b))

C = []
D = []
for n in range(N):
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)

M = 2500
S = min(S, M-1) # 2500枚あれば十分
dist = [[INF]*M for _ in range(N)] # dist[都市][銀貨の枚数]
dist[0][S] = 0
q = [(0,S,0)] # (距離、銀貨の枚数、都市)

while q:
    d, sil, node = heapq.heappop(q)
    if dist[node][sil] < d: # 探索の対象にする必要があるか確認
        continue 
    if sil+C[node] < M and d+D[node] < dist[node][sil+C[node]]:
        dist[node][sil+C[node]] = d + D[node]
        heapq.heappush(q, (d + D[node], sil+C[node] ,node))
    for to,a,b in adj[node]:
        if sil >= a and d + b < dist[to][sil-a]:
            dist[to][sil-a] = d + b
            heapq.heappush(q, (d + b, sil-a ,to))

for i in range(1,N):
    print(min(dist[i]))



Measured memory_bytes: 26008
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

A, B, X = map(int, input().split())
if A <= X <= A + B:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 6608
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
typedef  long long ll;
const int  maxn = 2110;
const int mod = 1000000007;
using namespace std;
ll n, m;

int main()
{
	cin >> n >> m;
	n--;
	for (ll i = -n; i <= n; i++)
	{
		if (m + i >= -1000000 && m + i <= 1000000)
		{
			printf("%lld", m + i);
		}
		if (i != n)printf(" ");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);

int main(){
  ll N,W;cin>>N>>W;
  vi v(N),w(N); REP(i,N) cin>>v[i]>>w[i];
  vvi dp(N,vi(W+1));
  REP(j,W+1) if(j%w[0]==0) dp[0][j]=(j/w[0])*v[0];
  FOR(i,1,N) REP(j,W+1){
    dp[i][j]=dp[i-1][j];
    if(j>=w[i])dp[i][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
  }
  ll ans=0; REP(i,W+1) ans=max(ans,dp[N-1][i]);
  cout<<ans<<endl;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

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

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

class MaximumFlow{
	const ll INF;
public:
	struct edge{
		int to;
		ll cap;
		int rev;
		bool isrev;
		int idx;
		edge()=default;
		edge(int t,ll c,int r,bool s,int i):to(t),cap(c),rev(r),isrev(s),idx(i){}
	};

	vector<vector<edge>> graph;
	vector<ll> min_cost,iter;

	MaximumFlow(int V):INF(numeric_limits<ll>::max()),graph(V){}

	void add_edge(int from,int to,ll cap,int idx=-1){
		graph[from].emplace_back(to,cap,graph[to].size(),false,idx);
		graph[to].emplace_back(from,0,graph[from].size()-1,true,idx);
	}

	bool bfs(int s, int t){
		min_cost.assign(graph.size(),-1);
		queue<int> que;
		min_cost[s] = 0;
		que.push(s);
		while(!que.empty() && min_cost[t]==-1){
			int p = que.front();
			que.pop();
			for(auto &e:graph[p]){
				if(e.cap>0 && min_cost[e.to]==-1){
					min_cost[e.to] = min_cost[p] + 1;
					que.push(e.to);
				}
			}
		}
		return min_cost[t] != -1;
	}

	ll dfs(int idx,const int t,ll flow) {
		if(idx == t) return flow;
		for(ll &i = iter[idx];i<graph[idx].size();i++){
			edge &e = graph[idx][i];
			if(e.cap>0 && min_cost[idx]<min_cost[e.to]){
				ll d = dfs(e.to, t, min(flow, e.cap));
				if(d>0){
					e.cap -= d;
					graph[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	ll MaxFlow(int s,int t){
		ll flow = 0;
		while(bfs(s, t)){
			iter.assign(graph.size(), 0);
			ll f = 0;
			while((f = dfs(s, t, INF)) > 0) flow += f;
		}
		return flow;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<pair<ll,ll>> R(N),B(N);
	REP(i,N){
		R[i].first=in();
		R[i].second=in();
	}
	REP(i,N){
		B[i].first=in();
		B[i].second=in();
	}

	MaximumFlow MF(2*N+2);
	REP(i,N){
		REP(j,N){
			if(B[i].first>R[j].first && B[i].second>R[j].second){
				MF.add_edge(i,N+j,1);
			}
		}
	}
	REP(i,N){
		MF.add_edge(2*N,i,1);
		MF.add_edge(N+i,2*N+1,1);
	}
	out(MF.MaxFlow(2*N,2*N+1));
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll signed long long int
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 1000005
using namespace std;

ll a[MAXX], b[MAXX], c[MAXX], k = 0;

signed main()
{
	FAST;
	ll n, m, f = 0;
	double pi = 3.14;
	cin >> n;
	cout << 2 * pi * n;
	
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
    
                        
     fio

          
     ld x,y;
     cin>>x>>y;
     
     fr(i,0,100)
     fr(j,0,100)
     if(i+j==x)
     if(2*i+4*j==y){cout<<"Yes";return 0;}
     cout<<"No";
              


return 0;}    


Measured memory_bytes: 3732
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int n,i;
	long int a,max,min,sum;
	sum=0;
	cin >> n;
	cin >> a;
	max = a;
	min = a;
	sum = sum + a;

	for (i=1;i<n;i++) {
		cin >> a;
		if ( max < a ) {
			max = a;
		}
		if ( min > a ) {
			min = a;
		}
		sum = sum + a;
	} 
	printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        int[][] cs = new int[3][q];
        for (int i = 0; i < q; i++) {
            cs[0][i] = sc.nextInt();
            cs[1][i] = sc.nextInt();
            cs[2][i] = sc.nextInt();
        }

        for (int i = 0; i < q; i++) {
            if (cs[0][i] == 0)
                uf.unite(cs[1][i], cs[2][i]);
            else {
                int ans = uf.hasSameRoot(cs[1][i], cs[2][i]) ? 1 : 0;
                System.out.println(ans);
            }

        }
    }

    static class UnionFind {
        int[] root;
        UnionFind(int n) {
            root = new int[n];
            for (int i = 0; i < n; i++)
                root[i] = i;
        }

        int getRoot(int x) {
            if (root[x] == x)
                return x;
            else
                return root[x] = getRoot(root[x]);
        }

        boolean hasSameRoot(int x, int y) {
            return getRoot(x) == getRoot(y);
        }

        void unite(int x, int y) {
            x = getRoot(x);
            y = getRoot(y);
            if (x == y)
                return;
            root[x] = y;
        }
    }
}

Measured memory_bytes: 103812
def solve():
    S = input()
    if len(S) < 7:
        return (False)
    keyence = "keyence"
    for i in range(len(keyence) + 1):
        head = S[0:i]
        tail = S[len(S) - len(keyence) + i:len(S)]
        if keyence[:i] != head:
            continue
        if keyence[i:] != tail:
            continue
        else:
            return (True)
    return (False)


if solve():
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
let () =
  let open Queue in
  let (n:int),(quantum:int) = Scanf.scanf "%d %d\n" (fun a b -> a,b) in
  let (q:(string * int) t) = create () in
  for i=1 to n do
    add (Scanf.scanf "%s %d\n" (fun a b -> a,b)) q
  done;
  let (sum:int ref) = ref 0 in
  try
    while true do
      let (p:string),(t:int) = take q in
      if t <= quantum then (sum := !sum+t; Printf.printf "%s %d\n" p !sum)
      else (add (p,t-quantum) q; sum := !sum+quantum)
    done;
  with _ -> ()

Measured memory_bytes: 12592
#include <bits/stdc++.h>
using namespace std;
int c,n;
int con=0;
bool coa[1001][1001];
bool cc[101];
bool coacheck(){
  if(con==0)return true;
  else return false;
}
int main(){
  cin >>c>>n;
  for(int i=1;i<=n;i++){
    string coaster;
    cin >> coaster;
    for(int j=1;j<=n;j++){
      int kari =coaster[j-1]-48;
      coa[i][j]=kari;
    }
  }

  for(int i=1;i<=n/2;i++){
    for(int j=1;j<=n/2;j++){
      if((coa[i][j]==coa[i][n-j+1])
      &&(coa[i][j]==coa[n-i+1][j])
      &&(coa[i][j]==coa[n-i+1][n-j+1])){
      }else{
        con++;
      }
    }
  }

  int coacon =0;
  if(coacheck())coacon++;
  for(int i=1;i<c;i++){
    int numcon =0;
    int num;
    cin >>num;
    int a[202];
    for(int j=1;j<=num*2;j++){
      cin >>a[j];
    }
    for(int j=1;j<=num;j++){
    bool check1;
    if((coa[a[j*2-1]][a[j*2]]==coa[a[j*2-1]][n+1-a[j*2]])
    &&(coa[a[j*2-1]][a[j*2]]==coa[n-a[j*2-1]+1][a[j*2]])
    &&(coa[a[j*2-1]][a[j*2]]==coa[n-a[j*2-1]+1][n-a[j*2]+1])){
      check1 =true;
    }else{
      check1 =false;
    }
    if(coa[a[j*2-1]][a[j*2]]==true)coa[a[j*2-1]][a[j*2]]=false;
      else coa[a[j*2-1]][a[j*2]]=true;
    bool check2;
    if((coa[a[j*2-1]][a[j*2]]==coa[a[j*2-1]][n+1-a[j*2]])
    &&(coa[a[j*2-1]][a[j*2]]==coa[n-a[j*2-1]+1][a[j*2]])
    &&(coa[a[j*2-1]][a[j*2]]==coa[n-a[j*2-1]+1][n-a[j*2]+1])){
      check2 =true;
    }else{
      check2 =false;
    }
    if((check1==true)&&(check2==false))con++;
    else if((check1==false)&&(check2==true))con--;
  }
    if(coacheck())coacon++;
  }
  cout << coacon <<endl;

  return 0;
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;


// ABC123C - Five Transportations
// https://atcoder.jp/contests/abc123/tasks/abc123_c
void ABC123C() {
	ll N; cin >> N;
	ll A; cin >> A;
	ll B; cin >> B;
	ll C; cin >> C;
	ll D; cin >> D;
	ll E; cin >> E;

	/*
		一度に運べる人数(minimum)が最小の都市間がボトルネックになるので、
		minimum/分のペースでかかる時間を計算すれば良い
	*/
	ll minimum = min(A, min(B, min(C, min(D, E))));
	ll transport = ceil((double)N / (double)minimum); //切り上げが必要。5分 ÷ 2人/分 = 2.5分 → 3分なので
	//printf("%lf\n", (double)N / (double)minimum);
	//cout << "transport : " << transport << endl;

	cout << transport + 4 << endl;
}


int main() {
	ABC123C();

	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = []
for i in range(N):
    s.append(input())
M = int(input())
t = []
for i in range(M):
    t.append(input())

st = list(set(s + t))
sl = list(map(lambda x : s.count(x), st))
tl = list(map(lambda x : t.count(x), st))

ans = []
for i in range(len(st)):
    ans.append(sl[i] - tl[i])
print(max(max(ans), 0))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

string s[10];

bool comp(const string& s1, const string& s2) {
	if(s1.size() == s2.size()) {
		return s1 < s2;
	}
	return s1.size() < s2.size();
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			cin >> s[i];
		}
		string dp[1 << 10][11];
		for(int i = 0; i < 1 << 10; i++) {
			for(int j = 0; j < 11; j++) {
				dp[i][j] = string(1000, 'z' + 1);
			}
		}
		for(int i = 0; i < n; i++) {
			dp[1 << i][i] = s[i];
		}

		int common[10][10] = { 0 };
		bool contain[10][10] = { 0 };
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i == j) continue;
				for(int k = 1; k <= min(s[i].size(), s[j].size()); k++) {
					if(s[i].substr(s[i].size() - k, k) == s[j].substr(0, k)) {
						common[i][j] = k;
					}
				}
				if(s[i].find(s[j]) != string::npos) {
					contain[i][j] = true;
				}
			}
		}

		for(int i = 1; i < 1 << n; i++) {
			for(int j = 0; j < n; j++) {
				if(dp[i][j][0] == 'z' + 1) continue;
				for(int k = 0; k < n; k++) {
					if(i & (1 << k)) continue;
					int c = common[j][k];
					string ns = dp[i][j];
					if(dp[i][j].find(s[k]) == string::npos) {
						ns += s[k].substr(c, s[k].size() - c);
						dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], ns, comp);
					}
					else {
						dp[i | (1 << k)][j] = min(dp[i | (1 << k)][j], ns, comp);
					}
					/*
					if(ns.find("waoter") != string::npos) {
					cout << endl;
					}
					*/
				}
			}
		}

		string ans = string(1000, 'z' + 1);
		for(int i = 0; i < n; i++) {
			ans = min(ans, dp[(1 << n) - 1][i], comp);
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 14576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll sum=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
		sum=sum+a[i-1]-a[i];
		a[i]=a[i-1];
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();
  for(int i=0;i<n;i++){
    if(s.at(i) == '1'){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 764
a,v=map(int,input().split())
b,w=map(int,input().split())
t=float(input())
ab=abs(a-b)
vw=v-w
if vw<=0:
    print('NO')
else:
    tab=ab/vw
    if tab<=t:
        print('YES')
    else:
        print('NO')

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

int main() {
  vector<int> vec(10);
  for(int i=1;i<=9;i++){
    cin>>vec.at(i);
  }
  
  vector<int> res(10);
  int N;
  cin>>N;
  for(int j=1;j<=N;j++){
    int b;
    cin>>b;
    for(int i=1;i<=9;i++){
      if(vec.at(i)==b){
        res.at(i)=1;
        break;
      }
    }
  }
  
  bool can=false;
  if(res.at(1)==1&&res.at(2)==1&&res.at(3)==1) can=true;
  if(res.at(4)==1&&res.at(5)==1&&res.at(6)==1) can=true;
  if(res.at(7)==1&&res.at(8)==1&&res.at(9)==1) can=true;
  if(res.at(1)==1&&res.at(4)==1&&res.at(7)==1) can=true;
  if(res.at(2)==1&&res.at(5)==1&&res.at(8)==1) can=true;
  if(res.at(3)==1&&res.at(6)==1&&res.at(9)==1) can=true;
  if(res.at(1)==1&&res.at(5)==1&&res.at(9)==1) can=true;
  if(res.at(2)==1&&res.at(5)==1&&res.at(7)==1) can=true;
  
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#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++)
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;

int main(){
    string S,T;
    cin >> S >> T;
    ll N = S.size();
    ll M = T.size();
    vector<vector<ll>> v(26);
    rep(i,N){
        v[S[i] - 'a'].push_back(i);
    }
    rep(i,N){
        v[S[i] - 'a'].push_back(i+N);
    }
    ll ans = 0;
    ll tmp = -1;
    rep(i,M){
        ll c = T[i] - 'a';
        if(v[c].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        tmp = *upper_bound(v[c].begin(), v[c].end(), tmp);
        if(tmp >= N){
            tmp -= N;
            ans += N;
        }
    }
    ans += tmp;
    cout << ans+1 << endl;
}
    /*
    rep(i,M){
        if(v[T[i] - 'a'].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        tmp = v[T[i] - 'a'].front();
        v[T[i] - 'a'].pop();
        if(ans < tmp){
            ans = tmp;
            v[T[i] - 'a'].push(tmp);        
        }else{
            bool flag = false;
            if(ans-tmp < N){
                rep(j,v[T[i] - 'a'].size()){
                    v[T[i] - 'a'].push(tmp);        
                    tmp = v[T[i] - 'a'].front();
                    v[T[i] - 'a'].pop();
                    if(ans < tmp){
                        ans = tmp;
                        v[T[i] - 'a'].push(tmp);
                        flag = true;
                        break;
                    }
                }
            }
            if(flag)continue;
            ll q = (ans-tmp)/N + 1;
            ans = tmp + q*N;
            v[T[i] - 'a'].push(tmp);        
        }
    }
    cout << ans+1 << endl;
}*/

Measured memory_bytes: 2800
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    public static void Main()
    {
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = x[0];
        int M = x[1];
        string[] readk = new string[M];
        for (int i = 0; i < M; i++)
        {
            readk[i] = Console.ReadLine();
        }
        int[] readp = Console.ReadLine().Split().Select(int.Parse).ToArray();

        light[] lights = new light[M];
        string switches = "";
        string lastStatus = "";

        for (int i = 0; i < M; i++)
        {
            lights[i] = new light(N, readk[i]);
            lights[i].residue =readp[i];
        }
        for (int i = 0; i < N; i++)
        {
            switches += "0";
            lastStatus += "1";
        }

        int output = 0;
        for (int i = 0; i <= 2048; i++)
        {
            

            bool breakflag = false;
            for (int j = 0; j < M; j++)
            {
                lights[j].changeStatus(switches);
                if (lights[j].on == false)
                {
                    breakflag = true;
                    break;
                }
            }
            if (breakflag == false)
            {
                output++;
            }


            if (lastStatus == switches) break;
            switches = next(switches);
        }
        Console.WriteLine(output);


    }

    public static string next(string now)
    {
        string output = "";
        output = now;

        if (now[output.Length-1] == '0')
        {
            output = now.Substring(0, output.Length-1) + "1";
            return output;

        }
        else
        {
            return next(now.Substring(0, output.Length - 1)) + "0";

        }

        
        

    }

    
}

public class light
{
    public bool on;
    public int[] rule;
    public int[] input;
    public int residue;
    public light()
    {

    }
    public light(int N,string read)
    {
        var split = read.Split();
        this.rule = new int[N];
        for (int i = 1; i < split.Length; i++)
        {
            int value = int.Parse(split[i]);
            this.rule[value-1] = 1;
        }


    }

    public bool changeStatus(string input)
    {

        int sum = 0;
        int N = input.Length;
        int[] intinput = new int[N];
        for (int i = 0; i < N; i++)
        {
            intinput[i] = int.Parse(input[i].ToString());
        }

        for (int i = 0; i < N; i++)
        {
            sum += intinput[i] * this.rule[i];
        }
        if (sum % 2 == this.residue)
        {
            this.on = true;
        }
        else
            this.on = false;
        return this.on;

    }
}

Measured memory_bytes: 13396
import sys
readline = sys.stdin.readline
def partition(A, p, r):
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1
def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q - 1)
        quicksort(A, q + 1, r)
def isStable(A):
    for i in range(0, len(A) - 1):
        if A[i][1] == A[i + 1][1]:
            if A[i][2] > A[i + 1][2]:
                return False
    return True
n = int(input())
f = lambda a, i: (a[0], int(a[1]), i)
A = [f(readline().split(), i) for i in range(n)]
quicksort(A, 0, n - 1)
print("Stable" if isStable(A) else "Not stable")
print("\n".join(f"{a} {b}" for a, b, c in A))



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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n;
string a, b;
 
int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	cin >> n;
	cin >> a >> b;
	forn(i, n) {
		cout << a[i];
		cout << b[i];
	}
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 998244353
#define F first
#define S second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n , w ;
    cin >> n >> w ;
    ll dp[w+1][n+1] ;
    vector<ll> weight(n+1) , cost(n+1) ;
    rep( i , 1 , n + 1 )
        cin >> weight[i] >> cost[i] ;
    memset(dp,0,sizeof(dp));
    rep( i , 1 , n + 1 )
    {
        rep( j , 1 , w + 1 )
        {
            dp[j][i] = dp[j][i-1] ;
            if( j >= weight[i] )
            {
                dp[j][i] = max(dp[j][i],dp[j-weight[i]][i-1]+cost[i]);
            }
        }
    }
    cout << dp[w][n] ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 79232
#include <stdio.h>
int main(void){
  int N, M;
  int i;
  int sum=0;
  int count=0;
  
  scanf("%d %d",&N,&M);
  
  int A[N];
  
  for(i=0; i<N; i++){
    scanf("%d", &A[i]);
    sum+=A[i];
  }
  
  for(i=0; i<N; i++){
    if(A[i]*4*M>=sum)
      count++;
  }
  
  if(count>=M)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1696
m[5]['= r'],z,d[4]={0,-2},k,i;f(i){m[k][i]=m[4][i]+47?0:m[k][i]?:1+f(d[k]-~i);}main(t){for(scanf("%*d%d",d);m[4][++i-~*d]=~getchar();d[2]=-*d-2);for(;k--?:(z=z<-t?-t:z,t=k=3,--i);)t-=f(i-~*d);printf("%d",z);}

Measured memory_bytes: 78464
fun addMatch(n : Int, i : Int, lm : MutableList<Int>, la : MutableList<Boolean>){
    val remain = n - i
    if(lm[i] < 0) return
    if(la[1] && remain >= 2) lm[i + 2] = lm[i] + 1
    if(la[2] && remain >= 5) lm[i + 5] = lm[i] + 1
    if(la[3] && remain >= 5) lm[i + 5] = lm[i] + 1
    if(la[4] && remain >= 4) lm[i + 4] = lm[i] + 1
    if(la[5] && remain >= 5) lm[i + 5] = lm[i] + 1
    if(la[6] && remain >= 6) lm[i + 6] = lm[i] + 1
    if(la[7] && remain >= 3) lm[i + 3] = lm[i] + 1
    if(la[8] && remain >= 7) lm[i + 7] = lm[i] + 1
    if(la[9] && remain >= 6) lm[i + 6] = lm[i] + 1
}

fun makeNumber(n : Int, lx : MutableList<Int>, lm : MutableList<Int>, la : MutableList<Boolean>){
    var m = n
    for(i in 1..lm[n]){
        if(la[9] && m >= 6 && lm[m] == lm[m - 6] + 1){
            lx.add(9)
            m -= 6
            continue
        }
        if(la[8] && m >= 7 && lm[m] == lm[m - 7] + 1){
            lx.add(8)
            m -= 7
            continue
        }
        if(la[7] && m >= 3 && lm[m] == lm[m - 3] + 1){
            lx.add(7)
            m -= 3
            continue
        }
        if(la[6] && m >= 6 && lm[m] == lm[m - 6] + 1){
            lx.add(6)
            m -= 6
            continue
        }
        if(la[5] && m >= 5 && lm[m] == lm[m - 5] + 1){
            lx.add(5)
            m -= 5
            continue
        }
        if(la[4] && m >= 4 && lm[m] == lm[m - 4] + 1){
            lx.add(4)
            m -= 4
            continue
        }
        if(la[3] && m >= 5 && lm[m] == lm[m - 5] + 1){
            lx.add(3)
            m -= 5
            continue
        }
        if(la[2] && m >= 5 && lm[m] == lm[m - 5] + 1){
            lx.add(2)
            m -= 5
            continue
        }
        // 絶対通るはず
        if(la[1] && m >= 2 && lm[m] == lm[m - 2] + 1){
            lx.add(1)
            m -= 2
            continue
        }
    }
}

fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val l = readLine()!!.split(" ").map(String::toInt)
    val la = mutableListOf<Boolean>()
    for(i in 0..9) {
        la.add(false)
    }
    l.forEach{
        la[it] = true
    }
    val lm = mutableListOf<Int>()
    lm.add(0)
    for(i in 1..n){
        lm.add(-1000000000)
    }
    for(i in 0..n){
        addMatch(n, i, lm, la)
    }
    val lx  = mutableListOf<Int>()
    makeNumber(n, lx, lm, la)
    for(i in 1..(lm[n])){
        print(lx[i - 1])
    }
    println()
}

Measured memory_bytes: 40600
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long> x(n);
    vector<long> y(n);
    for (int i = 0; i < n; ++i) {
        long p;
        cin >> p;
        x[i] = p;
        y[i] = p;
    }

    sort(y.begin(), y.end());
    double m = 0.5 * (y[n/2] + y[n/2 - 1]) ;
    vector<int> lr(n);
    for (int j = 0; j < n; ++j) {
        if(x[j] < m) cout << y[n/2] << endl;
        else cout << y[n/2-1] << endl;
    }



    return 0;
}


Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;

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

    for (int i = X + 1 - K; i < X + K; i++) {
        if (i == X + K - 1) cout << i << endl;
        else cout << i << " ";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO cin.tie(NULL); ios_base::sync_with_stdio(false);
#define ll long long int
#define ii pair<int,int>
#define endl '\n'
using namespace std;

void solve()
{
    int n, x=0;
    cin >> n;
    vector<int> v;
    for(int i=0; i<n; i++)
    {
        int t;
        cin >> t;
        x ^= t;
        v.push_back(t);
    }
    for(int i=0; i<n; i++)
    {
        cout << (v[i]^x) << " ";
    }
    cout << endl;
}
int main()
{
   FASTIO
/* 	int t;
	cin >> t;
	while (t--) */
        solve();
}

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


int main(){
  int N;
  string S;
  cin>>N>>S;
  
  ll r=0,g=0,b=0;
  rep(i,N){
  	if(S[i] == 'R') r++;
   	if(S[i] == 'G') g++;
  	if(S[i] == 'B') b++;
  }
  ll ans=r*g*b;
  
  rep(i,N-2){
  	for(int j=i+1;j<N-1;j++){
     	if(j+j-i<N){
        	if((S[i] != S[j]) && (S[i] != S[j+j-i]) && (S[j] != S[j+j-i])){ ans--;}
        }
    }
  }
  cout<<ans;
	
  
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int MAX_N = 100000;
int N;
vector<pii> G[MAX_N];
int col[MAX_N];
const int W = 1, B = -1;

void dfs(int v, int p, int c) {
    col[v] = c;
    rep(i, G[v].size()) {
        int to = G[v][i].first;
        if (to == p)continue;
        int cost = G[v][i].second;
        if (cost % 2 == 0) {
            dfs(to, v, c);
        } else {
            dfs(to, v, c * -1);
        }
    }
}

signed main() {
    cin >> N;
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(pii(v, w));
        G[v].push_back(pii(u, w));
    }
    dfs(0, -1, W);
    rep(i, N) {
        if (col[i] == W)cout << 0 << endl;
        else cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 11776
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int K, N;
    cin >> K >> N;
    vector<int> a;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    int *b;
    b = new int[N];
    lli sum = 0;
    for (int i = 0; i < N - 1; i++)
    {
        b[i] = a[i + 1] - a[i];
    }
    if (a[0] == 0)
    {
        b[N - 1] = K - a[N - 1];
    }
    else
    {
        b[N - 1] = a[0] + K - a[N - 1];
    }
    int *bcp;
    bcp = new int[N];
    for (int i = 0; i < N; i++)
    {
        bcp[i] = b[i];
    }
    sort(bcp, bcp + N);
    int maxnum = 0;
    for (int i = 0; i < N; i++)
    {
        if (bcp[N - 1] == b[i])
        {
            maxnum = i;
        }
    }
    for (int i = 0; i < N; i++)
    {
        if (i != maxnum)
        {
            sum += b[i];
        }
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  //cout << M << endl;*/

  //int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  int ans = 0;

  for (int i = 1; i <= N; i++){
    if(i%2 == 1){
      if(vec.at(i-1)%2 == 1){
        ans++;
      }
    }
  }

  cout << ans << endl;

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
typedef long long ll;
typedef long double ld;

string s;
int n,a[N],indeg[N];
vector<int> adj[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> s; n = s.length();
	for (int i = 0; i < n; ++i) {
		if (s[i] == '<') adj[i].push_back(i + 1), ++indeg[i+1];
		else adj[i + 1].push_back(i), ++indeg[i];
	}
	queue<int> q;
	for (int i = 0; i <= n; ++i)
		if (adj[i].size() > 0 && indeg[i]==0) {
			a[i] = 0; q.push(i);
		}
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int v : adj[u]) {
			if (a[u] + 1 > a[v]) {
				a[v] = a[u] + 1;
				q.push(v);
			}
		}
	}
	long long ans = 0LL;
	for (int i = 0; i <= n; ++i) ans += a[i];
	cout << ans << endl;
}

Measured memory_bytes: 32028
from fractions import gcd
while True:
    a = list(map(int, input().split()))
    if a.count(0) == 6:
        break
    x = a[0] % a[1]
    ix = 1
    while x != 1:
        x = a[0] * x % a[1]
        ix += 1
    y = a[2] % a[3]
    iy = 1
    while y != 1:
        y = a[2] * y % a[3]
        iy += 1
    z = a[4] % a[5]
    iz = 1
    while z != 1:
        z = a[4] * z % a[5]
        iz += 1
    ixy = ix * iy // gcd(ix, iy)
    print(ixy * iz // gcd(ixy, iz))

Measured memory_bytes: 10216
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi x(n);
		for(int i=0;i<n;i++) scanf("%d", &x[i]);

		int ans=100000000;
		sort(x.begin(), x.end());
		for(int v=x.front();v<=x.back();v++)
		{
			int s=0;
			for(int i=0;i<n;i++)
			{
				s+=(x[i]-v)*(x[i]-v);
			}
			min_u(ans, s);
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
a = ['R','U','D']
b = ['L','U','D']
s = input()
flag = True
for i in range(len(s)):
    if (i+1) % 2 == 0:
        if s[i] not in b:
            flag = False
    else:
        if s[i] not in a:
            flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
 	while(1){
 		int m,a,b; cin >>m>> a>>b;
 		if(m==0&&a==0&&b==0)break;
 		int ans=-1;
 		int dif=-1;
 		vector<int> s(m);
 		for(int i=0;i<m;i++){
 			cin >> s[i];
 		}
 		sort(s.begin(),s.end());
 		for(int i=m-b;i<=m-a;i++){
 			if(s[i]-s[i-1]>dif){
 				ans=m-i;
 				dif=s[i]-s[i-1];
 			}
 		}
 		cout << ans << endl;
 	}
 }


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

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

    cout << 2*N*M_PI << endl;
    //cout << endl;
    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
  string s;
  cin>>s;
  ll sum=0;
  ll n=(ll)s.length();
  for(ll i=0;i<n;i++)
  {
    sum+=s[i]-'0';
  }
  if(sum%9==0)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}


Measured memory_bytes: 3356
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n,k=iia()
arr=iia()
arr.sort()
s=0
for i in range(k):
    s+=arr[i]
print(s)

Measured memory_bytes: 9700
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         long H=gi();
         long W=gi();
         long N=gi();
         Map<Integer,Map<Integer,Boolean>> m=new HashMap<Integer,Map<Integer,Boolean>>();
         long[] ans=new long[10];
         ans[0]=(H-2)*(W-2);
         for (int i=0; i<N;i++) {
        	 int a=gi();
        	 int b=gi();
        	 if(m.containsKey(a)) {
        		 m.get(a).put(b, true);
        	 } else {
        		 Map map=new HashMap<Integer,Boolean>();
        		 map.put(b, true);
        		 m.put(a, map);
        	 }


        	 for(int j=-1; j<2;j++) {
        		 for(int k=-1; k<2;k++) {
            		 int ad=a+j;
            		 int bd=b+k;
            		 if(ad>1 && ad<H && bd>1 && bd<W) {
            			 int c=0;
            			 for(int ii=-1; ii<2;ii++) {
                    		 for(int jj=-1;jj<2;jj++) {
                        		 int add=ad+ii;
                        		 int bdd=bd+jj;
                        		 if(add>0 && add<=H && bdd>0 && bd<=W) {
                        			 if(m.containsKey(add) && m.get(add).containsKey(bdd)) {
                        				 c++;
                        			 }
                        		 }
                        	 }
                    	 }
            			 if(c>0) {
            				 ans[c-1]--;
            				 ans[c]++;
            			 }
            		 }
            	 }
        	 }
         }

         for(int i=0; i<ans.length;i++) {
             System.out.println(ans[i]);
         }
     }

  // a^nをmodで割ったあまり
 	public static long modpow(long a, long n, long mod) {
 		long res=1;
 		while(n>0) {
 			if((n & 1) == 1) res=res*a%mod;
 			a=a*a%mod;
 			n=n>>1;
 		}

 		return res;
 	}

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 91176
#include<bits/stdc++.h>
#define fora(i,a,b) for(int i=a,Wub=b;i<Wub;++i)
#define ford(i,a,b) for(int i=a,Wub=b;i>=Wub;--i)
#define SPEEDIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 1000000
#define MOD 1073741824
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin>>s;
    s[5]=s[13]=' ';
    cout<<s<<"\n";
    return 0;
}


Measured memory_bytes: 256