akhauriyash/Code-Regression huggingface dataset:
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextCharArray();
  var check = [["S", "S"], ["S", "W"], ["W", "S"], ["W", "W"]];
  for(var i = 0; i < check.length; i++){
    var ok = new Array(N + 2);
    ok[0] = check[i][0];
    ok[1] = check[i][1];
    for(var j = 0; j < N; j++){
      if(list[j] == "o"){
        if(ok[j] == ok[j + 1]){
          ok[j + 2] = "S";
        }else{
          ok[j + 2] = "W";
        }
      }else{
        if(ok[j] != ok[j + 1]){
          ok[j + 2] = "S";
        }else{
          ok[j + 2] = "W";
        }
      }
    }
    if(ok[0] == ok[N] && ok[1] == ok[N + 1]){
      ok.shift();
      ok.pop();
      myout(ok.join(""));
      return;
    }
  }
  myout(-1);
}


Measured memory_bytes: 37308
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		long b = sc.nextLong();
		// 文字列の入力
		if(a < 10 && b < 10){

			System.out.println( a * b);
		}else{
			System.out.println( - 1 );
		}
		
		
	}
}

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

int main()
{
    int n, a[100010];
    cin >> n;

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

    int ac[100010] = {};
    for (int i = 1; i <= n; i++) ac[i] = ac[i - 1] + abs(a[i] - a[i - 1]);

    ac[n + 1] = ac[n] + abs(a[n]);
    for (int i = 1; i <= n; i++) {
        int t = ac[n + 1] - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i - 1] - a[i + 1]);
        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  int n;
  double a[1010];
  cin >> n;
  REP(i, n) cin >> a[i];
  double b = 0;
  REP(i, n) b += 1/a[i];
  printf("%.10f\n", 1/b);

}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<cstdio>
using namespace std;

const double INF = 1e12;
const int MAX = 100;
int N;

struct S{
  double x,y,z,r;
  S(double _x,double _y,double _z,double _r){
    x = _x; y = _y; z = _z; r = _r;
  }
};

typedef pair<double,int>P;

vector<S>vec;
double G[MAX][MAX];
bool vis[MAX];

void input(){
  for(int i = 0 ; i < N ; i++){
    double x,y,z,r;
    cin >> x >> y >> z >> r;
    vec.push_back(S(x,y,z,r));
  }
}

double getDist(S s1,S s2){
  double x,y,z,d;
  x = s1.x - s2.x;
  y = s1.y - s2.y;
  z = s1.z - s2.z;
  d = sqrt(x*x + y*y + z*z);
  return max(0.0,d - (s1.r + s2.r));
}

void make(){
  for(int i = 0 ; i < N ; i++){
    for(int j = i+1 ; j < N ; j++){
      G[i][j] = G[j][i] = getDist(vec[i],vec[j]);
    }
  }
}

double prim(){
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0.0,0));
  double res = 0.0;
  while(que.size()){
    P p = que.top(); que.pop();
    double cost = p.first;
    int now = p.second;
    if(vis[now])continue;
    vis[now] = true;
    res += cost;
    for(int i = 0 ; i < N ; i++){
      if(G[now][i] < 0)continue;
      if(vis[i])continue;
      que.push(P(G[now][i],i));
    }
  }
  return res;
}

void init(){
  vec.clear();
  for(int i = 0 ; i < MAX;  i++){
    vis[i] = false;
    for(int j = 0 ; j < MAX; j++){
      G[i][j] = -INF;
    }
  }
}

void solve(){
  init();
  input();
  make();
  printf("%.3f\n",prim());
}

int main(){
  while(cin >> N,N){
    solve();
  }
  return 0;
}

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

int64_t GCD(int64_t a, int64_t b){
  int64_t na=max(a, b);
  int64_t nb=min(a, b);
  if(na%nb==0){
    return nb;
  }
  else{
    return GCD(nb, na%nb);
  }
}

int main(){
  int64_t N, X;
  cin >> N >> X;
  vector<int64_t> x(N);
  for(int i=0; i<N; i++){
    cin >> x.at(i);
    x.at(i)=abs(x.at(i)-X);
  }
  int64_t Ans=gcd(x.at(0), x.at(0));
  for(int i=0; i<N; i++){
    Ans=GCD(Ans, x.at(i));
  }
  cout << Ans << endl;
}
  

Measured memory_bytes: 4024
// AOJ 2262: Stopping Problem
// 2017.11.10 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define E 0
#define S 1
#define W 2
#define N 3
typedef struct { int r, c, mem, dir; } Q;
Q q[35000]; int top, end;

char m[22][22];
char mk[22][22][16][4];
int mv[4][2] = {{0,1},{1,0},{0,-1},{-1,0}};

int main()  
{  
	int h, w, i, ii, r, c, r2, c2, mem, dir, ans;

	scanf("%d%d", &h, &w);
	for (r = 0; r < h; r++) scanf("%s", m[r]);
	mk[0][0][0][0] = 1;
	q[0].r = 0, q[0].c = 0, q[0].mem = 0, q[0].dir = E; top = 0, end = 1;
	ans = 0;
	while (top < end) {
		r = q[top].r, c = q[top].c, mem = q[top].mem, dir = q[top++].dir;
		ii = 1;
		if      (m[r][c] == '<') dir = W;
		else if (m[r][c] == '>') dir = E;
		else if (m[r][c] == '^') dir = N;
		else if (m[r][c] == 'v') dir = S;
		else if (m[r][c] == '_') dir = mem ? W : E;
		else if (m[r][c] == '|') dir = mem ? N : S;
		else if (m[r][c] == '@') { ans = 1; break; }
		else if (isdigit(m[r][c])) mem = m[r][c] - '0';
		else if (m[r][c] == '+') { if (++mem > 15) mem = 0; }
		else if (m[r][c] == '-') { if (--mem < 0) mem = 15; }
		else if (m[r][c] == '?') ii = 4;

		for (i = 0; i < ii; i++) {
			r2 = r + mv[(dir+i)&3][0];
			c2 = c + mv[(dir+i)&3][1];
			if      (r2 < 0) r2 = h-1;
			else if (r2 >= h) r2 = 0;
			if      (c2 < 0) c2 = w-1;
			else if (c2 >= w) c2 = 0;
			if (mk[r2][c2][mem][(dir+i)&3]) continue;
			mk[r2][c2][mem][(dir+i)&3] = 1;
			q[end].r = r2, q[end].c = c2, q[end].mem = mem, q[end++].dir = (dir+i)&3;
		}
	}
	puts(ans ? "YES" : "NO");
	return 0;
}

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

int main(){
	int n, l;
	scanf("%d %d", &n, &l);
	int min = 2e9, sum = 0;
	for(int i=0; i<n; i++){
		sum += l+i;
		if(abs(min)>abs(l+i)) min = l+i;
	}
	printf("%d\n", sum-min);
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
#print("AB:", AB)

H = []
iab = 0
answer = 0
for i in range(M + 1):
  while iab <= N - 1 and AB[iab][0] <= i:
    heapq.heappush(H, -AB[iab][1])
    iab += 1
  if len(H):
    answer += heapq.heappop(H)
print(-answer)

Measured memory_bytes: 74200
// Problem : A - 500 Yen Coins
// Contest : AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main () {
	int k,x;
	scanf ("%d %d",&k,&x);
	printf (k*500>=x?"Yes\n":"No\n");
	return 0;
}

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

#define ll              long long int
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, cap;
    cin >> n >> cap;

    if(n == 0 or cap == 0){
        cout<<"0\n";
        return 0;
    }

    vector<ll> value(n);
    vector<ll> weights(n);

    ll maxVal = 0;

    for(ll i=0; i<n; i++){
        cin >> weights[i];
        cin >> value[i];
        maxVal = max(maxVal, value[i]);
    }

    //ll max_value = 100005;
    ll max_value = (maxVal*n) + 1;

    vector<vector<ll>> dp(n, vector<ll>(max_value, INT_MAX));
    ll ans = 0;

    dp[0][value[0]] = weights[0];
    dp[0][0] = 0;
    
    if(weights[0] <= cap){
        ans = max(ans, value[0]);
    }

    for(ll i=1; i<n; i++){
        for(ll j=0; j<max_value; j++){
            dp[i][j] = dp[i-1][j];

            if( (j - value[i] >= 0) and (dp[i-1][j - value[i]]) != INT_MAX){
                dp[i][j] = min(dp[i][j], weights[i] + dp[i-1][j - value[i]]);
            }

            if(dp[i][j] <= cap){
                ans = max(ans, j);
            }
        }
    }
    
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 79488
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static final int UPPER = 1260;
	public static final int UNDER = 540;
	public static final int MAX = UPPER - UNDER;

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

		while (true) {
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			if(N == 0 && M == 0){
				break;
			}
			
			final int r = sc.nextInt();

			int[][] students = new int[M][MAX];

			for (int i = 0; i < r; i++) {
				final int t = sc.nextInt() - UNDER;
				final int n = sc.nextInt();
				final int m = sc.nextInt() - 1;
				final int s = sc.nextInt();

				if (s == 1) {
					students[m][t]++;
				} else if (t < MAX) {
					students[m][t]--;
				}
			}
			
			for(int i = 0; i < M; i++){
				for(int t = 1; t < MAX; t++){
					students[i][t] += students[i][t-1];
				}
			}
			
			final int q = sc.nextInt();

			for (int i = 0; i < q; i++) {
				final int ts = sc.nextInt() - UNDER;
				final int te = sc.nextInt() - UNDER;
				final int m = sc.nextInt() - 1;
				
				int count = 0;
				for(int t = ts; t < te; t++){
					count += students[m][t] == 0 ? 0 : 1;
				}
				
				System.out.println(count);
				
			}
		}
	}
}

Measured memory_bytes: 163464
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 2009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll dp[maxn][maxn];
vector<pii> things;
ll solve(ll l,ll r,ll ind){
    if(ind>=things.size()) return 0;
    if(dp[l][r]!=-1)return dp[l][r];
    return dp[l][r]=max(solve(l+1,r,ind+1)+things[ind].F*abs(things[ind].S-l),solve(l,r-1,ind+1)+things[ind].F*abs(things[ind].S-r));
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp,-1,sizeof dp);
    ll n;
    cin>>n;
    rep(i,0,n){
        ll a;
        cin>>a;
        things.push_back({a,i+1});
    }
    sort(all(things));
    reverse(all(things));
    cout<<solve(1,n,0)<<'\n';
    return 0;   
}           


Measured memory_bytes: 35408
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#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 v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 
int main() {
    ll k;
    cin >> k;
    out(v[k-1]);
    re0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int K;
  cin>>K;
  int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
          };
  cout<<a[K-1]<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e5+5;
int a[maxn]={0};
int main()
{
	int n,t=1,k=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		{
			int t=a[i];a[i]=a[i+1];a[i+1]=t;
			k++;			
		}

			
	}
	cout<<k;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 1000000007
#define mod 998244353

int main(){
	set<int> A = { 1,2,3,5,6,9,10,13,17 };
	int N;
	cin >> N;
	if (A.count(N))cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int, S: "List[str]"):
    k=set(S)
    print(len(k))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ll inf = 1ll<<50;
const int maxN = 110;
const int maxM = 10010;
const int INF = 1000000009;
const int M = 10000;
const int MaxN=1000010;
int tot=0;
int n,m,S,T;

int main()
{
	int x;
	int y;
	scanf("%d %d",&x,&y);
	if(y < x)
		printf("%d\n",x-1);
	else
		printf("%d\n",x);
	return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void print(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void print(H head, T ...tail) { cout << head << " "; print(tail...); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll n, m; read(n, m);
	ll t = (n - m) * 100 + m * 1900;
	print(t << m);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long N,K;
    cin >> N >> K;
    vector<long long> V(N);
    cin >> V[0];
    for(long i=1;i<N;i++)   cin >> V[i];
    
    sort(V.begin(),V.end());
    
    long long min = 10e9;
    for(long i=K-1;i<N;i++){
        if (V[i]-V[i-(K-1)] < min){
            min = V[i]-V[i-(K-1)];
        }
    }
    cout<<min;
    return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long llong;

int N;
llong v_list[100001];
double tripartition;
	
llong BaumukuchenGetAnswer();
inline llong searchOne(int n0, int n1_left, int n2_left);
inline llong getMinV(int n0, int n1_left, int n2_left);
inline int findIndexBinary(int from_n, int to_n, double target);
inline int findIndexSequential(int from_n, double target);


int main(){
	/*
	FILE* fp = fopen("input.txt", "r");
	fscanf(fp, "%lld", &N);
	v_list[0] = 0;
	for(int n=1; n<N+1; n++){
		llong A;
		fscanf(fp, "%lld", &A);
		v_list[n] = v_list[n-1] + A;
	}
	fclose(fp);

	/*/
	scanf("%lld", &N);
	v_list[0] = 0;
	for(int n=1; n<N+1; n++){
		llong A;
		scanf("%lld", &A);
		v_list[n] = v_list[n-1] + A;
	}
	//*/
	printf("%lld\n", BaumukuchenGetAnswer());
}

llong BaumukuchenGetAnswer(){
	tripartition = v_list[N] / 3.0;
	int n0_max = findIndexBinary(0, N, tripartition);

	int n1_left = n0_max;
	int	n2_left = findIndexBinary(n1_left, N,  2*tripartition);
	llong interm_maxV = searchOne(0, n1_left, n2_left);
	for (int n0 = 1; n0 <= n0_max; n0++){
		n1_left = findIndexSequential(n1_left,   tripartition + v_list[n0]);
		n2_left = findIndexSequential(n2_left, 2*tripartition + v_list[n0]);
		
		llong tmp = searchOne(n0, n1_left, n2_left);
		if (tmp > interm_maxV) interm_maxV = tmp;
	}
	return interm_maxV;
}

llong searchOne(int n0, int n1_left, int n2_left){
	llong V_ll = getMinV(n0, n1_left  , n2_left  );
	llong V_lr = getMinV(n0, n1_left  , n2_left+1);
	llong V_rl = getMinV(n0, n1_left+1, n2_left  );
	llong V_rr = getMinV(n0, n1_left+1, n2_left+1);
	return max( max(V_ll,V_lr), max(V_rl, V_rr));
}

llong getMinV(int n0, int n1, int n2){
	llong V0 = v_list[n1] - v_list[n0];
	llong V1 = v_list[n2] - v_list[n1];
	llong V2 = v_list[n0] - v_list[n2] + v_list[N];
	return min(min(V0,V1),V2);
}

int findIndexBinary(int from_n, int to_n, double target){
	while (to_n - from_n != 1) {
		int n_mid = (to_n + from_n) / 2;
		if (v_list[n_mid] > target) to_n = n_mid;
		else from_n = n_mid;
	}
	return from_n;
}

int findIndexSequential(int from_n, double target){
	for(int n=from_n; n<= N; n++)if(v_list[n] > target) return n-1;
	return N-1;
}

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

using namespace std;

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

  int num_even = K / 2;
  int num_odd = K % 2 == 0 ? K / 2 : K / 2 + 1;
  cout << (num_even * num_odd) << endl;
  return 0;
}


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

const int maxn =2e5+10;
const int mod=1e9+7;
ll a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll p=1e18;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
	for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            cout<<0<<'\n';
            return 0;
        }
    }
        ll ans=1;
        for(int i=1;i<=n;i++)
        {
            if(ans<=p/a[i])
            {
                ans*=a[i];
            }
            else
            {
                cout<<-1<<'\n';
                return 0;
            }
        }
        cout<<ans<<'\n';






}


Measured memory_bytes: 4408
object Main extends App {
    def func():Boolean = {
        var s = scala.io.StdIn.readLine()
        val t = scala.io.StdIn.readLine()
        for (_ <- 1 to s.length){
            s = s.tail + s.head
            if (s==t) return true
        }
        return false
    }
    if (func()) println("Yes") else println("No")
}

Measured memory_bytes: 27320
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

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

int main(){
	ll K, X;
	cin >> K >> X;
	for(ll i = X - K + 1; i < X + K; i++){
		cout << i << " ";
	}
	cout << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

s = 0
t = 0
a_sum = []
b_sum = []
for i in range(n-1):
    s += a[i]
    a_sum.append(s)
    t += a[n-i-1]
    b_sum.append(t)
ans = 2*(10**14)
for i in range(n-1):
    ans = min(ans, abs(a_sum[i]-b_sum[n-i-2]))

print(ans)

Measured memory_bytes: 30220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (S == U) {
        cout << A - 1 << " " << B << endl;
    } else {
        cout << A << " " << B - 1 << endl;
    }
    return 0;
}

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

int main() {
    int x = -1;
    cin >> x;
    int i=1;
    while(x != 0) {
        cout << "Case " << i << ": " << x << endl;
        cin >> x;
        ++i;
    }

    return 0;
}



Measured memory_bytes: 3072
loop do
  h, w = gets.split.map(&:to_i)
  break if h.zero? && w.zero?

  (1..h).each do |he|
    (1..w).each do |wi|
      is_edge = he == 1 || wi == 1 || he == h || wi == w
      is_edge ? print('#') : print('.')
    end
    puts
  end
  puts
end



Measured memory_bytes: 6840
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

class ABCD
{
public:
	ABCD(){}
	ABCD(int _a, int _b, int _c, int _d)
	{
		a = _a;
		b = _b;
		c = _c;
		d = _d;
	}
	int a;
	int b;
	int c;
	int d;
};

vector<ABCD> vec;
int n, m, q;

int calcScore(long long int in)//const vector<int> &seq)
{
	// cout << in << " ";

	int score = 0;

	int seq[10] = {};
	for(int i = 0; i < n; ++i)
	{
		seq[i] = in % 10;
		in /= 10;
	}

	for(vector<ABCD>::iterator v = vec.begin(); v != vec.end(); v++)
	{
		if ((seq[(*v).a] - seq[(*v).b]) == (*v).c)
		{
			score += (*v).d;
		}
	}
	// cout << score << endl;
	return score;
}

int create(long long int a, int log)
{
	if (log <= 0)
	{
		return calcScore(a);
	}

	int score = 0;
	for(long long int i = a % 10; i < m; ++i)
	{
		long long int next = a * 10 + i;
		score = max(score, create(next, log - 1));
	}
	return score;
}

void solve()
{
	cin >> n >> m >> q;
	vec = vector<ABCD>(q);

	for (int i = 0; i < q; ++i)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		// convert a, b to "0 base index".
		vec[i] = ABCD(a - 1, b - 1, c, d);
	}

	cout << create(0, n) << endl;

}

int main()
{
	solve();

	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf

#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()

#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))

#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >

#define endl "\n";
#define line puts("-------");
#define dbb(x) cout<<#x<<" : "<<x<<"\n";

void __print(int x) {cerr << x;} void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;} void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V> void __print(const pair<T, V> &x)
{cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const queue<T> &x)
{queue<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.front() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const stack<T> &x)
{stack<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.top() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const T &x)
{int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v)
{__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
    #define db(x...) cerr << "[" << #x << "] = [", _print(x)
#endif
using ll = long long;
const int N = 100005;
const int MOD = 1000000007;

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt","w",stdout);
    #endif
    int i,n,x,y;
    sff(n,x);
    rep(i,n)
    {
        int r=n-i;
        if((i*2)+(r*4)==x)
        {
            puts("Yes");
            return 0;
        }
    }
    rep(i,n)
    {
        int r=n-i;
        if((i*4)+(r*2)==x)
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


Measured memory_bytes: 3768
#                         author:  kagemeka 
#                         created: 2019-11-08 23:31:18(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k:
            count += s - x  + 1
        elif k < s - x <= 2 * k:
            count += k - (s - x - k) + 1

    
    print(count)


if __name__ == "__main__":
    # execute only if run as a script
    main()

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    long[] a = new long[N];

    long allXor = 0;
    for(int i = 0; i<N; i++){
      a[i] = sc.nextLong();
      allXor = allXor ^ a[i];
    }

    for(int i = 0; i<N; i++){
      System.out.print(allXor ^ a[i]);
      System.out.print(" ");
    }

    return;
  }
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    rep(i,N+1) {
        for (int j = 0; i + j <= N; ++j) {
            int total = 10000 * i + 5000 * j + 1000 * (N - i - j);
            if (total == Y) {
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 3584
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[100100];
int main()
{
	int n,p=0;cin>>n;rep(i,n) cin>>a[i];//a[n]=0;sort(a,a+n+1);
	rep(i,n){
		if(a[i]%2>0){
			cout<<"first"<<endl;return 0;
		}
	}
	cout<<"second"<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        long ans = 0;
        int max = a[0];
        for (int i = 1; i < n; i++) {
            if (a[i] < max) {
                ans += max - a[i];
            } else {
                max = a[i];
            }
        }

        System.out.println(ans);
    }
}


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

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    ll ib = b * 100 + 0.5;
    a *= ib;
    a /= 100;
    printf("%lld\n", a);
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    vector<long long> divisor(long long n) {
        vector<long long> ret;
        for (long long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                ret.push_back(i);
                if (i * i != n) ret.push_back(n / i);
            }
        }
        sort(ret.begin(), ret.end()); // 昇順に並べる
        return ret;
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl A(n);
        rep(i,n)cin>>A[i];
        queue<ll> ans;
        rep(i,n){
            ll x=n-i;
            if(A[x-1]%2==0)continue;
            ans.push(x);
            for(ll y:divisor(x)){
                A[y-1]++;
            }
        }
        cout<<ans.size()<<endl;
        while (!ans.empty())
        {
            cout<<ans.front()<<' ';
            ans.pop();
        }
    }

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  string c="CODEFESTIVAL2016";
  int ans=0;
  for(int i=0;i<16;i++){
  	if(s[i]!=c[i])ans++;
  }
  cout<<ans<<endl;
}

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

int main() {
  int t;
  cin >> t;
  int N = t;
  int fx = 0;
  while(N > 0){
    fx += N % 10;
    N = N/10;
  }
  if(t%fx == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
implicit none
integer n,i
integer,parameter:: bit=380000
real x,sum
character u*3

read(5,*)n

sum=0

do i=1,n
read(5,*)x,u

if(u.eq."BTC") then
sum=sum+x*bit
else
sum=sum+x
endif

enddo

write(6,*) sum



end

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
main(){
  int x,y,w,c,a,b;
  while(1){
    c=0;
    cin>>a>>b;
    if(a==0&&b==0){
      break;
    }
    x=max(a,b);
    y=min(a,b);
    while(y){
      x=x%y;
      int temp;
      temp=x;
      x=y;
      y=temp;
      c++;
    }
    cout<<x<<" "<<c<<endl;
  }
}
    

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < (n);i++)
#define lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

signed main(){
    int n;
    cin>>n;
    vector<int>L(n);
    REP(i, n){
        cin>>L[i];
    }
    int cnt = 0;
    REP(i, n-2){
        for (int j=i+1; j<n-1; j++){
            for (int k=j+1; k<n; k++){
                int a=L[i], b=L[j], c=L[k];
                if (a<b){
                    swap(a,b);
                }
                if (a<c){
                    swap(a,c);
                }
                if (b<c){
                    swap(b,c);
                }
                //cout << a << " " << b << " " << c << endl;
                if (a == b or b == c){
                    //cout << "cont" << endl;
                    continue;
                }
                if (b+c>a){
                    cnt+=1;
                }
            }
        }
    }
    cout << cnt << endl;
}

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

int main(){
  int a,b;
  char op;
  while(1){
  cin >>a >>op >>b;

  if(op=='+'){
    cout<<a+b<<endl;
  }
  else if(op=='-'){
    cout<<a-b<<endl;
  }
  else if(op=='*'){
    cout<<a*b<<endl;
  }
  else if(op=='/'){
    cout<<a/b<<endl;
  }
  else
    break;
}
  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <cmath>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int nmax = 8;
bool graph[nmax][nmax]; //パスを格納

int dfs(int v, int n, bool already[nmax]){
	bool ok = true; //全部通ったか

	rep(i, n){
		if (already[i]==false){
			ok = false;
		}
	}

	if (ok){
		return 1;
	}

	int ret = 0;
	rep(i, n){
		if (graph[v][i] == false){
			continue;
		}
		if (already[i]){
			continue;
		}
		already[i] = true; //通った
		ret += dfs(i, n, already);
		already[i] = false;
	}
	return ret;
}

int main(){
	int n, m, a, b;
	cin >> n >> m;
	rep(i, m){
		cin >> a >> b;
		graph[a-1][b-1] = graph[b-1][a-1] = true;
	}
	bool already[nmax];
	rep(i,n){
		already[i] = false;
	}

	already[0] = true; //初期地点は通ったことにする
	puts(dfs(0, n, already))
}


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

using namespace std;
typedef long long ll;
ll a[10005];
ll b[10005];
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  ll ans = 0;
  
  for(int i = 0; i < n; i++) {
    if(a[i] == b[i]) continue;
    else if(a[i] < b[i]) ans += (b[i] - a[i]) / 2;
    else {
      ans -= a[i] - b[i];
    }
  }

  if(ans < 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void){
  
  int N,T,E;
  int x[10000];
  int flag = 0;
  int ans = -1;
  int temp;
 
 
  cin >> N >> T >> E;
 
  for( int i = 1 ; i <= N ; i++ ){
 
    cin >> x[i];
    temp = x[i];
 
    for( int j = 1 ; j <= N ; j++ ){
 
      if( flag == 0 ){
      	if( x[i] >= T - E && x[i] <= T + E ){
       	  flag = 1;
	  ans = i;
	}
     
	x[i] += temp;
      }
     
    }

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

Measured memory_bytes: 1172
// AOJ 1634 Balance Scale
// bal4u 2019.8.12

#include <stdio.h>
#include <string.h>

//// 入出力関係
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 整数の表示（出力）
	int i;
	char b[20];

	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
		
	}
	pc('\n');
}

//// ハッシュ関数
#define HASHSIZ 1000003
typedef struct { int n, b; } HA;
int ha1[HASHSIZ+5], *hae1 = ha1 + HASHSIZ;
HA  ha2[HASHSIZ+5], *hae2 = ha2 + HASHSIZ;

int lookup1(int n) {
	int *p = ha1 + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 1;
		if (++p == hae1) p = ha1;
	}
	return 0;
}

void insert1(int n) {
	int *p = ha1 + n % HASHSIZ;
	while (*p) {
		if (*p == n) return;
		if (++p == hae1) p = ha1;
	}
	*p = n;
}

int lookup2(int n, int b) {
	HA *p = ha2 + n % HASHSIZ;
	while (p->n) {
		if (p->n == n) {
			if (p->b == b-1) { p->b = b; return 1; }
			return 0;
		}
		if (++p == ha2) p = ha2;
	}
	return 0;
}

void insert2(int n) {
	HA *p = ha2 + n % HASHSIZ;
	while (p->n) {
		if (p->n == n) return;
		if (++p == ha2) p = ha2;
	}
	p->n = n, p->b = 1;
}

//// 本問題関連
#define INF 0x7fffffff
#define ABS(x)  ((x)>=0?(x):-(x))
int q[60000];   // 3^10
int a[102];
int w[12];
		
int main()
{
	int n, m, i, j, end, x, ans;
	
	while (n = in()) {
		m = in();
		for (i = 0; i < n; i++) a[i] = in();
		for (i = 0; i < m; i++) w[i] = in();
		q[0] = 0, end = 1;
		for (i = 0; i < m; i++) {
			int e = end;
			for (j = 0; j < e; j++) {
				q[end++] = q[j] + w[i];
				q[end++] = q[j] - w[i];
			}
		}
		memset(ha1, 0, sizeof(ha1));
		for (i = 0; i < end; i++) if (q[i] > 0) insert1(q[i]);
		x = 0, ans = 0; for (i = 0; i < n; i++) if (!lookup1(a[i])) {
			if (x == 0) {
				int t; ans = INF;
				memset(ha2, 0, sizeof(ha2));
				for (j = 0; j < end; j++) {
					if ((t = ABS(a[i]-q[j])) < ans) ans = t;
					insert2(t);
				}
				x = 1;
			} else {
				int t, r = 0; x++, ans = INF;
				for (j = 0; j < end; j++) {
					t = ABS(a[i]-q[j]);
					if (lookup2(t, x)) {
						if (t < ans) ans = t;
						r = 1;
					}
				}
				if (r == 0) { ans = -1; break; }
			}
		}
		out(ans);
	}
	return 0;
}


Measured memory_bytes: 13528
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
const int MAXN = 1e5+2;
int N, M, dp[MAXN], ans;
bool vis[MAXN];
vector<int>adj[MAXN];
void dfs(int cur){
	if(vis[cur])return;
	vis[cur] = true;
	int b = 0;
	for(int i:adj[cur]){
		dfs(i);
		b = max(dp[i]+1, b);
	}
	dp[cur] = b;
	ans = max(ans, b);
	return;
}
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N >> M;
	for(int i = 0, x, y;i<M;i++){
		cin >> x >> y;
		adj[x].push_back(y);
	}
	for(int i = 1;i<=N;i++){
		if(!vis[i])dfs(i);
	}
	cout << ans << el;
	return 0;
}

Measured memory_bytes: 8320
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

A, B = mi()

if abs(A-B)%2==1:
  print('IMPOSSIBLE')
  exit()
else:
  print((A+B)//2)





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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c;
  cin >> k;

  for (int i = 0; i < k; ++i){
    if (a >= b){
      b *= 2;
    } else if (b >= c){
      c *= 2;
    }
  }

  if ((a < b) && (b < c)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

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

    for(int i = 0;i < s.size();++i){
        cout << 'x';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num1[] = new int[6];
		for (int i = 0; i < 6; i++) {
			num1[i] = sc.nextInt();
		}
		Dice d1 = new Dice(num1);

		int num2[] = new int[6];
		for (int i = 0; i < 6; i++) {
			num2[i] = sc.nextInt();
		}
		Dice d2 = new Dice(num2);

		if (isEqualDice(d1, d2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static boolean isEqualDice(Dice d1, Dice d2) {
		while (true) {
			if (d1.num[0] == d2.num[0]) {
				break;
			}
			if (d1.num[0] == d2.num[1]) {
				d2.rollNorth();
			} else if (d1.num[0] == d2.num[2]) {
				d2.rollWest();
			} else if (d1.num[0] == d2.num[3]) {
				d2.rollEast();
			} else if (d1.num[0] == d2.num[4]) {
				d2.rollSouth();
			} else if (d1.num[0] == d2.num[5]) {
				d2.rollSouth();
				d2.rollSouth();
			} else {
				return false;
			}
		}

		while (true) {
			if (d1.num[1] == d2.num[1]) {
				break;
			}
			if (d1.num[1] == d2.num[2]) {
				d2.rollLeft();
			} else if (d1.num[1] == d2.num[3]) {
				d2.rollRight();
			} else if (d1.num[1] == d2.num[4]) {
				d2.rollRight();
				d2.rollRight();
			} else {
				return false;
			}
		}

		if (d1.num[2] == d2.num[2]) {
			return true;
		} else {
			return false;
		}
	}
}

class Dice {
	int num[];
	int temp;

	public Dice(int num[]) {
		this.num = num;
	}

	void printDice() {

		for (int i = 0; i < 6; i++) {
			System.out.print(num[i] + " ");
		}
		System.out.println();
	}

	void printDiceSide(int upSide, int frontSide) {
		while (true) {
			if (upSide == num[0] && frontSide == num[1]) {
				break;
			}

			if (upSide == num[1]) {
				rollSouth();
			} else if (upSide == num[2]) {
				rollEast();
			} else if (upSide == num[3]) {
				rollWest();
			} else if (upSide == num[4]) {
				rollNorth();
			} else if (upSide == num[5]) {
				rollSouth();
				rollSouth();
			}
			if (frontSide == num[2]) {
				rollRight();
			} else if (frontSide == num[3]) {
				rollLeft();
			} else if (frontSide == num[4]) {
				rollRight();
				rollRight();
			}
		}
		System.out.println(num[2]);
	}

	void rollWest() {
		temp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = temp;
	}

	void rollNorth() {
		temp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = temp;
	}

	void rollEast() {
		temp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = temp;
	}

	void rollSouth() {
		temp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = temp;
	}

	void rollRight() {
		temp = num[1];
		num[1] = num[3];
		num[3] = num[4];
		num[4] = num[2];
		num[2] = temp;
	}

	void rollLeft() {
		temp = num[1];
		num[1] = num[2];
		num[2] = num[4];
		num[4] = num[3];
		num[3] = temp;
	}
}

Measured memory_bytes: 26384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

public class Main {

    public static void main(String[] args) {

        List<String> inputList = new LinkedList<String>();

        try {
            setList(inputList);

            int rectangle = 0;
            int diamond = 0;

            for (String input : inputList) {

                String[] length = input.split(",");
                int x = Integer.parseInt(length[0]);
                int y = Integer.parseInt(length[1]);
                int diagonal = Integer.parseInt(length[2]);

                // 長方形の判定
                if (x * x + y * y == diagonal * diagonal) {
                    rectangle++;
                }

                // ひし形の判定
                if (x == y && x + y > diagonal) {
                    diamond++;
                }
            }

            System.out.println(rectangle);
            System.out.println(diamond);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void setList(List<String> inputDataList) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String input = null;

        try {
            while ((input = in.readLine()) != null) {
                inputDataList.add(input);
            }
        } finally {
            in.close();
        }
    }
}

Measured memory_bytes: 17092
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, a, b, cnt = 1;
    bool ok = 0; 
    cin >> k >> a >> b;
    for (int i = 1; i <= b/k; ++i)
        if (k * i >= a && k * i <= b) {ok = 1; break;}
    cout << (ok ? "OK" : "NG") << '\n';
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
  
using namespace std;
int main(){
        int size;
        cin >> size;
        vector<long>values;
        for(int i=0; i<size; i++){
                long next;cin>>next;
                values.push_back(next);
        }

        long maxx=values.at(0);
        long answer=0;
        for(int i=1; i<size; i++){
                        maxx= max(maxx,values.at(i));
                        answer+=(maxx-values.at(i));

        }
        cout << answer;

}

Measured memory_bytes: 5340