akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto s = new int[](n);
  foreach (i; 0..n) {
    s[i] = readln.chomp.to!int;
  }
  auto sum = s.sum;
  if (sum % 10) writeln(sum);
  else {
    bool flag = true;
    foreach (e; s.sort()) {
      if ((sum - e) % 10) {
        writeln(sum - e);
        flag = false;
        break;
      }
    }
    if (flag) writeln("0");
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 924844033

ll N,K;
ll dp[2001][2001][2];

int main(){
  cin>>N>>K;
  ll i=0;
  dp[0][0][0]=1;
  rep(r,2*K){
    for(ll j=r;j<N;j+=2*K,i++){
      rep(k,N+1){
        (dp[i+1][k][0]+=dp[i][k][0])%=mod;
        (dp[i+1][k][0]+=dp[i][k][1])%=mod;
        if(k<N){
          if(j-K>=0)(dp[i+1][k+1][0]+=dp[i][k][0])%=mod;
          if(j+K<N){
            (dp[i+1][k+1][1]+=dp[i][k][0])%=mod;
            (dp[i+1][k+1][1]+=dp[i][k][1])%=mod;
          }
        }
      }
    }
    rep(k,N+1){
      (dp[i][k][0]+=dp[i][k][1])%=mod;
      dp[i][k][1]=0;
    }
  }
  assert(i==N);
  ll res=0;
  rep(k,N+1){
    ll sgn=(k%2==0?1:mod-1);
    ll fac=1;
    rep(j,N-k)fac=fac*(j+1)%mod;
    (res+=((dp[N][k][0]*sgn%mod)*fac)%mod)%=mod;
    //dbg(k); dbg(fac);
    //dbg(dp[N][k][0]);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,x=0,y=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    sort(arr,arr+n);
    int t=1;
    for(int i=n-1; i>=0; i--)
    {
        if(t)
            x+=arr[i];
        else
            y+=arr[i];
        t^=1;
    }
    cout<<abs(x-y)<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std ;
const int N = 2e5 + 5 ;
int a[N] , nxt[N] ;

int main () {

    int n ;
    scanf("%d" , &n) ;
    for (int i = 1 ; i <= n ; i++) {
        scanf("%d" , a + i) ;
    }
    nxt[n] = n+1;
    for (int i = n - 1 ; i >= 1 ; i--) {
        if (a[i + 1] == 0) nxt[i] = nxt[i+1] ;
        else nxt[i] = i + 1 ;
    }
    long long cnt = 0 ;
    for (int i = 1 ; i <= n ; i++) {
        int sum = 0 , Xor = 0 ;
        int Count = 22 ;
        int j = i ;
        while (Count >= 0 and j <= n) {
            sum += a[j] , Xor ^= a[j] ;
            if (sum == Xor) {
                cnt = cnt + (long long)(nxt[j]-j) ;
            }
            j = nxt[j] ;
            Count-- ;
        }
    }
    printf ("%lld\n" , cnt);

    return 0 ;
}


Measured memory_bytes: 1792
/**
*    author:  yuya1234
*    created: 08.07.2020 17:27:56
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n,t;
  cin>>n>>t;

  int tt[200001];
  REP(i,n)cin>>tt[i];

  ll ans=0,diff;
  REP(i,n-1)
  {
    diff=tt[i]+t;
    if(diff>tt[i+1])ans+=tt[i+1]-tt[i];
    else ans+=t;
  }
  ans+=t;

  cout<<ans<<endl;

  return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/


const ld pi = 3.14159265358979323846264338327950;

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(10);

    long double a, b, x; cin >> a >> b >> x;
    if((a*a*b)/2 < x) {
        ld ans =  atan(2*(b*a*a - x)/(a*a*a));
        cout << ans*180./(pi) << '\n';
    }
    else if((a*a*b) == 2*x) {
        ld ans = (atan(b/a));
        cout << ans*180./(pi) << '\n';
    }
    else {
        ld ans=  atan((a*b*b)/(2*x));
        cout << ans*180./(pi) << '\n';
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll ans = 0;
  rep(i,n){
    if(a[i] >= b[i]) ans += b[i];
    else{
      if(a[i] + a[i+1] >= b[i]){
        ans += b[i];
        a[i+1] -= b[i]-a[i];
      }
      else{
        ans += a[i]+a[i+1];
        a[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4716
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:i64,
    }
    let mut n = n;
    if n == 2 {
        println!("{}", 1);
        return;
    }
    let mut ans = 0;
    let mut divs = divisor((n - 1) as usize);
    let mut dvs2 = divisor(n as usize);
    for &d in divs.iter().chain(dvs2.iter()) {
        if d == 1 {
            continue;
        }
        let mut m = n as usize;
        while m % d == 0 {
            m /= d;
        }
        if m % d == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}
pub fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res
}


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

int main() {
  ll a,b,k;
  cin >> k >> a >> b;
  if(a+2 >= b) cout << k+1 << endl;
  else{
    if(a+1 > k){
      cout << k+1 << endl;
      return 0;
    }
    ll ans = b;
    k -= a+1;
    ans += (k/2)*(b-a);
    k %= 2;
    ans += k;
    cout << ans << endl;
  }
}

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

using namespace std;





int main(){

  long long int Q;
  cin>>Q;
  set<int>das;

  while(Q--){

    long long ans;
    cin>>ans;

    if(das.find(ans) == das.end())
        das.insert(ans);
    else if(das.find(ans) != das.end() )
        das.erase(ans);

  }

  cout<<das.size()<<endl;

  return 0;
}


Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineInt();

            Console.WriteLine((n*800)-((n/15)*200));

            ReadLine();
        }

        /// <summary>
        /// コンビネーション
        /// </summary>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }

        static string[] GetAplhaLowerArray() => new string[]{ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<int> a(n+5);
	int c1 = 0, c2 = 0, c3 = 0;
	for(int i = 1; i<=n ; i++){
		cin >> a[i];
		if(a[i] == 1){
			c1++;
		}
		else if(a[i] == 2)
			c2++;
		else
			c3++;
	}
	double dp[n+5][n+5][n+5] = {};
	dp[0][0][0] = 0;
	// dp[1][0][0] = 1;
 
	for(int k = 0 ; k<=n ; k++){
		for(int j = 0; j<= n ; j++){
			for(int i = 0; i<=n ; i++){
				if(i == 0 && j == 0 && k == 0)
					continue;
				if(i + j + k > n)
					continue;
				double curr = (double)(i + j + k);
				if( i != 0){
					dp[i][j][k] += ((double)i/curr)*dp[i-1][j][k];
				}
				if( j != 0){
					dp[i][j][k] += ((double)j/curr)*dp[i+1][j-1][k];
				}
				if( k != 0){
					dp[i][j][k] += ((double)k/curr)*dp[i][j+1][k-1];
				}
				dp[i][j][k] += (double)n/curr;
			}
		}
	}
 
	cout<<fixed<<setprecision(10)<<dp[c1][c2][c3]<<endl;
 
	return 0;
}

Measured memory_bytes: 221952
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
ll x[99],y[99];
ll idx[99];
ll idx2[99];

int c(const void*a,const void*b){
	ll p=*(ll*)a,q=*(ll*)b;
	ll ppp=x[p]*2000000001+y[p];
	ll qqq=x[q]*2000000001+y[q];
	if(ppp<qqq)return -1;
	return 1;
}
int c2(const void*a,const void*b){
	ll p=*(ll*)a,q=*(ll*)b;
	ll ppp=x[p]*2000000001-y[p];
	ll qqq=x[q]*2000000001-y[q];
	if(ppp<qqq)return -1;
	return 1;
}

int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld %lld",x+i,y+i);
	rep(i,0,n)idx[i]=idx2[i]=i;
	qsort(idx,n,sizeof(ll),c);
	qsort(idx2,n,sizeof(ll),c2);
	ll ans=n;
	
	rep(aaa,0,n)rep(bbb,0,n)if(aaa!=bbb){
		//aaa,bbb間の移動を(p,q)に指定する
		ll p=x[aaa]-x[bbb];
		ll q=y[aaa]-y[bbb];
		ll tempx[99]={};
		ll tempy[99]={};

		if(p*q>=0){
			if(p>0||q>0){
				//左下から右下へ
				rep(i,0,n){
					tempx[i]=x[idx[i]];
					tempy[i]=y[idx[i]];
				}
			}else{
				//右上から左下へ
				for(ll i=n-1;i>=0;i--){
					tempx[i]=x[idx[i]];
					tempy[i]=y[idx[i]];
				}
			}
		}else{
			if(p<0){
				//左上から右下へ
				rep(i,0,n){
					tempx[i]=x[idx2[i]];
					tempy[i]=y[idx2[i]];
				}
			}else{
				//右下から左上へ
				for(ll i=n-1;i>=0;i--){
					tempx[i]=x[idx2[i]];
					tempy[i]=y[idx2[i]];
				}
			}
		}
		
		ll cnt=0;
		rep(i,0,n){
			if(tempx[i]!=INF){
				cnt++;
				int flag=1;
				ll crrx=tempx[i];
				ll crry=tempy[i];
				tempx[i]=INF;
				tempy[i]=INF;
				
				while(flag){
					flag=0;
					crrx+=p;
					crry+=q;
					rep(j,0,n){
						if(crrx==tempx[j]&&crry==tempy[j]){
							flag=1;
							tempx[j]=INF;
							tempy[j]=INF;
							break;
						}
					}
				}
			}
		}
		ans=min(ans,cnt);
	}
	printf("%lld",ans);
}


Measured memory_bytes: 128
R, C, T = map(int, input().split())
RC = []
for _ in range(T):
    RC.append(list(map(int, input().split())))
TR = [0] * (R + 1)
TC = [0] * (C + 1)
mxr=0
mxc=0
for r, c in RC:
    TR[r] += 1
    TC[c] += 1
    if(TR[r]>mxr):
      mxr=TR[r]
    if(TC[c]>mxc):
      mxc=TC[c]
ct = TR.count(mxr) * TC.count(mxc) - len([0 for r, c in RC if TR[r] == mxr and TC[c] == mxc])
print(mxc + mxr - (ct == 0))

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

int main() {
  long L, R;
  cin >> L >> R;
  if(R - L >= 2018) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 2019;
  for(long i = L; i < R; i++) {
    for(long j = i + 1; j <= R; j++) {
      if(i*j % 2019 < ans) ans = i*j % 2019;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

def resolve():
    n, m = map(int, input().split())
    heights = list(map(int, input().split()))
    bridges = [list(map(int, input().split())) for i in range(m)]

    # 結果を保持する配列
    bests = [True for i in range(n)]

    # 処理開始
    for bridge in bridges:

        bridge[0] -= 1
        bridge[1] -= 1

        if heights[bridge[0]] > heights[bridge[1]]:
            bests[bridge[1]] = False
        elif heights[bridge[0]] < heights[bridge[1]]:
            bests[bridge[0]] = False
        else:
            bests[bridge[1]] = False
            bests[bridge[0]] = False

    print(bests.count(True))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 3
1 2 3 4
1 3
2 3
2 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 102216
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main(){
  int n, m;
  cin>>n>>m;
  int a[n];
  for(int i=0; i<n; ++i) cin>>a[i];
  
  int x = n / gcd(n, m); //lcm/m -> n*m/gcd/m -> n/gcd
  int sum = 0;
  for(int i=0, cnt=0; i<x; ++i){
    int ma = 0, mi = 1e9;
    for(int j=0; j<m; ++j, ++cnt){
      if(cnt == n) cnt=0;
      ma = max(ma, a[cnt]);
      mi = min(mi, a[cnt]);
    }
    sum += ma - mi;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3108
#include<iostream>
#include<cmath>

using namespace std;

int main(){
 int n,d;
  cin >> n >> d;
  int x[n][d];
  
 for(int i=0;i<n;i++){
   for(int j=0;j<d;j++){
     cin >> x[i][j];
   }
 }
  int res=0;
  
  for(int i=0;i<n-1;i++){
   for(int j=i;j<n;j++){
     int dis=0;
     
     for(int k=0;k<d;k++) dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
     
     for(int l=1;l*l<=dis;l++){
      if(l*l==dis) res++; 
     }
   
   }
 }
  
  cout << res << endl;


}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n;
	vector<int>x(9); x[0] = 1; rep(i, 8) { x[i + 1] = x[i] * 2; }
	rep(i, 9) {
		if (n >= x[i] && n < x[i + 1]) {
			cout << x[i] << endl; return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
def main():
  w,a,b = list(map(int,input().split()))
  if (a+w)<=b or b+w<=a:
    if abs(a+w-b)<=abs(b+w-a):
      print(abs(a+w-b))
    else:
      print(abs(b+w-a))
  else:
    print(0)
main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long inf = 1000000007;

int main() {
    string s;
    cin >> s;
    bool ans = true;

    for (int i = 0; i < s.size() / 2; i++) {
        if (s.at(i) != s.at(s.size()-1 - i)) {
            ans = false;
            break;
        }
        if (s.at(i) != s.at((s.size()-1)/2-1-i) ){
            ans = false;
            break;
        }
        if (s.at(s.size()-1 - i) != s.at((s.size()+3)/2-1 + i)) {
            ans = false;
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


    


Measured memory_bytes: 256
a=int(input())
ans=[[0 for i in range(a-j-1)]for j in range(a-1)]

for i in range(a):
  for j in range(i+1,a):
    k=str(bin(i^j))
    l=len(k)
    for s in range(l):
      if k[-1-s]=="1":
        ans[i][j-i-1]=s+1
        break
        

for i in range(a-1):
  print(*ans[i])


Measured memory_bytes: 4976
#include"iostream"
#include"cstdio"

#define MAXN
using namespace std;

int N;
int s[100];

int main()
{
	cin >> N;
	if(N == 0)
	{
		putchar('0');
		return 0;
	}
	int p = 0;
	while(N)
	{
		int t = N % (-2);
		N /= -2;
		if(t < 0)
		{
			s[++p] = t + 2;
			N++;
		}
		else
			s[++p] = t;
	}
	for(int i = p; i >= 1; i--)
		cout << s[i];
	return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, m;
  cin >> n >> m;
  // if (m % n == 0) {
  //   cout << m / n << endl;
  //   return;
  // }
  vector<int> dv;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      dv.push_back(i);
      if (i * i != m) {
        dv.push_back(m / i);
      }
    }
  }
  sort(dv.begin(), dv.end(), greater<int>());
  dump(dv);
  int ans = 0;
  rep(i, dv.size()) {
    if (m / n >= dv[i]) {
      ans = dv[i];
      break;
    }
  }
  dump(ans);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N;
  cin >> N;
  
  long long int A;
  cin >> A;
  
  long long int B;
  cin >> B;
  
  if(N%(A+B)<=A) {
    cout << N/(A+B)*A+N%(A+B) <<endl;}
  
  else {
    cout << N/(A+B)*A+A << endl;}
  }


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

using namespace std;


vector<int> graph[200000];
vector<int> counter(200000, 0);
vector<int> ans(200000, 0);
void dfs (int n, int c) {
  ans[n] = c+counter[n];
  for (auto t : graph[n]) {
    dfs(t, ans[n]);
  }
}
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  int N,Q; cin>>N>>Q;
  for (int i = 0; i < N-1; i++) {
    int a,b; cin>>a>>b;
    a--,b--;
    graph[a].push_back(b);
  }
  for (int i = 0; i < Q; i++) {
    int p,x; cin>>p>>x;
    p--;
    counter[p] += x;
  }
  set<int> in;
  for (int i = 0; i < N; i++)
    in.insert(i);
  for (int i = 0; i < N; i++) {
    for (auto ee : graph[i]) {
      in.erase(ee);
    }
  }
  for (int i = 0; i < N; i++) {
    if (in.count(i)==0)
      continue;
    dfs(i, 0);
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 30592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

struct ST {
  ll index;
  ll value;
};

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<ll> B(N);
  iota(begin(B), end(B), 0);

  vector<ST> sts(N);
  for (ll i = 0; i < N; i++) {
    sts[i].index = B[i];
    sts[i].value = A[i];
  }

  sort(begin(sts), end(sts), [](auto x, auto y) { return x.value > y.value; });

  for (ll i = 0; i < N; i++) {
    ll print = 0;
    if (sts[0].index != i) {
      print = sts[0].value;
    } else {
      print = sts[1].value;
    }
    cout << print << endl;
  }

  return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

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

	double A, B, C, D, E, F, X, Y;
	while (cin >> A >> B >> C >> D >> E >> F) {
		X = (C * E - B * F) / (A * E - B * D);
		Y = (A * F - C * D) / (A * E - B * D);
		if (X == -0) X = 0.0;
		if (Y == -0) Y = 0.0;

		cout << fixed << setprecision(3) << X << " " << Y << "\n";
	}
	return 0;
}

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

int n, k, a[sz];

ll fnc(int x) {
   ll ans = 0;
   for(int i=0; i<n; i++) {
      ans += a[i] / x;
      if(a[i] % x == 0) ans--;
   }
   return ans;
}

int main() {
   cin >> n >> k;
   for(int i=0; i<n; i++) scanf("%d", &a[i]);

   int lo =  1, hi = 1e9;
   while(lo < hi) {
      int md = lo + hi >> 1;
      if(fnc(md) <= k) hi = md;
      else lo = md + 1;
   }
   cout << lo << endl;
}


Measured memory_bytes: 4392
n = int(input())
num_list = [int(i) for i in input().split()]
if len(num_list)==1:
  print(1)
else:
  res = 1
  flag = None
  pre = num_list[0]
  for i in num_list[1:]:
    if pre > i and not flag:
      flag = 'down'
  
    elif pre < i and not flag:
      flag = 'up'
      
    elif (pre > i and flag=='up') or (pre < i and flag=='down'):
      res += 1
      flag = None
    pre = i
  print(res)

Measured memory_bytes: 14252
sS = input().rstrip()
iL = len(sS)
for i in range(iL-1):
    if sS[i] == sS[i+1] :
        print(i+1,i+2)
        exit()
for i in range(iL-2):
    if sS[i] == sS[i+2] :
        print(i+1,i+3)
        exit()
print("-1 -1")


Measured memory_bytes: 3188
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  while(b <= a){
    if(k == 0){
      cout << "No" << endl;
      return 0;
    }
    k--;
    b *= 2;
  }

  while(c <= b){
    if(k == 0){
      cout << "No" << endl;
      return 0;
    }
    k--;
    c *= 2;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3628
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const ll INF=1e9;

int main(){
  int h,w;
  cin>>h>>w;
  
  ll d[10][10];
  ll x;
  rep(i,10){
    rep(j,10){
      cin>>x;
      d[i][j]=x;
    }
  }
  
  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
  }
  
  vector<ll> A(10,0);
  ll y;
  rep(i,h){
    rep(i,w){
      cin>>y;
      if(y!=-1) A[y]++;
    }
  }
  
  ll ans=0;
  rep(i,10) ans+=A[i]*d[i][1];
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)

string s;
set<string> ss;

int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL

	cin >> s;
	int k;
	cin >> k;

	int len = s.size();
	for (int i = 0; i < len; ++i) {
		for (int l = 1; l <= 5; ++l) {
			if (i + l - 1 >= len) continue;
			ss.insert(s.substr(i, l));
		}
	}
	set<string>::iterator it = ss.begin();
	for (int i = 1; it != ss.end() && i < k; ++i, ++it) {
		// prln(*it);
	}
	cout << *it << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll k,a,b;
  cin >> k >> a >> b;
  for(ll i=a;i<=b;i++) {
    if(i%k==0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vt<int> C(n), B(m);
  vvi A(n,vt<int>(m));
  rep(i,n){
    cin >> C[i];
    rep(j,m){
      cin >> A[i][j];
    }
  }

  int ans = 1e9;

  for(int bit = 0; bit < (1 << n); bit++){
    bool f = true;
    int money = 0;

    for(int i = 0; i < n; i++){
      if(bit & (1 << i)){
        money += C[i];
        rep(j,m)
          B[j] += A[i][j];
      }
    }

    rep(i,m){
      if(B[i] < x)
        f = false;
    }

    if(f && money < ans)
      ans = money;
    rep(i,m)
      B[i] = 0;
  }

  if(ans == 1e9)
    ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <ctime>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=3010, Mod=998244353;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
signed main()
{
	int n=read();
	int res=1; int pp=1e18;
	for(ri int i=1;i<=n;i++)
	{
		int x=read();
		if(!x) {puts("0"); return 0; }
		if(res>pp/x) res=-1;
		if(res!=-1) res=res*x;
		if(res>pp) res=-1;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3732
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}

template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define complex complex228

int f(int n) {
	if (n == 0) return 1;
	return f(n - 1) * n;
}

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	if (a + b - 1 > n) {
		cout << -1 << '\n';
		return 0;
	}
	--a;
	vector<int> ans;
	vector< vector<int> > block(n + 1);
	int mxblock = 0;
	for (int i = 1; i <= n - b; ++i) {
		block[(i - 1) / a].push_back(i);
		mxblock = (i - 1) / a;
	}
	for (int i = mxblock; i >= 0; --i) {
		for (int x : block[i]) ans.push_back(x);
	}
	if (mxblock + 1 > b) {
		cout << -1 << '\n';
		return 0;
	}
	for (int i = n; i > n - b; --i) ans.push_back(i);
	for (int i : ans) cout << i << " ";
	cout << endl;
    return 0;
} // kek










/*3 3 2

3 3 2
3 3 2
2 3 3
2 3 3
*/








Measured memory_bytes: 17900
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n, ga, sa, ba, gb, sb, bb;
  cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
  ll ans = 0;
  REP(i, n/ga+1) {
    ll d = n - i * ga;
    REP(j, d/sa+1) {
      ll bmax = (d - j*sa) / ba;
      ans = max(ans, n + i * (gb - ga) + j * (sb - sa));
      ans = max(ans, n + i * (gb - ga) + j * (sb - sa) + bmax * (bb - ba));
    }
  }
  if(n == ans) {
    REP(i, n/gb+1) {
      ll d = n - i * gb;
      REP(j, d/sb+1) {
        ll bmax = (d - j*sb) / bb;
        ans = max(ans, n + i * (ga - gb) + j * (sa - sb));
        ans = max(ans, n + i * (ga - gb) + j * (sa - sb) + bmax * (ba - bb));
      }
    }
    cout << ans << endl;
    return 0;
  }
  n = ans;
  if(gb >= ga) {
    REP(i, n/sb+1) {
      ll bmax = (n - i*sb) / bb;
      ans = max(ans, n + i * (sa - sb));
      ans = max(ans, n + i * (sa - sb) + bmax * (ba - bb));
    }
  }
  else if(sb >= sa) {
    REP(i, n/gb+1) {
      ll bmax = (n - i*gb) / bb;
      ans = max(ans, n + i * (ga - gb));
      ans = max(ans, n + i * (ga - gb) + bmax * (ba - bb));
    }
  }
  else if(bb >= ba) {
    REP(i, n/gb+1) {
      ll smax = (n - i*gb) / sb;
      ans = max(ans, n + i * (ga - gb));
      ans = max(ans, n + i * (ga - gb) + smax * (sa - sb));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
int mod = 1e9+7;
int add(int a,int b){
	return ((a%mod)+(b%mod))%mod;
}
int mul(int a,int b){
	return ((a%mod)*(b%mod))%mod;
}
int power(int a,int b){
	int res = 1;
	while(b>0){
		if(b&1)
			res = mul(res,a);
		b = b/2;
		a = mul(a,a);
	}
	return res;
}
int divi(int a,int b){
	return mul(a,power(b,mod-2));
}
signed main()
{
    fast;
	int n;
	cin>>n;
	int a[n+1];
	map<int,int> mp;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		map<int,int> tmp;
		int x = a[i];
		for(int j=2;j*j<=x;j++){
			while(x%j == 0){
				x = x/j;
				tmp[j]++;
				mp[j] = max(mp[j],tmp[j]);
			}
		}
		if(x>1)
			tmp[x]++;
		mp[x] = max(mp[x],tmp[x]);
	}
	int lcm = 1;
	for(auto it:mp){
		lcm = mul(lcm,power(it.first,it.second));
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans = add(ans,divi(lcm,a[i]));
	}
	cout<<ans;
}   


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int N;

int main() {
  cin >> N;
  int A[N];
  rep(i, N) {
    cin >> A[i];
  }
  
  bool can = true;
  rep(i, N) {
    if (A[i] %2 ==0) {
      if(A[i] %3 != 0 && A[i]%5 != 0) {
        can = false;
        break;
      }
    }
  }
    
  if(can) cout <<"APPROVED";
  else cout << "DENIED";
}


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

#define N_MAX 100
#define C_MAX 100
#define R_MAX 100

int p[N_MAX+1];
int m[R_MAX+1][C_MAX+1];


int chain_multiplication(int n)
{
    for (int i = 0; i < n; i++) {
        m[i][i] = 0;
    }
    for (int l = 1; l < n; l++) {
        for (int i = 0; i < n - l; i++) {
            int j = i + l;
            m[i][j] = 100000000;
            for ( int k = i ; k < j; k++) {
                int a = m[i][k] + m[k+1][j] + p[i] * p[k+1] * p[j+1];
//                printf("i %d k %d j %d a %d min %d\n", i, k, j, a, m[i][j]);
                if (m[i][j] > a) {
                    m[i][j] = a;
                }
            }
//            printf("m[%d][%d] = %d\n", i, j, m[i][j]);
        }
    }
    return m[0][n-1];
}

int main() {
    int n;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> p[i];
        cin >> p[i+1];
    }
    cout << chain_multiplication(n) << endl;
        
    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using lint=boost::multiprecision::cpp_int;
int main(){
    string s;
    cin>>s;
    lint n(s);
    if(n%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){
  
  int A,B;
    
  cin >> A >> B;
    
  if(B%A == 0){
    cout << B+A << endl;
  }else{
  	cout << B-A << endl;
  }


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)
//string 変数　　変数.size()で数字化

int main(void)
{
	string test;
	cin >> test;
	for (int i = 0; i < test.size(); i++) {
		if (test[i] == 'B') {
			for (int j = i; j != 0; j--) {
				if (test[j-1] == '0' || test[j-1] == '1') {
					test[j-1] = '3';
					break;
				}
			}
		}
	}

	for (int i = 0; i < test.size(); i++) {
		if (test[i] == '1')
			cout << 1;
		if (test[i] == '0')
			cout << 0;
	}
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int N;
vector<int> v;

int dp[15][100050]; //金額iを作るための最小コスト
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;

    v.push_back(1);
    int t1 = 6;
    while(t1 < 100000){
        v.push_back(t1);
        t1 *= 6;
    }
    int t2 = 9;
    while(t2 < 100000){
        v.push_back(t2);
        t2 *= 9;
    }
    sort(v.begin(), v.end());

    REP(i,0,v.size()+1){
        REP(j,0,100010){
            if(i > 0) dp[i][j] = j;
            else dp[i][j] = INF;

            if(j == 0) dp[i][j] = 0;
        }
    }

    REP(i,1,v.size()+1){
        REP(j,1,100010){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j - v[i-1] >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j - v[i-1]] + 1);
                dp[i][j] = min(dp[i][j], dp[i][j - v[i-1]] + 1);
            }
        }
    }


    cout<<dp[v.size()][N]<<endl;

    return 0;
}


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

vector<int>vec,ans;

int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) {
        int x;cin>>x;
        vec.push_back(x);
    }
    cout<<endl;
    for(int i=1;i<=n;i++){
        bool flag=0;
        for(int j=(int)vec.size()-1;j>=0;j--){
            if(vec[j]==j+1){
                ans.push_back(j+1),vec.erase(vec.begin()+j);
                flag=1;
                break;

            }

        }
        if(!flag) {cout<<-1<<endl;return 0;}
    }
    reverse(ans.begin(),ans.end());
    for(auto x:ans) cout<<x<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

bool path;
queue<int> q;
bool bfs(int from, int to, vector<bool> &passed,vvi &g,int bef){
    if(path)return true;
    int pos=q.front();q.pop();
    // cout<<pos<<" "<<bef<<endl;

    if(passed[pos]){
        return false;
    }
    passed[pos]=true;

    for(int i=0;i<g[pos].size();i++){
        if(pos==from&&g[pos][i]==to)continue;
        // cout<<"from:"<<from<<" "<<"to:"<<to<<" "<<"pos:"<<pos<<" "<<"i:"<<i<<endl;
        if(g[pos][i]==to&&pos!=from){
            path=true;
            return true;
        }
        q.push(g[pos][i]);
        bfs(from,to,passed,g,pos);
    }
    if(path)return true;

    return false;
}

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

    int n,m;
    cin>>n>>m;
    int A,B;
    vi a(m),b(m);

    vvi g(n);
    
    rep(i,m){
        cin>>A>>B;
        a[i]=A-1;
        b[i]=B-1;
        g[A-1].push_back(B-1);
        g[B-1].push_back(A-1);
    }
    int ans=0;
    for(int i=0;i<m;i++){
        // cout<<"main:"<<i<<endl;
        vector<bool> passed(n,false);
        path=false;
        while(!q.empty())q.pop();
        q.push(a[i]);
        if(bfs(a[i],b[i],passed,g,a[i]))ans++;
        // cout<<"ans:"<<ans<<endl;
    }

    fin(m-ans);

    

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    v = list(map(int, input().rstrip('\n').split()))
    v.sort()
    t = v[0]
    for i in range(1, n):
        t = (t + v[i]) / 2
    print(t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
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 anser = 0;
      	int count = 1;
      	
        while (count < B) {
            count = count + A - 1;
          	anser++;
        }
      	System.out.println(anser);
	}
}

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

int main(){
  string S;cin>>S;
  bool ans=true;
  if(S.at(2)!=S.at(3)) ans=false;
  if(S.at(4)!=S.at(5)) ans=false;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int sum_keta(int n){
  if(n==0) return 0;
  return n%10 + sum_keta(n/10);
}
int main(void){
  int N,D,X; cin >> N >> D >> X;
  
  int sum = 0;
  for(int i=0;i<N;i++){
  	int A;
    cin >> A;
    int day = 1;
    while(day <= D){
      sum++;
      day += A;      
    }
  }
  cout << X + sum << endl;
}

Measured memory_bytes: 256
/* Author : Pranav Deshmukh
            PICT,Pune
   Stay Focused!
*/

#include<bits/stdc++.h>
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define float           double
#define ms(s, n) 		memset(s, n, sizeof(s))
#define dip(type,var)   type var; cin>>var;
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)      int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)
#define mka(type,arr,n) type *arr=new type[n];
#define fo(i,n)         for(int i=0;i<n;i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define endl            "\n"
#define f               first
#define s               second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	int count = 0;
	dipi(n);
	mka(int, arr, n);
	fo(i, n) {
		cin >> arr[i];
	}
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (arr[i] + arr[j] > arr[k] && arr[j] + arr[k] > arr[i] && arr[i] + arr[k] > arr[j] && arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k]) {
					count++;
				}
			}
		}
	}
	cout << count << endl;
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}


Measured memory_bytes: 3808
using System;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            //入力された数字をcharにし、一文字ずつ格納
            char[] aryData = Console.ReadLine().ToCharArray();

            //終了条件
            if (aryData[0] == '0')
            {
                break;
            }

            int sum = 0;

            foreach (char c in aryData)
            {
                sum += int.Parse(c.ToString());
            }

            Console.WriteLine(sum);
        }

    }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  map<int,int>m;
  int c=0;
  for(int i=0;i<N;i++){
    if(a[i]<400)m[0]++;
    else if(a[i]<800)m[1]++;
    else if(a[i]<1200)m[2]++;
    else if(a[i]<1600)m[3]++;
    else if(a[i]<2000)m[4]++;
    else if(a[i]<2400)m[5]++;
    else if(a[i]<2800)m[6]++;
    else if(a[i]<3200)m[7]++;
    else c++;
  }
  int Min=m.size();
  int Max=Min+c;
  if(Min==0&c>0)Min=1;
  cout<<Min<<" "<<Max<<endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
 
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)

Measured memory_bytes: 3188