akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
//#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll pow(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
vector<int>g[100005];
int vis[100005];
int lev[100005];
void dfs(int s)
{
	vis[s]=1;
	for(int i=0;i<g[s].size();i++)
	{
		if(!vis[g[s][i]])
		{
			dfs(g[s][i]);
		}
	}
}
void bfs(int s)
{
	queue<int>q;
	q.push(s);
	vis[s]=1;
	lev[s]=0;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<g[x].size();i++)
		{
			if(!vis[g[x][i]])
			{
				vis[g[x][i]]=1;
				q.push(g[x][i]);
				lev[g[x][i]]=lev[x]+1;
			}
		}
	}
}


int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    //cin>>t;
    while(t--){
    	int r;
    	cin>>r;
    	float x=(44.0/7.0)*(r*1.0);
    	cout<<fixed << setprecision(10)<<x;
    }}
    	

Measured memory_bytes: 6168
#include<stdio.h>
int main(void)
{
  int min,max,sub,i,a,b;
  scanf("%d%d%d",&min,&max,&sub);
  a=min+sub-1;
  b=max-sub+1;
  if(a<b)
  {
    for(i=min; i<=a; i++)
    {
      printf("%d\n",i);
    }
    for(i=b; i<=max; i++)
    {
      printf("%d\n", i);
    }
  }
  else
  {
    for(i=min; i<=max; i++)
    {
      printf("%d\n", i);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
using namespace std;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}


int main(void) {
	int a, vMin, vMax;
	cin >> a;
	cin >> vMin >> vMax;

	bool isFind = false;
	do {
		int n = vMin % a;
		if (n == 0) {
			isFind = true;
			break;
		}

		int m = a - n;
		if ((vMin + m) <= vMax) {
			isFind = true;
			break;
		}
	} while (0);
	
	auto output = isFind ? "OK" : "NG";
	cout << output;
}


Measured memory_bytes: 3620
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n:i32 = read();
    let a:i32 = read();
    let rem = n % 500;
    if rem <= a {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D

// g++ -std=c++11 file_name.cpp
// ./file_name.out
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
//#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define YES printf("YES\n") ;
#define NO printf("NO\n") ;
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((ll) a.size())
typedef long long ll ;
const int MAXN = 1e6 + 10;
ll inf  = 1e18 ;
using namespace std ;
ll mod = 1e9 + 7;
ll mul(ll a , ll b){return ((a%mod)*(b%mod))%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a) ;}
ll powr(ll a , ll b) {if(b == 0) return 1LL ;ll x = powr(a,b/2) ;x = mul(x,x) ;if(b%2) return mul(a,x);return x;}
int main () {
    ll N ;
    cin >> N ;
    if(N == 1) cout<<0<<endl;
    else {
        N-- ;
        cout<<N*(N + 1)/2<<endl;
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100005];
bool f[100005];
main () {
	ll n,w;
	cin>>n>>w;
	
	for (int i=1; i<=100000; i++)
		dp[i]=1e15;
	
	f[0]=1;
	for (int i=1; i<=n; i++) {
		ll W,V;
		cin>>W>>V;
		for (int j=100000; j-V>=0; j--) 
			if (f[j-V]) 
				dp[j]=min(dp[j],dp[j-V]+W),f[j]=1;
	}
	
	ll ans=1e15,ANS=0;
	for (int i=1; i<=100000; i++)
		if (w>=dp[i]) ANS=i;
	cout<<ANS<<endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c)
        cout << "Yes" << "\n";
    else if (a + c == b)
        cout << "Yes" << "\n";
    else if (b + c == a)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
x1, x2, x3, x4, x5 = list(map(int, input().split()))
if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
elif x5 == 0:
    print(5)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl x[n][m];
    ccin(i,j,x);
    intl cnt = 0;
    rep(i,n){
        repi(j,i + 1,n){
            ld a = 0;
            rep(k,m){
                a += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            a = sqrtl(a);
            intl b = (intl)a;
            cnt += (a == b);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main() {
  std::string str1,str2;
  int n;
  int A[1001][1001];
  std::cin>>n;
  for(int i=0;i<n;i++){
    std::cin>>str1;
    std::cin>>str2;
    for(int j=0;j<1001;j++){
      for(int k=0;k<1001;k++){
	A[j][k]=0;
      }
    }
    for(int j=1;j<=str1.size();j++){
      for(int k=1;k<=str2.size();k++){
	if(str1[j-1]==str2[k-1]){
	  A[j][k]=A[j-1][k-1]+1;
	}else{
	  if(A[j-1][k]>A[j][k-1]){
	    A[j][k]=A[j-1][k];
	  }else{
	    A[j][k]=A[j][k-1];
	  }
	}
      }
    }
    std::cout<<A[str1.size()][str2.size()]<<"\n";
  }
  return 0;
 
}


Measured memory_bytes: 7108
#include <bits/stdc++.h>
#define t(w) int w; cin>>w; while(w--) 
typedef long long int ll; 
using namespace std;

void solve(){
	ll n;
	vector<ll> o,e;
	cin>>n;
	for(ll i=0;i<2*n;i++){
		ll a;
		cin>>a;
		if(a%2==0)
		e.push_back(i);
		else
		o.push_back(i);
	}
	if(e.size()%2!=0){
		e.pop_back();
		o.pop_back();
	}
	else if(o.size()%2==0){
		e.pop_back();
		e.pop_back();
	}
	
	for(ll i=0;i<e.size();i=i+2)
	cout<<e[i]+1<<" "<<e[i+1]+1<<endl;
	for(ll i=0;i<o.size();i=i+2)
	cout<<o[i]+1<<" "<<o[i+1]+1<<endl;
}
void solve1(){
	int n,k;
	vector<int> v;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	ll ans=0;
	for(int i=0;i<k;i++){
		ans+=v[i];
	}
	cout<<ans<<endl;
}
int main(){
	solve1();
	return 0;
}


Measured memory_bytes: 3548
#include <iostream>
using namespace std;
long long N,A[100002],B[100002];
int main(){
    long long i,x;
    cin >> N;
    for(i=1;i<=N+1;i++)
        cin >> A[i];
    for(i=1;i<=N;i++)
        cin >> B[i];
    x=0;
    A[0]=0;
    B[0]=0;

    for(i=1;i<=N;i++){
        if(A[i]>=B[i]){
            x=x+B[i];
            B[i]=0;  //一定要归零 不然下面会重复运算
        }
        else{
            x=x+A[i];
            B[i]=B[i]-A[i];  //先减掉
        }

        if(B[i]>=A[i+1]){
            x=x+A[i+1];
            A[i+1]=0; //归零
        }
        else if(B[i]>=0){
            x=x+B[i];
            A[i+1]-=B[i];
            B[i]=0;
        }
    }
    cout << x;
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  
  if( L > R ) {
    cout << "Left" << endl;
  }
  
  if( L == R ) {
    cout << "Balanced" << endl;
  }
  
  if( L < R ) {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
    int type, gram;
    cin >> type >> gram;
    int m[type];
    int kekka = 0;
    
    for (int i = 0; i < type; i++) {
        cin >> m[i];
        gram -= m[i];
        kekka++;
    }
    sort(m, m+type);
    while (gram >= m[0]) {
        gram -= m[0];
        kekka++;
    }
    
    cout << kekka << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

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

    string s;cin>>s;
    int w;cin>>w;
    string res="";
    int idx=0;
    while(idx<s.length()){
        res += s[idx];
        idx += w;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split(" ")))
m = int(input())
p_x = [tuple(map(int, input().split(" "))) for i in range(m)]

for i in range(m):
    t_ = t[:p_x[i][0]-1] + [p_x[i][1]] + t[p_x[i][0]:]
    print(sum(t_))

Measured memory_bytes: 3060
N = gets.to_i
A = gets.strip.split.map(&:to_i)
B = gets.strip.split.map(&:to_i)
a = []

for i in 0..N-1
    a[i] = A[i] - B[i]
end

a.sort!

i = 0
b = 0

while a[i] < 0
    b -= a[i]
    i += 1
end

j = 0
c = 0

while b > c && j <= N-1
    c += a[N-1-j]
    j += 1
end

if A.inject(:+) < B.inject(:+)
    puts -1
else
    puts j+i  
end


Measured memory_bytes: 20092
/*
 * Distance.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void) {

	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	double dDistance = 0.0;
	dDistance = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));

	cout << fixed << setprecision(8) << dDistance << endl;

	return 0;
}

Measured memory_bytes: 1280
import java.util.*;
import java.math.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static BigInteger a,b;
        public static void main(String[] args) {
                while(read()){
                        solve();
                }
        }
        static boolean read(){
                if(!sc.hasNext())
                        return false;
                a = sc.nextBigInteger(); b = sc.nextBigInteger();
                return true;
        }
        static void solve(){
                System.out.println(a.gcd(b));
        }
 
}

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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int x;
	cin >> x;
	if(x == 1){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
}

Measured memory_bytes: 3624
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BRACK 2
void visit(int);
int t=0,n;
int array[N][N], road_color[N] ,arr1[N], arr2[N];
int main(){
  int i,j,num1,num2,num3;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      array[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&num1,&num2);
    num1--;
    for(j=0;j<num2;j++){
      scanf("%d",&num3);
      num3--;
      array[num1][num3] = 1;
    }
  }
  for(i=0;i<n;i++) road_color[i] = WHITE;
 
  for(i=0;i<n;i++)  if(road_color[i] == WHITE) visit(i);
 
  for(i=0;i<n;i++) printf("%d %d %d\n", i+1,arr1[i],arr2[i]);
 
  return 0;
}
void visit(int u){
  int i;
  road_color[u] = GRAY;
  arr1[u] = ++t;
  for(i=0;i<n;i++){
    if(array[u][i] == 0) continue;
    if(road_color[i] == WHITE) visit(i);
  }
    road_color[i] = BRACK;
    arr2[u]=++t;
}

Measured memory_bytes: 636
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n,k) = scan "%d %d" Tuple2.make

let () =
  let i = n/k in
  Printf.printf "%d\n" @@ min (abs (n - k*i)) (abs (n-k*(i+1)))


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

    int N; cin >> N;
    if(N>=1000)cout << "ABD" << endl;
    else cout << "ABC" << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

int N = 0, a = 0, b = 0, c = 0, ans=1e9;
int l[8];

void dfs(int x, int A, int B, int C, int s) {
	if (x >= N) {
		if (A&&B&&C) {
			ans = std::min(ans, s + abs(a - A) + abs(b - B) + abs(c - C));
		}
		return;
	}

	dfs(x + 1, A, B, C, s);
	dfs(x + 1, A + l[x], B, C, s + 10 * (A>0));
	dfs(x + 1, A, B + l[x], C, s + 10 * (B>0));
	dfs(x + 1, A, B, C + l[x], s + 10 * (C>0));
}

int main() {



	cin >> N >> a >> b >> c;


	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	dfs(0, 0, 0, 0, 0);
	cout << ans << endl;

	return 0;

}
	


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const ll inf = 1e18 + 7;
const int N = 3e5 + 17;

ll n, s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (ll i = 2; i * i <= n; i++) {
		ll x = n;
		ll cur = 0;
		while (x) {
			cur += x % i;
			x /= i;
		}
		if (cur == s) { cout << i; re 0; }
	}
	ll m = n - s;
	if (!m) { cout << n + 1; re 0; }
	vll d;
	for (ll i = 1; i * i <= m; i++)
		if (m % i == 0) {
			d.pb(i);
			if (i != m / i) d.pb(m / i);
		}
	ll ans = inf;
	for (auto y: d) {
		ll b = m / y + 1;
		ll x = s - y;
		if (x >= 0 && x < b && y < b && x + b * y == n) ans = min(ans, b);
	}
	if (ans == inf) cout << -1;
	else cout << ans;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n1,n2) for(int i=n1;i<n2;i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    string s[100010];
    cin >> n;
    ll m=0,a=0,r=0,c=0,h=0;
    REP(i,n){
        cin >> s[i];
        if(s[i][0]=='M'){
            m++;
        }else if(s[i][0]=='A'){
            a++;
        }else if(s[i][0]=='R'){
            r++;
        }else if(s[i][0]=='C'){
            c++;
        }else if(s[i][0]=='H'){
            h++;
        }
    }
    ll res = m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ld EPS=10e-8;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

map<ll,ll> M;
 
int main() {
    ll N,Q,A,B;
    cin >> N >> Q;
    rep(i,Q){
        cin >>A >> B;
        M[A]++;M[B]++;
    }
    for(auto P : M){
        if(P.second%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 5632
t;main(a,b,c,d,e,f){for(;~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(b*f-c*e+0.)/t+0.,(c*d-a*f+0.)/t))t=b*d-a*e;}

Measured memory_bytes: 0
import java.util.*;

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

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

int main() {
 
  int N = 0;
  cin >> N;
  
  int64_t answer = 0; // リュカ数を初期化
  int64_t left = 2; // L0
  int64_t right = 1; // L1
  /*
  int l2 = l0 + l1; // 3
  int l3 = l1 + l2; // 4
  int l4 = l2 + l3; // 7
  int l5 = l3 + l4; // 11
  */
  
  for(int i = 1; i < N; i++) {
    answer = left + right;
    left = right;
    right = answer;
  } 
  
  if(N == 1) {
    answer = 1;
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S  = sc.next();
        char[]ss = S.toCharArray();

        int cou = 0;
        for(int i=0; i<S.length()/2; i++){
            if(ss[i]!=ss[i+S.length()/2]){
                cou++;
            }
}
        if(N%2!=0){
            System.out.print("No");
        }else if(cou==0){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
        }
     }


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

int main(){
  long long a, b, c, d;
  long long ans;
  cin >> a >> b >> c >> d;
  if (a >= 0 && d >= 0) ans = b * d;
  if (a >= 0 && d <= 0) ans = a * d;
  
  if (b <= 0 && c <= 0) ans =  a * c;
  if (b <= 0 && c >= 0) ans =  b * c;
  
  if (a < 0 && b > 0 && c > 0) ans  = b * d;
  if (a < 0 && b > 0 && d < 0) ans = a * c;
  if (a < 0 && b > 0 && c < 0 && d > 0) ans = max(a * c, b * d) ;
  cout << ans << endl;
}

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

int main() 
{
    int H,W;
    cin >> H >> W;
    vector<vector<char>> data(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++){
            cin >> data[i][j];
        }
    }
    
    string ans = "Yes";
    for (int i = 1; i < H-1; i++) {
        for (int j = 1; j < W-1; j++){
            if (data[i][j] == '#') {
                for (int k = 0; k < 4; k++) {
                    if (data[i][j+1] != '#' && data[i][j-1] != '#' && 
                        data[i+1][j] != '#' && data[i-1][j] != '#') {
                        ans = "No";
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int mx=100010;
struct Node{
	int u,co,l;
};
struct Node2{
	int id,co,d,k;
};
int n,m;
int fa[mx][20],dep[mx];
int dis[mx],cnt[mx],ret[mx];
vector<Node>G[mx];
vector<Node2>que[mx];
void pre(int x,int pr){
	fa[x][0]=pr;
	dep[x]=dep[pr]+1;
	for(auto to:G[x])if(to.u!=pr){
		pre(to.u,x);
	}
}
int update(int x,int dep){
	for(int i=0;i<=17;i++)if(dep&(1<<i))x=fa[x][i];
	return x;
}
int lca(int a,int b){
	if(dep[a]>dep[b])swap(a,b);
	b=update(b,dep[b]-dep[a]);
	if(a==b)return a;
	for(int i=17;i>=0;i--)
		if(fa[a][i]!=fa[b][i])a=fa[a][i],b=fa[b][i];
	return fa[a][0];
}
void dfs(int x,int pr,int d){
	for(auto cur:que[x]){
		ret[cur.id]+=cur.k*(d-dis[cur.co]+cnt[cur.co]*cur.d);
	}
	for(auto to:G[x])if(to.u!=pr){
		cnt[to.co]++,dis[to.co]+=to.l;
		dfs(to.u,x,d+to.l);
		cnt[to.co]--,dis[to.co]-=to.l;
	}
}
signed main(){
	cin>>n>>m;
	for(int i=1;i<n;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		G[a].pb((Node){b,c,d});
		G[b].pb((Node){a,c,d});
	}
	pre(1,0);
	for(int i=1;i<=17;i++)
		for(int j=1;j<=n;j++)
			fa[j][i]=fa[fa[j][i-1]][i-1];
	for(int i=1;i<=m;i++){
		int u,v,c,d;
		cin>>c>>d>>u>>v;
		que[u].pb((Node2){i,c,d,1});
		que[v].pb((Node2){i,c,d,1});
		que[lca(u,v)].pb((Node2){i,c,d,-2});
	}
	dfs(1,0,0);
	for(int i=1;i<=m;i++){
		cout<<ret[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 49680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;cin >> n;
  vector<long long> v(n);
  for (int i=0;i<n;i++) cin >> v[i];
  sort(v.begin(),v.end());
  double x=v[0]+v[1];
  x/=2;
  for (int i=2;i<n;i++) x=(x+v[i])/2;
  cout << fixed << setprecision(10) << x << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
int d[33][33];
int C[505][505];
int z[33];
int o[33];
int t[33];
const ll INF = 1e14;
int main() {
  int n,c;
  cin >> n >> c;
  for(int i = 1; i <= c; i++) {
    for(int j = 1; j <= c; j++) {
      cin >> d[i][j];
    }
  }

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

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      if((i + j) % 3 == 0) {
	z[C[i][j]]++;
      }
      else if((i + j) % 3 == 1) {
	o[C[i][j]]++;
      }
      else t[C[i][j]]++;
    }
  }
  ll ans = INF;

  for(int i = 1; i <= c; i++) {
    for(int j = 1; j <= c; j++) {
      if(i == j) continue;
      for(int k = 1; k <= c; k++) {
	if(i == k || j == k) continue;
	ll tmp = 0;
	for(int l = 1; l <= c; l++) {
	  tmp += d[l][i] * z[l];
	  tmp += d[l][j] * o[l];
	  tmp += d[l][k] * t[l];
	}
	ans = min(ans,tmp);
      }
    }
  }
  cout << ans << endl;
}
      


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

//mt19937 rng(333);
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N = 107;
const int MX = 107;

int dp[N][MX];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    int mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    sort(a.rbegin(), a.rend());
    map <int, int> who;
    int lst = -1;
    for (int i = 0; i < n; i++) {
        if (i == n - 1 || a[i] > a[i + 1]) {
            who[a[i] - 1 - i] = 1;
            for (int j = i - 1; j > lst; j--) {
                who[a[i] - 1 - j] = 3 - who[a[i] - 1 - (j + 1)];
            }
            lst = i;
        }
    }
    map <int, int> has;
    vector <pair <int, int> > cut;
    for (int i = 0; i + 1 < n; i++) {
        if (a[i] > a[i + 1]) {
            cut.push_back({a[i + 1] - 1, i});
            has[a[i + 1] - 1 - i] = 1;
        }
    }
    auto f = [&] (int x, int y) {
        int kek = a[y] - 1;
        int diff = kek - x;
        diff %= 2;
        return diff;
    };
    cut.push_back({0, n - 1});
    if (who[0]) {
        who[0]--;
        cout << (who[0] ? "First\n" : "Second\n");
    } else {
        if (has[0]) {
            bool good = false;
            for (auto to : cut) {
                if (to.first - to.second == 0) {
                    if (!f(to.first + 1, to.second) || who[to.first - to.second - 1] == 1) {
                        good = true;
                    }
                }
            }
            cout << (good ? "First\n" : "Second\n");
            return 0;
        }
        for (auto to : cut) {
            int x = to.second;
            if (x >= to.first && x <= a[to.second]) {
                cout << (f(x, x) ? "First\n" : "Second\n");
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 12648
#include<iostream>
using namespace std;
int main(){
    int h,w,i,j;
    for(;;){
    cin>>h>>w;
    if(h==0)exit(0);
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cout<<"#";
        }
        cout<<endl;
    }
    cout<<endl;
}
return 0;
}

Measured memory_bytes: 3024
#include <stdio.h>

int main(void)
{
 
  int a,b;
  int max;
  scanf("%d",&a);
  scanf("%d",&b);
  
    if(a>b+1){
    max=a+a-1;
  }else if(a+1<b){
    max=b+b-1;
  }else if(a==b){
    max=a+b;
  }else if(a==b+1){
    max=a+b;
  }else if(a+1==b){
    max=a+b;
  }
  
  printf("%d",max);
    
  return 0;
  
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 200

int V;
vector<int> G[NUM];
int match[NUM];
bool used[NUM];

void add_edge(int from,int to){
	G[from].push_back(to);
	G[to].push_back(from);
}

int dfs(int node_id){
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		int adj_node_id = G[node_id][i],pair_id = match[adj_node_id];
		if((pair_id < 0)||(used[pair_id] == false && dfs(pair_id) == true)){
			match[node_id] = adj_node_id;
			match[adj_node_id] = node_id;
			return true;
		}
	}
	return false;
}


int bipartie_matching(){
	int ret = 0;
	for(int i = 0; i < V; i++)match[i] = -1;
	for(int node_id = 0; node_id < V; node_id++){
		if(match[node_id] < 0){
			for(int i = 0; i < V; i++)used[i] = false;
			if(dfs(node_id)){
				ret++;
			}
		}
	}
	return ret;
}


int main(){

	int X,Y,E;

	scanf("%d %d %d",&X,&Y,&E);

	int from,to;

	for(int loop = 0; loop < E; loop++){
		scanf("%d %d",&from,&to);
		add_edge(from,X+to);
	}

	V = X+Y;

	printf("%d\n",bipartie_matching());

	return 0;
}



Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef  unsigned long long ULL;
typedef  double db;
typedef  long double ld;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fuck(x) cout<<x<<endl
#define fuck1(x,y) cout<<x<<" "<<y<<endl
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define MP(a,b) make_pair(a,b)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
const int INF = 0x3f3f3f3f3f,mod = 1e9+7;
const double eps  =1e-6,PI = acos(-1);
template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
const int maxn = 1e5+100;
int ax[maxn],done[maxn];
int main(){
    int N;
    read(N);
    for(int i = 1;i<=N;i++){
        read(ax[i]);
    }
    int max1 = ax[1],min1 = ax[1];
    bool flag = 0;
    for(int i = 2;i<=N;i++){
        if(max1>ax[i]&&max1-ax[i]>1)flag = 1;
        max1 = max(max1,ax[i]);
    }
    if(!flag)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <array>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    while(1) {
        int n,m;
        cin >> n >> m;
        if(n == 0 && m == 0) {
            break;
        }
        int s[200];    
        rep(i, n + m) {
            cin >> s[i];
        }
        int taro[n], hanako[m];
        int taros = 0, hanakos = 0;
        rep(i,n){
            taro[i] = s[i];    
            taros += s[i];
        }

        rep(i,m){
            hanako[i] = s[i+n];
            hanakos += s[i+n];
        }
        
        sort(taro, taro + n); 
        sort(hanako, hanako + m);

        int dif = taros - hanakos;
        if(dif % 2 == 1) {
            cout << "-1" << endl;    
            continue;
        }

        int sum = 200;
        int t = -1 ,h = -1;
        for(int i = n - 1; i > -1; i--) {
            rep(s,m) {
                if((taro[i] - hanako[s]) * 2 == dif) {
                    int tmp = taro[i] + hanako[s];
                    if(sum > tmp) {
                        sum = tmp;
                        t = taro[i];
                        h = hanako[s]; 
                    }
                }
            }
        }

        if(t != -1) {
            cout << t << " " <<  h << endl;
        } else {
            cout << "-1" << endl;
        }
        
    }
	return 0;
}

Measured memory_bytes: 3020
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread!ulong();
    bool b = A.reduce!((a, b) => a ^ b) == 0;
    writeln(b ? "Yes" : "No");
}


Measured memory_bytes: 4348
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . which "Heisei" "TBD" . ( <= "2019/04/30" )

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

int main() {
    vector <char> alphabet(26);
    alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'K', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    char xxx;
    cin >> xxx;
    for(int i = 0; i < 26; i++){
        int tmp = alphabet[i];
        if(tmp == xxx){
            cout << alphabet[i+1];
            break;
        }
    }
}


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

int main(){

  int N,L;
  cin >> N >> L;
  vector<int> A(N);
  for (int i = 0;i < N; i++) A.at(i) = i + L;
  
  bool isZero = 0;
  int sum = 0;
  
  for (int i = 0;i < N; i++){
    sum += A.at(i);
    if (A.at(i) == 0) isZero = 1;
  }

  if (A.at(0) > 0) sum -= A.at(0);
  if (A.at(N-1) < 0) sum -= A.at(N-1);
  
  cout << sum << endl;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

signed main() {
   string s;
   cin >> s;
   for (char &c:s) {
      if (c == '1') {
         c = '9';
      } else if (c == '9') {
         c = '1';
      }
   }
   cout << s << endl;

   return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0, left = 0, right = n - 1;
	while (left <= right) {
		if (s[left] == 'x'&&s[right] != 'x') {
			ans++;
			left++;
		}
		else if (s[left] != 'x'&&s[right] == 'x') {
			ans++;
			right--;
		}
		else if (s[left] == s[right]) {
			left++;
			right--;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    for(auto& e: w) cin >> e;
    vector<int> s_1(n+1), s_2(n+1);
    s_1[0] = 0;
    s_2[n] = 0;
    for(int i = 1;i <= n;i++) s_1[i] = s_1[i-1] + w[i-1];
    for(int i = n - 1;i >= 0;i--) s_2[i] = s_2[i+1] + w[i];
    int res = abs(s_1[n] - s_2[n]);
    for(int i = 1;i < n;i++) res = min(res, abs(s_1[i] - s_2[i]));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 2003;
const ll MOD = 1000000007;

int h, w, le[MAXN], re[MAXN], hei[MAXN];
bool org[MAXN][MAXN], tra[MAXN][MAXN], fin[MAXN][MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> h >> w;
    REP1 (i, h) {
        REP1 (j, w) {
            char c;
            cin >> c;
            org[i][j] = c == '#';
            tra[i][j] = org[i][j] ^ org[i-1][j];
            fin[i][j] = tra[i][j] ^ tra[i][j-1] ^ 1;
        }
    }

    REP1 (i, h) {
        fin[i][1] = 0;
    }
    REP1 (i, w) {
        fin[1][i] = 0;
    }

    int ans = max(h, w);
    REP1 (i, h) {
        REP1 (j, w + 1) {
            hei[j] = fin[i][j] ? hei[j] + 1 : 0;
        }
        vector<pair<int,int> > l, r;
        REP1 (j, w+1) {
            while (!l.empty() && l.back().second >= hei[j]) {
                l.pop_back();
            }
            if (l.size()) {
                le[j] = l.back().first;
            }
            l.emplace_back(j, hei[j]);
        }

        for (int j=w+1; j>=1; j--) {
            while (!r.empty() && r.back().second >= hei[j]) {
                r.pop_back();
            }
            if (r.size()) {
                re[j] = r.back().first;
            }
            r.emplace_back(j, hei[j]);
        }

        REP1 (j, w) {
            ans = max(ans, (hei[j]+1) * (re[j]-le[j]));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12032
#include <stdio.h>

int main(){
int c1,c5,c10,c50,c100,c500;

while(scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500)!=EOF){

if(c1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000)printf("1\n");
else printf("0\n");

}
return 0;
}

Measured memory_bytes: 1012
a,b = [int(i) for i in input().split()]
if (a-1)%4 == 0:
  s_a = a-1
elif (a-1)%4 == 1:
  s_a = 1
elif (a-1)%4 == 2:
  s_a = (a-1)^1
else:
  s_a = 0
  
if b%4 == 0:
  s_b = b
elif b%4 == 1:
  s_b = 1
elif b%4 == 2:
  s_b = b^1
else:
  s_b = 0
  
print(s_a^s_b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;
const string YES = "YES";
const string NO = "NO";

void solve();

ll H;
ll W;
vector<string> S;
vl ord;
bool ok;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> H;
    cin >> W;
    S=vector<string>(H);
    for(int i = 0; i < H; ++i){
        cin >> S[i];
    }
    solve();
}

void g(){
    vector<string> s(W);
    rep(i,H)rep(j,W){
        s[j]+=S[ord[i]][j];
    }
    map<string,ll> mp;
    rep(i,W){
        string rev=s[i];
        reverse(all(rev));
        if(mp[rev])mp[rev]--;
        else mp[s[i]]++;
    }
    ll sum=0;
    for(auto &p:mp){
        if(!p.second)continue;
        sum+=p.second;
        string rev=p.first;
        reverse(all(rev));
        if(rev!=p.first)return;
    }
    ok|=sum<=1;
}
void f(ll b,ll d){
    if(b==(1<<H)-1){
        g();
        return;
    }
    ll l=d;
    while(b>>l&1)++l;
    ord[d]=l;
    b|=1<<l;
    rep(r,l,H){
        if((b>>r&1)==0){
            ord[H-1-d]=r;
            f(b|1<<r,d+1);
        }
    }
}
void solve(){
    ord=vl(H);
    if(H%2)rep(i,H)ord[H/2]=i,f(1<<i,0);
    else f(0,0);
    cout<<(ok?YES:NO)<<endl;
}



Measured memory_bytes: 256
#include<iostream>

int s, t;

int main()
{
	int x;
	for( int i = 0; i < 4; i++ ){
		std::cin >> x;
		s += x;
	}
	
	for( int i = 0; i < 4; i++ ){
		std::cin >> x;
		t += x;
	}
	
	std::cout << std::max( s, t ) << std::endl;
	
 	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 5050
int K,n;
struct A {
	char s[10];
	bool operator < (const A &x) const {
		return strcmp(s,x.s)<0;
	}
	bool operator == (const A &x) const {
		return strcmp(s,x.s)==0;
	}
}a[N<<3];
char s[N];
int main() {
	int cnt=0;
	scanf("%s%d",s,&K);
	int i,j,k;n=strlen(s);
	for(i=0;i<n;i++) {
		for(j=1;j<=5&&i+j-1<n;j++) {
			++cnt;
			for(k=i;k<=i+j-1;k++) a[cnt].s[k-i]=s[k];
		}
	}
	sort(a+1,a+cnt+1);
	cnt=unique(a+1,a+cnt+1)-a-1;
	printf("%s\n",a[K].s);
}

Measured memory_bytes: 1904
#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 a, p;
  cin >> a >> p;
  p = p + a*3;
  int ans;
  ans = p/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
def calBonus():
    s = 0
    for i in range(n - 1):
        if a[i + 1] == a[i] + 1:
            s += c[a[i] - 1]

    return s


n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

base = sum(b)
bonus = calBonus()
print(base + bonus)


Measured memory_bytes: 3064
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: usize = read();
  let k: u64 = read();
  let mut res = 1;

  for i in 0..n {
    if res + k < 2 * res {
      res += k;
    }
    else {
      res *= 2;
    }
  }
  println!("{}", res);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    cout<<fixed<<setprecision(12);
    double r;
    cin>>r;
    double PI=acos(-1);
    double area=r*r*PI;
    double cir=(r+r)*PI;
    cout<<area<<" "<<cir<<endl;
    return 0;
}


Measured memory_bytes: 3260
N = int(input())
ABs = []
E = [set() for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  ABs.append((a, b))
  E[a].add(b)
  E[b].add(a)
K = max([len(s) for s in E])
print(K)
Is = sorted(range(N-1), key=lambda i: ABs[i])
#IIs = [-1]*(N-1)
#for i in Is:
#  IIs[Is[i]] = i
#print(Is)
#print(IIs)
cs = [-1]*(N-1)
V = [-1]*N
for i in range(N-1):
  j = Is[i]
  a, b = ABs[j]
  c = V[a]
  c = (c+1)%K
  V[a] = c
  V[b] = c
  cs[j] = c
#print(cs)
for c in cs:
  print(c+1)


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

ll n,m,a[N],l[N],r[N],rsub[N],cnt,x,maxx,ret;

int main(int argc, const char *argv[])
{
	cin>>n>>m;
	for (ll i = 0; i < n; i++) {
		cin>>a[i];
		a[i]--;
	}
	for (ll i = 0; i < n-1; i++) {
		l[a[i]]++;
		r[a[i+1]]++;
		rsub[(a[i+1]+1)%m]+=a[i]<a[i+1]?(a[i+1]-a[i]-1):(a[i+1]+m-a[i]-1);
		if(a[i]==m-1&&a[i+1]!=0){
			cnt++;
		}
		else if(a[i+1]==0){
			x+=(0+m-a[i]-1);
		}
		else if(a[i]>a[i+1]){
			x+=(0+m-a[i]-1);
			cnt++;
		}
		if(a[i]<a[i+1]){
			ret+=a[i+1]-a[i];
		}
		else{
			ret+=a[i+1]+m-a[i];
		}
	}
	maxx=x;
	for(ll i=1;i<m;i++){
		x+=cnt;
		x-=rsub[i];
		cnt+=l[i-1];
		cnt-=r[i];
		maxx=max(maxx,x);
	}
	cout<<ret-maxx<<endl;
	return 0;
}


Measured memory_bytes: 3328