akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll sum = 0;
	ll mx = 0;
	
	vector<int> table(n+1,0);
	for(ll i = 1; i <= n; i++){
		sum += i;
		table[i] = 1;
		if(sum >= n){
			mx = i;
			break;
		}
	}
	
	ll i = 1;
	ll j = 1;
	while(sum != n){
		if(sum > n){
			j = 1;
			table[i] = 0;
			sum -= i;
			i++;
		}
		if(sum < n){
			i = 1;
			table[j] = 1;
			sum += j;
			j++;
		}
	}
	
	for(int i = 1; i <= mx; i++){
		if(table[i] == 1){
			cout << i << endl;
		}
	}
	
	return 0;
}
 

Measured memory_bytes: 42328
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long int lli; 

int main(){
    lli i,k,n,x;
    cin >> n >> k;
    x = n % k;
    while(x > abs(x-k)){
        x = abs(x-k);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

for i in range(1,N+1):
    A[i-1] -= i
A.sort()

if N % 2 == 1:
    ans = 0
    for i in A:
        ans += abs(i - A[N//2])
else:
    ans = 0
    ansk = 0
    a = (A[N//2] + A[N//2-1]) // 2
    for i in A:
        ans += abs(i - a)
        ansk += abs(i - a-1)
    ans = min(ans, ansk)

print(ans)

Measured memory_bytes: 26180
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);


// ===

fn main() {
    let mut n: i32 = read();
    if n % 2 == 1 {
        n *= 2;
    }
    println!("{}", n);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = 0;
    

    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int main() {
    int N, cnt = 0; scanf("%d", &N);
    for(int i=0; i<N; i++) {
        int p; scanf("%d", &p);
        cnt += (p % 2);
    }
    printf("%s\n", (cnt % 2) ? "NO" : "YES");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    if(n % 2 == 0){
      System.out.println(n / 2);
    }else{
      System.out.println(n / 2 + 1);
    }
    
  }
}


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

const int mod = 1e9 + 7;

int n;
vector< pair<int,int> > vec;

int binpow(int a, int b) {
    int ret = 1;
    while(b) {
        if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        vec.push_back(make_pair(x, 0));
    }
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        vec.push_back(make_pair(x, 1));
    }

    sort(vec.begin(), vec.end());

    int cnt = 0;
    int ans = 1;
    for (auto &e : vec) {
        if (e.second == 1) {
            if (cnt > 0) ans = 1LL * ans * cnt % mod;
            --cnt;
        } else {
            if (cnt < 0) ans = 1LL * ans * (-cnt) % mod;
            ++cnt;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
using namespace std;
int n,p,w,m,mn;
int main(){
	while(cin>>n>>p){
		if(n==0&&p==0) break;
		int a[n];
		w=p;
		m=0;
		mn=0;
		for(int i=0;i<n;i++){
			a[i]=0;
		}
		while(p-m>0){
			for(int i=0;i<n;i++){
				if(w>0){
					w--;
					a[i]++;
				} else{
					w=w+a[i];
					a[i]=0;
				}
				m=max(m,a[i]);
				if(m-a[i]==0) mn=i;
			}
		}
		cout<<mn<<endl;
	}
    return 0;
}

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

typedef vector<int> vi;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vi v;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        v.push_back(t);
    }

    ll cash = 1000;
    for (int i = 0; i < n -1; i++) {
        if (v[i + 1] > v[i]) {
            cash += (v[i + 1] - v[i]) * (cash / v[i]);
        }
    }
    cout << cash << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(){
  long N,i;
  long long sum=0;
  scanf("%ld",&N);
  long long a[N+1],b[N];
  for(i=0;i<N+1;i++)scanf("%lld",&a[i]);
  for(i=0;i<N;i++)scanf("%lld",&b[i]);
  for(i=0;i<N;i++){
  if(b[i]<a[i]){
  sum = sum +b[i];
  continue;
  }      
  if(b[i]>=a[i]){
   sum =sum +a[i];
   b[i] = b[i]-a[i];
   if(b[i]>=a[i+1]){
   sum = sum +a[i+1];
   a[i+1] =0;
   }
  if(b[i]<a[i+1]){
  sum = sum +b[i];
  a[i+1] = a[i+1]-b[i];
  }
  }
  }
printf("%lld",sum);
return 0;
  }

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;  // 1e9+7
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  int ans;
  ans = (A + B) / 2;
  if ((A + B) % 2 == 0)
    cout << ans << '\n';
  else
    cout << "IMPOSSIBLE" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	int n,k; cin >> n >> k;
	if(k == 0){
		cout << (ll)n * n << endl;
		return;
	}
	ll ans = 0;
	for(int b = k+1; b <= n; b++){
		ans += (ll)n / b * (b-k);
		ans += (ll)max(0, (n % b) - k + 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
     int a,b,c;
     int ans,count=0;

     cin >> a >> b >> c;
     for(int i=1;i<=c;i++){
          if(c%i==0){
               ans=c/i;
               if(ans>=a && ans<=b){
                    count++;
               }
          }
     }
     cout << count << endl;
     return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {

    string s;
    long long int k;

    cin >> s >> k;

    int index = 0;
    char ans;
    while(k > 0){
        if(s[index] == '1'){
            k -= 1;
        }
        else{
            ans = s[index];
            break;
        }

        if(k <= 0){
            ans = s[index];
        }
        index++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
lst_x = list(map(int, input().split()))
lst = lst_x[:]
lst.sort()
b1 = lst[n//2 - 1]
b2 = lst[n//2]


for x in lst_x:
    if x <= b1:
        ans = b2
    else:
        ans = b1
    print(ans)

Measured memory_bytes: 93780
#幅優先探索
from collections import deque
d=deque()
e=deque()
import sys
sys.setrecursionlimit(1000000000)
n=int(input())
start_node=0
querie=[]
edge={i:[]for i in range(1,n+1)}
for j in range(n-1):
    a,b=map(int,input().split())
    querie.append((a,b))
    edge[a].append(b)
    edge[b].append(a)
    if j==0:
        start_node=a  

d.append((start_node,0))

#はじめにdequeに入れておいて幅優先探索を行うものを決める。そして、塗り分けの結果はans_dictに保存する
#print(edge) 
ans_dict={i:{}for i in range(1,n+1)}
K=0
for some in edge.values():
    K=max(K,len(some))
    
#幅優先探索に使用する すでに訪れたか確認するためのリスト

visited=[False for i in range(n+1)]
visited[start_node]=True

#使う頂点の数を記録した
#nodeをリスト型にしたリストを返す
#start_nodeを記録しておく
def determine_edge_color(node,color):
    new_color=0
    for some in edge[node]:
        if visited[some]==False:
            visited[some]=True
            new_color+=1
            if new_color==color:
                new_color+=1
                ans_dict[node][some]=new_color
                ans_dict[some][node]=new_color
                e.append((some,new_color))
            else:
                ans_dict[node][some]=new_color
                ans_dict[some][node]=new_color
                e.append((some,new_color))
        else:
            pass
            
while d:
    for some in d:
        if visited[some[0]]==True:
            determine_edge_color(some[0],some[1])
        else:
            determine_edge_color(some[1],some[0])
    d=e
    e=deque()
    
#ans_dictの完成
print(K)
#答えの出力
for item in querie:
    a,b=item[0],item[1]
    print(ans_dict[a][b])


Measured memory_bytes: 80668
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

const INF: i64 = 1 << 60;

use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    input!{
        N: usize,
        M: usize,
        A: [usize; N],
        BC: [(usize, usize); M],
    }
    let mut bh: BinaryHeap<(usize, usize)> = A.into_iter().map(|i| (i, 1)).collect();
    for i in 0..M {
        let (B, C) = BC[i];
        bh.push((C, B));
    }
    let mut count = 0;
    let mut ans = 0;
    while let Some((i, times)) = bh.pop() {
        if count + times > N {
            ans += i * (N - count);
            break;
        }
        ans += i * times;
        count += times;
        if count >= N {
            break;
        }
    }
    println!("{}", ans);
}


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

int n,q,a[20],m;
bool flag;

void dfs(int i,int sum){
	if(i == n){
		if(m == sum) flag = true;
		return;
	}
	dfs(i + 1,sum);
	dfs(i + 1,sum + a[i]);
}

int main() {
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	cin >> q;
	for(int i = 0;i < q;i++){
		cin >> m;
		flag = false;
		dfs(0,0);
		if(flag) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int n,x;
        vector<int>height;
        vector<int>dp;
        cin>>n;
        while(n--)
        {
                cin>>x;
                height.push_back(x);
        }
        dp.push_back(0);
        for(int i=1;i<height.size();i++)
        {
                if(i<2)
                        dp.push_back(abs(height[i]-height[i-1]));
                else{
                        dp.push_back(min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i-2]-height[i])));
                }
        }
        cout<<dp.back()<<endl;
        return 0;
}

Measured memory_bytes: 1400
A=[0]*3
A[0],A[1],A[2],N=map(int,input().split())
A.sort()
ret=0
for i in range(N//A[2]+1):
  n=N-A[2]*i
  for j in range(n//A[1]+1):
    if (n-j*A[1])%A[0]==0:
      ret+=1
print(ret)

Measured memory_bytes: 3060
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const double pi = acos(-1);
double eps = 1e-8;
int cmp(double x){
    if(fabs(x)<eps)return 0;
    if(x>0)return 1;
    return -1;
}
struct point{
    double x,y;
    int id;
    point(){}
    point(double a,double b):x(a),y(b){}
    void input(){
        scanf("%lf%lf",&x,&y);
    }
    friend point operator - (const point &a, const point &b){
        return point(a.x-b.x,a.y-b.y);
    }
    friend bool operator == (const point &a,const point &b){
        return cmp(a.x-b.x)==0 && cmp(a.y-b.y)==0;
    }
    double norm(){
        return sqrt(x*x + y*y);
    }
};
double det(const point &a,const point &b){
    return a.x*b.y-a.y*b.x;
}
double dot(const point &a,const point &b){
    return a.x*b.x+a.y*b.y;
}
struct polygon_convex{
    vector<point> P;
    polygon_convex(int Size=0){
        P.resize(Size);
    }
};
bool comp_less(const point &a,const point &b){
    return cmp(a.x-b.x)<0 || cmp(a.x-b.x)==0 && cmp(a.y-b.y)<0;
}
polygon_convex convex_hull(vector<point> a){
    polygon_convex res(2*a.size()+5);
    sort(a.begin(),a.end(),comp_less);
    a.erase(unique(a.begin(),a.end()),a.end());
    int m = 0;
    for(int i=0;i<a.size();++i){
        while(m>1 && cmp(det(res.P[m-1]-res.P[m-2],a[i]-res.P[m-2]))<=0)--m;
        res.P[m++] = a[i];
    }
    int k = m;
    for(int i=int(a.size())-2;i>=0;i--){
        while(m>k && cmp(det(res.P[m-1]-res.P[m-2],a[i]-res.P[m-2]))<=0)--m;
        res.P[m++] = a[i];
    }
    res.P.resize(m);
    if(a.size()>1) res.P.resize(m-1);
    return res;
}
double ans[110];
int main(){
    int n;
    scanf("%d",&n);
    vector<point> a;
    for(int i=0;i<n;i++){
        point p;
        p.id = i;
        p.input();
        a.push_back(p);
    }
    if(n==2){
        printf("%lf\n%lf\n",0.5,0.5);
        return 0;
    }
    polygon_convex ret = convex_hull(a);
    for(int i=0;i<n;i++){
        ans[i] = 0;
    }
    int m = ret.P.size();
    if(ret.P.size()==2){
        ans[ret.P[0].id] = 0.5;
        ans[ret.P[1].id] = 0.5;
    }
    else{
        for(int i=0;i<ret.P.size();i++){
            point a1 = ret.P[(i+1)%m]-ret.P[i];
            point a2 = ret.P[(i-1+m)%m]-ret.P[i];
            double tem = dot(a1,a2);
            tem = tem/a1.norm()/a2.norm();
            tem = acos(tem);
            tem = (pi - tem)/2.0/pi;
            ans[ret.P[i].id] = tem;
        }
    }
    for(int i=0;i<n;i++){
        printf("%.6lf\n",ans[i]);
    }
}

Measured memory_bytes: 892
// darksta5's template v2.0

#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back
#define del erase
#define sz size
#define ins insert
#define FOR(a,b,c) for(int a = b; a < c; a++)
#define FORS(a,b,c) for(int a = b; a <= c; a++)
#define FORN(a,b) for(int a = 0; a < b; a++)
#define FORD(a,b,c) for (int a = b; a >= c; a--)
#define RES(a,b) memset(a,b,sizeof(a))
#define LL long long
#define PI acos(-1)
#define eps 1e-9
#define MOD 1000000007
using namespace std;

int h, w, n;
LL ans[10];
set<pair<int, int> > st;

bool isValid(int x, int y) {
  return (x >= 0) && (x + 2 < h) && (y >= 0) && (y + 2 < w);
}

int countDot(int x, int y) {
  int ret = 0;
  FORS(i, x, x + 2) {
    FORS(j, y, y + 2) {
      if (st.find(mp(i, j)) != st.end()) {
        ret++;
      }
    }
  }

  return ret;
}

void draw(int x, int y) {
  FORS(i, x - 2, x) {
    FORS(j, y - 2, y) {
      if (isValid(i, j)) {
        int cnt = countDot(i, j);
        ans[cnt]--;
        ans[cnt+1]++;
      }
    }
  }

  st.ins(mp(x, y));
}

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

  cin >> h >> w >> n;
  
  RES(ans, 0LL);
  ans[0] = (LL)(h - 2) * (LL)(w - 2);
  st.clear();

  FORN(i, n) {
    int a, b;
    cin >> a >> b;

    draw(a - 1, b - 1);
  }

  FORN(i, 10) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		string[] c = new string[H];
		for(var i=0;i<H;i++){
			c[i] = Console.ReadLine();
		}
		for(var i=0;i<H;i++){
			Console.WriteLine(c[i]);
			Console.WriteLine(c[i]);
		}
	}
}

Measured memory_bytes: 13268
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
tree = [[] for _ in range(n)]
for i in l:
  tree[i[0]-1].append(i[1]-1)
  tree[i[1]-1].append(i[0]-1)
l = [i for i in range(n)]
global ans
ans = 0
def search(now, moved):
  moved.sort()
  if moved == l:
    global ans
    ans += 1
  for i in tree[now]:
    if i in moved:
      continue
    search(i, moved + [i])
  
search(0, [0])
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a=sc.next(),b=sc.next();
		char[] x=new char[a.length()];
		char[] y=new char[b.length()];
		char[] t=new char[b.length()];
		for(int i=0;i<a.length();i++){
			x[i]=a.charAt(i);
		}
		for(int i=0;i<b.length();i++){
			y[i]=b.charAt(i);
		}
		Arrays.sort(x);
		Arrays.sort(y);
		for(int i=0;i<b.length();i++){
			t[i]=y[b.length()-1-i];
		}
		String h="",j="";
		for(char p:x)
			h+=p;
		for(char p:t)
			j+=p;
		String[] r={h,j};
		String[] e={h,j};
		Arrays.sort(r);
		if(a.equals(b))
			System.out.print("No");
		else if(r[0].equals(e[0]))
			System.out.print("Yes");
		else
			System.out.print("No");
			
	}
}

Measured memory_bytes: 23636
#include<cstdio>
int main()
{
	int k,sum;
	scanf("%d %d",&k,&sum);
	for(int i=0;i<=k;i++){
		for(int j=0;j+i<=k;j++){
			int c=k-i-j;
			if(i*10000+j*5000+c*1000==sum){
				printf("%d %d %d\n",i,j,c);
				goto bre;
			}
		}
	}
	printf("-1 -1 -1\n");
	bre:
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#define inf 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof a)
typedef long long ll;
using namespace std;
const int N = 2e5+10;
const int M = 24005;
const int MOD = 1e9+7;
int h,w,a,b;
ll f[N];
ll finv[N];

ll c(ll n,ll m) {
    ll ret=f[n];
    ret=(ret*finv[n-m])%MOD;
    ret=(ret*finv[m])%MOD;
    return ret;
}

ll calc(ll i,ll j) {
    return c(i+j-2,i-1);
}

ll qp(ll x,ll n) {
    ll ret=1;
    while (n) {
        if (n&1) ret=(ret*x)%MOD;
        n=n>>1;
        x=(x*x)%MOD;
    }
    return ret;
}

int main() {
    scanf("%d%d%d%d",&h,&w,&a,&b);
    memset(f,0,sizeof(f));
    memset(finv,0,sizeof(finv));
    f[0]=finv[0]=1;
    for (int i=1; i<=200000; i++) {
        f[i]=(f[i-1]*i)%MOD;
        finv[i]=qp(f[i],MOD-2);
    }
    ll ans=0;
    for (int i=1; i<=w-b; i++) {
        ans=(ans+(calc(a,i)*calc(h-a,w-i+1))%MOD)%MOD;
        ans=(ans+MOD)%MOD;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main() {
	
	//B
	int n;
	cin >> n;
	int i;
	int cost = 0, v[20], c[20];
	for (i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (i = 0; i < n; i++) {
		if (v[i] - c[i] > 0) {
			cost = cost + v[i] - c[i];
		}
	}
	cout << cost << endl;
	return 0;

	//A
	/*
	int a, b, t;
	cin >> a >> b >> t;
	int bb = 0;
	int aa = 0;
	while (aa + a <= t) {
		bb = bb + b;
		aa = aa + a;
	}
	cout << bb << endl;
	return 0;
	*/
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)

	var s string
	if scanner.Scan() {
		s = scanner.Text()
	}

	var k int64
	if scanner.Scan() {
		tmp := scanner.Text()
		k, _ = strconv.ParseInt(tmp, 10, 64)
	}

	for i, c := range s {
		switch c {
		case '1':
			if int64(i) == k-1 {
				fmt.Println(1)
				return
			} else {
				continue
			}
		default:
			fmt.Println(string(c))
			return
		}
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
#define MAX_V 1005
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
string s;
long double kyori(int a,int b,int c,int d,int r1,int r2){
    double temp =0;
    temp = sqrt((a-c)*(a-c)+(b-d)*(b-d))-(long double)r1-(long double)r2;
    if(temp>0)return temp;
    return 0;
}
struct edge{
    int to;
    long double cost;
};
int V;
vector<edge> G[MAX_V];
double d[MAX_V];
void dijkstra(int s){
    priority_queue<pii,vector<pii>,greater<pii>>que;
    fill(d,d+V,1e11);
    d[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p = que.top();que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        rep(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] +e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}
signed main(){
    int a,b,c,jj;
    int n;
    cin >> a >> b >> c >> jj;
    cin >> n;
    vector<int>e,f,g;
    e.push_back(a);
    f.push_back(b);
    g.push_back(0);
    e.push_back(c);
    f.push_back(jj);
    g.push_back(0);
    rep(i,n){
        cin >> a >> b >> c;
        e.push_back(a);
        f.push_back(b);
        g.push_back(c);
    }
    rep(i,n+2){
        rep(j,n+2){
            if(i==j)continue;
            edge hoge;
            hoge.to=j;
            hoge.cost =kyori(e[i],f[i],e[j],f[j],g[i],g[j]);
            //cout << hoge.cost << endl;
            G[i].push_back(hoge);
        }
    }
    V = n+2;
    dijkstra(0);
    printf("%.10lf\n",d[1]);
}

Measured memory_bytes: 36628
n, k = [int(h) for h in input().split()]
s_s = list(input())

count = 0
for i in range(n):
  d = s_s[i]
  if d == 'L':
    if i > 0 and s_s[i - 1] == d:
      count += 1
  else:
    if i < n - 1 and s_s[i + 1] == d:
      count += 1

count += 2 * k

ans = min(n - 1, count)
      
print(ans)

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

//prime factor o(sqrt(n))
struct prime_factor
{
	map<ll, int> primes;
	prime_factor(ll n = 1)
	{
		for(ll i = 2; i * i <= n; i++)
		{
			int cnt = 0;
			while (n % i == 0)
			{
				n /= i;
				cnt++;
			}
			if(cnt > 0)primes[i] = cnt;
		}
		if(n > 1)primes[n]++;
	}

	ll get_prod()
	{
		ll res = 1;
		for(auto e : primes)
		{
			res *= ll(pow(e.first, e.second));
		}
		return res;
	}

	void show_factor()
	{
		for(auto e : primes)
		{
			cout << "(" << e.first << ", " << e.second << ")" << endl;
		}
	}
};

int order_to_prime(ll n, ll p)
{
	int res = 0;
	while (n % p == 0)
	{
		n /= p;
		res++;
	}
	return res;
}

void solve()
{
	ll n, m; cin >> n >> m;
	vector<ll> a(n);
	rep(i, n) 
	{
		cin >> a[i];
		a[i] /= 2;
	}
	prime_factor gcd_fact;
	int num_of_two = -1;
	rep(i, n)
	{
		auto cnt = order_to_prime(a[i], 2);
		if(num_of_two < 0)chmax(num_of_two, cnt);
		else if(num_of_two != cnt)
		{
			cout << 0 << endl;
			return;
		}

		ll tmp = a[i];
		for(auto e : gcd_fact.primes)
		{
			ll p = e.first;
			auto x = order_to_prime(tmp, p);
			chmax(gcd_fact.primes[p], x);
			tmp /= ll(pow(p, x));
		}
		prime_factor tmp_fact(tmp);
		for(auto e : tmp_fact.primes)
		{
			ll p = e.first;
			chmax(gcd_fact.primes[p], tmp_fact.primes[p]);
		}
	}
	ll g = gcd_fact.get_prod();
	ll ans = (m / g + 1)/ 2;
	cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int a,b;
cin>>a>>b;
if(a == 1){
    cout<<1<<endl;
}
else if(b == 1){
    cout<<1<<endl;
}
else if((a*b)%2 == 0){
    cout<<(a*b)/2<<endl;
}
else{
        cout<<((a*b)/2)+1;

}
    return 0;
}


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

int main() {
    string S;
	cin >> S;
	bool x = true;
	if (S[0] != 'A') {
	    x = false;
	}
	int c = 0;
	for (int i = 2; i < S.length() - 1; i++) {
	    if (S[i] == 'C') {
	        c++;
	    }
	}
	if (c != 1) {
	    x = false;
	}
	int l = 0;
	for (int i = 0; i < S.length(); i++) {
	    if (S[i] >= 'a' && S[i] <= 'z') {
	        l++;
	    }
	}
	if (l != S.length() - 2) {
	    x = false;
	}
	if (x) {
	    cout << "AC" << endl;
	} else {
        cout << "WA" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(((x-r)<0 || (x+r)>W) || (y-r)<0 || (y+r)>H) printf("No\n");
  else printf("Yes\n");

  return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N; cin >> N;
	int A[100100];
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<int>B;
	vector<int>C;
	C.push_back(0);
	B.push_back(0);
	for (int i = 0; i < N; ++i) {
		B.push_back(gcd(A[i], B[i]));
	}
	for (int i = N - 1; i >= 0; --i) {
		C.push_back(gcd(A[i], C[N-i-1]));
	}
	int ans = 1;
	for (int i = 0; i < N; ++i) {
		int key;
		key = gcd(B[i],C[N-i-1]);
		ans = max(ans, key);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1784
(defun split (delimiter target-string)
  (let ((delimiter-position (search delimiter target-string))
        (delimiter-size (length delimiter)))
    (if delimiter-position
        (cons (subseq target-string 0 delimiter-position)
              (split delimiter (subseq target-string (+ delimiter-position delimiter-size))))
        (list target-string))))

(let* ((strs (split " " (read-line))))
  (princ (concatenate 'string (cadr strs) (car strs))))

Measured memory_bytes: 11104
#!/bin/bash

read H W
arr=()
for i in `seq ${H}`; do
    read st
    arr+=($st)
done

range=(-1 0 1)
for i in `seq 0 $((H-1))`; do
    ans=''
    tl=${arr[$i]}
    for j in `seq 0 $((W-1))`; do
        t=${tl:j:1}
        if [ ${t} = '#' ]; then 
            ans=${ans}'#'
            continue
        fi

        cnt=0
        for k in ${range[@]}; do
            if [ $((i+k)) -lt 0 ] || [ $((i+k)) -ge ${H} ]; then
                continue
            fi
            al=${arr[$((i+k))]}
            for l in ${range[@]}; do
                if [ $((j+l)) -lt 0 ] || [ $((j+l)) -ge ${W} ]; then
                    continue
                fi
                a=${al:$((j+l)):1}
                if [[ ${a} = '#' ]]; then
                    let cnt++
                fi
            done
        done
        ans=${ans}${cnt}
    done
    echo ${ans} 
done


Measured memory_bytes: 676
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int a;
	long b;
} s;

int compare(const void *x, const void *y)
{
	return ((s*)x)->a - ((s*)y)->a;
}

int main(void)
{
	int N, i;
	long K, sum = 0;
	s array[100000];
	scanf("%d%ld", &N, &K);
	for (i = 0; i < N; ++i) scanf("%d%ld", &array[i].a, &array[i].b);
	qsort(array, N, sizeof(s), compare);
	for (i = 0; sum < K; ++i) sum += array[i].b;
	printf("%d", array[i - 1].a);
	return 0;
}

Measured memory_bytes: 3324
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    xor=0
    for a in A: xor^=a
    # xorのうち、bitが立っていない部分だけでスクリーニング
    for i in range(n): A[i]&=(~xor)
    # このAに対してsweeping
    r=0 # Aのrank
    for d in reversed(range(61)): # digit
        for i in range(r,n):
            if A[i]&(1<<d): # 候補のiをfixする
                for j in range(i+1,n): # sweep
                    if j==i: continue # 自分自身は掃き出さない
                    if A[j]&(1<<d): A[j]^=A[i]
                A[i],A[r]=A[r],A[i] # swap
                r+=1
                break
    # sweepしたAに対し、最上位bitから確定させていく
    x=0
    for i in range(r):
        d=A[i].bit_length()
        if not x&(1<<(d-1)):
            x^=A[i]
    print(xor+2*x)
resolve()

Measured memory_bytes: 69536
def main():
    _ = int(input())
    a = [int(s) for s in input().split()]
    print(solve(a))

def solve(a):
    s = sum(a)
    x = 0
    m = float('inf')

    for i in a[:-1]:
        x += i
        y = s - x
        m = min(m, abs(x - y))
    
    return m

main()


Measured memory_bytes: 25060
import java.io.*;
import java.util.*;
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */
public class Main 
{
	public static void main(String[] args) throws IOException
	{
		int n=ni();
		int a[]=nia(n);
		int max=0;
		for(int i=0; i<n; i++)
			max=Math.max(a[i], max);
		int index=0;
		double dif=Math.abs(max/2.0-a[0]);
		for(int i=0; i<n; i++)
		{
			if(Math.abs(max/2.0-a[i])<dif)
			{
				dif=Math.abs(max/2.0-a[i]);
				index=i;
			}
		}
		if(a[index]==max)
			a[index]=0;
		pr(max+" "+a[index]);
		System.out.println(ans);
	}
	static final long mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=false;
	static Reader in=new Reader();
	static StringBuilder ans=new StringBuilder();
	static long powm(long a, long b, long m)
	{
		long an=1;
		long c=a;
		while(b>0)
		{
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static Random rn=new Random();
	static void pd(){if(debug)ans.append("hola");}
	static void pd(Object a){if(debug)ans.append(a+"\n");}
	static void pr(Object a){ans.append(a+"\n");}
	static void pr(){ans.append("\n");}
	static void p(Object a){ans.append(a);}
	static void sop(Object a){System.out.println(a);}
	static int ni(){return in.nextInt();}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] ria(int n){int a[]=new int[n];for(int i=0; i<n; i++){a[i]=rn.nextInt(100);p(a[i]+" ");}pr();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static node[] graph(int n) {
		node[] ho=new node[n];
		for(int i=0; i<n; i++)
			ho[i]=new node();
		return ho;
	}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static long nl(){return in.nextLong();}
	static String ns(){return in.next();}
	static double nd(){return in.nextDouble();}
	static String pr(String a, long b)
	{
		String c="";
		while(b>0)
		{
			if(b%2==1)
				c=c.concat(a);
			a=a.concat(a);
			b>>=1;
		}
		return c;
	}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
    }
}
class node
{
	Set<Integer> adj=new HashSet<Integer>();
}   

Measured memory_bytes: 37196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e16+7;

//-------------------------<MATH>-------------------------------------------------------//
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;
ll c = (a * b)%mod;
//cout << a << " " << b << endl;
return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(5e5 + 5)] , inv_fac[(int)(5e5 + 5)];
void precomp_factorial(int M){fac[0] = 1;for(int i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(int i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int lo[(int)(1e3 + 6)];
void sieve(int M){for(int i = 2 ; i < M ; i++){ if(lo[i]) continue; for(int j = i ; j < M ; j += i)lo[j] = i;}}
int max_expo_prime_n_fac(ll N , int prime){int ress = 0;while(N){ress += (N/prime);N /= prime;}return ress;}
//-------------------------</MATH>-------------------------------------------------------//

//-------------------------<STRING>-------------------------------------------------------//
string get_prefix(string x , int MAX){return x.substr(0 , min((int)x.size() , MAX));}
string get_suffix(string x,int MAX){int dn=1;for(int i=x.size()-1;i>=0;i--){if(dn==MAX)return x.substr(i);dn++;}return x;}
string convert_to_binary(int x,int len) {string ans=""; while(x){if(x&1){ans='1'+ans;}
    else{ans ='0'+ans;}x/=2;}int k = ans.size();while(k < len){ans = '0' + ans;k++;}return ans;}
//-------------------------</STRING>-------------------------------------------------------//

ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};



ll getNex(ll n1){
   ll ans = 0;

   while((expo(26LL, ans)-1LL)/25LL <= n1) ans++;
   ans--;
   return ans;
}



int main(){
    
    int n;
    cin >> n;
    vector <int> vec(n);
    int res = 0;
    for(int i = 0; i < n; i++){
        cin >> vec[i];
        res ^= vec[i];
    }
    for(int i = 0; i < n; i++){
        cout << (res^vec[i]) << " ";
    }

}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll rui[ohara];
ll tatea[ohara];
ll tateb[ohara];
ll dat[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b;
    //端set() 区間計算

    cnt=2;
    rui[0]=1;
    rrep(i,1,46){
        rui[i]=cnt;
        cnt*=2;
    }

    tmp=a;
    while(1){
        rrrep(i,45,0){
            if(rui[i]<=tmp){
                tmp-=rui[i];
                tatea[i+1]++;
                break;
            }
        }
        if(tmp==0)break;
    }

    tmp=b;
    while(1){
        rrrep(i,45,0){
            if(rui[i]<=tmp){
                tmp-=rui[i];
                tateb[i+1]++;
                break;
            }
        }
        if(tmp==0)break;
    }
    //2^tのi乗の時
    rrep(i,1,45){
        //区間set
        //2^i(i+1乗)で割った余りが0のところが0
        tmp=a%rui[i];
        ll fi=a;
        if(tmp!=0){
        ll sa=rui[i]-tmp;
        fi=a+sa;
        if(tatea[i]!=0){
            sa=fi-a;
            dat[i]+=max(sa,0LL);
        }
        }

        tmp=b%rui[i];
        ll en=b;
        if(tmp!=0){
        en=b-tmp;
        if(tateb[i]!=0){
            dat[i]+=max(tmp-rui[i]/2+1,0LL);
        }
        }
        dat[i]+=max(((en-fi)/rui[i])*(rui[i]/2),0LL);

       // cerr<<rui[i]<<" "<<fi<<" "<<en<<" "<<dat[i]<<"\n";
    }

    rrep(i,1,45){
        if(dat[i]%2==1){
            //cerr<<i<<" "<<dat[i]<<" "<<rui[i-1]<<"\n";
            ans+=rui[i-1];
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main()
{     long long n,a,b,c;
      cin>>n;
      for(a=n/4;a<3500;a++)
          for(b=a;b<3500;b++)
  		    if(a>0&&b>0)
    		  if(n*(a+b)<4*a*b){
             	c=(n*a*b)/(4*a*b-n*b-n*a);
             	if(c<b)break;
             	if(double(n*a*b)/(4*a*b-n*b-n*a)-c!=0)break;
             	cout<<a<<' '<<b<<' '<<c<<endl;
             	return 0;
             }
    	  return 0;
		  }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const long long mod = 1000000007;
const int maxn = 100100;
vector<int> tr[maxn];
int add[maxn];
void push(int cur, int par){
    for(int nxt : tr[cur]){
        if(nxt == par) continue;
        if(tr[nxt].size() > 2){
            add[nxt]++;
            return;
        }
        push(nxt, cur);
    }
}
int main(){
    int n;
    cin >> n;
    for(int e = 0; e < n - 1; e++){
        int u, v;
        cin >> u >> v;
        tr[u].push_back(v);
        tr[v].push_back(u);
    }
    int root = -1;
    for(int e = 0; e < n; e++) if(tr[e].size() >= 3) root = e;
    if(root == -1) printf("1\n");
    else{
        for(int e = 0; e < n; e++) if(tr[e].size() == 1) push(e, -1);
        int ans = 0;
        for(int e = 0; e < n; e++) ans += max(add[e]-1, 0);
        cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 6656
a,b,c,d = map(int,input().split())

def gcd(x,y):
    if y == 0:
        return x
    return gcd(y,x%y)

g = gcd(c,d)
m = (c//g) * (d//g) * g

dc_a = (a-1)//c
dd_a = (a-1)//d

dc_b = b//c
dd_b = b//d

dm_a = (a-1)//m
dm_b = b//m

res = b-a+1

alll = (dc_b - dc_a) + (dd_b - dd_a) - (dm_b - dm_a)

res = res - alll
print(res)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main() {
	vector<long>ll;
	int n, ex;
	string s;
	while (cin >> n){
		if (n == 0)break;
		map<string, long>l;
		for (int i = 0; i < n; i++){
			cin >> s >> ex;
			l[s] = ex;
		}
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> s >> ex;
			long sum = 0;
			for (int i = 0; i < ex; i++) {
				string str;
				cin >> str;
				sum += l[str];
			}
			l[s] = min(l[s], sum);
		}
		cin >> s;
		ll.push_back(l[s]);
	}
	for (int i : ll) {
		cout << i << endl;
	}
	char c;
	cin >> c;
	return 0;
}

Measured memory_bytes: 3028
N=int(input())
binary=[int(s) for s in input().split()]

boxes=[0 for _ in range(N)]
ans=set()

for i in range(N-1,-1,-1):
  if sum(boxes[i::i+1])%2!=binary[i]:
    boxes[i]=1
    ans.add(i+1)
print(len(ans))
print(*ans)

Measured memory_bytes: 21368
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c$}SA&2Hm15WWY<I}li`BRO&q?=i4*+Z?->-cm!5CE6BDQwk+}lim{a)?51ky|sq|eJNl17@Z+0i6SY-DPceshx7N%#}WC7q%ZZR;CEzM?0HtD8=7wC4+*R2<;6-AJ1xIC<n%j9^Ichpnj}IbFIvv>WqMQ989ZD0E@7-lBeD_{%v@fi^-D=Jx+1LLYZ8pVhCxVpvCf$*`xXZHFOu)>s+`xb=s_)N#jpT{DNCw~RCHZ~<GafX0wZm-Vjhty|CyrYwIM@8W0Dy&UkNqdzLBCt4>*DEah&Enuj4q-j=&*Xh1wmC9|}&%CvtrKUH<+$zWs81`}O$x&++ZIfB*jT`1X2y{i87{eH@BBBWSf}Gm>#b*cd{DVVPdq;2-Z6<Ur=CDnY=bP$gQd6i5-dVppN1h?a9uy6xt_=k-PbYIu=?P0lE+o)K<Ia2y`<1sI}1=*n_(Jtxy{9<#cU=%KS%MSO^4dNlMyVlM5Y(<W~s<YdsM%OOfed2sMy0i3YVkV#L;Y$j!H?l{}et~G|}gSAH4Q!_FyVZluOz1JHi_(H}?cib!BIkjs`)Y!11EeEP(S7^|#oqqW!BfTclE|TE1VOjbZYrw5ZjTSyEi7HADK{=nnY-!D*30uEFkc+aPopd)bLu-<}hk&gtRn+mm%#xbImd_pdCNfL2J!Di?^F)Kdz8I)XJfyFvuML!n@8sEKc!^NAP}*2MmRO+Y0S<X!n9W=C-$A1!_xHqw<l2CwWBl5mmYa^C^<MBcdZ1XF+rl+liX!vaW$GaY`hirfc8us;VP8Pg+zI2o(_jPmih+3rB!f*OEC6%xOhyjNB(_~JMH#?b)F8kXp3cgw?WL`Y0qa8Z)b%P%ugalVNGvR`42td85cZ^5yfzPM%Pt&jlGrKUdu*8Y8Gt3;CC{<Q*Bc+Z!1)957?pLH&zq)X0cN_4`TIOD8RaFABE*kkZ+GQ}DNr;F=hjm>FYFLMFKV(1I-E_qgdRH`DccM@tCYvN{E9HY7<_-kZ!<b*9JOI3AIov*3Nh&8o_c)9-M~h|noJ}|?9&jArJ%{y&ru|d&Cs03jIMkH6~hD-K1OIy#us|13H^Uk`g(<047(kOn(*vIpE--IW}i91R&fSfg=Q<@;A4vR{}JEK=u@btHmo$%Xm#Oal;^VcgiGD(Cz2%gR|bclp||d7!}y%L^xV44)KP60ZlqX-?V{ak@)h%4$nJ06Cd))X`=_kEF_t3XYieC7^P-hkX~H3<Qb1Iz_P!_Sjs2en{XliPlj&_UTpfs8eTVeHYS}jd2q!@IrTZyL)C`3?vMXG+ju1a}fVW}POSi!8LvJ};^_~Fuh}03;M<|qe2Unl7&)HQ(MzCP?6dIY}^(Q&w?zbug9L#dAfrf=DqWQGh0gWdn9VKv{Z~Sz$Sj(ErH|!+v*SX9AnhIR?q#oZ-gTAvSPso1+0F0We8Wf{OrcZlBT;JePd5?#A04r?D(k%XB9+4$+WO_gGt4J!#!$+$fdaK&%b!y#tL+e8O29ksRfBN!b-2")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

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

int main()
{
    int l;
    double d,ans;

    cin >> l;

    d = (double)l / 3.0;
    ans = d * d * d;

    std::cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  int r = 0, l = 0;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    r += w[i];
  }
  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    ans = min(ans, abs(r - l));
    r -= w[i];
    l += w[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# プログラミングコンペティションサイト AtCode は、
# プログラミングコンテストを定期的に開催しています。
# AtCode で次に開催されるコンテストは ABC と呼ばれ、
# レーティングが 1200 未満の参加者のレーティングが変動します。
# その次に開催されるコンテストは ARC と呼ばれ、
# レーティングが 2800 未満の参加者のレーティングが変動します。
# そのさらに次に開催されるコンテストは AGC と呼ばれ、
# すべての参加者のレーティングが変動します。
# 高橋くんの AtCode でのレーティングは R です。
# 彼のレーティングが変動する次のコンテストは何でしょうか？

r = gets.to_i

if r < 1200
  puts "ABC"
elsif r < 2800
  puts "ARC"
else
  puts "AGC"
end


Measured memory_bytes: 1788
from math import factorial as f
n=int(input())
m=f(n)
ans=1
p=[1]*1000
for i in range(2,1001):
  while m%i==0:
    m//=i
    p[i]+=1
for i in p:
  ans*=i
  ans%=(10**9+7)
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

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

	Scanner scan = new Scanner(System.in);

	double a = scan.nextDouble();
	double b = scan.nextDouble();
	double c = scan.nextDouble();
	
	c = Math.toRadians(c);
	
	double h = b * Math.sin(c);
	double s = a*h/2;
	double l = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2*a*b*Math.cos(c)) + a + b;
	
	System.out.println(s);
	System.out.println(l);
	System.out.println(h);
	}
}

Measured memory_bytes: 27976