akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (a + b > c + d) System.out.println("Left");
		else if (a + b < c + d) System.out.println("Right");
		else System.out.println("Balanced");
	}
}


Measured memory_bytes: 22732
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000003;
vel kai(1000007, 1);
vel ink(1000007, 1);
template<typename T>
V<T> uni(V<T> &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	V<T> ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
signed main() {
	int n, x; cin >> n >> x;
	vel nb(n), nl(n), nu(n), nget(n); int goal = 0;
	V<pin> lis(n);
	rep(i, n) { cin >> nb[i] >> nl[i] >> nu[i]; goal += nb[i] * nl[i]; nget[i] = x * nl[i] + (x - nb[i])*(nu[i] - nl[i]); lis[i] = mkp(nget[i], i); }
	sor(lis); reverse(lis.begin(), lis.end());
	vel b(n), l(n), u(n), get(n);
	rep(i, n) { int ni = lis[i].second; b[i] = nb[ni]; l[i] = nl[ni]; u[i] = nu[ni]; get[i] = nget[ni]; }
	int ind = 0;
	int sum = 0;
	while (ind < n) {
		if (sum + get[ind] >= goal) { break; }
		sum += get[ind]; ind++;
	}
	if (ind == n) { cout << x * n << endl; }
	int ans = x;
	int ex = goal - sum;
	for (int i = ind; i < n; i++) {
		int qa;
		if (b[i] * l[i] >= ex) {
			qa = (ex + l[i] - 1) / l[i];
		}
		else {
			int qex = ex - b[i] * l[i];
			qa = b[i] + (qex + u[i] - 1) / u[i];
		}
		mmin(ans, qa);
	}
	sum += get[ind];
	rep(i, ind) {
		int ne = goal - (sum - get[i]);
		int qa;
		if (b[i] * l[i] >= ne) {
			qa = (ne + l[i] - 1) / l[i];
		}
		else {
			int qex = ne - b[i] * l[i];
			qa = b[i] + (qex + u[i] - 1) / u[i];
		}
		mmin(ans, qa);
	}
	cout << ans + ind * x << endl;
	return 0;
}


Measured memory_bytes: 23808
/*
[abc128] D - equeue
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 50;
const int INF = 1e9;

int N, K;
int V[MAX_N];

ll solve() {
    ll ans = -INF;
    for (int p = 0; p <= N; p++) {
        for (int q = 0; p + q <= N; q++) {
            for (int r = 0; r <= min(K - p - q, p + q); r++) {
                vector<int> d;
                for (int i = 0; i < p; i++) {
                    d.push_back(V[i]);
                }
                for (int i = N - 1; i >= N - q; i--) {
                    d.push_back(V[i]);
                }
                sort(d.begin(), d.end());

                ll s = 0;
                for (int i = r; i < (int)d.size(); i++) {
                    s += d[i];
                }
                ans = max(ans, s);
            }
        }
    }

    return ans;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long  ll;
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<endl; 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 200010;
const int INF = 1e8;
const ll MOD1=1073741824;
using namespace std;
 
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 long double a;
 cin>>a;
 long double b;
 cin>>b;
 ll d= (long double) a*b;
 //cout<<d<<" ";
 string c=to_string(d);
 for(int i=0;i<c.size();i++) 
 {
           if(c[i]=='.') break;
           cout<<c[i];
 }
 
 
 
 
 
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3848
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    
    ans = ''
    while N:
        if N % 26 == 0:
            ans += "z"
            N -= 1
            N //= 26
        else:
            ans += chr((N % 26) -1  + 97)
            N //= 26

    print(ans[::-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 9144
#define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

vector<int> split(string delim,string str){
	vector<int> res;
	str += delim;
	for(int i=0;i<str.size();i++){
		for(int j=1;i+j<=str.size();j++){
			if(str.substr(i,j).find(delim) != string::npos){
				int num = atoi(str.substr(i,j-1).c_str());
				if(str.substr(i,j-1).size() >0 ) res.push_back(num);
				i+=j-1;
				break;
			}
		}
	}

	return res;
}

int main(){
	string str;
	while(getline(cin,str)){
		vector<int> data = split(" ",str);
		if(data.size()==1 && data[0]==0) break;
		set<int>* dp = new set<int>[data.size()+1]; 

		dp[0].insert(0);
		for(int i=0;i<data.size();i++){
			if(data[i] == 1){
				for(set<int>::iterator it = dp[i].begin(); it != dp[i].end(); it++){
					dp[i+1].insert(*it+1);
					dp[i+1].insert(*it+11);
				}
			}
			else if(2 <= data[i] && data[i] <= 9){
				for(set<int>::iterator it = dp[i].begin(); it != dp[i].end(); it++){
					dp[i+1].insert(*it+data[i]);
				}
			}
			else{
				for(set<int>::iterator it = dp[i].begin(); it != dp[i].end(); it++){
					dp[i+1].insert(*it+10);
				}
			}
		}

		int res=MAX_N;
		for(set<int>::iterator it = dp[data.size()].begin(); it != dp[data.size()].end(); it++){
			if(*it <= 21 && abs(*it-21) < abs(res-21)){
				res = * it;
			}
		}

		printf("%d\n",res == MAX_N ? 0 : res);

		delete[] dp;
	}
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }

    (1..d.lastIndex-1).count { (d[it]-d[it-1])*(d[it]-d[it+1])<0 }
        .let { println(it) }

}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  int a;
  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }
  
  int max = 0, max_i = 0;
  for (int i = 0; i < N; i++){
    if (max < vec.at(i)){
      max = vec.at(i);
      max_i = i;
    }
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++){
    sum += vec.at(i);
  }
  
  if (vec.at(max_i)*2 < sum){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    int a[n+1];
    for (i=1;i<=n;i++)
        cin>>a[i];
    int cnt=0,f=0,vis[n+1]={0},st=1;
    while (st!=2)
    {
        if (vis[st])
        {
            f=1;
            break;
        }
        vis[st]=1;
        st=a[st];
        cnt++;
    }
    if (f)
        cout<<"-1\n";
    else
        cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int b[100001];
int main()
{
	int n,m,i,ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
		scanf("%d",&a[i]);
	if(n>=m)
	{
		printf("0");
		return 0;
	}
	sort(a+1,a+m+1);
	for(i=2;i<=m;i++)
	{
		b[i-1]=abs(a[i]-a[i-1]);
		ans+=b[i-1];
	}
	sort(b+1,b+m);
	for(i=m;i>m-n;i--)
		ans-=b[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int X = Integer.parseInt(lines[1]);
		int[] L = new int[N];


		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0 ; i < N ; i++) {
			L[i] = Integer.parseInt(lines[i]);
		}

		int count = 1;
		int D = 0;
		for(int i = 0 ; i < N ; i++) {
			D = D + L[i];
			if(D <= X) {
				count++;
			}
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 35820
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"3
10 40 70
20 50 80
30 60 90"# => r#"210"#,

r#"1
100 10 1"# => r#"100"#,

r#"7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1"# => r#"46"#,

}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize,
    }

    let mut dp = vec![vec![0; 3]; n + 1];

    for i in 0..n {
        input! {
            source = src_iter,
            abc: [isize; 3],
        }
        for j in 0..3 {
            for k in 0..3 {
                if j == k {
                    continue;
                }
                dp[i + 1][k] = std::cmp::max(dp[i + 1][k], dp[i][j] + abc[k]);
            }
        }
    }

    dp[n].iter().max().unwrap().to_string()
}

Measured memory_bytes: 12540
#include <stdio.h>


int maxprofit(int);
int main(){
  int n,max;


  scanf("%d",&n);
  max=maxprofit(n);
  printf("%d\n",max);


  return 0;
}

int maxprofit(int n){

  int i,j,r[n];
  int max,min;

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

  max=r[1]-r[0];
  min=r[0];
    
    for(j=1;j<n;j++){
      if(max<r[j]-min)max=r[j]-min;
      if(min>r[j])min=r[j];

  }
  return max;
}



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

typedef long long ll;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}



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

	ll l = lcm(c,d);
	ll ans = (b-(b/c)-(b/d)+(b/l)) - (a-(a/c)-(a/d)+(a/l));
	if (a%c!=0 && a%d!=0) ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  vector<string> S(N);
  map<string, Int> cnt;
  for(Int i=0;i<N;i++){
    string s;
    cin>>s;
    sort(s.begin(), s.end());
    cnt[s]++;
    S[i] = s;
  }

  Int ans = 0;
  for(Int i=0;i<N;i++){
    ans += cnt[S[i]] - 1;
  }

  cout<<ans/2<<endl;

  return 0;
}


Measured memory_bytes: 16660
//-----------------------------B-I-G------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define what_is(x) cerr << #x << " is " << x << endl;
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << "{"; for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi) { if (vi != v.begin()) os << ", "; os << *vi; } os << "}"; return os; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const ll M = 1000000007;

void solve(){
        string s , t;
        cin >> s >> t;
        cout << ( s == t.substr(0,t.length()-1)  ? "Yes" : "No") << endl;
}

signed main(){
        fast;
        ll t=1;
        // cin >> t;
        while( t-- )
        solve();
        return 0;
}
//-----------------------------B-I-G------------------------------------------------

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int s;
    cin>>s;

    int upper = s/100;
    int lower = s%100;
    // cout<<upper<<endl;
    // cout<<lower<<endl;

    bool YYMM = false;
    bool MMYY = false;

    if(  (1 <= lower && lower <= 12) )
        YYMM=true;

    if( (1 <= upper && upper <= 12)  )
        MMYY=true;

    // if((upper < 1 || 12 < upper))

    // if((lower < 1 || 12 < lower))


    if(YYMM && !MMYY)
        cout<<"YYMM"<<endl;
    else if(!YYMM && MMYY)
        cout<<"MMYY"<<endl;
    else if(YYMM && MMYY)
        cout<<"AMBIGUOUS"<<endl;
    else
        cout<<"NA"<<endl;
}

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

int main()
{
  while (1)
  {
    int x[2];
    scanf("%d %d", &x[0], &x[1]);
    if (x[0] == 0 && x[1] == 0)
      break;
    if (x[1] < x[0])
      swap(x[0], x[1]);

    printf("%d %d\n", x[0], x[1]);
  }

  return 0;
}


Measured memory_bytes: 2560
n, k = list(map(int, input().split()))
s = input()
group = 1
#print('s[1:]'+s[1:])


for c, d in zip(s, s[1:]):
	if c != d:
		group += 1
	#L,Rの連続してないところが何個あるか求める＝group
	#１回で２つ直せるから,2 * k
	#n(文字数)-直せなかった連続してない数
print(min(n - 1, n - (group - 2 * k)))
#先頭は幸福でないから最高でもn-1
#


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 87;
int dp[N];
int main()
{
    for (int i = 1; i < N; ++i) {
        dp[i] = dp[i-1];
        for (int k = 1; k <= i; k *= 6)
            dp[i] = min(dp[i],dp[i-k]);
        for (int k = 1; k <= i; k *= 9)
            dp[i] = min(dp[i],dp[i-k]);
        ++dp[i];
    }
    int n;
    cin >> n;
    cout << dp[n] << endl;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define fo(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;


int main() {
    
     int n,k;
     cin>>n>>k;
     vi vec(n+1,0);
     fo(i,k){
         int d;
         cin>>d;
         fo(j,d){
             int num;
             cin>>num;
             vec[num]++;

         }
     }
     int cnt=0;
     for(int i=1;i<=n;i++){
         if(vec[i]==0)cnt++;
     }
     cout<<cnt<<endl;
     

}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N = 20;
#define F(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define df(i,a,b) for(register int i=a;i>=b;--i)
int n,x[2][66];
long long ans,t,a[300005],inv[60];
int main() {
	scanf("%d",&n);inv[0]=1;
	f(i,1,60) inv[i]=(inv[i-1]<<1)%1000000007;
	f(i,1,n) scanf("%lld",&a[i]);
	df(i,n,1) f(j,0,60) {
		int p=a[i]&(1ll<<j)?1:0;
		++x[p][j];
		ans=(ans+inv[j]*x[p^1][j])%1000000007;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 2560
n,k,q = map(int,input().split(' '))
ans = [k-q]*n
i = 0
while i < q:
    p = int(input())
    ans[p-1] += 1
    i += 1
str = ''
for a in ans:
    if a > 0:
        str += 'Yes\n'
    else:
        str += 'No\n'
print(str)

Measured memory_bytes: 7056
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
int n, m, x, y;ll z = 0, w, h, sum = 0, ans = 0;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main(void) {
	cin >> n >> m;
	priority_queue<int> pq;
	rep(i, n) {
		cin >> x;
		pq.push(x);
	}
	rep(i, m) {
		y = pq.top(); pq.pop();
		pq.push(y / 2);
	}
	while (!pq.empty()) {
		y = pq.top(); pq.pop();
		ans += y;
	}cout << ans << endl;
}

Measured memory_bytes: 892
#!/usr/bin/env python3


def next_line():
    return input()


def next_int():
    return int(input())


def next_int_array_one_line():
    return list(map(int, input().split()))


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    n = next_int()
    ar = sorted(next_int_array_one_line())
    res = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if ar[i] < ar[j] and ar[j] < ar[k] and ar[i] + ar[j] > ar[k]:
                    res += 1
    print(res)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    //番兵
    S += '*';

    //どこを反転させても幸せ度は最大2しか変わらない
    //端っこを選ぶと1しか変わららない
    //なるべく真ん中をRかLに変更することを考えてみる
    //後は貪欲に向きを変更できるだけ変更する
    ll ans = 0;
    bool f = false;
    for(ll i = 1; i < S.length(); i++){
        if(S[i] == '*') break;
        if(S[i-1] == S[i]){
            ans++;
        }else{
            if(f == false){
                if(K > 0){
                    ans++;
                    K--;
                    f = true;
                }
            }else{
                f = false;
                ans++;
            }
        }
    }    

    cout << ans << endl;

}

Measured memory_bytes: 512
import numpy as np

d = int(input())

c = list(map(int, input().split()))

sd = np.zeros((d, 26), dtype=np.int)
for i in range(d):
  s = list(map(int, input().split()))
  s_array = np.array(s)
  sd[i, :] = s_array

pp = np.zeros(26, dtype=np.int)
  
for i in range(d):
  pp += c
  t = np.argmax(pp)+1
  pp[t-1] = 0
  print(t)

Measured memory_bytes: 27328
import * as fs from "fs";
const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split(/\n/);
const card = input[1]
  .split(/\s/)
  .map(Number)
  .sort((a, b) => b - a);

var pointDifferential = 0;
for (let index = 0; index < card.length; index++) {
  if (index % 2 == 0) {
    pointDifferential += card[index];
  } else {
    pointDifferential -= card[index];
  }
}
console.log(pointDifferential);

Measured memory_bytes: 29648
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
mod = 10 ** 9 + 7
ans = 0
x = 1
for bit in range(60):
    b = 0
    for i, aa in enumerate(a):
        if aa % 2:
            b += 1
        a[i] //= 2
    ans += (x * b * (n - b)) % mod
    ans %= mod
    x *= 2
    x %= mod
print(ans)


Measured memory_bytes: 92836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
using namespace std;

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

#define max_n 100

int N,K;

string S,s;

string reverses(string s,int f,int b)
{
	string r = s.substr(0,f);
	string r2 = s.substr(b);
	string r3 = s.substr(f, b - f);

	int size = r3.size();
	for (int i = 0; i <= size - 1 - i; i++)
	{
		int j = size - 1 - i;
		swap(r3.at(i), r3.at(j));
		if (r3.at(i) == 'L')r3.at(i) = 'R';
		else r3.at(i) = 'L';
		if (i == j)break;
		if (r3.at(j) == 'L')r3.at(j) = 'R';
		else r3.at(j) = 'L';
	}


	return r + r3 + r2;
}

int main() {

	cin >> N >> K >> S;

	int first = -1;
	rep(i,N-1)
	{
		if (S.at(i) == S.at(i + 1))continue;
		if (first < 0) { first = i + 1; continue; }


		S = reverses(S, first, i+1);


		first = -1;
		K--;
		if (K <= 0)break;
	}
	
	int ans = 0;

	rep(i, N - 1)
	{
		if (S.at(i) == S.at(i + 1))ans++;
	}

	if (K > 0) cout << S.size() - 1 << endl;
	else cout << ans <<endl;

	return 0;	
}

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

long long gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

	
int main()
{
	int n;
	long long int sum=0;  
	cin >> n;
	gcd(1, 1);
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			for(int k=1; k<=n; k++)
			{
				sum += gcd(i, gcd(j, k));
			}
		}
	}
	cout << sum << endl;
}



Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")   //Comment optimisations for an interatcive problem - use endl
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+6+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int qq;
ll x, y;
ll n, r;
ll ff[MAXN];
//<<-----Implement Functions Here---->>//
ll mult(ll a, ll b) {return (a * b)%MOD;}

ll fastModInv(ll x){
	ll res=1;
	ll y=MOD-2;
	while(y){
		if(y&1)res=mult(res,x);
		y>>=1;x=mult(x,x);
	}
	return res;
}

ll nCr(){
	if(r==0 || n-r==0)return 1;
	return mult(ff[n],mult(fastModInv(ff[r]),fastModInv(ff[n-r])));
}
//<<-----Start of Main--------------->>//

int main(){
	fastio;randomINIT;
	ff[0]=0;ff[1]=1;
	foo(i,2,MAXN-1)ff[i]=mult(ff[i-1],i);

	cin>>x>>y;	
	if((x+y)%3!=0){cout<<0;return 0;}
	n=(x+y)/3;r=x-n;
	if(y>2*n || y<n){cout<<0;return 0;}
	cout<<nCr();


}

Measured memory_bytes: 33280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++){    ;
int main() {
int A,B;
cin>>A>>B;
int h=max(A*2-1,B*2-1);
int k=A+B;
cout<<max(h,k)<<endl;
 }


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

int main() {
  int k;
  cin >> k;
  if((k % 2) == 0 || (k % 5) == 0) cout << -1 << endl;
  else if(k == 1 || k == 7) cout << 1 << endl;
  else {
    if((k % 7) == 0) k /= 7;
    vector<int> x(0);
    x.push_back(1 % k);
    while(1) {
      int X = (10 * x.at(x.size()-1)) % k;
      if(X == 1) break;
      x.push_back(X);
    }
    int c = 0, m = 0;
    bool b = 0;
    while(1) {
      for(int X : x) {
        c++;
        m += X;
        m = m % k;
        if(m == 0) {
          b = 1;
          break;
        }
      }
      if(b) break;
    }
    cout << c << endl;
  }
}

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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    if (n & 1) {
        cout << 0;
    } else {
        int ans = 0, base = 5;
        while (n >= base) {
            ans += n / (base * 2);
            if (base > (int)1e18 / 5)
                break;
            base *= 5;
        }
        cout << ans;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	

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

			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();
			
//			int a = Integer.parseInt(args[0]);
//			int b = Integer.parseInt(args[1]);
//			int c = Integer.parseInt(args[2]);
			boolean flag=true;
			if(a < b){
				if(b < c){
					System.out.println("Yes");
					flag = false;
				}
			}
			if(flag){
				System.out.println("No");
			}
		}
}



Measured memory_bytes: 25980
#!/usr/bin/env python3
import sys


def solve(N: int):
    result = len(str(N))
    for A in range(1, int(N ** 0.5) + 1):

        if N % A == 0:
            B = N // A
            f_value = max(len(str(A)), len(str(B)))
            result = min(result, f_value)

    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  int l,r,d; cin >>l >>r >>d;
  int ans=0;
  for(int i=l; i<=r; i++) if(i%d==0) ans++;
  cout <<ans;
return 0;}

Measured memory_bytes: 3636
/// time is tough.....so don't stop ...keep learning ...keep growing :)

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5+5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}
const int INF = 2e9 ;
int n, m, u, v;

int main(){
    int n;
    cin >> n ;
    ld p[n + 4] ;
    for(int i=1;i<=n;i++) cin >> p[i];
    ld dp[n + 4][n + 4] ;
    for(int i=0;i<n+4;i++) {
        for(int j=0;j<n+4;j++) {
            dp[i][j] = 0.f ;
        }
    }
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j== 0){
                dp[i][j] = dp[i-1][j]*(1.0-p[i]); continue ;
            }
            if(j == i) {
                dp[i][j] = dp[i-1][j-1]*p[i]; continue;
            }
            dp[i][j] = (dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*(p[i]));
        }
    }
    ld sol = 0.f ;
    for(int i=n/2+1;i<=n;i++) {
        sol += dp[n][i];
    }
    cout << fixed << setprecision(10) << sol << '\n' ;
    return 0;
}
 

// https://atcoder.jp/contests/dp/tasks






// // // // https://codeforces.com/problemset/problem/474/E
// // // // https://www.hackerrank.com/contests/codeagon/challenges/number-of-ways-1/problem
// // // // https://codeforces.com/contest/475/problem/D


// // https://www.spoj.com/problems/INS17M/
// // https://www.codechef.com/SEPT18B/problems/ANDSQR
// // 


// int d[] = {1, 2, 2, 4, 5, 10, 15, 28, 45, 79, 129, 218, 356, 589, 959, 1569, 2548, 4145, 6720, 10901, 17656, 28602, 46302, 74959};

// ll C[100][100];

// void pre(){
//   for(int i=0;i<=99;i++) C[i][0] = 1;
//   for(int i=1;i<=99;i++) {
//     for(int j=0;j<=min(99,i);j++){
//       C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod ;
//     }
//   }
// }

// int main() {
//     pre();
//   int x =0, y = 1,z ;
//   for(int i=0;i<=23;i++) {
//     z = x + y ;
//     int p = i;
//     cout << z << ' ' ;
//     x = y ;
//     y = z ;
//   }
//   cout << "\n\n";
//     for(int i=2;i<=24;i++){
//       ll res = 0;
//       for(int j=0;j<=i;j++)
//       {
//         res += C[i][j]*C[i][j];
//         res %= mod;
//         if(j < i) {
//           res += C[i-j-1][j];
//           res %= mod;
//         }
//         res -= C[i+j-1][j];
//         res += mod;
//         res %= mod;
//         if(j < i-1) {
//           res += C[i-j-2][i];
//           res %= mod;
//         }
//       }
//       cout << res<< ' ' ;
//     }
//     cout << '\n';
//   return 0 ;
// }

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> k(m);
  vector<int> p(m);
  rep(i,m){
    int K; cin>>K;
    rep(j,K){
      int s; cin>>s;
      s--;
      k[i].push_back(s);
    }
  }
  rep(i,m){
    cin>>p[i];
  }
  int ans=0;
  for(int i = 0; i < (1<<n); i++){
    bool ok=1;
    rep(j,m){
      int cnt=0;
      for(auto x : k[j]){
        if(i>>x&1) cnt++;
      }
      if(cnt%2!=p[j])ok=0;
    }
    if(ok)ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
char a[50][50];
int c,d,b[55][55];
int main()
{
  scanf("%d%d",&c,&d);
  for(int i=0;i<c;i++)  cin>>a[i];
  for(int i=0;i<c;i++)
    for(int j=0;j<d;j++)
      if(a[i][j]=='#')
        b[i][j]++,b[i][j+1]++,b[i][j+2]++,
        b[i+1][j]++,b[i+1][j+1]++,b[i+1][j+2]++,
        b[i+2][j]++,b[i+2][j+1]++,b[i+2][j+2]++;
  for(int i=0;i<c;i++)
  {
    for(int j=0;j<d;j++)
    {
	  if(a[i][j]=='#')  printf("#");
      else  printf("%d",b[i+1][j+1]);
	}
    printf("\n");
  }
  return 0; 
}

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

struct Node {
    int key;
    Node *left, *right, *parent;
};

void insert(Node** root, int key) {
    Node *y = nullptr;
    Node *x = *root;
    Node *z = new Node;
    z->key = key;
    z->left = nullptr;
    z->right = nullptr;

    while(x != nullptr) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        } 
    }

    z->parent = y;
    if(y == nullptr) {
        *root = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

void printInorder(Node* node) {
    if(node == nullptr) {
        return;
    }
    printInorder(node->left);
    cout << " " << node->key;
    printInorder(node->right);
}

void printPreorder(Node* node){
    if (node == nullptr) {
        return;
    }
    cout << " " << node->key;
    printPreorder(node->left);
    printPreorder(node->right);
}

int main() {
    Node *root = nullptr;
    Node **address = &root;
    int num;
    cin >> num;
    for(int i=0; i<num; i++) {
        string command;
        cin >> command;
        if(command == "insert") {
            int key;
            cin >> key;
            insert(&root, key);
        } else if(command == "print") {
            printInorder(root);
            cout << endl;
            printPreorder(root);
            cout << endl;
        }
    }
}


Measured memory_bytes: 26584
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s, t; cin >> s >> t; cout << t << s << endl;

	return 0;
}

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

int main() {
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
	    cin>>h[i];
	}
	int count=0,sum=0,dome=1;
	for(int i=0;i<n;i++){
	    sum+=h[i];
	}
	while(sum){
	    for(int i=0;i<n;i++){
	        if(h[i]){
	            for(int j=i;j<n;j++){
	                if(h[j]){
	                    h[j]--;
	                    if(j==n-1)goto LAB;
	                    //cout<<9;
	                }
	                else{
	                    goto LAB;
	                    //dome=0;
	                    //break;
	                }
	                //if(dome==0)break;
	            }
	            //if(dome==0)break;
	        }
	        //if(dome==0)break;
	    }
	    LAB:
	    for(int i=0;i<n;i++){
	        //cout<<h[i];
	    }
	    //cout<<endl;
	    count++;
	    //dome=1;
	    sum=0;
	    for(int i=0;i<n;i++){
	        sum+=h[i];
	    }
	}
	cout<<count;
	return 0;
}


Measured memory_bytes: 256
input = gets.split(" ")
a = input[0].to_f
b = input[1].to_f
c = input[2].to_f

s = (1.0/2.0)*a*b*Math.sin(c*Math::PI/180)
l = a + b + Math.sqrt( a**2 + b**2 - 2*a*b*Math.cos(c*Math::PI/180) )
h = b*Math.sin(c*Math::PI/180)

puts "%.8f" % s
puts "%.8f" % l
puts "%.8f" % h



Measured memory_bytes: 8980
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define dl 998244853
lli mini(lli a,lli b){
    if(a<=b)return a;
    return b;
}

int main() {
    int n,W;
    cin>>n>>W;
    int V=0;
    vector<vector<lli>> a(n,vector<lli>(2,0));
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
        V=V+a[i][1];
    }
    vector<lli> ans(V+1,INT_MAX);
    ans[0]=0;
    
    for(int i=0;i<n;i++){
        for(int j=V-a[i][1];j>=0;j--){
            ans[j+a[i][1]]=mini(ans[j+a[i][1]],ans[j]+a[i][0]);
            }
        }
       
   int lf=0;
    for(int j=0;j<=V;j++){
            if(ans[j]<=W){
                lf=j;
            }
    }
        // if(ans[n][j]>W){
        //     int W=ans[n][j-1];
        //      for(int i=0;i<j;i++){
        //     if(ans[n][i]==W && ans[]){
        //         cout<<i<<" ha"<<ans[n][i]<<endl;
        //         return 0;
        //     }
        //      }
        //     return 0;
        // }
    cout<<lf<<endl;
}

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

int main() {
  int p, q, r;
  cin >> p >> q >> r;
  //for(int i = 0; i < n; i++) {
    //}
    
  int m = p+q;
  m = min(m, q+r);
  m = min(m, r+p);
  
  cout << m << endl;
}


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

int main() {
	int i,n,Debt=100000;
	cin>>n;
	for(;n>0;--n){
		i=Debt*0.05;
		if(i%1000!=0) i=1000+(i/1000)*1000;
		Debt+=i;
	}
	cout<<Debt<<endl;
	return 0;
}

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

long long N, P[1 << 18], idx[1 << 18], ans;
set<long long>Set;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> P[i]; idx[P[i]] = i; }
	Set.insert(0); Set.insert(N + 1);

	for (int i = N; i >= 1; i--) {
		long long d1 = 0, d2 = 0, v1 = 0, v2 = 0;

		auto itr = Set.lower_bound(idx[i]);
		auto itr1 = itr; itr1--;
		d1 = idx[i] - (*itr1);
		if (itr1 != Set.begin()) {
			long long r1 = (*itr1); itr1--;
			long long r2 = (*itr1);
			v1 = (r1 - r2);
		}
		auto itr2 = itr;
		d2 = (*itr2) - idx[i]; itr2++;
		if (itr2 != Set.end()) {
			itr2--;
			long long r1 = (*itr2); itr2++;
			long long r2 = (*itr2);
			v2 = (r2 - r1);
		}
		Set.insert(idx[i]);

		ans += 1LL * i * (v1 * d2 + v2 * d1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    
    cin >> a >> b;
    
    int s = 0;
    int f = 0;
    int m = 0;
    int DT = -1;
    for(int i = 0; i < b;i++){
        s = f;
        cin >> f;
        if(DT == -1){
            DT = f;
        }
        if(f - s > m){
            m = f - s;
        }
    }
    
        if(m < (a - f + DT)){
            m = a - f + DT;
        }
    
    cout << a - m;
    
    /*int a,b;
    
    cin >> a >> b;
    
    int dekee = 0;
    int ko[b + 1];
    
    for(int i = 0;i < b;i++){
        cin >> ko[i];
    }
    
    ko[b] = a;
    
    for(int i = 0;i < b;i++){
        if(ko[i + 1] - ko[i] > dekee){
            dekee = ko[i + 1] - ko[i];
        }
    }
    
    cout << a - dekee;
    */
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  ll a,b,c,d;cin>>a>>b>>c>>d;
  a--;
  print(
    b+b/lcm(d,c)-b/c-b/d
   -a-a/lcm(d,c)+a/c+a/d 
  );
  return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

	int A[100000];

	int partition(int A[],int p,int r){
	int x = A[r-1];
	int i = p,j;
	for(j = p; j<r-1;j++){
	if(A[j] <= x){
	int temp = A[i];
	A[i] = A[j];
	A[j] = temp;
	i++;
	}
	}
	int temp = A[i];
	A[i] = A[r-1];
	A[r-1] = temp;
	 return i;
	}

	int main(){
	  int n,i,ip;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d",&A[i]);
	}
	ip = partition(A,0,n);
	for(i=0; i<n; i++){
	if(i == ip)
	 printf("[%d]",A[i]);
	else printf("%d",A[i]);
	putchar(i < n -1? ' ' : '\n');
	}
	}




	




Measured memory_bytes: 2108
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    allxor = 0
    ans = [0] * N
    for k in range(N):
        allxor ^= A[k]
    for i in range(N):
        ans[i] = allxor ^ A[i]
    print(*ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 102244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    for(int i = 1; i <= n-m; i++){
        bool flag = true;
        rep(j, m)
        {
            if(s[i+j]=='0'){
                flag =false;
                break;
            }
        }
        if(flag){
            cout << -1 << endl;
            return 0;
        }
    }
    int dp[n+1] = {};
    reverse(s.begin(), s.end());
    int now = 0;
    vector<int> ans;
    while (now != n)
    {
        for(int i = m; i > 0; i--){
            if(now + i > n)continue;
            if(s[now+i] == '1') continue;
            dp[now + i] = dp[now] + 1;
            now += i;
            ans.push_back(i);
            break;
        }
    }
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1528
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := make([]int, N+2)
	A[0] = 0
	for i := 1; i <= N; i++ {
		A[i] = sc.nextInt()
	}
	A[N+1] = 0
	S := 0
	for i := 0; i <= N; i++ {
		S += abs(A[i] - A[i+1])
	}
	for i := 1; i <= N; i++ {
		total := S + abs(A[i-1]-A[i+1]) - (abs(A[i-1]-A[i]) + abs(A[i]-A[i+1]))
		fmt.Fprintln(wtr, total)
	}

	wtr.Flush()
}


Measured memory_bytes: 3712