akhauriyash/Code-Regression huggingface dataset:
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

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

    int a, sum=0;
    pair<int,int>  v[n];
    forn(i, n)
    {
        cin>>a;
        v[i].ff=a;
    }
    forn(i, n)
    {
        cin>>a;
        v[i].ss=a;
    }

    forn(i, n)
    {
        if(v[i].ff>v[i].ss)
            sum+=v[i].ff-v[i].ss;
    }
    cout << sum << "\n";

    return 0;
}





Measured memory_bytes: 3596
n, k, s = map(int, input().split())
if n <= s:
    m = n - k + 1
    li = [s // m if i != m - 1 else s // m + s % m for i in range(m)]
    for i in range(n):
        if i != n - 1: print(li[i % m], end=' ')
        else: print(li[i % m])
else:
    for i in range(n):
        if i < k: print(s, end=' ')
        elif k <= i < n - 1: print(s + 1, end=' ')
        else: print(s + 1)

Measured memory_bytes: 7784
#include<stdio.h>
#include<string.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x;
  x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  if(a>b){
    return b;
  }
  else if(b>=a){
    return a;
  }
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11888
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e17
int va=10e8+7;
ll int dp[100004]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
    //cin>>t;
    while(t--){
//        ll n,x,t;
//        cin>>n>>x>>t;
//        ll ans=ceil((double)n/x);
//        ans*=t;
//        cout<<ans<<endl;
        ll sum{0};
        char ch;
        while(scanf("%c",&ch)){ 
            if(ch=='\n') break;
            sum+=(ch-'0');
        }
        if(sum%9==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
 return 0;
}

Measured memory_bytes: 3704
#[allow(dead_code)]
fn main() {
    let mut aa=i::i();
    let mut bb=i::i();
    let mut sou=0;
    let mut kai:f64=((bb-1)as f64)/((aa-1)as f64);
    println!("{}",kai.ceil());
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
from collections import Counter
import itertools
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]


m0 = Counter()
c0 = 0
m1 = Counter()
c1 = 0
m2 = Counter()
c2 = 0
for i in range(N):
    for j in range(N):
        if ((i+1)+(j+1)) % 3 == 0:
            m0[c[i][j]] += 1
            c0 += 1
        elif ((i+1)+(j+1)) % 3 == 1:
            m1[c[i][j]] += 1
            c1 += 1
        else:
            m2[c[i][j]] += 1
            c2 += 1

m = [m0, m1, m2]
cnt = [c0, c1, c2]

ans = float('inf')
for perm in itertools.permutations([i for i in range(1, C+1)], 3):
    tmp = 0
    for i in range(3):
        for k, v in m[i].items():
            if k != perm[i]:
                tmp += D[k-1][perm[i]-1] * v
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 45276
N,T=map(int,input().split())
k,s=map(int,input().split())
for i in range(1,N):
    c,t=map(int,input().split())
    if t<=T and c<k:
        k,s=c,t 
if s>T:
    print('TLE')
else:
    print(k)
    

Measured memory_bytes: 2940
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	VI A(N + 1, 0);
	REP(i, N) cin >> A[i + 1];

	VI B(N + 1, 0);
	for(int i = N; 0 < i;  i--){
		int j = N / i;
		int k = 0;
		while(0 < j){
			k ^= B[i * j];
			j--;
		}
		B[i] = k ^ A[i];
	}

	int ret = 0;
	FOR(i, 1, N + 1) ret += B[i] == 1;

	cout << ret << endl;
	FOR(i, 1, N + 1) if(B[i]) cout << i << " ";
	cout << endl;


	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main() {
	int h, w, i, j;
	while (1) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			break;
		}
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if (a > b) swap(a, b);
    cout << max(0, b-(a+W)) << endl;
    return 0;
}


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

int main() {
  int A,B,C,X,Y;
  cin >> A>>B>>C>>X>>Y;
  int sum=0;
  if(A+B>2*C){
    int m = min(X,Y);
    sum += m*C*2;
    int res = max(X,Y) - m;
    if(X>Y){
      if(A>C*2) sum += res*C*2;
      else sum += res*A;
    }
    else{
      if(B>C*2) sum += res*C*2;
      else sum += res*B;
    }
  }
  else{
    sum += A*X+B*Y;
  }
cout << sum << endl;
}


Measured memory_bytes: 256
import collections
import itertools
N, M = list(map(int, input().split()))
ABs = [list(map(int, input().split())) for _ in range(M)]

loads = [[] for _ in range(N+1)]

for AB in ABs:
    loads[AB[0]].append(AB[1])
    loads[AB[1]].append(AB[0])


dq = collections.deque()

dq.append(1)
ans_list = [0 for _ in range(N+1)]

#print(loads)
print("Yes")
while len(dq) != 0:
    i = dq.popleft()

    for vec in loads[i]:
#        print(vec)
        if(ans_list[vec] == 0):
            ans_list[vec] = i
            dq.append(vec)
#        print(ans_list)
#        print(dq)


for ans in ans_list[2:]:
    print(ans) 



Measured memory_bytes: 129676
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;

my $limit;
{
    my $line_1st = <STDIN>;
    $limit = (split(/\s+/, $line_1st))[1];
}

my @humans;
{
    my $line_2nd = <STDIN>;
    @humans = split(/\s+/, $line_2nd);
}

my $result = 0;
for (@humans){
    $result++ if $_ >= $limit;
}
say $result;


Measured memory_bytes: 16876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<ll> asum(N + 1);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        asum[i + 1] = asum[i] + a;
    }

    vector<vector<ll>> dp(N + 3, vector<ll>(N + 3, 1e15));
    vector<vector<int>> p(N + 3, vector<int>(N + 3));
    for (int i = 1; i <= N; ++i) {
        for (int l = 0; l <= N - i; ++l) {
            int r = l + i;
            if (r - l < 2) {
                dp[l][r] = 0;
                p[l][r] = l;
                continue;
            }
            ll sum = asum[r] - asum[l];
            for (int mid = p[l][r - 1]; mid <= p[l + 1][r]; ++mid) {
                ll tmp = dp[l][mid] + dp[mid][r] + sum;
                if (dp[l][r] > tmp) {
                    dp[l][r] = tmp;
                    p[l][r] = mid;
                }
            }
        }
    }

    cout << dp[0][N] << endl;

    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
#define mod2 20071027
#define mod 1000074259
#define base 139
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define tc(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=500010;
string s;
ll len, res,pro[N],pre;
int main()
{
    cin>>s;
    ll  f=-1, now=0, sz=s.length();
    for(int i=0;i<sz;i++)
    {
        if(s[i]=='>')
        {
            if(f==0)
            {
                pre=i;
                len=0;
            }
            f=1;
        }
        else
        {
            if(f==1)
            {
                pro[pre]=len;
                len=0;
            }
            f=0;
        }
        len++;
    }
    if(f==1)
        pro[pre]=len;
    pre=0;
    ll k=0;
    for(int i=0;i<sz;i++)
    {
        if(pro[i]>0)
        {
            k=pro[i];
            now=k;
        }
        if(k>0)
        {
            if(k==pro[i])
            {
                if(now>pre)
                res+=(now-pre);
            }
            else
            {
                res+=now;
            }
            pre=now;
            now--;
            k--;
        }
        else
        {
            if(k==0)
            {
                k=-1;
                now=1;
            }
            res+=now;
            pre=now;
            now++;
        }
    }
    cout<<res<<endl;

    return 0;
}
/*

*/


Measured memory_bytes: 4740
a,b,c,d = map(int,input())

if a+b+c+d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
elif a+b+c-d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a+b-c+d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a+b-c-d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c-d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
elif a-b-c+d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
elif a-b+c-d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
elif a-b+c+d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int inf = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,n;
	cin >> n;
	int ki = 1;
	for(int i=0;i<n;i++){
		cin >> a;
		if(a&1==1){

		}else{
			ki *= 2;
		}
	}
	cout << pow(3,n) - ki << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		
		int N = readInt(), candy[][] = new int[N+1][3], DP[][] = new int[N+1][3];
		for(int j = 1; j<=2; j++) for(int i = 1; i<=N; i++) candy[i][j] = readInt();
		for(int j = 1; j<=2; j++) for(int i = 1; i<=N; i++) DP[i][j] = Math.max(DP[i-1][j], DP[i][j-1]) + candy[i][j];
		println(DP[N][2]);
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBool() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readChar() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


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

int main(){
    int w,h,c;
    cin>>w>>h>>c;

    int ans=1;

    for(int i=1000;i>0;i--){
        if(w%i==0 && h%i==0){
            ans=i;
            break;
        }
    }

    ans = (w/ans)*(h/ans)*c;
        
    cout<<ans<<endl;   
    return 0;
}



Measured memory_bytes: 3104
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int N;
	int P[210000];
	int ind[210000] = {};
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> P[i];
		P[i]--;
		ind[P[i]] = i;
	}
	
	int ans = 0;
	int cnt = 1;
	for(int i = 0; i < N; i++){
		if(ind[i] < ind[i + 1]){
			cnt++;
		}else{
			ans = max(cnt, ans);
			cnt = 1;
		}
	}
	
	cout << N - ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
int main()
{
ll h , w ;
cin >> h >> w ;
vector<vector<ll>> v(h, vector<ll>(w,0) );
rep(i,h)rep(j,w){
  ll a ;
  cin >> a ;
  v[i][j]=a;
}
rep(i,h)rep(j,w){
  ll a ;
  cin >> a ;
  v[i][j]=abs(a-v[i][j]);
}
vector<vector<bitset<13000>>> dp(h, vector<bitset<13000>>(w) );

dp[0][0][v[0][0]]=1;
rep(i,h)rep(j,w){
  rep(k,13000){
    if(i-1>=0&&dp[i-1][j][k]){
      if(abs(k-v[i][j])<13000)dp[i][j][abs(k-v[i][j])]=1;
      if(k+v[i][j]<13000)dp[i][j][k+v[i][j]]=1;
    }
    if(j-1>=0&&dp[i][j-1][k]){
      if(abs(k-v[i][j])<13000)dp[i][j][abs(k-v[i][j])]=1;
      if(k+v[i][j]<13000)dp[i][j][k+v[i][j]]=1;
    }
  }
}
rep(i,13000){
  if(dp[h-1][w-1][i]){ans=i;break;}
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 12676
#include <iostream>
#include <vector>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

int main(int argc, const char * argv[]) {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> vec(10, vector<int>(10, 0));
  rep(i, 10){
    rep(j, 10){
      cin >> vec[i][j];
    }
  }
  rep(k, 10){
    rep(i, 10){
      rep(j, 10){
        vec[i][j] = min(vec[i][j], vec[i][k] + vec[k][j]);
      }
    }
  }

  int ans = 0;
  rep(i, h){
    rep(j, w){
      int num;
      cin >> num;
      if(num != -1){
        ans += vec[num][1];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;

int D;
int C[26];
int A[365][26];
int con[365];
set<int>st[26];
int score(){
	vector<int>last(26,-1);
	int res=0;
	rep(i,D){
		last[con[i]]=i;
		res+=A[i][con[i]];
		rep(j,26){
			res-=C[j]*(i-last[j]);
		}
	}
	return res;
}
int change(int x,int y){
	int res=A[x][y]-A[x][con[x]];
	auto pre_old=--st[con[x]].lower_bound(x);
	auto next_old=st[con[x]].upper_bound(x);
	res+=(*next_old-x-1)*(*next_old-x)/2*C[con[x]];
	res-=(x-*pre_old+*next_old-*pre_old-1)*(*next_old-x)/2*C[con[x]];
	auto pre_new=--st[y].lower_bound(x);
	auto next_new=st[y].lower_bound(x);
	res+=(x-*pre_new+*next_new-*pre_new-1)*(*next_new-x)/2*C[y];
	res-=(*next_new-x-1)*(*next_new-x)/2*C[y];
	return res;
}
double rand_double(){
	return (double)rand()/RAND_MAX;
}
signed main(){
	cin>>D;
	rep(i,26){
		cin>>C[i];
		st[i].insert(-1);st[i].insert(D);
	}
	vector<int>last(26,-1);
	rep(i,D){
		int mx=-mod,idx;
		rep(j,26){
			cin>>A[i][j];
			if(chmax(mx,A[i][j]+C[j]*(i-last[j])))idx=j;
		}
		con[i]=idx;st[idx].insert(i);
       last[idx]=i;
	}
	int score_=score();
	cerr<<score_<<endl;
	double C=1970*100;
	int cnt=0;
	while(1000.*clock()/CLOCKS_PER_SEC<=1970){
		int x=rand()%D,y;
		do{
			y=rand()%26;
		}while(con[x]==y);
		int diff=change(x,y);
		double ti=1970-1000.*clock()/CLOCKS_PER_SEC;
		double rem=ti/1970.;
		if(diff>=0||ti/C>rand_double()&&diff>=-10000.*rem){
			score_+=diff;
			st[con[x]].erase(x);
			con[x]=y;
			st[y].insert(x);
		}
		cnt++;
		if(cnt%100000==0)cerr<<score_<<endl;
	}
	rep(i,D)cout<<con[i]+1<<"\n";
	cerr<<score_<<endl;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string>
using namespace std;

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

    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());

    int i = 0;
    bool flag = false;
    while(s[i] != '\0'){
        if(s[i] == t[0] || s[i] == '?'){
            int j = 0;
            int k = i;
            int cnt = 0;
            while(true){
                if(s[k] == t[j] || s[k] == '?'){
                    cnt++;
                    if(cnt == t.size()){
                        break;
                    }
                    //cout << "cnt:" << cnt << endl;
                }
                else{
                    break;
                }
                j++;
                k++;
            }
            if(cnt == t.size()){
                int l = 0;
                flag = true;
                while(t[l] != '\0'){
                    s[i] = t[l];
                    i++;
                    l++;
                }
                break;
            }
        }
        i++;
    }

    if(flag){
        int j = 0;
        while(s[j] != '\0'){
            if(s[j] == '?'){
                s[j] = 'a';
            }
            j++;
        }
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    else{
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 998244353
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b , int p ) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return res % p;
}

int modinv( int a , int p )
{
    return (binpow(a,p-2,p)%p);
}
//START OF CODE ->->->->->->->

void solve()
{
    int n,s;
    cin>>n>>s;

    vector<int> a(n);

    rep(i,0,a.size())
    {
        cin>>a[i];
    }

    int dp[n+1][s+1];
    zero(dp);
    dp[0][0] = (binpow(2,n,mod)); 

    rep(i,0,n)
    {
        rep(j,0,s+1)
        {
            dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
            if ( j+a[i] <= s )
            {
                dp[i+1][j+a[i]] = (dp[i][j]*modinv(2,mod))%mod;
            }
        }
    }

    cout<<dp[n][s]<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 73904
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
  static void Main(string[] args){
    int n=int.Parse(Console.ReadLine());
    string[] a=Console.ReadLine().Split(' ');
    int m=Gcd(int.Parse(a[0]),int.Parse(a[1]));
    for(int i=2;i<n;i++){
      m=Gcd(m,int.Parse(a[i]));
    }
    Console.WriteLine(m);
  }
  public static int Gcd(int a, int b) {
    if (a < b)
      return Gcd(b, a);
      while (b != 0) {
      int remainder = a % b;
        a = b;
        b = remainder;
      }
    return a;
  }
}

Measured memory_bytes: 19680
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


mint dp[3010][3010];

int main(){
    ll n,s;
    cin >> n >> s;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    rep(i,3010)rep(j,3010)dp[i][j]=0;
    dp[0][0]=1;
    for(int i=0;i<=n;i++){
        for(int j = 0;j<=s;j++){
            dp[i+1][j]+=dp[i][j]*2;
            if(j-a[i]>=0)dp[i+1][j]+=dp[i][j-a[i]];
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}


Measured memory_bytes: 74440
N, K = map(int, input().split())
X = list(map(int, input().split()))
# print(X)
ans = float("inf")
for left in range(0, N-K+1):

    right = left+K

    minus = 0
    plus = 0

    if X[left] < 0:
        minus = min(minus, X[left])
    if X[right-1] > 0:
        plus = max(plus, X[right-1])

    ans = min(ans, 2*abs(minus)+plus, abs(minus)+2*plus)

print(ans)

Measured memory_bytes: 62576
#include "bits/stdc++.h"
using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	
	int a[n+1];
	for (int i = 1; i <= n; i++)
	cin >> a[i];
	long long int dp[n+1];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	for (int i = 3; i <= n; i ++)
	{
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),dp[i-2] + abs(a[i]-a[i-2]));
		
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/env php
<?php
if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {

	$a = 0;
	$b = 0;
	$c = 0;

  while ($line = fgets(STDIN)) {
    $tokens = explode(' ', $line);
    $a = intval($tokens[0]);
    $b = intval($tokens[1]);
    $c = intval($tokens[2]);
  }

  if ($a <= $c && $c <= $b) {
  	echo("Yes");
  } else {
  	echo("No");
  }
}
?>

Measured memory_bytes: 4856
#include <iostream>
using namespace std;
int main(void){
    int n, m, p;
    while (cin >> n >> m >> p && n) {
        int t = 0, w;
        for (int i = 0; i < n; ++i) {
            int v;
            cin >> v;
            t += v;
            if (i == m - 1) w = v;
        }
        if (w == 0)
            cout << 0 << endl;
        else 
            cout << t * (100 - p) / w << endl;
    }
}

Measured memory_bytes: 1156
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int DESC(const int *a,const int *b){
	return (*b - *a);
}

int main(int argc, char const *argv[])
{
	int n,a[200003],b[200003];
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	qsort(b,n,sizeof(int),DESC);
	for (int i = 0; i < n; ++i)
	{
		if(a[i] == b[0])	printf("%d\n", b[1]);
		else printf("%d\n", b[0]);
	}
	return 0;
}


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

using namespace std;

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

  int N,M,L; cin>>N>>M>>L;
  vector<pair<int, int>> graph[N];
  for (int i = 0; i < M; i++) {
    int a,b,c; cin>>a>>b>>c;
    if (c <= L) {
	  graph[--a].emplace_back(--b, c);
	  graph[b].emplace_back(a, c);
    }
  }
  struct ExpInfo {
    int id;
	int cnt;
    int gas;
    bool operator<(const ExpInfo& x) const {return cnt != x.cnt ? cnt > x.cnt : gas < x.gas;}
  };

  int cnts[N][N];
  for (int s = 0; s < N; s++) {
    vector<ExpInfo> info(N);
	for (int i = 0; i < N; i++) {
	  info[i] = {i, numeric_limits<int>::max(), 0};
	}
	info[s] = {s,0,L};
	priority_queue<ExpInfo> qs;
	qs.push(info[s]);
	while (not qs.empty()) {
	  auto q = qs.top(); qs.pop();
	  if (q < info[q.id])
		continue;
	  for (auto &path : graph[q.id]) {
		auto c = info[q.id];
		if (c.gas < path.second) {
		  c.cnt++;
		  c.gas = L;
		}
		c.gas -= path.second;
		if (info[path.first] < c) {
		  info[path.first] = c;
		  info[path.first].id = path.first;
		  qs.push(info[path.first]);
		}
	  }
	}
	for (int i = 0; i < N; i++) {
	  cnts[s][i] = info[i].cnt;
	}
  }

  int Q; cin>>Q;
  while (Q--) {
    int s,t; cin>>s>>t;
    s--; t--;

    if (cnts[s][t] == numeric_limits<int>::max())
      cout << -1 << endl;
	else
	  cout << cnts[s][t] << endl;
  }

  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  int a[n]; for(int i = 0; i < n + 1; i++) cin >> a[i];
  int b[n]; for(int i = 0; i < n; i++) cin >> b[i];
  unsigned long long int sum = 0;
  for(int i = 0; i < n; i++){
    if(b[i] > a[i]){
      int x = b[i] - a[i];
      sum += a[i];
      a[i] = 0;
      if(x > a[i + 1]){
        sum += a[i + 1];
        a[i + 1] = 0;
      }
      else{
        sum += x;
        a[i + 1] -= x;
      }
    }
    else{
      sum += b[i];
      a[i] -= b[i];
    }
  }
  cout << sum << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1024
s=input()
n1=int(s[0:2])
n2=int(s[2:4])
if 0<n1<13:
    if 0<n2<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 0<n2<13:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int i,N;
    double M;
    double proarr[1000];
    scanf("%d %lf",&N,&M);
    for(i=0;i<N;i++){
        scanf("%lf",&proarr[i]);
    }
    double sum=0;
    for(i=0;i<N;i++){
        sum += proarr[i];
    }
    int count = 0;
    for (i=0;i<N;i++){
        if(proarr[i]>=sum/4/M){
            count ++;
        }
        if(count==M){
            break;
        }
    }
    if(count==M){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int n;
	int ans = 0;
	string c;
	int h[2][103] = { 0 };
	int ll = 0; int rr = 0;
	while (1) {
		cin >> n;
		if (n == 0)break;
		int kk=0;
		for (int i = 1; i <= n; i++) {
			cin >> c;
			if (c == "ru" ) {
				rr=1;
			}
			if (c == "rd") {
				rr = 0;
			}
			if (c == "lu") {
				ll = 1;
			}
			if (c == "ld") {
				ll = 0;
			}
			h[0][i] = ll;
			h[1][i] = rr;

		}
		for (int i = 2; i <= n; i++) {
			if (h[0][i - 2] == 0 && h[1][i - 2] == 0 && h[0][i] == 1 && h[1][i] == 1)ans++;

			if (h[0][i - 2] == 1 && h[1][i - 2] == 1 && h[0][i] == 0 && h[1][i] == 0)ans++;
		}

		cout << ans << endl;
		ans = 0; ll = 0; rr = 0;
	}
}


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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
constexpr int MOD = 1e9 + 7;
typedef string::const_iterator State;
int MAX = 1000001;
int R;
int number(State &begin);
string factor(State &begin);
bool fin = false;
void consume(State &begin, char expected) {
    if (fin) begin++;
    if (*begin == expected)
        begin++;
    else {
        begin++;
        // cerr << "expected " << expected << " but got " << *begin << endl;
        // cerr << "rest string is ";
        // while (*begin) {
        //     cerr << *begin++;
        // }
        // cerr << endl;
    }
}
string expression(State &begin) {
    if (fin) return "";
    string ret = factor(begin);
    for (;;) {
        if (ret.size() > R) {
            fin = true;
            return ret;
        }
        if (isdigit(*begin))
            ret += expression(begin);
        else if (isupper(*begin))
            ret += expression(begin);
        else if (*begin == '(')
            ret += expression(begin);
        else
            break;
    }
    return ret;
}
string factor(State &begin) {
    string ret;
    if (fin) return ret;
    int cnt = 1;
    if (*begin == '(') {
        consume(begin, '(');
        ret = expression(begin);
        consume(begin, ')');
        return ret;
    } else if (isdigit(*begin)) {
        cnt = number(begin);
        // begin++;
        // cerr << cnt << endl;
        string res = factor(begin);
        // begin++;
        REP(_, cnt) {
            ret += res;
            if (ret.size() > R) {
                fin = true;
                return ret;
            }
        }
        // ret += factor(begin);
        // cerr << ret << endl;
        return ret;
    } else if (isupper(*begin)) {
        while (isupper(*begin)) {
            ret += *begin;
            begin++;
        }
        // ret += factor(begin);
        return ret;
    } else
        return ret;
}
int number(State &begin) {
    int ret = 0;
    if (fin) return ret;
    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    // cerr << ret << endl;
    return ret;
}

bool solve() {
    string S;
    fin = false;
    int r;
    cin >> S;
    if (S == "0") return false;
    cin >> r;
    R = r;
    // cerr << S << endl;
    State begin = S.begin();
    string res = expression(begin);
    // cerr << res << endl;
    if (r >= res.size())
        cout << '0' << endl;
    else
        cout << res[r] << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 8712
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val s = sc.next
//  val list = List.fill(n + 1)(sc.nextLong)

  val yearRange = 0 to 99
  val monthRange = 1 to 12

  val ans = ((s(0).toString + s(1).toString).toInt, (s(2).toString + s(3).toString).toInt) match {
    case (first, second) if monthRange.contains(first) && monthRange.contains(second) => "AMBIGUOUS"
    case (first, second) if yearRange.contains(first) && monthRange.contains(second) => "YYMM"
    case (first, second) if monthRange.contains(first) && yearRange.contains(second) => "MMYY"
    case _ => "NA"
  }

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

int main(){
  while (1){
    int n;
    cin >> n;
    if(n==0) break;

    vector<string> words(n+1);
    for(int i=1; i<=n; i++){
      cin >> words[i];
    }
    
    for(int i=1; i<n+1; i++){
      bool flag = false;
      int tanka[5]={5,7,5,7,7};
      int now = 0;
      for(int j=0; j+i<n+1; j++){
        int len=words[i+j].length();
        if(tanka[now]-len>=0){
          tanka[now] -= len;
        }else{
          break;
        }
        if(tanka[now]==0){
          now++;
        }
        if(now==5){
          cout << i << endl;
          flag = true;
          break;
        }
      }
      if(flag){
        break;
      }
        
    }
    
  }
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, ans = 0;
  long long h, w, x, y;
  cin >> n >> h >> w;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x >= h && y >= w) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a, b, c string
	var current *[]string

	fmt.Scan(&a, &b, &c)
	as := strings.Split(a, "")
	bs := strings.Split(b, "")
	cs := strings.Split(c, "")

	current = &as
	buf := "a"
	for {
		if len(*current) == 0 {
			break
		}

		switch buf {
		case "a", "":
			buf, as = as[0], as[1:]
		case "b":
			buf, bs = bs[0], bs[1:]
		case "c":
			buf, cs = cs[0], cs[1:]
		}

		switch buf {
		case "a":
			current = &as
		case "b":
			current = &bs
		case "c":
			current = &cs
		}
	}

	fmt.Println(strings.ToUpper(buf))
}


Measured memory_bytes: 640
n = int(input())
a,b = map(int, input().split())
p = list(map(int, input().split()))
A,B,C = 0,0,0
for v in p:
  if v <= a: A += 1
  elif v <= b: B += 1
  else: C += 1
print(min(A,B,C))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> v(n);
    for (int i = 0; i < n; i++)cin >> v[i];

    int ret = 0;
    for (int i = 0; i <= min(limit, n); i++) {
        for (int j = 0; j <= i; j++) {
            vector<int> now;
            for (int k = 0; k < j; k++)now.push_back(v[k]);
            for (int k = 0; k < i - j; k++)now.push_back(v[n - 1 - k]);

            sort(now.begin(), now.end());
            int nowsum = 0;
            for (int k = 0; k < now.size(); k++) {
                if (k < limit - i && now[k] < 0)continue;
                nowsum += now[k];
            }

            ret = max(ret, nowsum);
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main (String[] args){

		Scanner sc = new Scanner(System.in);

		int n= sc.nextInt();
		String stuff= "No";

		for (int i=1; i<=9; i++) {

			if ((n%i)==0 && i<=9){
				if(n/i > 9)
					stuff = "No";
				else
					stuff="Yes";
			}
		}

		System.out.println(stuff);
	}

}

Measured memory_bytes: 23380
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll a,b,c;
  cin>>a>>b>>c;
  ll n=a+b+c;
  set<pll> usd;
  int re=0;
  while(1){
    if(a%2||b%2||c%2) break;
    auto tmp=pll(min({a,b,c}),max({a,b,c}));
    if(usd.count(tmp)){
      cout<<-1<<Endl;
      return 0;
    }
    usd.insert(tmp);
    ++re;
    a=(n-a)/2;
    b=(n-b)/2;
    c=(n-c)/2;
  }
  cout<<re<<endl;
  return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

// vll dp;

// ll solve(int S) {
// 	if(S < 3)
// 		return 0;
// 	else if(S == 3)
// 		return 1LL;

// 	if(dp[S] != -1) return dp[S];

// 	ll count = 1LL;
// 	for(int s = 3; s <= S; ++s) {
// 		count = (count + solve(S - s))%MOD;
// 	}
// 	return dp[S] = count;
// }

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

  ll dp[2005] = {0};// pref[S + 1] = {0};

  dp[3] = dp[4] = dp[5] = 1;
  //pref[3] = 1; pref[4] = 2; pref[5] = 3;

  for(int i = 6; i <= S; ++i) {
  	dp[i] = 1;
  	for(int j = i - 3; j >= 3; --j) {
  		dp[i] = (dp[i] + dp[j])%MOD;
  	}
  }

  cout << dp[S] << endl;
  return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int d, n, ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> d >> n;
    ll dec = (ll)pow(100, d);
    ans = dec * n;
    if (d == 0 && n == 100) ans = 101;
    else if (d == 1 && n == 100) ans = 10100;
    else if (d == 2 && n == 100) ans = 1010000;
    cout << ans << endl;
    return 0;
}


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

int main()
{
	long double x1,x2,y1,y2;
	long double dis = 0.0;

	cin >> x1 >> y1 >> x2 >> y2;

	dis = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));

	cout << fixed << setprecision(7) <<dis << '\n';
}


Measured memory_bytes: 3272
import sys
input = sys.stdin.readline
from bisect import bisect_left

n, res = int(input()), 0
s = sorted(list(map(int, input().split())))
for i in range(n-1):
    for j in range(i+1, n):
        res += (bisect_left(s, s[i] + s[j])) - (j + 1)
print(res)

Measured memory_bytes: 74340
#define MOD 1000000007

#include <iostream>
using namespace std;

long pow(long a, long b) {
	if (b == 0) return 1;
	long c = pow(a, b / 2);
	if (b % 2) c = a * c % MOD * c % MOD;
	else c = c * c % MOD;
	return c;
}

int main() {
	long n, k;
	cin >> n >> k;
	cout << pow(k, n) << endl;
}


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

int main()
{
int A;
int B;
int C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;
	cin >> C;

	if( A + B >= C )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}






Measured memory_bytes: 256
use std::io;

fn read_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .ok();
  line
}

fn main() {
  let line = read_line();

  let v: Vec<i32> = line.trim()
    .split_whitespace()
    .map(|val| { val.parse().unwrap() })
    .collect();
  
  let (a, b, c) = (v[0], v[1], v[2]);

  let ans = if a < b && b < c { "Yes" } else { "No" };

  println!("{}", ans);
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll cnt[110000];

ll f(ll n, ll p, ll m) {
  if(p==0) return 1LL;
  if(p%2==0) {
    ll t = f(n, p/2, m);
    return t%m*t%m;
  }
  return n%m*f(n,p-1,m)%m;
}

int main() {
  ll n, k;
  cin >> n >> k;
  for(ll i = 1; i<=k; i++) {
    ll a = k / i;
    ll m = n;
    cnt[i] = f(a,m,mod);
  }
  for(ll i = k; i>=1; i--) {
    for(ll j = i*2; j<=k; j+=i) cnt[i] -= cnt[j];
  }
  ll ans = 0;
  for(ll i = 1; i<=k; i++) {
    ans += cnt[i]*i;
    ans %= mod;
  }
  if(ans<0) ans += mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4360
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int a, b;
    cin >> a >> b;
    cout << --a * --b << endl;
}


Measured memory_bytes: 256