akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	int h, w;
	string s;
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> s;
			if (s == "snuke") {
				cout << (char)('A' + j) << i + 1 << endl;
			}
		}
	}

}




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


	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse
h = Hash.new(0)

ans = 0
a.each{|t|
  r = 1<<t.bit_length
  if h[t]>0
    h[t]-=1
    ans+=1
  else
    h[r-t]+=1
  end
}

p ans


Measured memory_bytes: 31460
#include<iostream>
#include<algorithm>
using namespace std;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    int n,W;
    cin>>n>>W;
    long long w[110],v[110];
    for(int i=0;i<n;++i) cin>>w[i]>>v[i];

    long long dp[110][100010]={0};
    for(int i=0;i<=n;++i){
        for(int j=0;j<=W;++j){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<=W;++j){
            chmax(dp[i+1][j],dp[i][j]);
            if(j>=w[i]) chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
        }
    }
    
    cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 86144
// コイン問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cassert>

#include<vector>
#include<queue>
#include<set>

using namespace std;

const int INF = 100000;
const int MAX_N = 50000;
const int MAX_M = 20;

// コインの額面を保持する配列
// ( １を開始とする配列 )
int C[MAX_N + 1];
// コインの枚数を保持する配列
int T[MAX_M + 1][MAX_N + 1];

// n : 支払額, m : コインの種類
int n, m;

int CoinProblem();

int main(void)
{

    // 配列の初期化
    for(int i = 0; i < MAX_M + 1; i++)
    {
        for(int j = 0; j < MAX_N + 1; j++)
        {
            if( j == 0 )
            {
                // 支払額がゼロの時は, コインは不要
                T[i][j] = 0;
            }
            else
            {
                // 初期値の設定
                T[i][j] = INF;
            }
        }
    }

    cin >> n >> m;

    for(int i = 1; i <= m; i++)
    {
        // 要素数：１からコインの要素を入れていく
        cin >> C[i];
    }

    // 動的計画法からコイン問題を解く
    CoinProblem();

    printf("%d\n", T[m][n]);

    return 0;
}

// コイン問題を解く関数
int CoinProblem()
{

    for(int j = 0; j <= n; j++)
    {
        for(int i = 1; i <= m; i++)
        {
            int num = j - C[i];

            if( num >= 0 )
            {
                // i番目のコインを使う時
                T[i][j] = T[i][num] + 1;
            }
            else
            {
                // i番目のコインを使わない時
                T[i][j] = T[i - 1][j];
            }

            // コインの枚数が少ない方を設定する
            T[i][j] = min(T[i - 1][j], T[i][j]);
        }
    }

    return 0;

}



Measured memory_bytes: 7320
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt
  px = readline() |> split |> parseArray

  ix=zeros(Int,n)
  ix[px]=1:n
  l=[2:n+2...,n+2]
  r=[1,1:n+1...]

  ans=0
  for p in 1:n-1
    i=ix[p]+1
    x=l[i]
    y=r[i]
    w=l[x]
    z=r[y]

    ans+=p*((x-w)*(y-i)+(i-x)*(z-y))

    l[y]=x
    r[x]=y
  end

  println(ans)
end

main()


Measured memory_bytes: 152180
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		long ans = A+B+C-Math.Max(Math.Max(A,B),C);
		Console.WriteLine(ans);
	}
}


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

int main(void) {
    long long X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    long long ans;
    if (X / D < K && (K - X / D) % 2 == 1) {
        ans = D - (X - D * (X / D));
    } else if (X / D <= K) {
        ans = X - D * (X / D);
    } else {
        ans = X - D * K;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3760
# coding: utf-8
import sys


def main(argv=sys.argv):
  a, b, c, d = map(int, input().split(' '))
  
  if a + b > c + d:
    print('Left')
  elif a + b < c + d:
    print('Right')
  else:
    print('Balanced')
    
    
  return 0


if __name__ == '__main__':
  sys.exit(main())

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

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

    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a.at(i);
        //cout << "a.at(" << i << "): " << a.at(i) << endl;
    }

    int start = 1;
    int goal = 2;
    int next = 1;
    int count = 0;
    int normal_end = 0;
    int current = 1;
    for(int i = 0; i < n; i++) {
        current = next;
        next = a.at(current - 1);
        //cout << next << endl;
        ++count;
        if(next == goal) {
            normal_end = 1;
            break;
        }
    }
    if(normal_end == 1) {
        cout << count << endl;
    } else {
        cout << "-1" << endl;
    }
}



Measured memory_bytes: 640
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
	  #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
      }
	
int main()
{   
   //sublime();
   ios_base::sync_with_stdio(false);
	cin.tie(NULL);
   
	  ll n,i;
	   ll a,b,c;
	   cin>>a>>b>>c;
	   if(a<0)
	   	a*=-1;
	   double x=(double)a/(double)c;
	   double y=(double)b;
	   if(x>=y)
	   {
	   	 ll ans=a-b*c;
	   	 cout<<ans;
	   	 return 0;
	   }
	   ll val= (a+c-1)/c;
	   ll ans1=abs(a-val*c);
	   ll ans2=abs(a-(val-1)*c);
	   b-=val;
	   if(b&1)
	   	cout<<ans2;
	   else
	   	cout<<ans1;

	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <set> 
#include <iterator> 

using namespace std; 

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    multiset <long, greater <long> > health;
    multiset <long, greater <long> > :: iterator itr; 
    for(int i = 0; i<n; i++){
        long num;
        scanf("%ld", &num);
        health.insert(num);
    }
    int c = 0;
    int f1 = n-k;
    long sum = 0;
    multiset <long> health2(health.begin(), health.end());
    for(itr= health2.begin();itr!=health2.end();++itr){
        if(c<f1){
            c++;
            sum += *itr;
        }
        else{
            break;
        }
    }
   

    // long sum = 0;
    // for(int i=0; i<n-k;i++){
    //     sum +=health[i]; 
    // }
    printf("%ld",sum);

}

Measured memory_bytes: 18944
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(C>A && C<B){
        printf("Yes");
    }
    else if(C==A && C==B){
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    r, g, b = input().split()
    number = int(r + g + b)
    print("YES" if number % 4 == 0 else "NO")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int n;
long long num[55];
bool cmp(long long x, long long y) {
    return x > y;
}
long long work() {
    long long ans = 0;
    bool done = false;
    long long sigma = 0;
    long long cnt[55];
    sort(num + 1 ,num + n + 1, cmp);
    for(int i = 1;i <= n;i++) cnt[i] = 0;
    while(true) {
        for(int i = 1;i <= n;i++) {
            num[i] += sigma - cnt[i];
            sigma -= cnt[i];
            cnt[i] = num[i] / n;
            ans += cnt[i];
            sigma += cnt[i];
            num[i] %= n;
            if(!sigma) break;
        }
        if(!sigma) break;
    }
    return ans;
}
int main () {
    while(cin >> n) {
        for(int i = 1;i <= n;i++) cin >> num[i];
        long long cnt = 0;
        for(int i = 1;i <= n;i++) cnt += num[i];
        cnt -= (n-1)*n;
        if(true) {
            cout << work() << endl;
        } else {
            cout << cnt + (n-1)*n/2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//created by pyoxiao on 2020/04/26
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 2019;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
char s[200010];
int st[2100];
void solve() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    int cur = 0;
    LL ans = 0;
    for(int i = n; i >= 1; i --) {
        cur = (cur % mod + fpow(10, n - i + 1) * (s[i] - '0') % mod + mod) % mod;
        //cout << cur << ' ';
        if(cur == 0) ans ++;
        if(st[cur]) {
            ans += st[cur];
        }
        st[cur] ++;
    }
    //puts("");
    printf("%lld\n", ans);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define pb push_back
#define SQ(a) (a)*(a)

const int N = 200005;

using namespace std;

vector<ll> divisors(10000009);


int main()
{
    std::ios::sync_with_stdio(false);
    //ll p = 1000000007; 
    
    int T = 1;
    //cin>>T;
    // cin.ignore(); must be there when using getline(cin, s)
    while(T--)
    {
        ll n;
        cin>>n;
        ll sum = 0;
         for (ll i = 1; i <= n; ++i)
             for (ll j = i; j <= n; j += i)
                divisors[j]+=1;
          for(ll i = 1;i<=n;i++)
          {
            sum += divisors[i]*i;
          }
          cout<<sum<<endl;

    }
    return 0;
}

 

Measured memory_bytes: 81244
n = gets.to_i
dt = n.times.map { gets.split.map(&:to_i) }
current = [0, 0, 0]
dt.each do |i|
  dist = (i[1] - current[1]).abs + (i[2] - current[2]).abs
  unless dist <= i[0] - current[0]
    puts 'No'
    exit 0
  end

  # if (dist - (i[0] - current[0])).even?
  if (dist.odd? && (i[0] - current[0]).odd?) || (dist.even? && (i[0] - current[0]).even?)
    current = i
    next
  else
    puts 'No'
    exit 0
  end
end

puts 'Yes'


Measured memory_bytes: 20812
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
y=[0 for i in range(len(X)-1)]
sum=0
for i in range(len(X)-1):
    y[i]=X[i+1]-X[i]
    sum+=y[i]
y.sort()
y.reverse()
if N>=M:
    print(0)
else:
    for i in range(N-1):
        sum-=y[i]
    print(sum)

Measured memory_bytes: 13968
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	string S;
	cin >> S;

	string fes = "FEStival";
	for (int i = 0; i < S.length() - fes.length(); i++)
	{
		cout << S[i];
	}
	cout << endl;

}





Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
S=input()
cnt = 0
for s in S:
    if s=='R':
        cnt += 1

yn(cnt>(N-cnt))

Measured memory_bytes: 3064
import sys
from functools import lru_cache

N = int(input())
sys.setrecursionlimit(10 ** 9)


@lru_cache(maxsize=10 ** 9)
def dfs(x):
    ans = False
    if x == 0:
        return True
    elif x < 0:
        return False
    else:
        ans |= dfs(x - 100)
        ans |= dfs(x - 101)
        ans |= dfs(x - 102)
        ans |= dfs(x - 103)
        ans |= dfs(x - 104)
        ans |= dfs(x - 105)
    return ans

print(1 if dfs(N) else 0)


Measured memory_bytes: 26440
#include<bits/stdc++.h>
#include <sys/stat.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
#ifdef LOCAL_DEBUG
	struct stat sb;
	ifstream in("/dev/shm/input.txt");
	if (stat("/dev/shm/input.txt",&sb)==0){ cin.rdbuf(in.rdbuf()); }
#endif
	int N;
	cin >> N;
	ll maxA=-1;
	ll maxB=0;
	for(int i=0;i<N;i++){
		ll a,b;
		cin >> a >> b;
		if (maxA<a){
			maxA = a;
			maxB = b;
		}
	}
	printf("%ld\n",maxA+maxB);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin>>n;
	vector<int>x;
	for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        x.push_back(a-i);
	}
	sort(x.begin(),x.end());
	int b = x[n/2];
	long long int ans = 0;
	for(int i=0;i<n;i++){
        ans+=abs(x[i]-b);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>

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

  unsigned N = 0;
  std::cin >> N;
  unsigned dp[3];
  unsigned a, b, c;
  for (unsigned i = 0; i < N; ++i)
  { 
    std::cin >> a >> b >> c;
    if (i > 0)
    { 
      a = a + std::max(dp[1], dp[2]);
      b = b + std::max(dp[0], dp[2]);
      c = c + std::max(dp[0], dp[1]);
    }
    dp[0] = a;
    dp[1] = b;
    dp[2] = c;
  }
  std::cout << std::max({dp[0], dp[1], dp[2]});

  return 0;
}

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

#define MOD 1000000007
#define INF 100000000000

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

vector<vector<int>> G;
vector<int> dp;

int rec(int v) {
    if (dp[v] >= 0) return dp[v];
    int ret = 0;
    for (int u : G[v]) {
        ret = max(ret, rec(u) + 1);
    }
    return dp[v] = ret;
}

int main(int argc, char const *argv[]) {
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= 1;
    }

    vector<int> visited(N, -1);
    int count = 0;
    int town = 0;
    while (true) {
        // print(count, town);
        if (visited[town] != -1) break;
        visited[town] = count;
        count += 1;
        town = A[town];
    }

    if (K >= visited[town]) {
        int loop_len = count - visited[town];
        int res = (K - visited[town]) % loop_len;
        // print("loop_len", loop_len, res, town);
        for (int i = 0; i < res; ++i) {
            town = A[town];
        }
    } else {
        town = 0;
        for (int i = 0; i < K; ++i) {
            town = A[town];
        }
    }

    cout << town + 1 << endl;

    return 0;
}


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


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

    bool ans = true;
    bool aCheck = false;
    bool cCheck = false;


    if (S[0] == 'A') {
        aCheck = true;
        for (int i = 1; i < S.size(); ++i) {
            if (S[i] >= 'a' && S[i] <= 'z') {
                continue;
            } else if (i >= 2 && i <= S.size() - 2 && !cCheck) {
                if (S[i] == 'C') {
                    cCheck = true;
                }
            } else {
                ans = false;
            }
        }
    } else {

    }

    if (ans && aCheck && cCheck) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		double a = nd();
		double b = nd();
		double h = nd();
		double m = nd();

		double mm = 6.0 * m;
		double hh = (0.5 * (h * 60.0 + m)) % 360;
		double ang = Math.abs(360 - Math.abs(hh - mm)) % 360;

		if (ang == 0) {
			out(Math.abs(a - b));
		} else if (ang == 180) {
			out(a + b);
		} else {
			out(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang * Math.PI / 180)));
		}

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


Measured memory_bytes: 37472
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r){
    if(l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(),find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m + 1,r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0,pre.size());
    for (int i = 0; i < n ; ++i) {
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main(){
    int k;
    cin >> n;

    for (int i = 0; i < n ; ++i) {
        cin >> k;
        pre.push_back(k);
    }
    for (int i = 0; i < n ; ++i) {
        cin >> k;
        in.push_back(k);
    }
    solve();
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

int M, D;

void _main() {
	cin >> M >> D;
	int count = 0;

	rep(m, 1, M + 1) {
		rep(d, 1, D + 1) {

			if (d >= 10) {

				int d10 = d / 10;
				int d1 = d % 10;


				if (d10 >= 2 && d1 >= 2  && d10 * d1 == m) {
					count++;
				}
			}
		}
	}


	cout << count << endl;
}

Measured memory_bytes: 256
program i_hate_factorization
    integer(8) X
    integer(8) i, j
    integer(8) :: ans = 0
    logical :: det = .false.
    read *, X
    do i = 119, -118, -1
        if(det .eqv. .true.)exit
        do j = -118, 119, 1
            ans = (i**5)-(j**5)
            if(x == ans)then
                det = .true.
                print *, i, '', j
                exit
            end if
        end do
        
    end do
end program

Measured memory_bytes: 2792
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll ans[200005];

int main(){
	ll N, Q;
	cin >> N >> Q;

	vector<tuple<ll, ll, ll> > XST;

	rep(i, N) {
		ll s, t, x;
		cin >> s >> t >> x;
		s-=x;
		t-=x;
		XST.emplace_back(x, s, t);
	}

	sort(XST.begin(), XST.end());
	
	map<ll, ll> memo;
	set<ll> D;
	rep(i, Q) {
		ll tmp;
		cin >> tmp;
		D.insert(tmp);
		memo[tmp] = i;
		ans[i] = -1;
	}

	rep(i, N) {
		ll x = get<0>(XST[i]);
		ll s = get<1>(XST[i]);
		ll t = get<2>(XST[i]);

		set<ll>::iterator it = D.lower_bound(s);
		while(it != D.end() && *it < t) {
			ans[memo[*it]] = x;
			D.erase(it++);
		}
	}

	rep(i, Q) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 31332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int W = s.nextInt();
		int H = s.nextInt();
		int C = s.nextInt();
		
		int a = 0;
		int b = 0;
		int c = 0;
		int x = 0;
		
		if(W>H){
			a = W;
			b = H;
		}else{
			a = H;
			b = W;
		}                   
		
		
		while(C>0){
			if(a%b != 0){
				c = a;
				a = b;
				b = c%b;
				
			}else{
				x = b;
				break;
			}
		}
		
		System.out.println(W/x * H/x * C);         
	}
}

Measured memory_bytes: 26336
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    String str=s.next();
    if(str.charAt(str.length()-1)=='s'){
      str+="es";
    }
    else
      str+="s";
    
    System.out.println(str);
  }
}


Measured memory_bytes: 38452
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int a,b; cin >> a >> b;
    int tmp = 1;
    int ans = 0;
    while(tmp < b) ans++,tmp+=a-1;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define endl '\n'

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n + 1), b(n);
	ll sum = 0;
	rep(i, n + 1) cin >> a[i], sum += a[i];
	rep(i, n) cin >> b[i];
	//simple greedy lol
	rep(i, n){
		//do current
		if(b[i] >= a[i]){
			b[i] -= a[i];
			a[i] = 0;
		}
		else{
			a[i] -= b[i];
			b[i] = 0;
		}
		//do next
		if(b[i] >= a[i + 1]){
			b[i] -= a[i + 1];
			a[i + 1] = 0;
		}
		else{
			a[i + 1] -= b[i];
			b[i] = 0;
		}
	}
	ll rem = 0;
	rep(i, n + 1) rem += a[i];
	cout << sum - rem << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  string days[]={"Sunny", "Cloudy", "Rainy"};
  string mausam;
  cin>>mausam;
  int i;
  for(i=0;i<3;i++)
    	if(mausam==days[i])	break;
  cout<<days[(i+1)%3]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int payment, x, l, c, d, total, x2, l2, c2, d2;

    scanf("%d", &payment);
    while(1)
    {
        scanf("%d %d %d %d", &x, &l, &c, &d);

        total = 10 * x + 50 * l + 100 * c + 500 * d - payment;
        d2 = total / 500, total %= 500;
        c2 = total / 100, total %= 100;
        l2 = total / 50, total %= 50;
        x2 = total / 10;

        if(x > x2) printf("10 %d\n", x - x2);
        if(l > l2) printf("50 %d\n", l - l2);
        if(c > c2) printf("100 %d\n", c - c2);
        if(d > d2) printf("500 %d\n", d - d2);

        scanf("%d", &payment);

        if(!payment) break;
        else puts("");
    }

    return 0;
}

Measured memory_bytes: 608
#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(u==s)a--;
    if(u == t)b--;
    cout << a <<" "<< b<<endl; 


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC079
{
    class D
    {
        static long[] res;
        static int[,] c;

        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int Y = input[0];
            int X = input[1];

            int C = 10;
            c = new int[C, C];
            for (int y = 0; y < C; y++)
            {
                int[] cij = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int x = 0; x < C; x++)
                {
                    c[x, y] = cij[x];
                }
            }

            int[,] a = new int[X, Y];
            int[] count = new int[10];
            for (int y = 0; y < Y; y++)
            {
                int[] aij = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int x = 0; x < X; x++)
                {
                    a[x, y] = aij[x];
                    if (-1 < aij[x]) count[aij[x]]++;
                }
            }

            res = new long[10];
            for (int y = 0; y < 10; y++)
            {
                res[y] = c[1, y];
            }

            for (int i = 0; i < 10; i++)
            {
                Change(i, i, 0);
            }

            //Console.WriteLine(string.Join(",", res));
            long ans = 0;
            for (int i = 0; i < 10; i++)
            {
                ans += res[i] * count[i];
            }
            Console.WriteLine(ans);

            /*
            for (int y = 0; y < Y; y++)
            {
                for (int x = 0; x < X; x++)
                {
                    Console.Write(a[x, y]);
                }
                Console.WriteLine();
            }
            */


        }
        static void Change(int start, int now, int cost)
        {
            //if (start == 8) Console.WriteLine(cost);
            for (int next = 0; next < 10; next++)
            {
                if (next == now) continue;
                cost += c[next, now];

                if (next == 1) { res[start] = Math.Min(res[start], cost); }
                if (cost < res[start]) Change(start, next, cost);

                cost -= c[next, now];
            }
        }
    }
}


Measured memory_bytes: 15404
# 解説コード
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < 10000000; i++) {
		if ((1 << i) <= N) {
		}
		else {
			cout << (1 << (i - 1)) << endl;
			break;
		}
	}
}


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

using namespace std;

using ll = long long;

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

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

void Ans(ll N, vector<ll> A)
{
    ll total = 1;
    for(ll i=0;i<N;i++)
    {
        if((ll)1e18/A[i]<total)
        {
            OUT0("-1");
            return;
        }
        total *= A[i];
    }
    OUT0(total);
}

bool zero_check(vector<ll> A)
{
    for(auto x : A)
    {
        if(x==0)
        {
            return false;
        }
    }
    return true;
}

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

    vector<ll> A(N);
    ALLIN1_NUMBER(A);

    if(zero_check(A))
    Ans(N,A);
    else
    OUT0('0');

    return 0;
}

Measured memory_bytes: 4928
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
bool lexi(string& a,string& b){
    return lexicographical_compare(a.begin(),a.end(),b.begin(),b.end());
}
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    ll n,a,b;
    cin>>n>>a>>b;
    if((abs(b-a))%2==0){
        cout<<abs(b-a)/2;
    }
    else{
        ll ans=0;
        ll left=max(a-1,b-1);
        ll right=max(n-a,n-b);
        if(left<right){
            ll temp=min(a-1,b-1);
            a-=temp;
            b-=temp;
            ans+=temp;
            a=min(a,b);
            b=max(a,b);
            b--;
            ans++;
            ans+=abs(b-a)/2;
        }
        else{
            ll temp=min(n-a,n-b);
            a+=temp;
            b+=temp;
            ans+=temp;
            a=min(a,b);
            b=max(a,b);
            a++;
            ans++;
            ans+=abs(b-a)/2;
        }
        cout<<ans;

    }
 
 
    return 0;
             
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vll;
ll mod = 1e9+7, INF = 1e18;
int main(){
  ll n, sum = 0;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    a[i] = sum;
  }
  for (ll i = 0; i < n - 1; i++) {
    ll d = abs(a[n-1] - 2*a[i]);
    if (INF > d) INF = d;
  }
  
  cout << INF << endl;
}

Measured memory_bytes: 1792
N = int(input())
x = [0]*N
y = [0]*N
for i in range(N):
    x[i], y[i] = map(int, input().split())

import itertools
import math
dim = 0
count = 0
for n in itertools.permutations(range(N)):
    count += 1
    for num in range(1,N):
        x_dim = pow((x[n[num-1]]-x[n[num]]), 2)
        y_dim = pow((y[n[num-1]]-y[n[num]]), 2)
        dim += math.sqrt(x_dim + y_dim)

print(dim/count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

int n, p[510];
double d[510];

void solve(int tc){
	scanf("%d", &n);
	for(int i=1;i<=n;i++)scanf("%d", p+i);
	for(int i=1;i<=n;i++){
		d[i] = p[i];
		for(int j=i-1;j;j--){
			d[i] = max(d[i], d[j] + 2*sqrt(p[i] * p[j]));
		}
	}
	double ans = 0;
	for(int i=1;i<=n;i++)ans = max(ans, d[i] + p[i]);
	printf("%.8f\n", ans);
}

int main(){
	int Tc = 1;// scanf("%d",&Tc);
	for(int i=1;i<=Tc;i++){
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3224
x1, y1, x2, y2 = map(int,input().split())

x = abs(x1-x2)
y = abs(y1-y2)

if x1 >= x2 and y1 >= y2:
  x3 = x2 + y
  y3 = y2 - x
  x4 = x3 + x
  y4 = y3 + y
elif x1 <= x2 and y1 >= y2:
  x3 = x2 + y
  y3 = y2 + x
  x4 = x3 - x
  y4 = y3 + y
elif x1 <= x2 and y1 <= y2:
  x3 = x2 - y
  y3 = y2 + x
  x4 = x3 - x
  y4 = y3 - y
else:
  x3 = x2 - y
  y3 = y2 - x
  x4 = x3 + x
  y4 = y3 - y

print(x3,y3,x4,y4)

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

using namespace std;
using ll = long long;

template <typename T>
vector<T> divisor(T x) {
	vector<T> ret;
	for (T i = 1; i * i <= x; ++i) {
		if (x % i == 0) {
			ret.push_back(i);
			if (i * i != x) { ret.push_back(x / i); }
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}


int main() {
	ll N;
	cin >> N;
	vector<ll> v = divisor(N);

	ll res = 0;
	for (int i = 0; i < v.size(); ++i) {
		ll x = v[i];
		ll m = N / x - 1;
		if (m == 0) { continue; }
		if (N / m == N % m) { res += m; }
	}
	cout << res << endl;

	return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int SZ=1<<12;
vector<pair<int,int>> D[1<<18], T;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, v, w;
	cin>>N>>v>>w;
	D[1].emplace_back(0,0);
	D[1].emplace_back(w,v);
	for(int i=2;i<=N;i++) {
		int j=1, k=0, jsz, ksz;
		cin>>v>>w;
		T=D[i/2];
		for(auto &[W,V]: T) {
			W+=w;
			V+=v;
		}
		while(T.size() && T.back().first>100000) T.pop_back();
		D[i].emplace_back(0,0);
		if(i>=2*SZ && i<4*SZ) {
			jsz=ksz=1;
		}
		else {
			jsz=D[i/2].size();
			ksz=T.size();
		}
		while(j<jsz && k<ksz) {
			if(D[i/2][j]<T[k]) {
				if(D[i].back().first==D[i/2][j].first) D[i].pop_back();
				if(D[i].back().second<D[i/2][j].second) D[i].push_back(D[i/2][j]);
				j++;
			}
			else {
				if(D[i].back().first==T[k].first) D[i].pop_back();
				if(D[i].back().second<T[k].second) D[i].push_back(T[k]);
				k++;
			}
		}
		while(j<jsz) {
			if(D[i].back().first==D[i/2][j].first) D[i].pop_back();
			if(D[i].back().second<D[i/2][j].second) D[i].push_back(D[i/2][j]);
			j++;
		}
		while(k<ksz) {
			if(D[i].back().first==T[k].first) D[i].pop_back();
			if(D[i].back().second<T[k].second) D[i].push_back(T[k]);
			k++;
		}
	}
	for(cin>>N;N--;) {
		int v, L;
		cin>>v>>L;
		if(v<2*SZ) {
			w=upper_bound(D[v].begin(),D[v].end(),make_pair(L,0x7fffffff))-D[v].begin()-1;
			cout<<D[v][w].second<<'\n';
		}
		else {
			int p=v, j, ans=0;
			while(p>=2*SZ) p>>=1;
			for(auto[W,V]: D[v]) {
				if(W>L) break;
				j=upper_bound(D[p].begin(),D[p].end(),make_pair(L-W,0x7fffffff))-D[p].begin()-1;
				ans=max(ans,V+D[p][j].second);
			}
			cout<<ans<<'\n';
		}
	}
	return 0;
}

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

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

	for (int i = 0; 1; i++) {
		bool flag = true;
		for (int j = 0; j < n; j++) {
			if (p[j] == x-i) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << x-i << endl;
			return 0;
		}

		flag = true;
		for (int j = 0; j < n; j++) {
			if (p[j] == x+i) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << x+i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define INF 200000000
#define Maxn 13
#define Maxm 13

int n, m, x, c[Maxn], a[Maxn][Maxm], ul[Maxm], Res = INF;
bool choose[Maxn];

void dfs(int dep)
{
	if (dep > n)
	{
		for (int i=1; i<=m; i++) ul[i]=0;
		int Rep = 0;
		for (int i=1; i<=n; i++)
			if (choose[i])
			{
				Rep += c[i];
				for (int j=1; j<=m; j++) ul[j]+=a[i][j];
			}
		bool flag = true; for (int i=1; i<=m; i++) if (ul[i] < x) { flag = false; break; }
		if (flag) Res = min(Res, Rep);
		return;
	}
	for (int i=0; i<=1; i++)
	{
		choose[dep] = i;
		dfs(dep + 1);
	}
}

int main()
{
	scanf("%d%d%d", &n, &m, &x);
	for (int i=1; i<=n; i++)
	{
		scanf("%d", &c[i]);
		for (int j=1; j<=m; j++) scanf("%d", &a[i][j]);
	}
	dfs(1);
	if (Res == INF) puts("-1");
	else printf("%d\n", Res);
}

Measured memory_bytes: 3768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  char a; cin >> a;
  if(isupper(a)) cout << 'A' << endl;
  else cout << 'a' << endl;
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> wc(n,0);
    vector<int> ec(n,0);

    int co=0;
    for(int i=0;i<n;i++){
        wc.at(i) = co;
        if(s.at(i)=='W')co++;
    }

    co=0;
    for(int i=n-1;i>=0;i--){
        ec.at(i) = co;
        if(s.at(i)=='E')co++;
    }

    int mi=1000000;
    for(int i=0;i<n;i++){
        mi = min(mi,wc.at(i)+ec.at(i));
    }

    cout<<mi<<endl;
}





Measured memory_bytes: 3076
N, M = map(int, input().split())
X = list(map(int, input().split()))

x_ = sorted(X)
d = []
f = x_[0]
ans = 0
for n in x_[1:]:
    d.append(n - f)
    ans += n - f
    f = n

d_ = sorted(d, reverse=True)
ans -= sum(d_[:N-1])
print(ans)

Measured memory_bytes: 13968
#include<cstdio>
// printf scanf //
#include<cstring>
// char型の文字列を操作できるもの //

int main(){
    char s[201],t[101],p[101];
    // sを201個のメモリの文字型の箱にしましたよ //
    
    scanf("%s %s",s,p);
    //文字列として出力する（＆不要）//
    strcpy(t,s);
    // 文字列tの箱に文字列sをコピーする //
    strcat(s,t);
    // 文字列sの箱に文字列tを連結する //
     if (strstr(s,p) == NULL) printf("No\n");
     // 文字列sの箱からtを探す //
     else printf("Yes\n");
     
     return 0;
}



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


int main(){
  string s; cin >> s; bool flag = true;
  rep(i,s.size()){
    if(i % 2 == 0){
      if(s.at(i) == 'L'){
        flag = false;
        break;
      }
    }
    else{
      if(s.at(i) == 'R'){
        flag = false;
        break;
      }
    }
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> PP;
int wa[1000001];
int main(void)
{
	priority_queue<PP> qu;
	int i,q,n,a,v,x,y;
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++){
		wa[i]=0;
	}
	for(i=0;i<q;i++){
		scanf("%d %d",&a,&v);
		wa[a]+=v;
		qu.push(PP(wa[a],-a));
		while(1){
			x=qu.top().first;
			y=-qu.top().second;
			if(wa[y]==x){
				printf("%d %d\n",y,x);
				break;
			}
			else{
				qu.pop();
			}
		}
	}
	return 0;
}


Measured memory_bytes: 7292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 4e5+5;

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

	int n,k;
	cin>>n>>k;
	if(k==1)
		cout<<0;
	else
		cout<<n-k;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var strings = Enumerable.Range(0, n).Select(_ => Console.ReadLine()).ToArray();
            var result = strings
                .SelectMany(Divide)
                .ToLookup(x => x.Key, x => x.Value)
                .Where(x => x.Count() == n)
                .OrderBy(x => x.Key)
                .SelectMany(x => Enumerable.Repeat(x.Key, x.Min()));

            Console.WriteLine(string.Concat(result));
        }

        private static IReadOnlyDictionary<char, int> Divide(string data)
        {
            return data.GroupBy(x => x)
                .Select(x => (Char: x.Key, Count: x.Count()))
                .ToDictionary(x => x.Char, x => x.Count);
        }
    }
}

Measured memory_bytes: 28912
#include <bits/stdc++.h>
using namespace std;
int gcdl(int x, int y){
  if(y==0) return x;
  gcdl(y, x%y);
}
int main() {
  int n;
  cin >> n;
  int a[100100];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  vector<int> L(n+1);
  for(int i=0; i<n; i++){
    L[i+1] = gcdl(L[i], a[i]);
  }
  cout << L[n] << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

int dp[334][334];
int w[334];

int rec(int l, int r){
    assert(l < r);
    if(dp[l][r] >= 0) return dp[l][r];
    if(r-l == 1) return dp[l][r] = 0;
    int rm = (abs(w[r-1]-w[l]) <= 1 ? 2 : 0);
    if(r-l == 2) return dp[l][r] = rm;
    int ret = rec(l+1, r-1);
    if(ret == r-l-2) ret += rm;
    for(int mid=l+1; mid<r; mid++) {
        ret = max(ret, rec(l, mid)+rec(mid, r));
    }
    return dp[l][r] = ret;
}

int main(){
    int n;
    cin >> n;
    while(n > 0){
        memset(dp, -1, sizeof(dp));
        rep(i, n) cin >> w[i];
        cout << rec(0, n) << endl;

        // rep(i, n+1){
        //     rep(j, n+1) cout << dp[i][j] << " ";
        //     cout << endl;
        // }
        cin >> n;
    }
}




Measured memory_bytes: 3536