akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    // cout << fixed << setprecision(15) << solve<vector<vector<int>>>() << endl;
    ll C,N,M; cin >> C >> N >> M;
    vector<ll> s(N),p(N);
    for(int i = 0; i < N;i++) cin >> s[i] >> p[i];
    
    vector<vector<ll>> dp(2,vector<ll>(C+1));
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= C;j++){
            dp[(i+1)&1][j] = max(dp[(i+1)&1][j],dp[i&1][j]);
            if(j+s[i] <= C){
                dp[(i+1)&1][j+s[i]] = max(dp[(i+1)&1][j+s[i]],dp[i&1][j] + p[i]);
            }
            dp[i&1][j] = 0;
        }
    }
    for(int i = 1; i <= M;i++){
        cout << dp[N&1][C/i]*i << endl;
    }
    return 0;
}



Measured memory_bytes: 3436
import Foundation
 
let c = Int(readLine()!)!
 
for_i: for a in -100 ..< 10000 {
    for b in -100 ..< 10000 {
        if a*a*a*a*a - b*b*b*b*b == c{
            print(String(format: "%d %d",a,b))
            break for_i
        }
    }
}

Measured memory_bytes: 13792
#include <stdio.h>

int main(){
  long long n, ans, a, b, c;
  scanf("%lld",&n);
  a = n/3;
  b = n/5;
  c = n/15;
  ans = n*(n+1)/2;     //nまでに含まれる整数の和
  ans -= (3+n-n%3)*a/2;    //nまでの3の倍数の和
  ans -= (5+n-n%5)*b/2;     //nまでの5の倍数の和
  ans += (15+n-n%15)*c/2; //までの15の倍数の和
  printf("%lld",ans);
}

Measured memory_bytes: 1728
# -*- coding: utf-8 -*-

a,b,c,d = map(int,input().split())

num = 0

import fractions
lcm = c*d//int(fractions.gcd(c, d))

num = b-b//c-b//d+b//lcm-((a-1)-(a-1)//c-(a-1)//d+(a-1)//lcm)





print(str(num))

Measured memory_bytes: 5048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
vector<vector<int>> dir{{1,0},{0,1},{-1,0},{0,-1}};
ll h,w;
void dfs(int x,int y,int cnt,vector<ll> &tmp,vector<vector<ll>> &a){
    bool f=false;
    
    rep(i,4){
      if(x+dir[i][0]>=0&&x+dir[i][0]<h&&y+dir[i][1]>=0&&y+dir[i][1]<w){
        if(a[x+dir[i][0]][y+dir[i][1]]>a[x][y]){
          f=true;
          cnt++;
          dfs(x+dir[i][0],y+dir[i][1],cnt,tmp,a);
          cnt--;
        }
      }
    }
    if(!f){
      tmp.push_back(cnt);
      op(cnt);
      cout<<":"<<endl;
    }
  }

void setup(){
  
  cin>>h>>w;
  ll last=0;
  vec(ans,0);
  mat(a,h,w);
  rep(i,h){
    rep(j,w){
      
      cin>>a[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      rep(k,4){
        if(i+dir[k][0]>=0&&i+dir[k][0]<h&&j+dir[k][1]>=0&&j+dir[k][1]<w){
          if(a[i+dir[k][0]][j+dir[k][1]]<=a[i][j]){
            break;
          }
        }
        if(k==3){
          op(i);
          op(j);
          dfs(i,j,1,ans,a);
        }
      }
    }
  }
  cout<<endl;
  rep(i,ans.size()){
    last+=(ans[i]-1)*(ans[i])/2;
    last%=MOD;
  }
  op((last+(h*w))%MOD);
}
vec(so,100000);

void ss(ll num){
  for(int i=2;i<=num;i++){
    if(num%i==0){
      
      so[num]++;
    }
  }
}


int main(){
  ll n;
  cin>>n;
  vec(v,n);
  ll sum=0;
  rep(i,n){
    cin>>v[i];
    sum+=v[i];
  }
  sort(all(v));
  ll cnt=0;
  rep(i,n){
    if(v[i]<0)cnt++;
  }
  if(cnt%2==0){
    rep(i,cnt){
      sum-=(2*v[i]);
    }
    op(sum);
    return 0;
  }
  ll tmp=sum;
  rep(i,cnt-1){
      tmp-=(2*v[i]);
  }
  if(cnt+1<=n){
  rep(i,cnt+1){
    sum-=(2*v[i]);
  }
  }
  op(max(sum,tmp));
  return 0;

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i,n) 
    cin >> a[i];
  ll dp[n-1][21];
  memset(dp,0,sizeof(dp));
  dp[0][a[0]] = 1;
  for (int i=1; i<n-1; ++i) {
    REP(j,21) {
      if (j + a[i] <= 20)
        dp[i][j + a[i]] += dp[i-1][j];
      if (j - a[i] >= 0)
        dp[i][j - a[i]] += dp[i-1][j];
    }
  }
  cout << dp[n-2][a[n-1]] << endl;
}

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

int main()
{ 
  int n ;
  cin >> n ;
  int64_t answer = 0 ;
  for(int i = 0 ; i < n ; i++)
  {
    int a, b ;
    cin >> a >> b ;
    answer += b - a + 1 ;
  }

  cout << answer << endl ;
}


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

using namespace std;

const int B1 = 256;
const int B2 = 128;
const int MOD1 = 2000000011;
const int MOD2 = 1000000007;
const int N = 5e3 + 5;

int n;
char s[N];

int mul(int a , int b , int m) {
    return a * 1ll * b % m;
}

int add(long long a , int b , int m) {
    a += b;
    while (a >= m)a -= m;
    while (a < 0) a += m;
    return a;
}

pair<int, int> prefix[N];
void hash_prefix() {
    int h1, h2;
    h1 = h2 = 0;
    for (int i = 0; s[i]; i++) {
        h1 = ((1LL * h1 * B1) % MOD1 + s[i]) % MOD1;
        h2 = ((1LL * h2 * B2) % MOD2 + s[i]) % MOD2;
        prefix[i] = make_pair(h1, h2);
    }
}

int p[N] , pp[N];
void pre() { // one time for all test cases
    p[0] = pp[0] = 1;
    for (int i = 1 ;i < N ;i++) {
        p[i] = mul(p[i - 1] , B1 , MOD1);
        pp[i] = mul(pp[i - 1] , B2 , MOD2);
    }
}

pair<int , int> get(int l , int r) {
    if (!l) return prefix[r];
    int len = r - l + 1;
    return {add(prefix[r].first , -mul(p[len] , prefix[l - 1].first , MOD1) , MOD1)
            , add(prefix[r].second, -mul(pp[len] , prefix[l - 1].second , MOD2) , MOD2)};
}

bool good(int len) {
    map<pair<int ,int> , int> exist;
    vector<pair<int , int> > v(n);

    for (int i = 0 ;i + len - 1 < n ;i++) {
        auto c = get(i , i + len - 1);
        v[i].first = c.first;
        v[i].second = c.second;
    }

    for (int i = len ;i + len - 1 < n ;i++)
        exist[v[i]]++;

    if (exist[v[0]])
        return 1;

    int r = len;
    while (r < n) {
        exist[v[r]]--;
        if (exist[v[r - len + 1]])
            return 1;
        r++;
    }

    return 0;
}

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n >> s;

    pre();
    hash_prefix();

    int l = 1 , r = n , ans = 0;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (good(mid)) {
            ans = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }

    cout << ans;
}

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

int main() {
  string s;
 
  cin >> s;
  int ans=0;
  rep(i,s.size()){
    ans+=s.at(i)-'0';
  }
  if(ans!=1){
    cout<<ans<<endl;
  }
  else{
    cout<<10<<endl;
  }
}




Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int[] num = {0, 1, 2, 3, 5, 7, 8, 9};

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;
		StringBuilder ans = new StringBuilder();
		while (n != 0){
			ans.append(num[n%8]);
			n /= 8;
		}
		ans.reverse();
		out.println(ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 52716
import sys

import numpy as np


def main(n,k,p,c):
    ans = -10**9
    for i in range(n):
        x = i
        t = k
        count = 0
        l = True
        sub = 0
        ln = 0
        while True:
            x = p[x] - 1
            if l:
                count += c[x]
                ln += 1
                if x == i:
                    if t > ln:
                        if count > 0:
                            sub += (t // ln - 1) * count
                            t %= ln
                            t += ln
                        else:
                            t = 0
                    l = False
            sub += c[x]
            t -= 1
            ans = max(sub, ans)
            if t < 1:
                break
    return ans


# >>> numba compile >>>
if sys.argv[-1]=='ONLINE_JUDGE' or sys.argv[-1]=='main.py':
  from numba.pycc import CC
  cc=CC('my_module')
  cc.export('main','i8(i8,i8,i8[:],i8[:])')(main)
  cc.compile()
  exit()
from my_module import main
# <<< numba compile <<<
(n, k), p, c = [np.int_(i.split()) for i in open(0)]
print(main(n,k,p,c))


Measured memory_bytes: 28036
n=gets.to_i
as=gets.split.map(&:to_i)
bs=[0]*(10**5+1)
as.each{|i| bs[i]+=1}
cur=bs[0]+bs[1]+bs[2]
ans=cur
3.upto(10**5) do |i|
  cur=cur-bs[i-3]+bs[i]
  ans=[ans,cur].max
end
puts ans


Measured memory_bytes: 11524
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import java.util.Set;
import java.util.HashSet;

class Main{
  public static void main(String... args)throws IOException{
    FastScanner fs = new FastScanner();
    Set<Long> dic = new HashSet<Long>();
    int n = fs.nextInt();
    for(int i=0;i<n;i++){
      long l = fs.nextLong();
      if(dic.contains(l))
        dic.remove(l);
      else
        dic.add(l);
    }
    System.out.println(dic.size());
  }
}



class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine(){
			String line = "";
			try{
				line = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return line;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}


Measured memory_bytes: 46344
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


ll calc(int n, char *s, int r, int g, int b)
{
	vi bc(n+1, 0), gc(n+1, 0);
	ll ret=0;

	for(int i=n-1;i>=0;i--)
	{
		bc[i]=bc[i+1];
		if(s[i]==b) bc[i]++;
	}

	for(int i=n-2;i>=0;i--)
	{
		gc[i]=gc[i+1];
		if(s[i]==g) gc[i]+=bc[i];
	}

	for(int i=n-3;i>=0;i--)
	{
		if(s[i]==r) ret+=gc[i];
	}

	for(int i=0;i<n;i++)
	{
		if(s[i]!=r) continue;
		for(int j=1;i+j*2<n;j++)
		{
			if(s[i+j]==g && s[i+j*2]==b) ret--;
		}
	}
	return ret;
}


int main(void)
{
	int n;
	char s[4000+2];

	while(scanf("%d\n%4000[RGB]", &n, s)==2)
	{
		ll ans=0LL;
		ans+=calc(n, s, 'R', 'G', 'B');
		ans+=calc(n, s, 'R', 'B', 'G');
		ans+=calc(n, s, 'G', 'R', 'B');
		ans+=calc(n, s, 'G', 'B', 'R');
		ans+=calc(n, s, 'B', 'R', 'G');
		ans+=calc(n, s, 'B', 'G', 'R');

		printf("%lld\n", ans);
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	vector<int> sides(3);
	cin >> sides[0] >> sides[1] >> sides[2];
	
	sort(sides.begin(), sides.end());
	
	cout << sides[0] * sides[1] / 2;
	

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
 
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();

    if (a < b && b < c) {
        System.out.println("Yes");
    } else {
        System.out.println("No");
    }
 
    scanner.close();
  }
}


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

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

    if (s <= "2019/04/30") {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}


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

#define st first
#define nd second
const int N = 55;
int n;
pair<int,int> point[N];
int ans = 0;
map<pair<int,int>,int> mp;
map<pair<int,int>,vector<int> > vec;
pair<int,int> pos;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> point[i].st >> point[i].nd;
    }
    sort(point,point+n);
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            int p = point[j].st-point[i].st, q = point[j].nd-point[i].nd;
            if (p < 0)
            {
                p = -p;
                q = -q;
            }
            mp[{p,q}]++;
            if (mp[{p,q}] > ans)
            {
                ans = max(ans,mp[{p,q}]);
                pos = {p,q};
            }
        }
    }
    //cout << pos.st << ' ' << pos.nd << endl;
    cout << n-ans;
}
/*
50
562555884 -421990420
562555886 -421990420
562555884 -421990406
562555884 -421990416
562555886 -421990419
562555886 -421990416
562555886 -421990409
562555884 -421990417
562555884 -421990411
562555885 -421990406
562555884 -421990408
562555885 -421990414
562555886 -421990405
562555884 -421990407
562555885 -421990407
562555885 -421990408
562555885 -421990405
562555884 -421990414
562555885 -421990411
562555886 -421990404
562555884 -421990413
562555884 -421990415
562555885 -421990416
562555884 -421990409
562555885 -421990410
562555884 -421990405
562555886 -421990415
562555885 -421990415
562555886 -421990417
562555886 -421990410
562555886 -421990408
562555885 -421990409
562555886 -421990413
562555884 -421990404
562555885 -421990419
562555886 -421990414
562555885 -421990420
562555886 -421990412
562555884 -421990412
562555884 -421990410
562555885 -421990404
562555885 -421990412
562555885 -421990417
562555886 -421990407
562555884 -421990418
562555884 -421990419
562555886 -421990406
562555886 -421990418
562555885 -421990418
562555886 -421990411
*/


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

int A(int x,int y){
  return x+y;
}

int B(int x,int y){
  return x-y;
}

int C(int x,int y){
  return x*y;
}

int D(int x,int y){
  return x/y;
}


int main() {
  int a,b;
  char op;
  while(1){
    
    cin >> a >> op >> b;
    
    if(op == '?')
      break;
    
    if(op == '+')
      cout << A(a,b) << endl;
    
    if(op == '-')
      cout << B(a,b) << endl;
    
    if(op == '*')
      cout << C(a,b) << endl;
    
    if(op == '/')
      cout << D(a,b) << endl;
   
  }
}



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

vector<complex<double>> fft(vector<complex<double>> a, bool inverse = 0) {
    int n = a.size();
    int h = (int)log2(n);

    for (int i = 0; i < n; i++) {
        int j = 0;
        for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if (i < j) swap(a[i], a[j]);
    }

    for (int b = 1; b < n; b *= 2) {
        for (int j = 0; j < b; j++) {
            complex<double> w = polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for (int k = 0; k < n; k += b * 2) {
                complex<double> s = a[j + k];
                complex<double> t = a[j + k + b] * w;
                a[j + k] = s + t;
                a[j + k + b] = s - t;
            }
        }
    }
    if (inverse)
        for (int i = 0; i < n; i++) a[i] /= n;
    return a;
}
vector<complex<double>> ifft(vector<complex<double>> &a) { return fft(a, 1); }

vector<complex<double>> fft(vector<double> a, bool inverse = 0) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}
vector<complex<double>> ifft(vector<double> a) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, 1);
}

// 畳み込み : return v | v[k] = sum_{0<=j<=k}(a[j]b[k-j])
vector<double> convolve(vector<double> a, vector<double> b) {
    int s = a.size() + b.size() - 1;
    int t = 1;
    while (t < s) t *= 2;
    a.resize(t);
    b.resize(t);
    vector<complex<double>> A = fft(a);
    vector<complex<double>> B = fft(b);
    for (int i = 0; i < t; i++) {
        A[i] *= B[i];
    }
    A = ifft(A);
    a.resize(s);
    for (int i = 0; i < s; i++) a[i] = A[i].real();
    return a;
}

int main() {
    int n;
    ll m, ans = 0;
    cin >> n >> m;
    vector<double> P(200001, 0.0), Q(200001, 0.0);
    for (int i = 0; i < n; i++) {
        int A;
        cin >> A;
        P[A]++, Q[A]++;
    }
    vector<double> V = convolve(P, Q);
    for (ll i = 200000; i >= 1 && m > 0; i--) {
        ll v = round(V[i]);
        if (m > v)
            ans += v * i, m -= v;
        else
            ans += m * i, m = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42304
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		double A = double.Parse(str[0]);
		double B = double.Parse(str[1]);
		double X = double.Parse(str[2]);
      	double N = 0;
      	if(X<A*A*B/2){
			N = 90 - Math.Atan((X/B/B*2)/(A)) / Math.PI * 180;
        } else {
			X = A*A*B-X;
          	N = Math.Atan((X/A/A*2)/(A)) / Math.PI * 180;
        }
		Console.WriteLine(N);
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl


string str;

int main() {
  while (cin >> str) {
	int res = 0;
	for (auto c : str) if (c == '1') ++ res;
	cout << res << endl;
  }
}


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

int main(){
    int n; cin>>n;
    int a,b;
    cin>>a>>b;
    vector<int> p(n);
    for(int i=0;i<n;i++) cin>>p[i];
    vector<int> cnt(3);
    for(int i=0;i<n;i++){
        if(p[i]<=a) cnt[0]++;
        else if(p[i]<=b) cnt[1]++;
        else cnt[2]++;
    }
    cout<<min({cnt[0],cnt[1],cnt[2]})<<endl;

    return 0;
}

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

const int MAXN = 2e5+7;
LL a[MAXN];

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

    vector< LL >c(n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        c[i-1] = a[i]-i;
    }

    sort(c.begin(), c.end());
    LL b = c[n/2];

    LL ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += abs(a[i]-(b+i));
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
    int n, W;
    cin >> n >> W;
    int a[n + 1][3];
    for (int i = 1; i <= n; i++) {
        cin >> a[i][2] >> a[i][1]; // weight and value
    }
    long long dp[n + 1][W + 1]; // amount N of guys in backpack with weight W
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 0;
    }
    for (int i = 0; i <= W; i++) {
        dp[0][i] = 0;
    }
    for (int k = 1; k <= n; k++) {
        for (int s = 1; s <= W; s++) {
            if (s - a[k][2] >= 0) {
                dp[k][s] = std::max(dp[k - 1][s], dp[k - 1][s - a[k][2]] + a[k][1]);
            }
            else {
                dp[k][s] = dp[k - 1][s];
            }
        }
    }
    cout << dp[n][W];
    return 0;
}

Measured memory_bytes: 79104
#include<stdio.h>
int main(void){
	int b, a;
	
	scanf("%d %d", &a, &b);
	
	if((a+b) % 2 == 0) printf("%d\n", (a+b)/2);
	else printf("%d\n", (a+b)/2 + 1);
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
   ll a, b, x; cin >> a >> b >> x;
   ll aa = 0, bb = 0, ans = 0;
   bb = b / x;
   if(a == 0) aa = -1;
   else aa = (a - 1) / x;

   if(a != 0 && a != x && a == b) ans = 0;
   else ans = bb - aa;
   cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int ans= -1;
  int on_idx= 1;
  for(int i=0; i<N; i++){
    on_idx= vec.at(on_idx-1);
    if( on_idx==2 ){
      ans= i+1;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	for (int i = 0;i < 3;++i) {
		if (s[i] == 'a')++a;
		if (s[i] == 'b')++b;
		if (s[i] == 'c')++c;
	}
	if (a == 1 && b == 1 && c == 1) {
		cout << "Yes" << endl;
	}
  else {
    cout<<"No"<<endl;
  }

	return 0;
}

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


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    vector<int> As = {A, B, C};
    int cnt = 0;
    rep(i, 3) {
        rep(j, 3) {
            if(i==j) continue;
            if(As[i] == As[j]) {
                ++cnt;
            }
        }
    }   
    if(cnt==2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
S = input()
T = input()
X = "UNRESTORABLE"
ans = ""
x = 0
res = []
for inds, s in enumerate(S):
    if (inds + len(T) > len(S)):
        break
    for indt, t in enumerate(T):
        if S[inds + indt] == t or S[inds+indt] == "?":
            pass
        else:
            break
    else:
        res.append(ans+T + S[inds + len(T):len(S)])
    ans += s

if (len(res) > 0):
    ans = res[0].replace("?", "a")
    for i in res:
        ans = min(i.replace("?", "a"), ans)
    print(ans)
else:
    print(X)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        out.println(a - b + 1);
        out.close();
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<pii> ab(m);
    REP(i, m){
        int a,b;
        cin >> a >> b;
        ab[i] = make_pair(a,b);
    }
    SORT(ab);

    int ans = 1;
    int min_b = ab[0].se;
    REP(i, m){
        min_b = min(min_b, ab[i].se);
        if(ab[i].fi >= min_b){
            ans++;
            min_b = ab[i].se;
        }
    }

    pr(ans);

}

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

int solve(int x,int y,int Z[95][95]){
	Z[x][y]=0;
	int ans=1;
	if(Z[x][y+1]==1){int s=solve(x,y+1,Z)+1; if(ans<s)ans=s;}
	if(Z[x][y-1]==1){int s=solve(x,y-1,Z)+1; if(ans<s)ans=s;}
	if(Z[x+1][y]==1){int s=solve(x+1,y,Z)+1; if(ans<s)ans=s;}
	if(Z[x-1][y]==1){int s=solve(x-1,y,Z)+1; if(ans<s)ans=s;}
	Z[x][y]=1;
	return ans;
}

int main(){
while(1){
	int n,m,I[95][95]={0},J[95][95]={0},ans=0;
	scanf("%d%d",&m,&n);
	if(n==0&&m==0)break;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d",&I[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(I[i][j]==1){
				int s=solve(i,j,I);
				if(ans<s)ans=s;
			}
		}
	}
	printf("%d\n",ans);
}
return 0;
}

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

int main()
{
	int q = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		double p0x = 0, p0y = 0, p1x = 0, p1y = 0, p2x = 0, p2y = 0, p3x = 0, p3y = 0,
			   u = 0, s = 0, t = 0;
		int n = 0;

		cin >> p0x >> p0y >> p1x >> p1y >> p2x >> p2y >> p3x >> p3y;

		u = (p3y - p0y) * (p2x - p0x) - (p3x - p0x) * (p2y - p0y);

		if (u != 0) {
			s = ((p3y - p0y) * (p1x - p0x) - (p3x - p0x) * (p1y - p0y)) / u;
			t = -((p2y - p0y) * (p1x - p0x) - (p2x - p0x) * (p1y - p0y)) / u;

			if (s >= 0 && t >= 0) {
				if (s + t >= 1)
					n = 1;
			}
		}
		else {
			double t0 = (p2x - p0x) * (p3x - p0x) + (p2y - p0y) * (p3y - p0y),
				t1 = (p2x - p1x) * (p3x - p1x) + (p2y - p1y) * (p3y - p1y),
				t2 = (p0x - p2x) * (p1x - p2x) + (p0y - p2y) * (p1y - p2y);

			if ((p1y - p0y) * (p2x - p0x) - (p1x - p0x) * (p2y - p0y) != 0) {
				if (t0 <= 0)
					n = 1;
			}
			else if ( (t0 <= 0) || (t1 <= 0) || (t2 <= 0))
				n = 1;
		}

		cout << n << endl;
	}

	return 0;
}


Measured memory_bytes: 3196
str = input()

n,s,e,w = -1,-1,-1,-1

n = str.find("N")
s = str.find("S")
e = str.find("E")
w = str.find("W")

ch = 1

if(n>=0 and s==-1):
    ch  = 0
elif(n==-1 and s>=0):
    ch  = 0
elif(w>=0 and e==-1):
    ch = 0
elif(e>=0 and w==-1):
    ch = 0

if(ch):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
ll t1,t2,a1,a2,b1,b2;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(t1*a1+t2*a2==t1*b1+t2*b2){
		cout<<"infinity\n";
		return 0;
	}
	if(a1<b1){
		swap(a1,b1);
		swap(a2,b2);
	}
	if(a1>b1&&a2>b2){
		cout<<"0\n";
		return 0;
	}
	ll x=t1*a1-t1*b1,y=-(t1*a1+t2*a2-t1*b1-t2*b2);
	if(y<0)cout<<"0\n";
	else if(x%y==0)cout<<x/y*2<<endl;
	else cout<<x/y*2+1<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int64_t n;
	cin >> n;

	unordered_set<int64_t> d;
	d.insert(n);
	if(n - 1 > 1) d.insert(n - 1);
	for(int64_t i = 2; i * i <= n; i++) {
		int64_t c = 0;
		int64_t t = n;
		while(t % i == 0) {
			t /= i;
			c++;
		}

		if(t % i == 1) {
			d.insert(i);
			if(c == 0) d.insert((n - 1) / i);
		}
	}

	cout << d.size();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int k; cin >> k;
	string s; cin >> s;
	if(s.size()<=k)
		cout << s << endl;
	else{
		REP(i,k)
			cout << s[i];
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    ll ans=0;
    rep(i,1,n){
        if(i%3!=0 && i%5!=0){
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3648
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int N;
// 候補は nの約数か (n-1) の約数

bool f(int k){
    int ni = N;
    while( ni >= k) {
        ni = ni%k ? ni%k : ni/k;
    }
    return ni == 1;
}

vi divisor(int n){
    vi ret;
    for(int i = 1; i*i <= n; i++) if (n%i == 0){
        ret.pb(i);
        if (i*i != n) ret.pb(n/i);
    }
    return ret;
}

signed main(){
    cin >> N;
    set<int> cand;
    for (auto i: divisor(N)) cand.insert(i);
    for (auto i: divisor(N-1)) cand.insert(i);

    int ret = 0;
    for(auto i: cand){
        if (i == 1) continue;
        ret += f(i);
    }
    cout << ret << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int X;
	cin >> X;
	if(X == 7 || X == 5 || X == 3){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int K;
	string cur = "0";
	cin >> K;
	while (K--) {
		int sz = cur.size();
		
		bool update = false;
		for (int i = sz - 1; i >= 0; --i) {
			bool ok = true;
			if (cur[i] == '9') ok = false;
			if (i > 0 && abs((int)cur[i - 1] - (int)(cur[i] + 1)) > 1) ok = false;
			if (i < sz - 1 && abs((int)(cur[i] + 1) - (int)cur[i + 1]) > 1) ok = false;
			if (ok) {
				++cur[i];
				for (int j = i + 1; j < sz; ++j) {
					cur[j] = max((int)cur[j - 1] - 1, (int)'0');
				}
				update = true;
				break;
			}
		}
		if (!update) {
			cur = "1";
			REP(i, sz) cur += '0';
		}
	}
	cout << cur << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <climits>
using namespace std;

int main()
{
  int n;
  int n4 = 0, n2 = 0, els = 0;
  cin >> n;

  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;

    if (tmp % 4 == 0)
    {
      n4++;
    }
    else if (tmp % 2 == 0)
    {
      n2++;
    }
    else
    {
      els++;
    }
  }

  if (n2 != 0)
  {
    els++;
  }

  // answer
  if (n4 + 1 >= els)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}
signed main() {
  int n;cin>>n;int a[100000];rep(i,n)cin>>a[i];
  int ans = a[0];
  repd(i,1,n){
    ans = gcd(ans,a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,j;cin>>N;ll C[N-1],S[N-1],F[N-1];
  REP(i,N-1)cin>>C[i]>>S[i]>>F[i];
  REP(i,N){
    ll T=0;
    FOR(j,i,N-1)T=(max(T,S[j])+F[j]-1)/F[j]*F[j]+C[j];
    cout<<T<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    rep(i, T) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int sum = 0;
    rep(i, T) sum += a[i];
    cout << max(0, a[0] - (sum - a[0]) - 1) << endl;

    return 0;
}


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

using namespace std;
using ll = long long int;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;
    ll s = accumulate(a.begin(), a.end(), 0ll);
    for(ll i=1; i<n; i+=2)
        s -= a[i]*2;
    cout << s << ' ';
    for(ll i=0; i<n-1; i++)
        s = (2*a[i] - s), cout << s << ' ';
    cout << endl;
}


Measured memory_bytes: 2176
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; 

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); 
	cout.tie(NULL);
	
ll n;
cin>>n;
ll a[n];
F0R(i,n)
cin>>a[i];
ll ans=0,sum=0;
F0R(i,n)
{
    if(i!=0)
    {
        sum= ((sum%MOD) + (a[i-1]%MOD))%MOD;
        ans= ((ans%MOD) +(( sum%MOD) * (a[i]%MOD)))%MOD;
    }
}
cout<<ans%MOD<<nl;
	return 0;
}


Measured memory_bytes: 5216
li = [int(x) for x in input().split()]
ans = 0
bar = 0
odd = []
for ind,i in enumerate(li):
    bar+=i%2
    if(i%2==1):
        odd.append(ind)
if(bar == 0 or bar == 3):
    ans = 0
elif(bar == 1):
    for ind,i in enumerate(li):
        if(not ind in odd):
            li[ind]+=1
    ans = 1
else:
    for ind,i in enumerate(li):
        if(ind in odd):
            li[ind]+=1
    ans = 1
li.sort()
ans += (2*li[2]-li[0]-li[1])//2
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int w;
    cin>>n>>w;

  long long  int wt[n];
   long long  int val[n];

    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];

    }

    long long int dp[n+1][w+1];

    for(int i=0;i<=n;i++){
        dp[i][0]=0;

    }
    

    for(int i=0;i<=w;i++){
        dp[0][i]=0;
        
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){

           if(wt[i-1]<=j){
               dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);

           }else{
               dp[i][j]=dp[i-1][j];

           }

        }
    }

    cout<<dp[n][w];


}


Measured memory_bytes: 79104
#include <stdio.h>

#define MAX 100005
#define R -1

typedef struct{
  int parent;
  int right;
  int left;
}Node;

Node A[MAX];
int n;
int B[MAX];
int C[MAX];

int height(int u){
  int x1=0,x2=0;
  if(A[u].left!=R) x1=height(A[u].left)+1;
  if(A[u].right!=R) x2=height(A[u].right)+1;
  return C[u]=(x1>x2 ? x1:x2);
}

void depth(int u,int p){
  if(u==R) return;
  B[u]=p;
  depth(A[u].right,p+1);
  depth(A[u].left,p+1);
}

int getsibling(int u){
  //A[u]???root??????????????????????????????R????????????
  if(A[u].parent==R) return R;
  //A[u]?????????????????????A[u]????????§?????????????????????????????????????????£???????????°????????????????????????
  if(A[A[u].parent].left != u && A[A[u].parent].left!=R)
    return A[A[u].parent].left;
  if(A[A[u].parent].right != u && A[A[u].parent].right!=R)
      return A[A[u].parent].right;
  return R;
}
/*void print2(int i){
  int c,j;
  c=A[i].left;
  for(j=0,c=A[i].left;c!=R;j++,c=A[c].right){
    if(j)printf(", ");
    printf("%d",c);
  }
}
*/
void print(){
  int i,flag1=0,flag2=0;
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",A[i].parent);
    printf("sibling = %d, ",getsibling(i));
    if(A[i].left!=R) flag1=1;
    if(A[i].right!=R) flag2=1;
    printf("degree = %d, ",flag1+flag2);
    flag1=0;
    flag2=0;
    printf("depth = %d, ",B[i]);
    printf("height = %d, ",C[i]);
    if(A[i].parent==R) printf("root\n");
    else if(A[i].left==R && A[i].right==R) printf("leaf\n");
    else printf("internal node\n");
  /*  printf("[");
    print2(i);
    printf("]\n");
    */
  }
}

int main(int argc, char const *argv[]) {
  int i,j,root,x,y,s;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    A[i].parent=R;
    A[i].left=R;
    A[i].right=R;
  }
  for(i=0;i<n;i++){
    scanf("%d",&root);
    scanf("%d",&x);
    scanf("%d",&y);
    A[root].left=x;
    A[root].right=y;
    if(x!=R) A[x].parent=root;
    if(y!=R) A[y].parent=root;
  }

  for(i=0;i<n;i++){
    if(A[i].parent==R) s=i;
  }
  depth(s,0);
  height(s);
  print();
  return 0;
}

Measured memory_bytes: 620
#include <stdio.h>

int main(void){
  int w, h, x, y, r;
  int flag = 0;

  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);

  if (x + r > w || x - r < 0) {
    flag = 1;
  }
  if (y + r > h || y - r < 0) {
    flag = 1;
  }

  if (flag == 0) {
    printf("Yes\n");
  }
  else if (flag == 1){
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 2136
let n, h = Scanf.scanf " %d %d" @@ fun a b -> a, ref b
let m, ans = ref 0, ref 0
let bs = Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> m := max !m a; b
let _ = Array.(sort (fun x y -> y - x) bs; iter (fun b -> if b > !m then (if !h > 0 then (incr ans; h := !h - b))) bs); ans := !ans + (max 0 !h + !m - 1) / !m; Printf.printf "%d\n" !ans

Measured memory_bytes: 4992
#include <math.h>
#include <bits/stdc++.h>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define val 1000000000000000000
using namespace std;
int main()
{
    l a,b;
    ll c=1;
    cin>>a>>b;
    b=b*1000;
    c=(a*b)/1000;
    cout<<c<<endl;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
	int n,t,e,p=-1,a;
	cin>>n>>t>>e;
	r(i,0,n){
		cin>>a;
		if((t+e)%a<=2*e)p=i+1;
	}
	cout<<p<<endl;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

bool isOk(char c)
{
    if (c == 'A') { return true; }
    if (c == 'C') { return true; }
    if (c == 'G') { return true; }
    if (c == 'T') { return true; }
    return false;
}

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

    const int n = s.size();

    int ans = 0;

    REP(i, 0, n)
    REP(j, i, n)
    {
        bool ok = true;
        REP(k, i, j+1) { if (!isOk(s[k])) { ok = false; } }

        if (ok) { ans = max(ans, j - i + 1); }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		for(int i=0;i<N;i++) {
			int tmp = sc.nextInt();
		}
		System.out.println((int)(Math.ceil((N-1)/(K-1.0))));
	}
}


Measured memory_bytes: 48500
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

// (a ^ b) % mod
ll powMod(ll x, ll k, ll m) {
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k / 2, m);
	else            return x*powMod(x, k - 1, m) % m;
}


int arr[100] = {};

bool check(int g1,int g2,int g4) {

	//cout << g1 << " " << g2 << " " << g4 << endl;

	for (int i = 0; i < 100; i++) {
		if (arr[i] % 4 == 1 || arr[i] % 4 == 3) {
			g1--;
			arr[i]--;
		}
	}

	for (int i = 0; i < 100; i++) {
		if (arr[i] >= 4) {
			g4--;
			arr[i] -= 4;
			i--;
		}
		if (g4 == 0)
			break;
	}

	for (int i = 0; i < 100; i++) {
		if (arr[i] >= 2) {
			g2--;
			arr[i] -= 2;
			i--;
		}
	}

	if (g1 == 0 && g2 == 0 && g4 == 0) {
		return true;
	}

	return false;

}

int main() {

	int h, w;
	cin >> h >> w;


	for (int i = 0; i < h*w; i++) {
		char c;
		cin >> c;
		arr[c - 'a']++;
	}

	sort(arr,arr+100);

	bool f = false;

	if (h % 2 == 1 && w % 2 == 1) {
		if (check(1, h / 2 + w / 2, (h / 2)*(w / 2))) {
			f = true;
		}
			
	}
	else if (h % 2 == 1) {
		if (check(0, w / 2, (h / 2)*(w / 2))) {
			f = true;
		}
	}
	else if (w % 2 == 1) {
		if (check(0, h / 2, (h / 2)*(w / 2))) {
			f = true;
		}
	}
	else {
		if (check(0, 0, (h / 2)*(w / 2))) {
			f = true;
		}
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256