akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int a[100];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];

  sort(a, a + n, greater<int>());

  int Alice = 0, Bob = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) Alice += a[i];
    else Bob += a[i];
  }

  cout << Alice - Bob << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
S = input().split()
a = int(S[0])
b = int(S[1])
c = int(S[2])
k = int(S[3])

if a < k :
    if b <k -a:
        print(a-(k-a-b))
    else:
        print(a)
else:
    print(k)

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

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

	int sq = sqrt(N);
	long int d = 1 + N;
	long int j = 0;
	long int td = 0;
	for (long int i = 1; i <= sq; i++) {
		if (N % i != 0) continue;
		j = N / i;
		td = (i - 1) + (j - 1);
		if (td < d) {
			d = td;
		}
	}
	cout << d << endl;

	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}



struct UnionFind {
  vector<int> data; // 根の場合は集合の大きさ*-1、子の場合は親の番号が入る
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) { // 要素xが含まれる集合の大きさ
    return -data[root(x)];
  }
  bool same(int x, int y) { // 同じ集合ならtrue
    return root(x) == root(y);
  }
};


const int MAX_N = 112345;
const int MAX_M = 212345;
pair<int,int> A[MAX_N];
pair<int,int> range[MAX_M];
int D[MAX_N];

vector<int> g[MAX_N];
vector<int> ans;
map< pair<int,int>, int > edgeId;

bool vis[MAX_N];
void dfs(int cur, int prev) {
  vis[cur] = true;
  for (int nxt : g[cur]) if (nxt != prev) {
    dfs(nxt, cur);
  }
  if (prev != -1) {
    if (D[cur] == 1) {
      D[cur] ^= 1;
      D[prev] ^= 1;

      int e = edgeId[make_pair(min(cur, prev), max(cur, prev))];
      ans.push_back(e);

    }
  }
}




int main2() {
  REP(i, MAX_N) g[i].clear();
  ans.clear();
  edgeId.clear();

  int N = nextInt();
  int M = nextInt();
  REP(i, N) {
    int a = nextInt();
    int b = nextInt();
    A[i] = {a, b};
  }
  sort(A, A+N);
  REP(i, N+1) {
    if (i == 0) D[i] = A[i].second;
    else if (i == N) D[i] = A[i-1].second;
    else D[i] = A[i].second ^ A[i-1].second;
  }

  REP(i, M) {
    int L = nextInt();
    int R = nextInt();
    int li = lower_bound(A, A+N, make_pair(L, 0)) - A;
    int ri = upper_bound(A, A+N, make_pair(R, 2)) - A;
    range[i] = {li, ri};
  }

  UnionFind uf(N+1);

  // pv(A, A+N);
  // pv(range, range+M);

  REP(i, M) {
    int a = range[i].first;
    int b = range[i].second;
    if (a < b) {
      if (!uf.same(a, b)) {
        uf.link(a, b);
        g[a].push_back(b);
        g[b].push_back(a);
        edgeId[ make_pair(min(a,b), max(a,b)) ] = i+1;
      }
    }
  }

  bool ok = true;
  CLR(vis, 0);
  REP(i, N+1) if (!vis[i]) {
    dfs(i, -1);
    if (D[i] == 1) ok = false;
  }

  if (ok) {
    sort(ALL(ans));
    cout << ans.size() << endl;
    REP(i, ans.size()) {
      if (i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  double a = 0;
  REP(i, n){
    double b;
    cin >> b;
    a += 1. / b;
  }
  printf("%.10f\n", 1. / a);
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  map <ll,ll>mp;
  
  REP(i,n){
    int a;
    cin >> a;
    mp[a]++;
  }

  ll f = 1, x =0, y = 0;
  ITR(itr,mp){
    if(itr->second >= 4){ x = y = itr->first;}
    else if(itr->second >= 2 && f == 1){ x = itr->first; f *= -1;}
    else if(itr->second >= 2 && f == -1){ y = itr->first;f *= -1;}
  }
  
  cout << x*y << endl;

 return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m,a[51],b[51];
	int i,j,k,x,y,cnt,cnt1;
	int leng[100001],par[100001];
	
	cin>>n>>m;
	
	for(i=1;i<=m;i++) cin>>a[i]>>b[i];
	

	cnt1=0;
	for(i=1;i<=m;i++){
	
		cnt=0;
		for(j=1;j<=n;j++) {leng[j]=1,par[j]=j;}
		
		for(k=1;k<=m;k++){
		
			if(i==k) continue;
			
			x=a[k];
			while(x!=par[x]) x=par[x];
			
			y=b[k];
			while(y!=par[y]) y=par[y];
		
			if(x!=y){
			
				cnt++;
				
				if(leng[x]>leng[y]) par[y]=x;
				
				else if(leng[x]<leng[y]) par[x]=y;
				
				else {par[y]=x,leng[x]++;}
			}		
		}
		if(cnt!=n-1) cnt1++;
	}
	
	cout<<cnt1<<endl;
	
	return 0;

}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long f(long long b, long long n) {
    if (n < b) {
        return n;
    }
    return f(b, n/b) + n%b;
}
int main () {
    long long n, s;
    cin >> n >> s;
    long long q = (sqrt(4*n+1)-1)/2;
    for (long long i = 2; i <= q+q; i++) {
        if (f(i, n) == s) {
            cout << i << endl;
            return 0;
        }
    }
    // 2桁
    for (long long i = q; i >= 1; i--) {
        long long l = n/(i+1) + 1;
        long long r = n/i;
        if ((s-i) <= n%l && (s-i) >= n%r && (s-i-n%r) % i == 0) {
            cout << l + (n%l-(s-i))/i << endl;
            return 0;
        }
    }
    // 1桁
    if (n == s) {
        cout << n+1 << endl;
        return 0;
    }
    puts("-1");
}

Measured memory_bytes: 256
def check(f, e)
  yymm_f = mmyy_f = true
  if f.to_i <= 0 || f.to_i > 12
    mmyy_f = false
  end
  if e.to_i <= 0 || e.to_i > 12
    yymm_f = false
  end  
  if yymm_f && mmyy_f
    puts "AMBIGUOUS"
  elsif yymm_f
    puts "YYMM"
  elsif mmyy_f
    puts "MMYY"
  else
    puts "NA"
  end
end

a = gets
f = a[0,2]
e = a[2,2]
check(f, e)

Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N,res,ans;
std::vector<int>A[2];

int main()
{
	in >> N;
	A[0].resize(N);
	A[1] = A[0];
	rep(i, N) { in >> A[0][i]; }
	rep(i, N) { in >> A[1][i]; }

	rep(i, N)
	{
		res = 0;
		for (int j = 0; j < i; ++j)
		{
			res += A[0][j];
		}
		res += A[0][i];
		for (int j = i; j < N; ++j)
		{
			res += A[1][j];
		}
		ans = std::max(ans, res);
	}
	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static class Range implements Comparable<Range> {
		long x, l;
		
		public Range (long x, long l) {
			this.x = x;
			this.l = l;
		}

		@Override
		public int compareTo(Range o) {
			return Long.compare(this.x + this.l, o.x + o.l);
		}
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			final int S = sc.nextInt();
			
			for(int i = 0; i < N; i++) {
				if(i < K) {
					System.out.print((i == 0 ? "" : " ") + (S + 0));
				}else {
					System.out.print((i == 0 ? "" : " ") + (S + 1 > 1000000000 ? 1 : S + 1));
				}
			}
			System.out.println();
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main() {

    int A, B;
    cin >> A >> B;

    int tax8 = 0;
    int tax10 = 0;
    int ans = -1;

    for (int i = 0; i < 10000; i++) {
        tax8 = i * 0.08;
        tax10 = i * 0.1;

        if (tax8 == A && tax10 == B) {
            ans = i;
            break;
        }
        
    }

    
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  var Array(n,x) = readLine.split(" ").map(_.toInt)
  var z = 0
  var i = 0
  readLine.split(" ").foreach{s=>
    if(z<=x){
      i += 1
      z += s.toInt
    }      
  }
  if(z<=x) i += 1
  println(i)
}

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

const int INF = 1e9;

int main() {
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<6;i++){
    if(s[i]=='1'){
      ++cnt;
    }
  }
  cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	int x = 0, N = 0, i;
	int max = x;
	 
	cin >> N;
	
	char S[N];
	
	cin >> &S[0];
	
	for(i = 0; i < N; i++){
		if(S[i] == 'I')
			x++;
		else if(S[i] == 'D')
			x--;
		else{
			cout << "error" << endl;
			break;
		}
		if(x > max)
			max = x;
	}
	
	cout << max;
	
	return 0;
}


Measured memory_bytes: 256
#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;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
double x[3],y[3];
double L[3],t[3];
int main(){
	rep(i,3) cin>>x[i]>>y[i];
	rep(i,3) L[i]=sqrt((x[i]-x[(i+1)%3])*(x[i]-x[(i+1)%3])+(y[i]-y[(i+1)%3])*(y[i]-y[(i+1)%3]));
	rep(i,3) t[i]=acos((L[i]*L[i]+L[(i+2)%3]*L[(i+2)%3]-L[(i+1)%3]*L[(i+1)%3])/(2*L[i]*L[(i+2)%3]));
	double ans=0;
	rep(i,3){
		double r=L[i]/(2+1.0/tan(t[i]/2)+1.0/tan(t[(i+1)%3]/2));
		chmax(ans,r);
	}
	printf("%.12f\n",ans);
}


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

int main (void) {

    char a, b;

    cin >> a >> b;

    if (a == 'H' && b == 'H') {
        cout << 'H' << endl;
    }else if (a == 'D' && b == 'D'){
        cout << 'H' << endl;
    }else{
        cout << 'D' << endl;
    }
        
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;

  string enpty_S = "";
  for (int i = 0; i < W; i++) {
    enpty_S += ".";
  }

  string prev_S = enpty_S;
  string current_S;
  string next_S;

  cin >> current_S;

  for (int i = 0; i < H; i++) {
    if (i == H - 1) {
      next_S = enpty_S;
    } else {
      cin >> next_S;
    }

    for (int j = 0; j < W; j++) {
      char current_grid = current_S.at(j);
      if (current_grid == '#') {
        cout << current_grid;
        continue;
      }

      int mines_count = 0;
      for (int k = j - 1; k <= j + 1; k++) {
        if (k < 0) {
          continue;
        } else if (k == W) {
          break;
        }
        if (prev_S.at(k) == '#') {
          mines_count++;
        }
        if (current_S.at(k) == '#') {
          mines_count++;
        }
        if (next_S.at(k) == '#') {
          mines_count++;
        }
      }
      cout << mines_count;
    }
    cout << endl;

    prev_S = current_S;
    current_S = next_S;
  }
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] d = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			d[i] = scan.nextInt();
		}
		int[] c = new int[103];
		for (int i = 0; i < n; i++) {
			c[d[i]]++;
		}
		for (int i = 1; i <= 101; i++) {
			if (c[i] > 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> node(N);
  rep(i, M)
  {
    int a, b;
    cin >> a >> b;
    node[a - 1]++;
    node[b - 1]++;
  }
  for (int count : node)
  {
    if (count % 2 == 1)
    {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int h = scn.nextInt();
        int w = scn.nextInt();

        while ((h != 0) || (w != 0)) {
            for (int i = 0; i < h; i++) {

                if (i == 0 || i == (h-1)) {
                    for (int j = 0; j < w; j++) {
                        System.out.print("#");
                    }

                }else{
                    System.out.print("#");
                    for (int k = 0; k < (w-2); k++) {
                        System.out.print(".");

                    }
                    System.out.print("#");
                }


                System.out.println("");
            }
            System.out.println("");
            h = scn.nextInt();
            w = scn.nextInt();


        }

        scn.close();


    }
}


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


int main(){
  double v;
  while(cin >> v){
    double t = v/9.8;
    double y = v*v/(2*9.8);

    for(int i=0; i<2000; i++){
      if(5.0*i-5.0 >= y){
        cout << i << endl;
        break;
      }
    }
  }
}
  
  


Measured memory_bytes: 3212
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[])=>{for(let i=0;i<a.length;i+=2)if(s==a[i])return a[i+1]};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};
const main = ()=>{
  let [a,b]=nrin(2);
  out(a*b%2==0?"No":"Yes");
}
main();

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;



int main(){
  int n,m;
  cin >> n >> m;
  int ans = 1;
  for(int i=1;i*i<=m;i++){
    if(m%i==0){
      int j = m/i;
      if((long)i*n<=m)ans = max(ans,i);
      if((long)j*n<=m)ans = max(ans,j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static int A = 0;
    public static int B = 0;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();

        String output = "";
        int C = A + Math.abs(B);
        if (C % 2 == 0) {
            output = Integer.toString(C / 2);
        } else {
            output = "IMPOSSIBLE";
        }
        System.out.println(output);
    }
}

Measured memory_bytes: 22736
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int H, W;
        while(true){
            H = scan.nextInt();
            W = scan.nextInt();
            if(H == 0 && W == 0) break;
            drawFrame(H, W);
            System.out.println();
        }
    }
    public static void drawFrame(int H, int W){
        for(int i = 0; i < H; i++){
            for(int k = 0; k < W; k++){
                if(i == 0 || i == H - 1 || k == 0 || k == W - 1){
                    System.out.print("#");
                }else{
                    System.out.print(".");
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 37084
n = int(input())
if (n == 999):
   print("111")
elif (n == 991):
    print("119")
elif (n == 911):
    print("199")
elif (n == 919):
    print("191")
elif (n == 199):
    print("911")
elif (n == 191):
    print("919")
elif (n == 199):
    print("911")
elif (n == 119):
    print("991")
elif (n == 111):
    print("999")

Measured memory_bytes: 3064
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var ac = 0, wa = 0, tle = 0, re = 0;
  for(var i = 0; i < n; i++){
    var s = nextstr();
    if(s === "AC")ac++;
    else if(s === "WA")wa++;
    else if(s === "TLE")tle++;
    else re++;
  }
  console.log("AC x",ac);
  console.log("WA x",wa);
  console.log("TLE x",tle);
  console.log("RE x",re);
}

Measured memory_bytes: 37396
i = 1
while True:
  a, op, b = input().split()
  if op == '?':
    break
  if op == '+':
    print(int(a) + int(b))
  elif op == '-':
    print(int(a) - int(b))
  elif op == '*':
    print(int(a) * int(b))
  else:
    print(int(a) // int(b))
  i += 1


Measured memory_bytes: 5592
S = input()
T = input()

ls = len(S)
lt = len(T)

DP = [[0] * (ls+1) for _ in range(lt+1)]

for i in range(lt):
    for j in range(ls):
        if T[i] == S[j]:
            DP[i+1][j+1] = DP[i][j] + 1
        else:
            DP[i+1][j+1] = max(DP[i+1][j], DP[i][j+1])

ans = ''
while ls * lt > 0:
    if DP[lt][ls] == DP[lt-1][ls]:
        lt -= 1
    elif DP[lt][ls] == DP[lt][ls-1]:
        ls -= 1
    elif DP[lt][ls] == DP[lt-1][ls-1] + 1:
        lt -= 1
        ls -= 1
        ans += S[ls]
print(ans[::-1])



Measured memory_bytes: 112220
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
  int n,i,j,flg;
  int *A;
  int count=0;
  
  scanf("%d",&n);
  A  = (int *)malloc(n * sizeof(int));

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

  
  for(i=0;i<n;i++){
    if(A[i]<2){
      flg = 1;
	}
    
  else if (A[i] == 2){
    flg=0;
  }

  else if(A[i] % 2 == 0){ 
    flg=1;
  }

  else{

    
    flg=0;
    
    for(j=3 ; j<=sqrt(A[i]) ; j+=2){
      if(A[i]%j==0){
	flg=1;
	break;
      }
      
      
    }
  }
     if(flg==0) count++;
      
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  map<string,int>mp;
  string s;
  rep(i,n){
    cin>>s;
    mp[s]++;
  }
  int maxv=0;
  for(auto x:mp){
    chmax(maxv,x.second);
  }
  set<string>ss;
  for(auto x:mp){
    if(x.second==maxv)ss.insert(x.first);
  }
  for(auto x:ss)cout<<x<<"\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 33280
#include <iostream>

using namespace std;

struct Process {
  char name[10];
  int time;
};

static const int MAX = 60000;
Process P[MAX];
int tail, head;

void enqueue (struct Process& p) {
  P[tail] = p;
  tail = (tail + 1) % MAX;
}

void dequeue (struct Process& p) {
  p = P[head];
  head = (head + 1) % MAX;
}

int main () {
  int n, q;

  scanf("%d %d",&n,&q);

  for (int i = 0; i < n; i++) {
    scanf("%s %d",P[i].name, &P[i].time);
  }

  int count = 0;

  tail = n;

  struct Process p;

  while (head != tail) {
    dequeue(p);
    p.time -= q;
    if (p.time <= 0) {
      count += q + p.time;
      printf("%s %d\n",p.name, count);
    } else {
      count += q;
      enqueue(p);
    }
  }

}

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

using namespace std;

int N, nr, p[200009], aib[200009];
char sir[200009];
vector < int > v[26];
pair < int, int > h[100009];

void Upd (int pos) {while (pos <= N) aib[pos] ++, pos += pos - (pos & (pos - 1));}
int Qry (int pos) {int sum = 0; while (pos) sum += aib[pos], pos &= pos - 1; return sum;}

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

scanf ("%s", sir + 1), N = strlen (sir + 1);
for (int i=1; i<=N; i++)
    sir[i] -= 'a', v[sir[i]].push_back (i);
bool oneOdd = 0;
for (int i=0; i<26; i++)
{
    int L = v[i].size ();
    if (L & 1)
    {
        if (oneOdd)
        {
            printf ("-1\n");
            return 0;
        }
        p[v[i][L / 2]] = N / 2 + 1;
        oneOdd = 1;
    }
    for (int j=0, k = L - 1; j<k; j++, k --)
        h[++nr] = {v[i][j], v[i][k]};
}
sort (h + 1, h + nr + 1);
for (int i=1, j = N; i<=nr; i++, j--)
    p[h[i].first] = i, p[h[i].second] = j;

long long ans = 0;
for (int i=1; i<=N; i++)
    ans += i - 1 - Qry (p[i]), Upd (p[i]);
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 3832
#include<stdio.h>
#include<math.h>

int main(){
    long long int n;
    scanf("%lld", &n);
    if(n%2 == 1 || n < 10){
        printf("0");
    }else{
        long long int x = 0;
        long long int f=10;
        while(f <= n){
            x += n / f;
            f *= 5;
        }
        printf("%lld", x);
    }

    return 0;
}

Measured memory_bytes: 128
n = input()
list_n = list(n)
c = len(list_n)
ans_a = 0
ans_b = 0

for i in range(c):
    if i % 2 == 0:
        if list_n[i] == "0":
            ans_a += 1
    if i % 2 == 1:
        if list_n[i] == "1":
            ans_a += 1

for i in range(c):
    if i % 2 == 0:
        if list_n[i] == "1":
            ans_b += 1
    if i % 2 == 1:
        if list_n[i] == "0":
            ans_b += 1

print(min(ans_a, ans_b))

Measured memory_bytes: 3956
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var input = p.ConvertIntArray(p.ReadInput());
        var count = 1;
        var A = input[0] - 1;
        var B = input[1] - 1;

        if(input[1] == 1)
        {
            count = 0;
        }
        else
        {
            while (B > A)
            {
                B  -= A;
                count++;
            }
        }
        Console.WriteLine(count);
    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
    	cin >> v[i];
    }
    sort(v.begin(), v.end());
    int diff = v[k - 1] - v[0];
    for (int i = 1; i + k - 1 < n; i++) {
    	diff = min(diff, v[k - 1 + i] - v[i]);
    }
    cout << diff << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<math.h>

#define REP(i,a,b) for(i=a;i<b;i++)

using namespace std;

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

  REP(i, a, b+1) {
    if (c % i == 0) cnt++;
  }
  cout << cnt << endl;
}

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

int main(){
	
	int s[9];
	for (int i=0; i<9; ++i) cin >> s[i];
	//cout << s[0] << s[8] << endl;
	
	int n;
	cin >> n;
	//cout << n << endl;
	
	int k[n];
	for ( int i=0; i<n; ++i) cin >> k[i];
	//cout << k[0] << k[n] << endl;
	
	int a[9];
	for (int i=0; i<9; ++i) a[i] =0;
	
	for (int i=0; i<9; ++i){
		for (int j=0; j<n; ++j){
			if (s[i] == k[j]) a[i] = 1;
		}
	}
	
	if (a[0] + a[1] + a[2] == 3) cout << "Yes" << endl;
	else if (a[0] + a[1] + a[2] == 3) cout << "Yes" << endl;
	else if (a[3] + a[4] + a[5] == 3) cout << "Yes" << endl;
	else if (a[6] + a[7] + a[8] == 3) cout << "Yes" << endl;
	else if (a[0] + a[3] + a[6] == 3) cout << "Yes" << endl;
	else if (a[1] + a[4] + a[7] == 3) cout << "Yes" << endl;
	else if (a[2] + a[5] + a[8] == 3) cout << "Yes" << endl;
	else if (a[0] + a[4] + a[8] == 3) cout << "Yes" << endl;
	else if (a[2] + a[4] + a[6] == 3) cout << "Yes" << endl;
	else cout << "No" << endl;

}

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

string S;
int cntl, cntr;

void range(int i) {
	cntl = 0, cntr = 0;
	int j = i + 1;
	while(S[i] == 'R') {
		cntl++;
		i--;
		if (S[i] == 'R') {
			cntr++;
			i--;
		}
	}
	while (S[j] == 'L') {
		cntr++;
		j++;
		if (S[j] == 'L') {
			cntl++;
			j++;
		}
	}
	return;
}

int main() {
	cin >> S;
	int ss = S.size();
	vector<int> A(ss);
	bool r = false;
	for (int i = 0;i < ss - 1;i++) {
		if (S[i] == 'R'&&S[i + 1] == 'L') {
			range(i);
			A[i] = cntl;
			A[i + 1] = cntr;
		}
	}
	for (int i : A)
		cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int mini=min(s.length(),t.length());
  int c=0;
  for (int i=0;i<mini;i++)
  {
    if (s.at(i)!=t.at(i))
      c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 3864
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,k = NextInts()
da = NextIntList()
for i in range(n):
    da[i]-=1

dp = [[0 for i in range(n)] for i in range(61)]

dp[0] = da

for i in range(60):
    for j in range(n):
        dp[i+1][j] = dp[i][dp[i][j]]

ans = 0
for i in range(61):
    if k&1:
        ans = dp[i][ans]
    k >>= 1
print(ans+1)

Measured memory_bytes: 217408
#include <stdio.h>

int main() {
  char str[5], prev = 0;
  int i;
  scanf("%s", str);
  for (i = 0; i < 4; i++) {
    if (prev == str[i]) {
      printf("Bad\n");
      return 0;
    }
    prev = str[i];
  }
  printf("Good\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		Integer n = scan.nextInt();
		List<Integer> xList = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			xList.add(scan.nextInt());
		}

		int xMax = xList.stream().mapToInt(x -> x).max().getAsInt();
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < xMax; i++) {
			int p = 0;
			for (int j = 0; j < n; j++) {
				int x1 = xList.get(j);
				int x2 = i + 1;
				p += (x1 - x2) * (x1 - x2);
			}
			min = Math.min(p, min);
		}

		System.out.println(min);
		scan.close();
	}
}

Measured memory_bytes: 28748
import java.util.Scanner;
class Main {
	int n,i,x;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for(i = 3;i <= n;i++){
			x = i;
			if(x % 3 == 0){
				System.out.print(" ");
				System.out.print(i);
			}else{
				while(x >= 3){
					if(x % 10 == 3){
						System.out.print(" ");
						System.out.print(i);
						x = 0;
					}else{
						x /= 10;
					}
				}
			}
		}
        System.out.println();
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

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

using namespace std;

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

    int diff = 0;// diff=(')'の数)-('('の数の差)
    int left = 0;
    for (char c : S) {
        if (c == '(') {
            diff--;
        } else {
            diff++;
        }
        left = max(left, diff);
    }

    int right = left - diff;
    for (int i = 0; i < left; ++i) {
        cout << '(';
    }
    cout << S;
    for (int i = 0; i < right; ++i) {
        cout << ')';
    }
    return 0;
}


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

vector<string> a;
vector<string> b;
int m, n;

bool found(int i, int j) {
    for(int x = 0; x < m; x++)
        for(int y = 0; y < m; y++) {
            if(x + i >= n || y + j >= n) {
                return false;
            }
            if(a[i + x][j + y] != b[x][y])
                return false;
        }
    return true;
}

int main() {
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    rep(i, n) { cin >> a[i]; }
    rep(i, m) { cin >> b[i]; }
    rep(i, n) rep(j, n) {
        if(found(i, j)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=2e5,MAX_SQRT_N=448;
int N,Q,A,B;
const ll INF=1e16;
ll dp[MAX_N],bsm[MAX_SQRT_N+1],bqu[MAX_SQRT_N+1][2];
int sq;
int main(){
	cin>>N>>Q>>A>>B;
	sq=1;
	while(sq*sq<N){
		sq++;
	}
	REP(i,N){
		dp[i]=INF;
	}
	int x;
	cin>>x;
	A--;
	B--;
	x--;
	dp[A]=abs(B-x);
	dp[B]=abs(A-x);
	REP(i,(N+sq-1)/sq){
		bqu[i][0]=INF+1;
		REP(j,sq){
			if (i*sq+j>=N){
				break;
			}
			bqu[i][0]=min(bqu[i][0],dp[i*sq+j]+j+1);
		}
		bqu[i][1]=INF+1;
		int c=1;
		for(int j=sq-1;j>=0;j--){
			if (i*sq+j>=N){
				continue;
			}
			bqu[i][1]=min(bqu[i][1],dp[i*sq+j]+c);
			c++;
		}
	}
	int prex=x;
	REP(q,Q-1){
		cin>>x;
		x--;
		ll tem=INF;
		REP(i,(N+sq-1)/sq){
			if (i*sq<=x && x<(i+1)*sq){
				REP(j,sq){
					if (i*sq+j>=N){
						break;
					}
					tem=min(tem,dp[i*sq+j]+abs(i*sq+j-x)+bsm[i]);
				}
			}else if ((i+1)*sq<=x){
				tem=min(tem,bqu[i][1]+x-(i+1)*sq+bsm[i]);
			}else{
				tem=min(tem,bqu[i][0]+i*sq-x-1+bsm[i]);
			}
		}
		REP(i,(N+sq-1)/sq){
			if (i*sq<=prex && prex<(i+1)*sq){
				REP(j,sq){
					if (i*sq+j>=N){
						break;
					}
					dp[i*sq+j]+=bsm[i]+abs(x-prex);
				}
				bsm[i]=0;
			}else{
				bsm[i]+=abs(x-prex);
			}
		}
		dp[prex]=min(dp[prex],tem);
		bqu[prex/sq][0]=INF+1;
		REP(j,sq){
			if (prex/sq*sq+j>=N){
				break;
			}
			bqu[prex/sq][0]=min(bqu[prex/sq][0],dp[prex/sq*sq+j]+j+1);
		}
		bqu[prex/sq][1]=INF+1;
		int c=1;
		for(int j=sq-1;j>=0;j--){
			if (prex/sq*sq+j>=N){
				continue;
			}
			bqu[prex/sq][1]=min(bqu[prex/sq][1],dp[prex/sq*sq+j]+c);
			c++;
		}
		prex=x;
	}
	ll ans=INF;
	REP(i,N){
		ans=min(ans,dp[i]+bsm[i/sq]);
	}
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 1792
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    val=1
    while val<=N:
        val=val*2
    print(val//2)

resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main(){
  string s;
  getline(cin, s);
  
  int a, b;
  sscanf(s.c_str(), "%d %d", &a, &b);
  
  cout << a * b << endl;
  
  return 0;
}

Measured memory_bytes: 3300
#include <stdio.h>
#include <math.h>

int main()
{
    int len1, len2, len3;
    int count1 = 0, count2 = 0;
    
    while(scanf("%d,%d,%d", &len1, &len2, &len3) != EOF){
        if (len1 != len2 && len3 * len3 == len1 * len1 + len2 * len2) count1++;
        if (len1 == len2 && len1 * sqrt(2) != len3) count2++;
    }
    printf("%d\n%d\n", count1, count2);
    
    return 0;
}

Measured memory_bytes: 596
def primes(n):
    import math
    max = math.sqrt(n)
    candidates = [i for i in range(2, n+1)]
    primes = []
    while candidates[0] <= max:
        primes.append(candidates[0])
        candidates = [candidates[i] for i in range(len(candidates)) if candidates[i] % candidates[0] != 0]
    primes.extend(candidates)
    return primes

def resolve():
    X = int(input())
    _primes = primes(10**5+4)
    import bisect
    print(_primes[bisect.bisect_right(_primes, X)] if X not in _primes else X)



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 13260
# coding: utf-8
# Your code here!
a = input()

big = ["A","B","C","D","E","F","G","H","I","J","K","L",
        "M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
        
small = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
        'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']  
        
if a in big:
    print("A")
else:
    print("a")

Measured memory_bytes: 9024
#include<iostream>
#include<string>

int main(){
	std::string s;
	while (std::cin >> s){
		int JOI = 0, IOI = 0;
		for (int i = 0; i < s.size() - 2; ++i){
			if (s[i] == 'J' &&s[i + 1] == 'O' &&s[i + 2] == 'I')JOI++;
			if (s[i] == 'I' &&s[i + 1] == 'O' &&s[i + 2] == 'I')IOI++;
		}
		std::cout << JOI << std::endl << IOI << std::endl;
	}
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[2][MAX_N];  /* dp[id][i+1] : id = 0 のとき、a+bの先頭i文字(iは0-index)がsの先頭i文字と一致しているときの組の数
                                   id = 1 のとき、a+bの先頭i文字がsの先頭i文字より辞書順で小さいときの組の数 */
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    dp[0][0] = 1;
    rep(i, n) {
        // (a[i], b[i]) = (0, 0) のとき
        if(s[i] == '0') {
            dp[0][i+1] += dp[0][i];
            dp[1][i+1] += dp[1][i];
        }
        else if(s[i] == '1') {
            dp[1][i+1] += dp[0][i] + dp[1][i];
        }
        // (a[i], b[i]) = (0, 1), (1, 0) のとき
        if(s[i] == '0') {
            dp[1][i+1] += 2*dp[1][i];
        }
        else if(s[i] == '1') {
            dp[0][i+1] += 2*dp[0][i];
            dp[1][i+1] += 2*dp[1][i];
        }
        dp[0][i+1] %= mod;
        dp[1][i+1] %= mod;
    }

    ll ans = 0;
    rep(id, 2) {
        ans += dp[id][n];
        ans %= mod;
    }

    out(ans);
    re0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
	}
	int sum = 0;	
	
	sort(p.begin(),p.end());
	p.at(N - 1) /= 2;
	
	for (int x : p) {
		sum += x;
	}		
	
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int sum = 0;
    REP(i,0,n) sum += a[i];
    cout << sum - n << endl;
}

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

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$s=trim(fgets(STDIN));
$c=strlen($s);
$a=str_split(strtoupper('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'));
$i=0;
while($i<$c){
  echo $a[array_search($s[$i],$a)+$n];
  ++$i;
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	string S;
	for(;;){
		cin >> n;
		if(n == 0) break;
		cin >> m;
		cin >> S;
		int ans = 0;
		for(int i = 0; i < m; i++){
			int cnt = 0;
			while(S[i] == 'I' && S[i + 1] == 'O' && S[i + 2] == 'I'){
				cnt++;
				i += 2;
			}
			ans += max(0, cnt - n + 1);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int ans = 0;
	REP(i, 1, n+1)
	{
		if(i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int k;
    cin >> k;
    for (int _=0; _<k; _++) {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3128
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;

typedef pair<long long, string> pls;


#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, k, a, b, c, d, e,H, W,Q;
long long A[200000]= {};
long long B[200005] = {};
long long C[20][200] = {};
bool f;
bool ff;
string S[200];
set <long long>sll;
pl buf;
pls bufls;
vector <long long>vl;
vector <pl>vpl;
vector <pls>vpls;
vector <string> vs;

struct ST
{
	long long hajime;
	long long owari;
	long long zahyou;
	int bangou;

	bool operator<(const ST& another) const
	{
		return hajime < another.hajime;//年齢を比較
	};

};



vector <ST> vst;
ST st[200005];

int main() {

	cin >> a>>b;
	e = 0;
	for (int i = a; i <= b; i++) {
		c = i;
		d = 0;
		while (c > 0) {
			A[d] = c % 10;
			d++;
			c /= 10;
		}
		f = true;
		for (int j = 0; j < d / 2; j++) {
			if (A[j] != A[d - 1 - j]) {
				f = false;
			}
		}

		if (f) {
			e++;
		}

	}


	cout << e << endl;

	return 0;

}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
vector<int> adj[200005];
int val[200005];
void dfs(int s,int p)
{
    for(auto it : adj[s])
    {
        if(it == p) continue;
        else{
            val[it] += val[s];
            dfs(it,s);
        }
    }
}
signed main()
{
    IOS
    int n,q; cin>>n>>q;
    for(int i=0;i<=n;i++) {
        val[i] = 0;
    }
    int a,b;
    for(int i=0;i<n-1;i++)
    {
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int node,upd;
    while(q--)
    {
        cin>>node>>upd;
        val[node] += upd;
    }
    dfs(1,1);
    for(int i=1;i<=n;i++)
        cout<<val[i]<<" ";
    return 0;
}

Measured memory_bytes: 24320
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, W;
	cin >> n >> W;
	ll w[n+1], v[n+1];
	for (int i = 0; i < n; i ++)
	cin >> w[i] >> v[i];
	ll dp[W+1][n+1];
	for (int i = 0; i <= W; i++)
	{
		for (int j = 0; j <= n;j++)
		{
			
			if ( i == 0 || j == 0)
			{
				dp[i][j] = 0;
				continue;
			}
			
			if ( w[j-1] <= i)
			{
				dp[i][j] = max(dp[i-w[j-1]][j-1]+v[j-1], dp[i][j-1]);
			}
			else
			dp[i][j] = dp[i][j-1];
		}
	}
	cout << dp[W][n] << endl;

	return 0;
}


Measured memory_bytes: 79104
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

mod=10**9+7

ans=0
for i in range(60):
  on=0
  off=0
  for j in a:
    if (j>>i)&1:
      on+=1
    else:
      off+=1
  ans+=(on*off)*(2**i)
  ans%=mod

print(ans)

Measured memory_bytes: 118956
s = list(input())
for i in range(8):
    siki = s[0]
    for j in range(3):
        if i&(1<<j):
            siki+='+'+s[j+1]
        else:
            siki+='-'+s[j+1]
    g=int(siki[0])
    for j in range(1,6,2):
        if siki[j]=='+':
            g+=int(siki[j+1])
        else:
            g-=int(siki[j+1])
    if g==7:
        print(*siki,sep="",end="")
        print("=7")
        break

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  int a[n], x = 0;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    x = x ^ a[i];
  }
  for (int i=0; i<n; i++) cout<<(x ^ a[i])<<' ';
  cout<<'\n';
}

Measured memory_bytes: 4396
def median_cal(data):
    num = len(data)
    data.sort()
    if num % 2 == 0:
        median1 = int(num / 2)
        median2 = int(num / 2 - 1)
        median = (data[median1] + data[median2]) / 2.0
        return median
    else:
        median = int((num + 1) / 2 - 1)
        median = data[median]
        return median

n=int(input())
A=[0]*n
B=[0]*n
for i in range(n):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b
if n % 2 == 0:
    print(int(median_cal(B)*2 - median_cal(A)*2 + 1))
else:
    print(median_cal(B) - median_cal(A) + 1)

Measured memory_bytes: 25612