akhauriyash/Code-Regression huggingface dataset:
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    vector<int> v;
    for(int i = 1; i <= n; i++){
        if(sum + i < n){
            sum += i;
            v.PB(i);
        }else{
            sum += i;
            v.PB(i);
            int delta = sum - n;
            for(auto &x : v){
                if(x != delta){
                    cout << x << nl;
                }
            }
            break;
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b; cin >> a >> b;
	cout << (a * 3 + b) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

signed main(){
    FASTER;
    int n,m;cin>>n>>m;
    vector<vector<char>> v(n,vector<char>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>v[i][j];
        }
    }
    
    vvi Rnext(n,vi(m));
    vvi Rprev(n,vi(m));
    for(int i=0;i<n;i++){
        int last=m-1;
        for(int j=m-1;j>=0;j--){
            if(v[i][j]=='.')Rnext[i][j]=last;
            else last=j-1;
        }
    }
    for(int i=0;i<n;i++){
        int last=0;
        for(int j=0;j<m;j++){
            if(v[i][j]=='.')Rprev[i][j]=last;
            else last=j+1;
        }
    }
    
    vvi Cnext(n,vi(m));
    vvi Cprev(n,vi(m));
    for(int j=0;j<m;j++){
        int last=n-1;
        for(int i=n-1;i>=0;i--){
            if(v[i][j]=='.')Cnext[i][j]=last;
            else last=i-1;
        }
    }
    for(int j=0;j<m;j++){
        int last=0;
        for(int i=0;i<n;i++){
            if(v[i][j]=='.')Cprev[i][j]=last;
            else last=i+1;
        }
    }
    
    vvi dpR(n,vi(m));
    for(int i=0;i<n;i++){
        dpR[i][0]=(v[i][0]=='.');
        for(int j=1;j<m;j++){
            dpR[i][j]=dpR[i][j-1]+(v[i][j]=='.');
        }
    }
    vvi dpC(n,vi(m));
    for(int j=0;j<m;j++){
        dpC[0][j]=(v[0][j]=='.');
        for(int i=1;i<n;i++){
            dpC[i][j]=dpC[i-1][j]+(v[i][j]=='.');
        }
    }
    
    int ans=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(v[i][j]=='#')continue;
            int r=Rnext[i][j];
            int l=Rprev[i][j];
            int d=Cnext[i][j];
            int u=Cprev[i][j];
            int mx=-1;
            mx+=dpR[i][r]-(l?dpR[i][l-1]:0);
            mx+=dpC[d][j]-(u?dpC[u-1][j]:0);
            ans=max(ans,mx);
        }
    }
    
    cout<<ans;
}

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

int main()
{  long long int n;
 cin>>n;
 string s,t,ans="";
  cin>>s>>t;
  
  
  for(long long int i=0;i<n;i++)
  {
    ans=ans+s[i]+t[i];
  }
    cout<<ans;
  
  return 0;
      
      
      
      }

Measured memory_bytes: 256
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= (n - i); ++j)
		{
			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y)
			{
				printf("%d %d %d\n", i, j, n - i - j);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
import sys
import fractions
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = IL()

print(str(min(a,b))*max(a,b))

Measured memory_bytes: 66156
#input
N, K = map(int, input().split())
B = {i:0 for i in range(N)}

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        B[a-1] += 1
#output
answer = 0
for j in B.values():
    if j == 0:
        answer += 1

print(answer)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string s;
 
  cin >> s;
  
  s[5]=' ',s[13]=' ';
  
  for (int i = 0; i < s.size(); i++) {
      if ( s.at(i) == ',' ) {
        s.at(i) = ' ';
      }  
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3600
N, D = map(int, input().split())
X = []
for l in range(N):
    X.append(list(map(int, input().strip().split())))

r = []
for i in range(N-1): # 点を動かす
    for j in range(i+1, N): # もう片方の点を動かす
        r0 = 0
        for k in range(D): # 座標の成分を動かす
            r0 += (X[i][k] - X[j][k]) ** 2
        r1 = r0 **0.5
        r.append(r1)
count = 0
for i in range(len(r)):
    if r[i].is_integer():
        count += 1
    else:
        pass
print(count)

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;
  
  //cout << fixed << setprecision(10);
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	al := make([]int, n+1)
	Lim := 317

	// loop回す
	for x := 1; x <= Lim; x++ {
		for y := 1; y <= Lim; y++ {
			for z := 1; z <= Lim; z++ {
				p := f(x, y, z)
				if p <= n {
					al[p]++
				}
			}
		}

	}

	for i := 1; i <= n; i++ {
		fmt.Println(al[i])
	}

}
func f(x int, y int, z int) int {
	return x*x + y*y + z*z + x*y + y*z + x*z
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int s = a + b + c;
  if(s >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
input=sys.stdin.readline
##import numpy as np
#sys.setrecursionlimit(10**7)
mo=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
##def power(x, y):
##    if(y == 0):return 1
##    temp = power(x, int(y / 2))%mo
##    if (y % 2 == 0):return (temp * temp)%mo 
##    else:
##        if(y > 0):return (x * temp * temp)%mo 
##        else:return ((temp * temp)//x )%mo
##
##for _ in range(inin()):
n=inin()
if(n%1000==0):
    print(0)
else:
    print(1000-n%1000)
    
    
    
    
    
    
        
    
    
    
    
    
    
        
        
    
    
    
    


    





##
        
    
    
    
    
    
    
        
        
    
    
    
    


    





##def msb(n):n|=n>>1;n|=n>>2;n|=n>>4;n|=n>>8;n|=n>>16;n|=n>>32;n|=n>>64;return n-(n>>1) #2 ki power
##def pref(a,n,f):             
##    pre=[0]*n
##    if(f==0):         ##from beginning
##        pre[0]=a[0]
##        for i in range(1,n):
##            pre[i]=a[i]+pre[i-1]
##    else:              ##from end
##        pre[-1]=a[-1]
##        for i in range(n-2,-1,-1):
##            pre[i]=pre[i+1]+a[i]
##    return pre
##maxint=10**24 
##def kadane(a,size): 
##    max_so_far = -maxint - 1
##    max_ending_here = 0
##       
##    for i in range(0, size): 
##        max_ending_here = max_ending_here + a[i] 
##        if (max_so_far < max_ending_here): 
##            max_so_far = max_ending_here 
##  
##        if max_ending_here < 0: 
##            max_ending_here = 0   
##    return max_so_far


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

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

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c=0,d,i;
	scanf("%d%d",&a,&b);
	d=b-a;
	for(i=1; i<=d; i++){
		c=c+i;
	}
	printf("%d\n",c-b);
	return 0;
}

Measured memory_bytes: 760
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	int n1,n2;
	n1=a.length();
	n2=b.length();
	if(n1>n2)
		printf("GREATER\n");
	else if(n1<n2)
		printf("LESS\n");
	else{
		if(a>b)
			printf("GREATER\n");
		else if(a<b)
			printf("LESS\n");
		else
			printf("EQUAL\n");
	}
}

Measured memory_bytes: 256
n = int(input())
s = input()

sum_e = s.count("E")
sum_w = s.count("W")

cnt_e, cnt_w = 0, 0

ans = 10 ** 6
for x in s:
    if x == "E":
        cnt_e += 1
        ans = min(ans, cnt_w + (sum_e - cnt_e))
    if x == "W":
        ans = min(ans, cnt_w + (sum_e - cnt_e))
        cnt_w += 1

print(ans)

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back


int main() {
  ll a,b,c,d; cin>>a>>b>>c>>d;
  cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a, b,c,ans=1,i=1;
	vector<int>vec;
	vec.push_back(2);
	cin >> a >> b;
	c = gcd(a, b);
	while (c != 1) {
		i++;
		if (!prime(i)) {
			continue;
		}
		if (i * i > c) {
			ans++;
			break;
		}
		if (c % i == 0) {
			ans++;
		}
		while (c % i == 0) {
			c /= i;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
s = input()
t = "keyence"

c = 0
for i in range(len(t)):
    if s[i] != t[i]:
        c = i
        break
else:
    c = 7
    
for i in range(len(t)):
    if s[-i-1] != t[-i-1]:
        c += i
        break
else:
    c += 7

if c>= 7:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let a_pos = h / 12.0 + m / 60.0 / 12.0;
    let b_pos = m / 60.0;

    let rad = 2.0 * std::f64::consts::PI * (a_pos - b_pos);
    println!("{}", (a * a + b * b - 2.0 * a * b * rad.cos()).sqrt());
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    if(temp % 2 == 1) cnt++;
  }
  (cnt % 2) ? cout << "NO" << endl : cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

int n;
char data[maxn];

int main()
{
    while(~scanf("%d", &n)){
        scanf("%s", data);
        int sum=0, sum2=0;
        for(int i=0;i<n;i++){
            if(data[i]=='(')sum++;
            else{
                if(sum)sum--;
                else sum2++;
            }
        }
        for(int i=0;i<sum2;i++)putchar('(');
        printf("%s", data);
        for(int i=0;i<sum;i++)putchar(')');
        puts("");
    }
    return 0;
}



Measured memory_bytes: 256
# AOJ 0239: Calorie Counting
# Python3 2018.6.25 bal4u

while 1:
	n = int(input())
	if n == 0: break
	s, p, q, r = [0]*1002, [0]*1002, [0]*1002, [0]*1002
	for i in range(n):
		s[i], p[i], q[i], r[i] = map(int, input().split())
	P, Q, R, C = map(int, input().split())
	f = False
	for i in range(n):
		c = ((p[i]+r[i]) << 2) + (q[i] << 3) + q[i]
		if p[i] > P or q[i] > Q or r[i] > R or c > C: pass
		else:
			print(s[i])
			f = True
	if not f: print("NA")


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

int p[1050], q[1050], r[1050], c[1050], n;
int pp, qq, rr, cc, ind[1050];

int main(){
    while(cin >> n, n){
	for(int i = 0;i < n;i++){
	    cin >> ind[i] >> p[i] >> q[i] >> r[i];
	    c[i] = 4 * p[i] + 9 * q[i] + 4 * r[i];
	}
	cin >> pp >> qq >> rr >> cc;
	int ok = 0;
	for(int i = 0;i < n;i++){
	    if(p[i] <= pp && q[i] <= qq && r[i] <= rr && c[i] <= cc){
		cout << ind[i] << endl;
		ok = 1;
	    }
	}
	if(ok == 0)cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = a;
		if (a > b)
			c--;
		System.out.println(c);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;

int N;
int d[300][300];
bool notUsed[300][300];

int main() {
  cin >> N;

  rep(i, N) {
    rep(j, N) {
      cin >> d[i][j];
      notUsed[i][j] = false;
    }
  }

  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if (k==i || k==j || j==i) continue;
        if (d[i][j] > d[i][k] + d[k][j]) {
          cout << -1 << endl;
          return 0;
        }
        notUsed[i][j] = notUsed[i][j] || (d[i][j] == d[i][k] + d[k][j]);
      }
    }
  }

  long ans = 0;
  rep(i, N) {
    for (int j=i+1; j<N; j++) {
      if (!notUsed[i][j]) {
        ans += (long)d[i][j];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
  long long n,i,a,b,min=1000000,max=-1000000,sum,tem,t;
  scanf("%lld",&n);
  sum = 0;
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    sum = sum + a;
    if(a<min){
      min=a;
    }
    if(a>max){
      max=a;
  }
  }
  printf("%lld ",min);
  printf("%lld ",max);
  printf("%lld\n",sum);
  return 0;
}
    
    

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int A[100000],n,i,j,r,p,q,x,stac;
  
 scanf("%d",&n);
 for(i=1;i<=n;i++){
   scanf("%d",&A[i]);
 }
 p=1;
 r=n;
 x=A[r];
 i=p-1;
 for(j=p;j<=r-1;j++){
   if(A[j]<=x){
     i=i+1;
   stac=A[i];
   A[i]=A[j];
   A[j]=stac;
   }
 }
 stac=A[i+1];
 A[i+1]=A[r];
 A[r]=stac;
 q=i+1;
 for(i=1;i<=n;i++){
   if(i>1){
     printf(" ");
   }
   if(q==i)
     printf("[%d]",A[i]);
   else
   printf("%d",A[i]);
 }
 printf("\n");
 return 0;
}

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

int N,M;
vector<int> G[100005];
vector<int> ans;
bool visited[100005];

void fdfs(int pos){
  ans.push_back(pos);
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(!visited[to]){
      fdfs(to);
      break;
    }
  }
}


void dfs(int pos, vector<int> &v){
  
  v.push_back(pos);
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(!visited[to]){
      dfs(to,v);
      break;
    }
  }
}

void solve(){
  for(int i=0;i<N;i++){
    if(G[i].size()==1){
      fdfs(i);
      return;
    }
  }
  vector<int> fi,se;
  dfs(0,fi);
  dfs(0,se);
  reverse(se.begin(),se.end());
  /*
  for(int i=0;i<(int)se.size();i++)
    cout<<se[i]<<' ';
  cout<<endl;


  for(int i=0;i<(int)fi.size();i++)
    cout<<fi[i]<<' ';
  cout<<endl;

  */
    for(int i=0;i<(int)se.size();i++)ans.push_back(se[i]);
  
    for(int i=1;i<(int)fi.size();i++)ans.push_back(fi[i]);

}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

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


Measured memory_bytes: 9976
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,a,b,x,kin,x2,mn,j;
	scanf("%d %d %d",&a,&b,&x);
	i=0;
	mn=1000000;
	while(1)	{
		kin=i*a;
		x2=x-i*1000;
		if(x2>0)	{
			j=x2/500;
			if(x2%500!=0)	j++;
			kin=kin+b*j;
		}
		mn=min(mn,kin);
		if(x2<=0)	break;
		i++;
	}
	printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 2764
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;

int main() {
	int a, b, c, cou = 0;
	cin >> a >> b >> c;
	for (int i = min(a, b); i >= 1; --i) {
		if (a%i == 0 && b%i == 0) { ++cou; }
		if (cou == c) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int N;

int selectmax(vector<int>x) {
	sort(ALL(x), greater<int>());
	int ans = 0;
	rep(i, N)ans += x[i];
	return ans;
}
int selectmin(vector<int>x) {
	sort(ALL(x));
	int ans = 0;
	rep(i, N)ans += x[i];
	return ans;
}

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

	cin >> N;
	vector<int>a(3 * N);

	rep(i, 3 * N)cin >> a[i];

	vector<int>s1(N + 1), s2(N + 1);
	multiset<int>p;
	int sum = 0;
	rep(i, N) {
		sum += a[i];
		p.insert(a[i]);
	}
	s1[0] = sum;
	for (int i = N; i < 2 * N; i++) {
		sum += a[i];
		p.insert(a[i]);
		auto itr = p.begin();
		sum -= *itr;
		p.erase(itr);
		s1[i - N + 1] = sum;
	}
	p.clear();
	sum = 0;
	for (int i = 3 * N - 1; 2 * N <= i; i--) {
		sum += a[i];
		p.insert(-a[i]);
	}
	s2[N] = sum;
	for (int i = 2 * N - 1; N <= i; i--) {
		sum += a[i];
		p.insert(-a[i]);
		auto itr = p.begin();
		sum += *itr;
		p.erase(itr);
		s2[i - N] = sum;
	}

	int ans = -intmax;
	for (int i = 0; i <= N; i++) {
		int score = s1[i] - s2[i];
		ans = max(ans, score);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  cout << ceil((a + b) / 2.0) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String input = Console.ReadLine();
                Char[] a = input.ToCharArray();
                int sum = 0;
                if (input == "0")
                {
                    break;
                }
                for (int i = 0; i < a.Length; i++)
                {
                    string b = a[i].ToString();
                    int c = int.Parse(b);
                    sum = sum + c;

                }
                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e6 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const LL mod=1e9+7;
int k;
char a[N];
LL dp[111][111];
LL pm(LL x,LL y){
	if(!x)return 1;
	LL z=1;
	while(y){
		if(y&1)z=z*x%mod;
		y>>=1;
		x=x*x%mod;
	}
	return z;
}
LL fac[N],inv[N];
void P(){
	fac[0]=1;
	for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%mod;
	inv[N-1]=pm(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL get(int x,int y){
	//cout<<x<<' '<<y<<' '<<fac[x]*inv[y]%mod*inv[x-y]<<endl;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>k>>a+1;P();
  int n=strlen(a+1);
  LL ans=0;
  for(int i=0;i<=k;i++){
  	int last=k-i;
  	ans+=pm(26,i)*pm(25,last)%mod*get(last+n-1,n-1)%mod;
  	ans%=mod;
  }
  cout<<ans<<'\n';
 	return 0;
}

Measured memory_bytes: 35844
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
#include<random>
using namespace std;
typedef long long int llint;
const int big=1e9+100000;
const int mod=1e9+7;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	llint n,a,ans=0,ka=1;
	cin>>n;
	while(n--){
		cin>>a;
		if(a==ka){ka++;continue;}
		ans+=(a-1)/ka;
		if(ka==1){ka++;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
a, b = map(int, input().split())

def factorize(n: int) -> int:
    b = 2
    ret = []
    while b*b <= n:
        while n%b == 0:
            n //= b
            ret.append(b)
        b = b + 1

    if n > 1:
        ret.append(n)

    return list(set(ret))

g = fractions.gcd(a, b)
print(len(factorize(g))+1)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
vi a;
int main() {
    cin>>n;
    a.resize(n);
    REP(i,n) cin>>a[i];

    int ban1 = 0;
    int ban2 = 0;
    int idx;

    REP(i,n){
        if(ban1 < a[i]){
            ban2 = ban1;
            ban1 = a[i];
            idx = i;
        } else if(ban2 < a[i]){
            ban2 = a[i];
        }
    }

    REP(i,n){
        if(i==idx)
            cout << ban2 << endl;
        else
            cout << ban1 << endl;
    }
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
#define gamma sss
typedef int iiii;
#define int ll

typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

const ll mod = (1e+9) +7;
int N;
int cnt;
int a[100001];
bool b[100000];
int gamma[100001];
int Z;
int x=-1,y=-1;



int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b != 0){
    d = extgcd( b , a%b, y, x);
    y -= (a/b)*x;
  } else{
    x=1; y=0;
  }
  return d;
}

int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m) %m;
}

int comb(int n,int m){
  if(n<m) return 0;
  return ( gamma[n] * mod_inverse( (gamma[n-m]*gamma[m])%mod , mod)  )%mod;
}

void calc(int k){
  int res=0;
  if(k==1){
    cout<<N<<endl;
    return;
  }
  res += comb( N-1, k );
  res%=mod;
  res += comb( N-1, k-2 );
  res%=mod;
  res += 2*comb(N-1,k-1);
  res%=mod;
  res -= comb(N-(y-x),k-1 );
  res = (res%mod +mod)%mod;
  cout<<res<<endl;
  return;
  //res += pow2[ N-1 ];
  //if(y-x > 1) res += 2 * (pow2[x]*(pow2[y-x] - )* pow2[N-y]  )%mod
}

iiii main()
{
  cin>>N;
  gamma[0]=1LL;
  rep(i,N){
    gamma[i+1]= ((i+1) * gamma[i])%mod;
  }
  rep(i,N+1){
    cin>>a[i];
    a[i]--;
    if(b[a[i]]) Z=a[i];
    b[a[i]]=1;
  }
  rep(i,N+1){
    if(a[i]==Z){
      if(x==-1) x=i;
      else y=i;
    }
  }
//  cout<<x<<" "<<y<<endl;
  rep1(i,N+1) calc(i);
}


Measured memory_bytes: 2816
#include <bits/stdc++.h> 
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define vp vector<pair<ll, ll>>
#define all(a) a.begin(), a.end()
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>
#define mp make_pair
#define fi first
#define sc second
#define for0(i, n) for(ll i=0; i<n; i++) 
#define for1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ll mod = 1e9+7;

void solve(){
	int a, b, c, k;
	cin>>a>>b>>c>>k;
	int x=0;
	while(b<=a){
		b*=2;
		x++;
	}
	if(x>k){
		cout<<"No";
		return;
	}
	while(c<=b){
		c*=2;
		x++;
	}
	if(x>k)
		cout<<"No";
	else
		cout<<"Yes";
}

int main() {

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

	ll test = 1;
	//cin>>test;
	while(test--)
		solve();

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll sum=0;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    sum+=a;
  }
  cout<<sum-(n+1)*n/2<<endl;
  return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>

int x,y;
int gcd(x,y){
   if(y==0){
      return x;
   }else{
      return gcd(y,x%y);
   }
}
 
int main(){
   int x,y;
   scanf("%d %d",&x,&y);
   if(x>=y)
      printf("%d\n",gcd(x,y));
   else{
      printf("%d\n",gcd(y,x));
   }
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  int cnt = 1 ;
  REP(i,n){
    int a ;
    cin >> a ;
    if(a%2==0){
      cnt *= 2 ;
    }
  }
  int ans = 1 ;
  REP(i,n){
    ans *= 3 ;
  }
  
  cout << ans-cnt <<endl ;
  


  return 0 ;
}




Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
struct dot{
    int x,y;
}a[51],b[51];
int n,m;
int main(){
    cin>>n>>m;
    int i,j;
    for(i=1;i<=n;i++)
    cin>>a[i].x>>a[i].y;
    for(i=1;i<=m;i++)
    cin>>b[i].x>>b[i].y;
    for(i=1;i<=n;i++)
    {
        int minn=1000000000,k;
        for(j=1;j<=m;j++)
        {
            int dis=abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y);
            if(dis<minn)minn=dis,k=j;
        }
        cout<<k<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
capasity = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    b,f,r,v = map(int, input().split())
    capasity[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(capasity[i][j][k]),end='')
        print()
    if i != 3:
        print('#'*20)


Measured memory_bytes: 5624
use proconio::{input, fastout};
use std::ops::{AddAssign, Sub};

#[derive(Debug)]
pub struct FenwickTree<T> {
    n: usize,
    data: Vec<T>,
}

impl<T> FenwickTree<T>
    where T: Default + Clone,
{
    pub fn new(n: usize) -> Self {
        FenwickTree { n, data: vec![T::default(); n] }
    }
}

impl<T> FenwickTree<T> 
    where T: AddAssign + Sub<Output = T> + Default + Clone + Copy,
{
    pub fn add(&mut self, p: usize, x: T) {
        assert!(p < self.n);
        let mut p = p as isize;
        p += 1;
        while p <= self.n as isize {
            self.data[(p-1) as usize] += x;
            p += p & -p;
        }
    }

    pub fn sum(&self, l: usize, r: usize) -> T {
        assert!(l <= r && r <= self.n);
        self._sum(r) - self._sum(l)
    }

    fn _sum(&self, r: usize) -> T {
        let mut s = T::default();
        let mut r = r as isize;
        while r > 0 {
            s += self.data[(r-1) as usize];
            r -= r & -r;
        }
        s
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        aa: [usize; n],
        queries: [(usize, usize, usize); q],
    }

    let mut tree = FenwickTree::new(n);

    for (i, a) in aa.into_iter().enumerate() {
        tree.add(i, a);
    }

    for (q, l, r) in queries {
        if q == 0 {
            tree.add(l, r);
        } else if q == 1 {
            let ans = tree.sum(l, r);
            println!("{}", ans);
        }
    }
}


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

using namespace std;

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

    bool status0 = false;
    bool statusover = false;
    unsigned long long int result = 1;

    for (int i = 0; i < n; i++)
    {
        unsigned long long int a;
        cin >> a;

        if(a == 0) status0 = true;
        
        unsigned long long int updated_result = result * a;

        if(updated_result > 1000000000000000000 || updated_result < result){
            statusover = true;
        }

        result = updated_result;
    }

    if(status0) cout << "0" << endl;
    else if(statusover) cout << "-1" << endl;
    else cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  std::list<int> b;
  for (size_t i = 0; i < a.size(); i++) {
    cin >> a[i];
    if (i % 2 == 1) {
      b.push_front(a[i]);
    } else {
      b.push_back(a[i]);
    }
  }
  if (b.size() % 2 == 0) {
    for (auto itr = b.begin(); itr != b.end(); ++itr) {
      std::cout << *itr << " ";
    }
    cout << endl;
  } else {
    auto end = b.end();
    end--;
    for (auto itr = end; itr != b.begin(); --itr) {
      std::cout << *itr << " ";
    }
    cout << *b.begin() << endl;
  }

  return 0;
}

Measured memory_bytes: 10112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();//red
		int B = sc.nextInt();//green
		int C = sc.nextInt();//blue
		int K = sc.nextInt();

		//red < green and green < blue
		for(int i = 0; i < K; i++) {
			if(B <= A) {
				B = B*2;
			}else if(C <= B){
				C = C*2;
			}
		}

		if(A < B && B < C) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        char c = s.next().charAt(0);
        if(c=='S') System.out.println("Cloudy");
        else if(c=='C') System.out.println("Rainy");
        else System.out.println("Sunny");

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25316
H = gets.to_i
array = gets.split.map &:to_i
nodes = Array.new
array.each_with_index do |a,idx|
  nodes[idx+1] = a
end

class << nodes
  def puts_info
    self.each_with_index do |node, idx|
      next if node.nil?
      print "node #{idx}: key = #{node}, "
      print "parent key = #{self[parent(idx)]}, " if self[parent(idx)]
      print "left key = #{self[left(idx)]}, " if self[left(idx)]
      print "right key = #{self[right(idx)]}, " if self[right(idx)]
      print "\n"
    end
  end
end

def parent(int)
  int / 2
end

def left(int)
  int * 2
end

def right(int)
  int * 2 + 1
end

nodes.puts_info



Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
int a[100],b[101]={0};
int main()
{
	int n,s=0,i,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[a[i]]++;
		if(a[i]>max)
			max=a[i];
	}
	for(i=1;i<=max;i++)
	{
		if(b[i]!=0)
			s++;
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
def test():
    n,m = map(int,input().split())
    d = list(map(int,input().split()))
    b = set(d[1:])
    for i in range(n-1):
        a = list(map(int,input().split()))
        c = set(a[1:])
        b = b & c

    print(len(b))


if __name__ == "__main__":
    test()


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    
    int x;
    cin>>x;
    if(400<=x&&x<600) cout<<8<<endl;
    else if(x<800) cout<<7<<endl;
    else if(x<1000) cout<<6<<endl;
    else if(x<1200) cout<<5<<endl;
    else if(x<1400) cout<<4<<endl;
    else if(x<1600) cout<<3<<endl;
    else if(x<1800) cout<<2<<endl;
    else if(x<2000) cout<<1<<endl;

    
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp
./a.out

*/

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, W, H, x, y, S, T;

    while (cin >> N && N) {
        cin >> W >> H;
        vector< vector<int> > persimmon(H + 1, vector<int>(W + 1, 0));
        for (int i=0; i<N; ++i) {
            cin >> x >> y;
            persimmon[y][x] = 1;
        }
        cin >> S >> T;

        vector< vector<int> > count = persimmon;
        for (int i=0; i<=H; ++i) {
            for (int j=1; j<=W; ++j) {
                count[i][j] += count[i][j - 1];
            }
        }
        for (int j=0; j<=W; ++j) {
            for (int i=1; i<=H; ++i) {
                count[i][j] += count[i - 1][j];
            }
        }

        int ans = 0;
        for (int i=1; i<=H; ++i) {
            for (int j=1; j<=W; ++j) {
                int x1 = j, y1 = i, x2 = j + S - 1, y2 = i + T - 1;
                if (W < x2 || H < y2) continue;
                int c = count[y2][x2] - count[y2][x1 - 1] - count[y1 - 1][x2] + count[y1 - 1][x1 - 1];
                ans = max(ans, c);
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;



int main(){

    string s;
    cin >> s;
    int ans = 0;

    rep(i,3){
        if(s[i] == '1') ans++;
    }

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

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int N = sc.nextInt();
            int T = sc.nextInt();
            int L = sc.nextInt();
            int B = sc.nextInt();
            if(N==0 && T==0 && L==0 && B==0) break;
            int[] square = new int[N+1];
            for(int i=0; i<L; i++) square[sc.nextInt()] = 1;
            for(int i=0; i<B; i++) square[sc.nextInt()] = 2;

            double[][] dp = new double[N+1][T+1];
            dp[0][0] = 1;
            for(int j=0; j<T; j++){
                for(int i=0; i<N; i++){
                    for(int s=1; s<=6; s++){
                        int idx = 1;
                        int num = i+s;
                        if(square[i]==1) idx = 2; 
                        if(i+s>N) num = 2*N-(i+s);

                        if(square[num]==2 && j+idx<=T){
                            dp[0][j+idx] += dp[i][j] * 1.0/6;
                        }else if(j+idx<=T){
                            dp[num][j+idx] += dp[i][j] * 1.0/6;
                        }
                    }
                }
            }

            double goal = 0.0;
            for(int i=0; i<=T; i++) goal += dp[N][i];
            System.out.printf("%.6f\n",goal);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 24440