akhauriyash/Code-Regression huggingface dataset:
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = x.split(/\n/);

var calc = {
  '+': function (a, b) {return a + b; }, 
  '-': function (a, b) {return a - b; }, 
  '*': function (a, b) {return a * b; }, 
  '/': function (a, b) {return ~~(a / b); }
};

for (var i = 0; i < lines.length; i ++) {
  var arr = lines[i].split(' ');
  var a = Number(arr[0]);
  var op = arr[1];
  var b = Number(arr[2]);
  if (op === '?') {
    break;
  }
  console.log(calc[op](a, b));
}



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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    a[i] = make_pair(ai, i);
  }
  sort(a.begin(), a.end());
  for (auto i: a){
    cout << i.second + 1 << endl;
  }
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int res = INT_MAX;
  for (int i = 0; i < s.size() - 2; i++) {
    int v = stoi(s.substr(i, 3));
    res = min(res, abs(v - 753));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;



int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if (d > 0 && 4 * a * b < d * d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}

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

using namespace std;

int main() {
    long long N, blue, red, anadir;
    cin >> N >> blue >> red;
    if (N%(blue+red) <= blue) anadir = N%(blue+red);
    else anadir = blue;
    cout << ((N/(blue+red))*blue)+anadir;
}

Measured memory_bytes: 256
# !/usr/bin/env python
# -*- coding utf-8 -*-

import sys

S = raw_input()

S = S[:-1]

if len(S)%2 == 1:
    S = S[:-1]

while(1):
    if S[:len(S)/2] == S[(len(S)/2):]:
        print(len(S))
        break
    else:
            S = S[:(len(S) - 1)]

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

int main()
{
	int x;
	std::cin >> x;

	std::vector<int> val(x);
	for (int i = 0; i < x; i++)
		std::cin >> val[i];

	std::vector<int>::iterator p;
	p = val.end();
	while (p != val.begin()) {
		p--;		
		if(p == val.begin())
			printf("%d\n", *p);
		else
			printf("%d ", *p);
	}

	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	if(b==0) return a;
	else return gcd(b,a%b);
}
ll extgcd(ll a,ll b,ll &x,ll &y){
	ll g = a; x = 1; y = 0;
	if(b != 0) g = extgcd(b,a%b,y,x),y-=(a/b)*x;
	return g;
}
ll AxB(ll A,ll B,ll C){
	//minimum non-negaitive x such that Ax godo b (mod C)
	if(B%gcd(A,C) != 0) return -1;
	ll x,y;
	extgcd(A,C,x,y);
	x = x*B/gcd(A,C)%(C/gcd(A,C));
	ll f = C/gcd(A,C);
	if(x > 0){
		x %= abs(f);
	}
	else{
		x = (x%abs(f)+abs(f))%abs(f);
	}
	return x;
}
int n;
int main(){
    cin>>n;
    rep(q,n){
    	ll a,b;cin>>a>>b;
    	ll g=gcd(a,b);
    	if(g<=50000){
    		ll v = AxB(a,g,b);
    		ll vv = a*v-g;
    		vv /= b;
    		//a*v-b*vv = g
    		ll v2 = AxB(a,-g,b);
    		ll vv2 = a*v2+g;
    		vv2 /= b;
    		//a*v2-b*vv2 = -g
    		assert((v>=0 && vv>=0) || (v2>=0 && vv2>=0));
    		if(v2>=0 && vv2>=0){ v = v2; vv = vv2; }
    		cout<<3<<endl;
    		cout<<0<<" "<<0<<endl;
    		cout<<a<<" "<<b<<endl;
    		cout<<vv<<" "<<v<<endl;
    	}
    	else{
    		cout<<4<<endl;
    		cout<<0<<" "<<1<<endl;
    		cout<<a<<" "<<b<<endl;
    		cout<<1<<" "<<0<<endl;
    		cout<<a-a/g<<" "<<b-b/g<<endl;
    	}
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int cnt=K;
  for (int i=1; i<N; i++) {
    cnt*=(K-1);
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    int f = 0;
    rep(i, a+b+1){
        if(i == a){
            if(s.at(i) != '-'){ f = 1; break;}
        }else{
            if(!(s.at(i) <= '9' && s.at(i) >= '0')){ f = 1; break;}
        }
    }
    if(f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S;
  T = "CODEFESTIVAL2016";
  int count;
  for (int i = 0; i < 16; i++){
    if (S.at(i) != T.at(i)) count++;
  }
  cout << count;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() 
{
  int n,m;
  cin >> n >> m;
  int a = m/n;
  while(1){
    if(m % a == 0){
      break;
    } else{
      a--;
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
L=[0]*N
V=list(map(int,input().split()))
C=list(map(int,input().split()))
for i in range(N):
  L[i]=V[i]-C[i]
L=sorted(L)
s=0
for i in range(N):
  if L[i]>=0:
    s+=L[i]
print(s)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define speedhack ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fromfile freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout); 
#define mod int (1e9+7)
#define MAXN int (1e9)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;




int d,e,f,n;

int main() {
    speedhack;
    //fromfile;
    cin >> n;
    int dp[n+1][3];
    vector<int> a, b, c;
    a.pb(0);
    b.pb(0);
    c.pb(0);
    for(int j = 0; j<n; j++){
        cin >> d >> e >> f;
        a.pb(d);
        b.pb(e);
        c.pb(f);
    }
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for(int i = 2; i<=n; i++){
        dp[i][0] = a[i] + max( dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max( dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max( dp[i-1][1], dp[i-1][0]);
    }
    int ans = max(dp[n][0], dp[n][1]);
    ans = max(ans, dp[n][2]);
    cout << ans;



    /*
    vector<int> dp(n+1,MAXN);
    vector<int> h;
    h.pb(0); // shifting index
    for (int j = 0; j<n; j++){
        cin >> l;
        h.pb(l);
    }
    dp[1] = 0;
    for (int k = 2; k<=n; k++){
        for (int j = 1; j<=x; j++){
            if (k-j > 0){
                dp[k] = min(dp[k], dp[k-j] + abs(h[k] - h[k-j]) );
            }
        }
    }
    cout << dp[n];
    */

    }

Measured memory_bytes: 2924
fn main() {
    let v = read_vec::<u32>();
    let n = v[0];
    let x = v[1];

    let mut ms = vec![];
    for _ in 0..n {
        ms.push(read::<u32>());
    }
    let min_m = ms.iter().min().unwrap();
    let sum = ms.iter().fold(0, |a, b| a + b);
    let ans = n + (x - sum) / min_m;
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
 
long long dp[105][100005];
long long w[105], v[105];
int main() {
    int N, W; cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < N; i++) {
        for (int maxw = 0; maxw <= W; maxw++) {
            if(maxw >= w[i]) {
                dp[i+1][maxw] = max(dp[i+1][maxw],dp[i][maxw-w[i]]+v[i]);
            }
            dp[i+1][maxw] = max(dp[i+1][maxw],dp[i][maxw]);
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
#include <stdio.h>

int main(int argc, char const *argv[])
{
    /* code */
    int num = 0,A = 0,B = 0;
    scanf("%d", &num);
    if (num==1) {
        /* code */
        printf("Hello World\n");
    }
    else
    {
        /* code */
        scanf("%d", &A);
        scanf("%d", &B);
        printf("%d\n",A+B);
    }
    return 0;
}


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

int main() {
  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> ices(10, 0);
    for(int i = 0; i < n; ++i) {
      int type;
      cin >> type;
      ++ices[type];
    }
    for(int i = 0; i < 10; ++i) {
      if(ices[i] == 0) {
        cout << '-' << endl;
      } else {
        for(int j = 0; j < ices[i]; ++j) cout << '*';
        cout << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		String a[]=new String[K];
		int x=1;
		for(int i=0;i<K;i++){
			a[i]=stdIn.next();
		}
		while(true){
			boolean key=true;
			if(x>=N){
				for(int i=0;i<K;i++){
					String b=String.valueOf(x);
					if(b.indexOf(a[i])!=-1){
						key=false;
						break;
					}
				}
				if(key)
					break;
			}
			x++;
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 31444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<numeric>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int a[110000];
Int rem[110000];
Int n, ans;
int main(){
    cin >> n;
    for(int i = 0;i <= n;i++)cin >> a[i];
    rem[0] = 1;
    for(int i = 0;i <= n;i++){
        rem[i] -= a[i];
        if(rem[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        rem[i+1] = rem[i] * 2;
        rem[i+1] = min(rem[i+1], LINF);
    }
    for(int i = n;i > 0;i--){
        if(a[i] <= rem[i-1]){
            a[i-1] += a[i];
            ans += a[i];
        }
        else{
            a[i-1] += rem[i-1];
            ans += a[i];
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 4732
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

breakA = []
for i, v in enumerate(A):
  for _ in range(v):
    breakA.append(i + 1)

# breakAをWでchunck
# 奇数行目だけ[::-1]
import itertools
def splitparN(iterable, N):
    for i, item in itertools.groupby(enumerate(iterable), lambda x: x[0] // N):
        yield (x[1] for x in item)

for i, x in enumerate(splitparN(breakA, W)):
  if i % 2 == 0:
    print(*list(x))
  else:
    print(*list(x)[::-1])

Measured memory_bytes: 3920
#include <stdio.h>

#define A 4800

int main() {
	static char used[16];
	int n, i, k, c, cnt;

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

		scanf("%d", &a);
		if (a < 3200)
			used[a / 400] = 1;
		else
			k++;
	}
	cnt = 0;
	for (c = 0; c < 8; c++)
		if (used[c])
			cnt++;
	if (cnt == 0)
		printf("1 %d\n", n);
	else
		printf("%d %d\n", cnt, cnt + k);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N, M, K; cin >> N >> M >> K;

	bool ok = false;
	int curr = 0;
	for (int r = 0; r <= N; ++r){
		for (int c = 0; c <= M; ++c){
			curr = r * M + c * N - 2*(r == 0 || c == 0 ? 0 : r * c);
//			cerr << "r: " << r << " c: " << c << " curr: " << curr << endl;
			ok |= (curr == K);
		} // end for
	} // end for

	cout << (ok ? "Yes" : "No") << endl; 
	
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn main() {
    input!{
        s: chars,
    }

    for x in 0..s.len() {
        print!("x");
    }

}



Measured memory_bytes: 4352
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys


a = int(sys.stdin.readline())

print(a+a**2+a**3)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;;
#define llong long long
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int main(){
    string s;
    cin >> s;
    int rmv=0;
    int smem=0;
    int tmem=0;
    for(int i =0; i<s.size(); i++){
        if(s[i]=='T'){
            if(smem){
                smem--;
                rmv += 2;
            }
        }else{
            smem++;
        }
    }
    cout << s.size() - rmv << endl;


}

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

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

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

    sort(prices, prices+n);
    int min = 0;
    for (int i = 0; i < k; i++)
        min += prices[i];
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 3540
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
paths = [list(map(int, input().split(' '))) for _ in range(M)]
good_observatory = [True]*N
for path in paths:
    if good_observatory[path[0]-1] and H[path[0]-1] <= H[path[1]-1]:
        good_observatory[path[0]-1] = False
    if good_observatory[path[1]-1] and H[path[1]-1] <= H[path[0]-1]:
        good_observatory[path[1]-1] = False

print(sum(boolean for boolean in good_observatory))

Measured memory_bytes: 31868
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i, b) for( int i = 0; i < b; i++ )

int main(){
	int n, w;
	while( cin >> n >> w, n ){
		int num = (101 % w == 0) ? num = 101/w : num = 101/w+1;
		vector<double> hist(num);
		fill( hist.begin(), hist.end(), 0 );
		double max = 0;
		rep(i, n){
			int v;
			cin >> v;
			hist[v/w]++;
			if( max < hist[v/w] ) max = hist[v/w];
		}
		double sum = 0;
		rep(i, hist.size()) if( hist[i] != 0 ) num = i+1;
		//cout << num << endl;
		rep(i, num){
			sum += (double)(num-i-1) * hist[i] / (max * (double)(num-1));
		}
		sum += 0.01;
		cout << sum << endl;
		//printf("%.5f\n", sum);
	}
}

Measured memory_bytes: 1260
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC175
{
    class Program
    {
        static void Main(string[] args)
        {
            //var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var N = NK[0]; var K = NK[1];
            // var A = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            var N = long.Parse(Console.ReadLine());
            var L = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();

            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    for (int k = j + 1; k < N; k++)
                    {
                        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i])
                        {
                            if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) ans++;
                        }

                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28424
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

vector<ll> v;
ll max_d = 0;
int n, k;
ll ans = 0;
bool isNotZero = false;

void dfs(bool start, int d){
	if(d == -1)  return;
	int num  =0;
	vector<ll> v2;
	rep(i, v.size()){
		if(v[i] >> d & 1) {
			num++;
			v2.push_back(v[i]);
		}
	}
	if(num >= k){
		isNotZero = true;
		v = v2;
	}
	bool nS = start | num >= k;
	dfs(nS, d-1);
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	cin >> n >> k;
	vector<ll> a(n), h(n+1);
	rep(i, n) {
		cin >> a[i];
		h[i+1]  = h[i] + a[i];
	}

	rep2(i, 0, n+1){
		rep2(j, i+1, n+1){
			ll tmp = h[j] - h[i];
			v.push_back(tmp);
			ll d = 0;
			while(tmp > 0){
				tmp >>= 1;
				d++;
			}
			chmax(max_d, d);
		}
	}
	// print(max_d);

	dfs(false, 50);
	if(!isNotZero){
		cout << 0 << endl;
		return 0;
	}
	ans = v[0];
	rep(i, k){
		ans &= v[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14292
#include<stdio.h>
#include<math.h>

#define N 100

int main(){
  int x, n, p[N], ans;
  scanf("%d %d", &x, &n);
  for(int i=0; i<n; i++){
    scanf("%d", &p[i]);
  }
  
  if(n==0){
    printf("%d",x);
  }
  else{
    for(int j=0; j<=n; j++){
      int x1 = x-j, x2 = x+j, a;
      a=1;
      for(int i=0; i<n; i++){ 
        if(p[i]==x1){
          a=0;
        }
      }
      if(a==1){
        printf("%d",x1);
        return 0;
      }
      a=1;
      for(int i=0; i<n; i++){
        if(p[i]==x2){
          a=0;
        }
      }
      if(a==1){
        printf("%d",x2);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1736
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
long long arr[200005];
long long total,sum;
int main(){
    scanf("%d",&n);
    for (int x=0;x<n;x++){
        scanf("%lld",&arr[x]);
        total+=arr[x];
    }

    long long ans=1000000000000000000;
    ans=min(ans,max(sum,total-sum)*2-total);

    for (int x=0;x<n;x++){
        sum+=arr[x];
        ans=min(ans,max(sum,total-sum)*2-total);
    }

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


Measured memory_bytes: 1664
#include <stdio.h>
#include <cstdlib>
#include <string.h>
#include <math.h>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
//#include "windows.h"
//#include "../../gmp_int.h"
//#include "../../common.h"
#define MAX(a, b)		((a)>(b)?(a):(b))
#define MAX3(a, b, c)	(MAX((a),MAX((b),(c))))
#define FOR(a,b,c)		for (s32(a)=(b);(a)<(s32)(c);(a)++)
#define BL				{char bl[10];cin.getline(bl, 10);}
#define GL(c)			cin.getline(c, sizeof(c))
typedef char					s8;
typedef unsigned char			u8;
typedef short					s16;
typedef unsigned short			u16;
typedef int						s32;
typedef unsigned int			u32;
typedef long long int			s64;
typedef unsigned long long int	u64;
using namespace std;

//ifstream test_input;
//#define cin test_input

s64 ExtGcd(s64 a, s64 b, s64& x, s64& y) {
	if (b == 0) {
		x = 1; y = 0; return a;
	}
	s64 g = ExtGcd(b, a % b, y, x);
	y -= a / b * x;
	return g;
}

/**
* Find x who satisfies x*n=1 (mod p).
*/
s64 InvMod(s64 n, s64 p) {
	s64 x, y;
	return ExtGcd(n, p, x, y) == 1 ? (x + p) % p : 0;
}

int main(int argc, char* argv[])
{
	cout.precision(15);

	s64 H, W, A, B, D=1000000007;
	H = 10, W = 7, A = 3, B = 4;
	H = 2, W = 3, A = 1, B = 1;
	cin >> H >> W >> A >> B;

	s64 a = 1, b = 1;
	FOR(i, 0, B - 1) {
		a = (a * (H - A + B - 2 - i + D)) % D;
		a = (a * InvMod(B - 1 - i + D, D)) % D;
	}
	FOR(i, 0, W - B - 1) {
		b = (b * (W - B + A - 1 - i + D)) % D;
		b = (b * InvMod(W - B - 1 - i + D, D)) % D;
	}
	s64 ans = 0;
	s64 X = H - A + B - 2, Y = W - B + A - 1;
	for (s64 i = 1; i <= H - A; i++) {
		ans = (ans + (a*b)) % D;
		a = (a * (X - B - i + 2 + D)) % D;
		a = (a * InvMod(X - i + 1 + D, D)) % D;
		b = (b * (Y + i + D)) % D;
		b = (b * InvMod(Y + i - W + B + 1 + D, D)) % D;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int MAX_N = 100;

int main()
{
    long long N,M;
    long long a, total=0;
    int err = -1;

    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        cin >> a;
        total += a;

    }
    
    if (total > N)
    {
        cout << err << endl;
    }else
    {
        cout << N-total << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N,A,B;
	scanf("%d %d %d", &N, &A, &B);

	int ans = 0;
	for(int i=1;i<=N;i++){
		int sum = 0;
		int j = i;
		while(j>0){
			sum+=j%10;
			j/=10;
		}
		if(A<=sum && sum<=B) ans+=i;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
N,M = [int(it) for it in input().split()]
pli=[int(it)-1 for it in input().split()]
sli=[ [int(it)-1 for it in input().split()] for i in range(M)]
ue = [-1]*N
dw = [[] for i in range(N)]

for a,b in sli:
  if ( b == ue[a] or a == ue[b] ):
    continue
  else:
    _a = ue[a] if ue[a]!=-1 else a 
    _b = ue[b] if ue[b]!=-1 else b
    if (_a == _b and _a != -1):
      continue
    if (len(dw[_a]) < len(dw[_b])):
      _a,_b=_b,_a
    if len(dw[_b])>0:
      dw[_a].extend(dw[_b])
      for _p in dw[_b]:
        ue[_p]=_a
      dw[_b]=[]
    dw[_a].append(_b)
    ue[_b]=_a

s = 0
for i in range(N):
  if ue[i]==-1:
    ue[i]=i 
for i in range(N):
  if (ue[i]==ue[pli[i]]):
    s+=1
print (s)


Measured memory_bytes: 36140
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        StringBuilder sb = new StringBuilder();
        sb.append(S.substring(0,4));
        sb.append(' ');
        sb.append(S.substring(4));
        System.out.println(sb.toString());
    }
}


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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> re(n+1, k);
    int x;
    for (int i = 0; i < q; i++) {
        cin >> x;
        re[x]++;
    }
    for (int i = 1; i <= n; i++){
        re[i]-=q;
        //cout << re[i] << ": ";
        if (re[i] > 0) cout << "Yes"; else cout << "No";
        cout << endl;
    }
}


Measured memory_bytes: 1024
n = int(input())
mod = 10 ** 9 + 7

n10 = pow(10, n, mod)
n9 = pow(9, n, mod)
n8 = pow(8, n, mod)
ans = 2 * (n10 - n9) - (n10 - n8)
ans %= mod

print(ans)

Measured memory_bytes: 9168
#include <iostream>
#include <string>

using namespace std;

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

    char res = s[0];
    for (int i = 1; i < static_cast<int>(s.size()) && i < k && res == '1'; i++) {
        res = s[i];
    }

    cout << res << endl;
}


Measured memory_bytes: 256
n,x,m=map(int,input().split())
tab=[0 for i in range(10**5+1)]

end=False
now=x
for i in range(1,n+1):
    if tab[now]>0:
        las=tab[now]
        cyc=i-las
        break
    tab[now]=i
    now=now*now%m
else:
    end=True
    
if end:
    ans=0
    for i in range(10**5+1):
        if tab[i]>0:
            ans+=i
    print(ans)
else:
    ans=0
    head=0
    body=0
    foot=0
    lop=(n-las)//cyc
    rem=(n-las)%cyc
    for i in range(10**5+1):
        if tab[i]>=las and las+rem>=tab[i]:
            body+=i
            foot+=i
        elif tab[i]>=las:
            body+=i
        elif tab[i]>0:
            head+=i
    ans=head+body*lop+foot
    print(ans)
        
    
    

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

using namespace std;

int main()
{
    const int N = 2001;
    int h, w;
    cin >> h >> w;
    auto map = vector<uint8_t>(N * N, 0);
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        int ofs = N * i;
        for (int i = 0; i < w; i++) {
            map[i + ofs] = s[i] == '.';
        }
    }
    auto left = vector<uint16_t>(N * N, 0);
    auto right = vector<uint16_t>(N * N, 0);
    auto up = vector<uint16_t>(N * N, 0);
    auto down = vector<uint16_t>(N * N, 0);
    // left
    for (int y = 0; y < N; y++) {
        int ofs = N * y;
        if (map[ofs]) left[ofs] = 1;
        for (int x = 1; x < N; x++) {
            if (map[ofs + x]) {
                left[ofs + x] = left[ofs + x - 1] + 1;
            }
        }
    }
    // right
    for (int y = 0; y < N; y++) {
        int ofs = N * y;
        if (map[ofs + N - 1]) left[ofs + N - 1] = 1;
        for (int x = N - 2; x >= 0; x--) {
            if (map[ofs + x]) {
                right[ofs + x] = right[ofs + x + 1] + 1;
            }
        }
    }
    // up
    for (int x = 0; x < N; x++) {
        if (map[x]) up[x] = 1;
        for (int y = 1; y < N; y++) {
            if (map[N * y + x]) {
                up[N * y + x] = up[N * (y - 1) + x] + 1;
            }
        }
    }
    // down
    for (int x = 0; x < N; x++) {
        if (map[x + N * (N - 1)]) down[x + N * (N - 1)] = 1;
        for (int y = N - 2; y >= 0; y--) {
            if (map[N * y + x]) {
                down[N * y + x] = down[N * (y + 1) + x] + 1;
            }
        }
    }
    int best = 0;
    for (int y = 0; y < N; y++) {
        int ofs = N * y;
        for (int x = 0; x < N; x++) {
            if (!map[ofs + x]) continue;
            int val = up[ofs + x] + down[ofs + x] + left[ofs + x] + right[ofs + x] - 3;
            //if (y < h && x < w) cerr << left[ofs + x];
            //if (y < h && x < w) cerr << val;
            if (val > best) best = val;
        }
        //if (y < h) cerr << endl;
    }
    cout << best << endl;
}


Measured memory_bytes: 35456
#!python3.8
# -*- coding: utf-8 -*-
# abc166/abc166_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S=i2s()
    if S == 'ABC':
        print('ARC')
    else:
        print('ABC')
    return

main()


Measured memory_bytes: 9012
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
  vector <long long> a(3);
  cin >> a[0] >> a[1]>>a[2];
  sort(a.begin(),a.end());
  if((a[0]%2==0)||(a[1]%2==0)||(a[2]%2==0)){
    cout << 0 << endl;
  }
  else{
    cout << a[0]*a[1]<<endl;
  }
  return 0;
}


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

int main(){
  int n,m,x,a;
  cin >> n >> m >> x;
  int left = 0;
  int right = 0;
  for(int i = 0; i < m; i++){
    cin >> a;
    if(x < a) right++;
    else left++;
  }
  cout << min(right , left) << endl;
}


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

int main(){
    int a,b;
    cin >> a>>b;
  	int plus = a+b;
  	int min = a-b;
  	int time = a*b;
  vector<int> v;
  v.push_back(plus);
  v.push_back(min);
  v.push_back(time);
  	sort(v.begin(),v.end());
  cout << v[2] <<endl;
   }

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

// dp[pos][restrcited][count]
int dp[105][2][5];

int solve(string &n, int pos, int restricted, int cnt, int k){
    if(pos == (int)n.size()){
        return cnt == k ? 1 : 0;
    }
    
    if(dp[pos][restricted][cnt] != -1){
        return dp[pos][restricted][cnt];
    }
    
    int res = 0;
    
    if(restricted == 0){
        for(int i = 0; i <= 9; i++){
            if(i == 0){
                res += solve(n, pos + 1, 0, cnt, k);
            }else{
                if(cnt < k){
                    res += solve(n, pos + 1, 0, cnt + 1, k);
                }
            }
        }
    }else{
        int limit = n[pos] - '0';
        for(int i = 0; i <= limit; i++){
            int n_restricted = restricted;
            if(i < limit){
                n_restricted = 0;
            }
            if(i == 0){
                res += solve(n, pos + 1, n_restricted, cnt, k);
            }else{
                if(cnt < k){
                    res += solve(n, pos + 1, n_restricted, cnt + 1, k);
                }
            }
        }
    }
    
    return dp[pos][restricted][cnt] = res;
    
}






int main(){
    
    string n; int k;
    cin >> n >> k;
    memset(dp, -1, sizeof(dp));
    int res = solve(n, 0, 1, 0, k);
    
    cout << res << endl;
    
}


Measured memory_bytes: 3644
N, M = map(int, raw_input().split())

s_flag = [True] * (N+1)

for m in xrange(M):
    a = int(raw_input())
    s_flag[a] = False

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if s_flag[1] else 0
for n in range(2, N+1):
    if s_flag[n]:
        dp[n] = (dp[n-1] + dp[n-2])% 1000000007

print dp[N]

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n,k;
	cin>>n>>k;
	int a[n],sum=0;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++)
		sum+=a[i];
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define lg long long
#define jxc 1000000007
int f[5005];
lg A(lg x,lg y){return (x+y)%jxc;}
lg D(lg x,lg y){return (x-y+jxc)%jxc;}
lg M(lg x,lg y){return 1ll*x*y%jxc;}
lg P(lg x,lg y){
	lg ans=1;
	for(;y;y>>=1,x=M(x,x))if(y&1)ans=M(ans,x);return ans;
}
int gf(int x){
	return f[x]==x?x:f[x]=gf(f[x]);
}
struct Node{
	int u,v;lg w;
}eg[10005];
int n,m;lg X;
bool operator<(Node A,Node B){
	return A.w<B.w;
}
int main(){
	scanf("%d%d%lld",&n,&m,&X);
	for(int i=1;i<=m;++i){
		scanf("%d%d%lld",&eg[i].u,&eg[i].v,&eg[i].w);
	}
	sort(eg+1,eg+m+1);
	lg B=0,S=0,E=0;
	for(int i=1;i<=m;++i){
		for(int j=1;j<=n;++j)f[j]=j;
		lg ans=eg[i].w;
		f[gf(eg[i].u)]=gf(eg[i].v);
		for(int j=1;j<=m;++j){
			if(i!=j){
				if(gf(eg[j].u)!=gf(eg[j].v)){
					f[gf(eg[j].u)]=gf(eg[j].v);
					ans+=eg[j].w;
				}
			}
		}
		if(ans<X)++S;
		if(ans>X)++B;
		if(ans==X)++E;
	}
	// cout<<E<<' '<<S<<endl;
	if(!E)return puts("0"),0;
	lg res=P(2,B),a=D(P(2,E),1);
	// cout<<res<<' '<<a<<' '<<S<<endl;
	if(S==0)a=D(a,1);else res=M(2,res);
	// cout<<res<<' '<<a<<endl;
	res=M(a,res);
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll sum=0;
  ll K;
  cin>>K;
  rep(i,K){
    rep(j,K){
      rep(l,K){
        sum+=gcd(i+1,gcd(j+1,l+1));
      }
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define N 310
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,w,h;
ll a[100500], b[100500];
ll min1[1005], max1[1005], val[1005];
ll minbl[1005][505], maxbl[1005][505], curbl0[1005][505], curblx[1005][505];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> x >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (i%2)
            b[i-1] = a[i-1] - a[i];
        else
            b[i-1] = a[i] - a[i-1];
    }
    for (i = 0; i < n; i++)
    {
        a[i] = a[i+1];
    }
    for (i = 0; i < 323; i++)
    {
        int cur = 0;
        int mn = MOD, mx = -MOD;
        for (j = i*N; j < i*N+N; j++)
        {
            cur += b[j];
            mn = min(mn, cur);
            mx = max(mx, cur);
            minbl[i][j-i*N] = mn;
            maxbl[i][j-i*N] = mx;
        }
        val[i] = cur;
        for (j = 0; j < N; j++)
        {
            int cr = 0;
            for (k = j+1; k < N; k++)
            {
                cr += b[k+i*N];
                cr = max(cr, 0);
                cr = min(cr, x);
            }
            curbl0[i][j] = cr;
            cr = x;
            for (k = j+1; k < N; k++)
            {
                cr += b[k+i*N];
                cr = max(cr, 0);
                cr = min(cr, x);
            }
            curblx[i][j] = cr;
        }
    }
    cin >> q;
    for (i = 0; i < q; i++)
    {
        int tim;
        scanf("%d %d",&tim,&z);
        for (j = 0; j < 323; j++)
        {
            if (j*N+N >= n || a[j*N+N-1] >= tim)
                break;
            int mn = minbl[j][N-1];
            int mx = maxbl[j][N-1];
            if (z + mn >= 0 && z + mx <= x)
            {
                z += val[j];
                continue;
            }
            ll l = 0, r = N-1;
            while (l < r)
            {
                ll mid = (l+r)/2;
                int mn = minbl[j][mid];
                int mx = maxbl[j][mid];
                if (z + mn < 0 || z + mx > x)
                    r = mid;
                else
                    l = mid+1;
            }
            mn = minbl[j][l];
            mx = maxbl[j][l];
            if (z + mn < 0)
                z = 0;
            else
            if (z + mx > x)
                z = x;
            if (z == 0)
            {
                z = curbl0[j][l];
            } else
                z = curblx[j][l];
        }
        int pos = j*N;
        while (tim > a[pos] && pos < n)
        {
            z += b[pos];
            z = max(z, 0);
            z = min(z, x);
            pos++;
        }
        int sign = (pos%2?1:-1);
        z += sign*(tim-a[pos-1]);
        z = max(z, 0);
        z = min(z, x);
        if (!sign)
            z = x-z;
        printf("%d\n", z);
    }
    return 0;
}


Measured memory_bytes: 8576
import scala.io.StdIn._

object Main extends App {


  val n = readInt()
  val S = Array.fill(n)(readLine())

  def solve() = {
    val strAndCntSeq = S.groupBy(identity).mapValues(_.length).toSeq.sortBy(- _._2)
    val maxCnt = strAndCntSeq.head._2
    strAndCntSeq.foldLeft(Seq.empty[String]) { case (acc, (str, cnt)) =>
      if(cnt == maxCnt) str +: acc else acc
    }.sorted.mkString("\n")
  }

  println(solve())

}



Measured memory_bytes: 163200
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int n;
		Boolean[][] card = new Boolean[4][13];
		for(int i=0;i<4;i++)
			for(int j=0;j<13;j++)
				card[i][j]=false;
		String suit;
		String[] Suits = {"S","H","C","D"};
		int value;
		
		
		Scanner scan = new Scanner(System.in);
		n=scan.nextInt();
		
		for(int i=0;i<n;i++){
			suit = scan.next();
			value = scan.nextInt();
			switch(suit){
				case "S":
					card[0][value-1]=true;
					break;
				case "H":
					card[1][value-1]=true;
					break;
				case "C":
					card[2][value-1]=true;
					break;
				case "D":
					card[3][value-1]=true;
					break;
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				if(card[i][j]==false){
					System.out.println(Suits[i] + " " + (j+1));
				}
			}
		}
		
		
	}

}


Measured memory_bytes: 26524
#include	<stdio.h>
int	main(void)
{
	int a,b,d,r;
	double f;
//	scanf("%d,%d",&a,&b);
	scanf("%d",&a);
	scanf("%d",&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
class UnionFind{
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;

    //作る時はParentの値を全て-1にする
    //こうするとずべてバラバラになる
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているのか調べる
    int root(int A){
      if(Parent[A]<0) return A;
      return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
      return -Parent[root(A)];//親を取ってきたい
    }

    //AとBをくっつける
    bool connect(int A,int B){
      //AとBを直すつつなぐのではなく、root(A)にroot(B)をくっつける)
      A = root(A);
      B = root(B);
      if(A==B){
        //すでにくっついているからくっつけない
        return false;
      }
      //大きい方(A)に小さい方(B)をくっつけたい
      //大小が逆だったらひっくり返しちゃう
      if(size(A)<size(B)) swap(A,B);

      //Aのサイズを更新する
      Parent[A] += Parent[B];
      //Bの親をAに変更する
      Parent[B] = A;

      return true;
    }
  };
  int main(){
    ll N,M;cin>>N>>M;
    vector<ll> A(M),B(M);
    ll i,j;
    rep(i,M){
      cin>>A[i]>>B[i];
      A[i]--;B[i]--;
    }
    vector<ll> ans(M);
    ans[M-1] = N*(N-1)/2;

    UnionFind Uni(N);

    for(i=M-1;i>=1;i--){
      ans[i-1] = ans[i];
      if(Uni.root(A[i]) != Uni.root(B[i])){
        ans[i-1] -= Uni.size(A[i]) * Uni.size(B[i]);
        Uni.connect(A[i],B[i]);
      }
    }
    rep(i,M) cout<<ans[i]<<endl;
  }


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

int main()
{
    int n,k;
    string s;
    cin>>n>>k>>s;
    int sum = 1;
    for(int i=0;i<s.length()-1;i++) if(s[i]!=s[i+1]) sum++;
    sum = max(1,sum-k*2);
    cout<<n-sum<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main {
  private static String[] TENKI = {"Sunny","Cloudy","Rainy"};
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String w = sc.next();
    if (w.equals("Sunny")) {
      System.out.println("Cloudy");
    } else if (w.equals("Cloudy")) {
      System.out.println("Rainy");
    } else if (w.equals("Rainy")) {
      System.out.println("Sunny");
    }
  }
}

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    ll A,B,C,D,tmp,tmp2;
    ll L,R,l,r;
    ll ans = 100000000;
    cin >> L >> R;

    if(R - L > 2019){
		cout << 0 << endl;
		return 0;
	}

    l = L % 2019;
    r = R % 2019;
    // r < lの場合は2019の倍数を含むので除去
    if(r <= l || l == 0 || r == 0){
		cout << 0 << endl;
		return 0;
	}
	else{
        for(ll i = l; i < r; i++){
            for(ll j = i+1; j <= r; j++){
                ans = min(ans, (i*j) % 2019);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <string.h>

using namespace std;

#define BUF_SIZE 1024

int count = 0;

void insertionSort(int array[],int n,int g){
	int v,j;
	for(int i = g;i < n; i++){
		v = array[i];
		j = i - g;
		while(j >= 0 && array[j] > v){
			array[j+g] = array[j];
			j = j - g;
			count++;
		}
		array[j+g] = v;
	}
}

void shellSort(int array[],int n){
	int m = 0;
	int s = 1;

	while((n/s) > 0){
		s *= 2;
		m++;	
	}

	int G[20];

	for(int k = 0,t = 1; k < m; k++){
		G[k] = n/t;
		t *= 2;
	}

	for(int i = 0; i < m;i++){
		insertionSort(array,n,G[i]);
	}

	printf("%d\n",m);
	for(int i = 0; i < m; i++){
		if(i != m-1){
			printf("%d ",G[i]);
		}else{
			printf("%d\n",G[i]);
		}
	}
	printf("%d\n",count);
	for(int i = 0; i < n; i++){
		printf("%d\n",array[i]);
	}

}

int main(int argc,char* argv[]){
	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[1000000];

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

	shellSort(array,n);

}


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

int main() {
    long long q, h, s, d, n;
    cin >>q >>h >>s >>d >>n;
    long long min1 = min({4*q,2*h,s});
    long long min2 = min({min1*2,d});

    long long ans = min2 * (n/2);
    ans += (n%2==0) ? 0 : min1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h,w,a,b=map(int,input().split())

s=[[0]*w for i in range(h)]
for i in range(a):
    for j in range(b):
        s[j][i]=1
for i in range(a,w):
    for j in range(b,h):
        s[j][i]=1
for i in range(h): 
    print(''.join(map(str, s[i])))

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

int main(){
    int64_t N, D;
    cin >> N >> D;
    vector<int64_t> X(N);
    vector<int64_t> Y(N);
    for(int64_t i=0;i<N;i++){
        cin >> X.at(i) >> Y.at(i);
    }

    int64_t count = 0;
    for(int64_t i=0;i<N;i++){
        if(X.at(i)*X.at(i) + Y.at(i)*Y.at(i) <= D*D) count++;
    }

    cout << count << endl;
    
    return 0;
}

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

using namespace std;

template <class T> inline T updmax(T& a, T b) { return a = max(a, b); }
template <class T> inline T updmin(T& a, T b) { return a = min(a, b); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; i++) { cout << i << " "; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    ll n, ans = 0;
    cin >> n;
    vector<ll> p(n), pos(n+1);
    for(int i=0;i<n;i++){
        cin >> p[i];
        pos[p[i]] = i;
    }
    set<ll> st;
    st.insert(n);
    st.insert(-1);
    st.insert(pos[n]);
    for(ll i=n-1;i>0;i--){
        ll l, r, ll, rr;
        l = *--st.lower_bound(pos[i]);
        if(l >= 0) ll = *--st.lower_bound(l);
        r = *st.lower_bound(pos[i]);
        if(r < n) rr = *st.upper_bound(r);
        if(l >= 0) ans += i * (l-ll) * (r-pos[i]);
        if(r < n) ans += i * (pos[i]-l) * (rr-r);
        st.insert(pos[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int cnt = 0;

    for(int i = 0; i < n; i++){
      int a = sc.nextInt();
      int b = sc.nextInt();
      cnt += b - a + 1;
    }

    System.out.println(cnt);
  }
}

/*
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/


Measured memory_bytes: 24660
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);
	int t = 0;
	for (int i = 0; i <= 100; ++i) {
		if (max(a, c) <= i && i < min(b, d)) {
			++t;
		}
	}
	printf("%d\n", t);
	return 0;
}

Measured memory_bytes: 128