akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N;cin >> N;
    vector<LL> a(N);
    rep(i,N)cin >> a[i];
    LL ans = INF;
    LL tmp = 0;
    for(LL i = -100;i <= 100;i++){
        tmp = 0;
        rep(j,N){
            LL t = 0;
            t = abs(i-a[j]);
            t *= t;
            tmp += t;
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vs = vector<string>;
using ii = vector<vector<long long>>;
int main() {
	string x;
	cin >> x;
	ll a;
	cin >> a;
	ll count = 0;
	char counta = 0;
	for (int i = 0; i < x.size(); i++) {
		if (x[i] == '1') {
			count++;
		}
		if (x[i] != '1') {
			counta = x[i];
			break;
		}
	}
	if (a <= count) {
		cout << 1 << endl;
	}
	else {
		cout << counta << endl;
	}
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>

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

int main() {
    long long n, d;
    cin >> n >> d;

    long long x, y;
    long long count = 0;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        if(sqrt(x*x + y*y) <= d) count++;
    }

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

Measured memory_bytes: 3160
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count = 0
  
for i in range(N):
  value = 0
  A = list(map(int, input().split()))
  for j in range(M):
    value += A[j]*B[j]
  
  value += C
  if value > 0:
    count += 1
  
  
print(count)

Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define all(x) x.begin(),x.end()
#define rep(i,N) for(int i=0;i<(int)N;++i)
using namespace std;
using ll = long long;
using vint = vector<int>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
const ll INF = (1LL << 30);
const ll LINF = (1LL << 60);
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
   return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b) {
   return a / gcd(a, b) * b;
}

struct Node {
   ll p, q;
   int r, b;
   ll w = 0;
};

Node node[101];
bool used[101];

ll dfs(int idx) {
   if (used[idx]) return node[idx].w;
   ll x = 1, y = 1;
   if (node[idx].b != -1) y = dfs(node[idx].b);
   if (node[idx].r != -1) x = dfs(node[idx].r);

   ll L = lcm(x * node[idx].p, y * node[idx].q);
   node[idx].w = L / node[idx].p + L / node[idx].q;

   used[idx] = true;
   return node[idx].w;
}

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

   while (true) {
      int n; cin >> n;
      if (n == 0) break;
      rep(i, n) used[i] = false;
      rep(i, n) {
         ll p, q;
         int r, b;
         cin >> p >> q >> r >> b;
         r--, b--;
         ll g = gcd(p, q);
         p /= g, q /= g;
         node[i] = Node{ p, q, r, b };
      }

      ll ans = 0;
      rep(i, n) {
         ans = max(ans, dfs(i));
      }

      cout << ans << endl;
   }
}


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

int main(void)
{
    long long n, ans = 0;
    cin >> n;
    vector<string> s(n);
    map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++)
    {
        m[s[i]]++;
        //cout << s[i] << " " << m[s[i]] << endl;
        if (m[s[i]] > 1)
            ans += m[s[i]] - 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13568
#include <cstdio>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    if(a == b && a == c && b == c)
    {
        printf("1");
    }
    else if((a == b && a != c) || (b == c && b != a) || (a == c && a != b))
    {
        printf("2");
    }
    else
    {
        printf("3");
    }
    
    
}

Measured memory_bytes: 1656
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int abs(int x){return x>0?x:-x;}
void mins(int &a,int b){if(a>b)a=b;}
void maxs(int &a,int b){if(a<b)a=b;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=500010;

int n,f[maxn][3],s[maxn],ans=0,b[maxn],tot,suml[maxn],sumr[maxn];
char ss[maxn];
int main(){
    n=read();
    scanf("%s",ss+1);
    for(int i=1;i<=n;i++)s[i]=ss[i]-'0';
    int num=0;
    for(int i=1;i<=n;i++)if(s[i]==0)b[i]=++tot;
    for(int i=1;i<=n;i++){
    	if(s[i]==0){suml[b[i]]=num;num=0;}
    	else num++;
    }
    num=0;
    for(int i=n;i>=1;i--){
    	if(s[i]==0){sumr[b[i]]=num;num=0;}
    	else num++;
    }
    memset(f,-30,sizeof(f));
    f[0][0]=0;
    int ans=0;
    for(int i=1;i<=tot;i++){
    	f[i][0]=max(f[i-1][0],max(f[i-1][1],f[i-1][2]));
    	if(suml[i]&&sumr[i])f[i][1]=max(f[i-1][0]+suml[i],suml[i]>=1?f[i-1][1]+suml[i]-1:-inf);
    	if(suml[i]&&sumr[i])f[i][2]=max(max(f[i-1][0]+sumr[i],suml[i]>=2?f[i-1][1]+sumr[i]:0),f[i-1][2]+sumr[i]-1);
    	ans=max(f[i][0],max(f[i][1],f[i][2]));
    }
    //or(int i=1;i<=tot;i++)for(int j=0;j<=2;j++)printf("f[%d][%d]=%d\n",i,j,f[i][j]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 14336
s = input()
t = input()
# print(t[:-1])

answer = False
answer1 = len(t) == len(s) + 1
answer2 = t[:-1] == s
answer = answer1 and answer2
# print(answer1)
# print(answer2)
# print(answer)

if answer:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 8916
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string.h>
#include<vector>
#include<algorithm>
#define ll long long
#define maxn 210000
using namespace std;
vector<ll>q[2];
ll x[maxn],y[maxn];
ll bit[100];
int n;

ll solve()
{
    ll ans=0;
    for(ll i=0;i<62;i++)
    {
        ll tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(x[j]>>i)&1].push_back(x[j]);
        for(ll j=0;j<q[0].size();j++)
            x[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            x[++tot]=q[1][j];
        tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(y[j]>>i)&1].push_back(y[j]);
        for(ll j=0;j<q[0].size();j++)
            y[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            y[++tot]=q[1][j];
        ll len1=1,len2=1,len3=1;
        ll limit1=1ll<<i;
        ll limit2=1ll<<(i+1);
        ll all=(1ll<<(i+1))-1;
        ll sum=0;
        for(ll i=n;i>=1;i--)
        {
            while((((x[i]&all)+(y[len1]&all))<limit1) && (len1<=n)) len1++;
            while((((x[i]&all)+(y[len2]&all))<limit2) && (len2<=n)) len2++;
            while(((x[i]&all)+(y[len3]&all)<limit1+limit2) && (len3<=n)) len3++;
            sum+=n-(len1-1-len2+1+len3-1);
        }
        if(sum&1) ans+=bit[i];
    }
    return ans;
}

int main()
{
    bit[0]=1;
    for(ll i=1;i<=61;i++)
    bit[i]=bit[i-1]*2;
        scanf("%I64d",&n);
        for(ll i=1;i<=n;i++)
            scanf("%I64d",&x[i]);
        for(ll i=1;i<=n;i++)
            scanf("%I64d",&y[i]);
       printf("%I64d\n",solve()) ;
}

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

long long n, k, w[100005];

bool cal(long long x){
	long long sum = 0;
	long long cnt = 0;
	
	for(long long i = 0 ; i < n ; i++){
		if(w[i] > x) return 0;
		if(sum + w[i] > x){
			sum = 0;
			cnt++;
		}
		sum += w[i];
	}
	if(cnt < k) return 1;
	else return 0;
}

int main(){
	cin >> n >> k;
	for(long long i = 0 ; i < n ; i++){
		cin >> w[i];
	}
	
	long long l = 0, r = 1000000000, mid;
	
	for(int i = 0 ; i < 1000 ; i++){
		mid = (l + r) / 2;
		if(cal(mid)) r = mid;
		else l = mid;
	}
	
	cout << r << endl;
	
	return 0;
}

Measured memory_bytes: 1940
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
using namespace std;
int main() {
	int n;
	int kizi_cal,kizi_money,topping_money;
	int topping[101] = { 0 };
	int cal[101] = { 0 };
	int percal[101] = { 0 };
	scanf("%d%d%d%d", &n, &kizi_money, &topping_money,&kizi_cal);
	for (int i = 1;i <= n;++i) scanf("%d", &topping[i]);
	sort(topping, topping + 101, greater<int>());
	for (int i = 1;i <= n;++i) {
		cal[i] = cal[i - 1] + topping[i-1];
	}
	for (int i = 1;i <= n;++i) {
		percal[i] = (cal[i] + kizi_cal) / ((topping_money * i) + kizi_money);
	}
	sort(percal, percal + 101, greater<int>());
	printf("%d\n", percal[0]);
}


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

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int gcd(int x, int y){
  if (y == 0){
    return x;
  } else {
    return gcd(y, x % y);
  }
}

static const int MAXP = 1000000;
vector<int> ps, fs;
void init(){
  fs.reserve(1 + MAXP);
  for(int i = 0; i <= MAXP; i++){fs.push_back(i);}
  for(int i = 2; i <= MAXP; i++){
    if (fs[i] == i){
      ps.push_back(i);
      for (int j = i; j <= MAXP; j += i){
        fs[j] = min(fs[j], i);
      }
    }
  }
}
bool isprime(const long long& n){
  if (n <= MAXP){
    return (1 < n && fs[n] == n);
  } else {
    for(int p: ps){
      if (n % p == 0){return false;}
    }
    return true;
  }
} 
vector<pair<int, int>> factor(int n){
  vector<pair<int, int>> v;
  int i = n;
  if (MAXP < i){
    for(int p: ps){
      int r = 0;
      while (i % p == 0){r++; i /= p;}
      if (0 < r){v.push_back(make_pair(p, r));}
      if (i <= MAXP){break;}
    }
    if (MAXP < i){
      v.push_back(make_pair(i, 1));
      i = 1;
    }
  }
  while(1 < i){
    if (v.empty() || (*v.rbegin()).first != fs[i]){
      v.push_back(make_pair(fs[i], 1));
    } else {
      (*v.rbegin()).second++;
    }
    i /= fs[i];
  }
  return v;
}

int main(){
  init();
  map<int, int> mp;
  INT(n); VI(as, n);
  int d = as[0], cnt = 1;
  for(int a: as){
    d = gcd(d, a);
    for(auto p: factor(a)){
      mp[p.first]++;
    }
  }
  for(auto p: mp){cnt = max(cnt, p.second);}
  if (cnt == 1){
    printf("pairwise coprime\n");
  } else if (d == 1){
    printf("setwise coprime\n");
  } else {
    printf("not coprime\n");
  }
  return 0;
}

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

int main(){
	int n,ans=0;
	cin >> n;
	int x[n],y[n];
	for(int i = 0 ; i < n ; i += 1){
		cin >> x[i];
	}
	for(int i = 0 ; i < n ; i += 1){
		cin >> y[i];
	}
	for(int i = 0 ; i < (1 << n) ; i += 1){
		int v1=0,v2=0;
		for(int j = 0 ; j < n ; j += 1){
			if(i & (1 << j)){
				v1 += x[j];
				v2 += y[j];
			}
		}
		ans = max(ans , v1-v2);
	}
	cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Linq;
 
class ITP1
{
    static void Main()
    {
        int[] x = new int[8];
        string str = Console.ReadLine();
        for (int i = 0; i < 6; i++)
        {
            x[i + 1] = int.Parse(str.Split()[i]);
        }
        int a = int.Parse(Console.ReadLine());
        int[] y = new int[a];
        for (int i = 0; i < a; i++)
        {
            string str2 = Console.ReadLine();
            int b = int.Parse(str2.Split()[0]);
            int c = int.Parse(str2.Split()[1]);
 
            if (b == x[1])
            {
                if (c == x[2]) y[i] = x[3];
                if (c == x[3]) y[i] = x[5];
                if (c == x[5]) y[i] = x[4];
                if (c == x[4]) y[i] = x[2];
            }
            if (b == x[2])
            {
                if (c == x[3]) y[i] = x[1];
                if (c == x[1]) y[i] = x[4];
                if (c == x[4]) y[i] = x[6];
                if (c == x[6]) y[i] = x[3];
            }
            if (b == x[3])
            {
                if (c == x[2]) y[i] = x[6];
                if (c == x[6]) y[i] = x[5];
                if (c == x[5]) y[i] = x[1];
                if (c == x[1]) y[i] = x[2];
            }
            if (b == x[4])
            {
                if (c == x[2]) y[i] = x[1];
                if (c == x[1]) y[i] = x[5];
                if (c == x[5]) y[i] = x[6];
                if (c == x[6]) y[i] = x[2];
            }
            if (b == x[5])
            {
                if (c == x[1]) y[i] = x[3];
                if (c == x[3]) y[i] = x[6];
                if (c == x[6]) y[i] = x[4];
                if (c == x[4]) y[i] = x[1];
            }
            if (b == x[6])
            {
                if (c == x[5]) y[i] = x[3];
                if (c == x[3]) y[i] = x[2];
                if (c == x[2]) y[i] = x[4];
                if (c == x[4]) y[i] = x[5];
            }
        }
        for (int i = 0; i < a; i++)
        {
            Console.WriteLine(y[i]);
        }
    }
}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
string a[101];
int n,l;
int main(){
    scanf("%d%d",&n,&l);
    for(register int i=0;i<n;++i)
        cin>>a[i];
    sort(a,a+n);
    for(register int i=0;i<n;++i)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
def c_poll():
    from collections import Counter
    N = int(input())
    S = [input() for _ in range(N)]

    vote = Counter(S)
    most = (vote.most_common(1))[0][1]
    ans = [k for k, v in vote.items() if v == most]
    return '\n'.join(map(str, sorted(ans)))

print(c_poll())

Measured memory_bytes: 35564
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
    }
    else if(h % 2 != 0 && w % 2 != 0){
        cout << (w * h + 1) / 2 << endl;
    }
    else{
        cout << w * h / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll a[200005];

int main(int argc, char** argv) {
	int h,n;
	scanf("%d%d",&n,&h);
	int sum=0;
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	ll ans=0;
	for(int i=n-h;i>=1;i--)
	{
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut mat = vec![vec![0 as i64; n]; n];
    for y in 0..n {
        for x in 0..n {
            mat[y][x] = read();
        }
    }
    let mut min_dists = mat.clone();
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                min_dists[i][j] = std::cmp::min(min_dists[i][j], min_dists[i][k] + min_dists[k][j]);
            }
        }
    }
    if mat != min_dists {
        println!("-1");
        return;
    }
    let mut ans = 0;
    for i in 0..n {
        'edge_to: for j in i + 1..n {
            for k in 0..n {
                if k == i || k == j {
                    continue;
                }
                if min_dists[i][j] == min_dists[i][k] + min_dists[k][j] {
                    continue 'edge_to;
                }
            }
            ans += min_dists[i][j];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int r, d, x;
  cin >> r >> d >> x;
  for(int i = 0; i < 10; i++){
    x = r * x - d;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner input = new Scanner(System.in);
       
        int N = input.nextInt();
        int sum = 0;
        for(int i = 1; i <=N; i++)
            sum += i;
            
            System.out.println(sum); 
    }
}

Measured memory_bytes: 26976
N = int(input())
a = list(map(int, input().split(" ")))

B = [y - x - 1 for x, y in enumerate(a)]
B_s = sorted(B)

# if odd 
if N % 2 == 1 :  
    median = [B_s[int(N / 2)]]
else :
    median = [B_s[int(N / 2)], B_s[int(N / 2) + 1]]

min_sum = None 

for m in median :
    sum_over = 0
    
    for i, j in enumerate(a) :
        sum_over += abs(j - (m + i + 1))

    if min_sum == None or sum_over < min_sum :
        min_sum = sum_over
        
print(min_sum)

Measured memory_bytes: 25744
#include <bits/stdc++.h>
using namespace std;
long long int dp[1000][1000];
int H,W;
long int m = pow(10,9) + 7;
long long int ways(char point[1000][1000],int h,int w)
{
    if ( dp[h][w] != -1)
    return dp[h][w]%m;
    else
    {
        if ( h == H-1  )
        {
          if(w == W-1)
          return 1;
          else
          {
              if (point[h][w+1] != '.')
              {   dp[h][w] = 0;

              }
              else
              dp[h][w] = ways(point,h,w+1)%m;

          }
        }
        else if ( w == W-1  )
        {
          if(h == H-1)
          return dp[h][w]%m;
          else
          {
              if (point[h+1][w] != '.')
              {   dp[h][w] = 0;

              }
              else
              dp[h][w] = ways(point,h+1,w)%m;

          }
        }
        else
        {
             if (point[h+1][w] != '.')
             {
                  if ( point[h][w+1] != '.')
                  dp[h][w] = 0;
                  else
                  dp[h][w] = ways(point,h,w+1)%m;

             }
             else

              {
                  if ( point[h][w+1] != '.')
                  dp[h][w] = ways(point,h+1,w)%m;
                  else
                  dp[h][w] = (ways(point,h,w+1)%m+ ways(point,h+1,w)%m)%m;
              }
        }
    }
    return dp[h][w]%m;
}
int main()
{

    cin >> H >> W;
    char point[1000][1000];
    for (int i =0;i<H;i++)
    {

        for (int j=0;j<W;j++)
            cin >> point[i][j];
    }
    memset(dp,-1,sizeof(dp));
    cout << ways(point,0,0) << endl;
    return 0;
}


Measured memory_bytes: 9088
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    println(if (a + b ==c || b + c == a || a + c == b) "Yes" else "No")
}


Measured memory_bytes: 31264
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll a,b,k;
cin>>a>>b>>k;
for(int i=a;i<min(a+k,b+1);i++){
    cout<<i<<endl;
}
for(int i=max(b-k+1,a);i<=b;i++){
    if(i>=a+k){
    cout<<i<<endl;
    }
}
}












Measured memory_bytes: 256
S = input()
ans = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == '<':
        ans[i + 1] = ans[i] + 1

for i in range(len(S) - 1, -1, -1):
    if S[i] == '>':
        ans[i] = max(ans[i + 1] + 1, ans[i])
print(sum(ans))


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

int n, s[200005];

signed main(){
  
  cin>>n;
  
  vector<int> div;

  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      div.push_back(i);
      if(i*i!=n) div.push_back(n/i);
    }
  }

  sort(div.begin(), div.end());
  
  for(int i=0;i<n;i++) cin>>s[i];
  
  for(int i=0;i<div.size();i++){
    
    int flag=1;
    int l=div[i];

    for(int i=0;i<n;i++)
      
      if(s[i]!=s[i%l]) flag=0;
    
    if(flag){
      cout<<n/l<<endl;
      return 0;
    }
  }
  
  return 0;
}




Measured memory_bytes: 4728
N = int(input())
s = list(map(int, input().split()))

#print(s)

count = 0
odd = 0

min1 = abs(s[0])
#print(min1)
for i in range(N):
  min1 = min(min1, abs(s[i]))
  count += abs(s[i])
  if abs(s[i]) != s[i]:
    odd += 1

count2 = count - 2*min1

if odd%2 == 1:
  print(count2)
else:
  print(count)
  

Measured memory_bytes: 14412
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	    
}


vector<int> adj[100500];
vector<bool> vis(100500);
vector<int> d(100500);
queue<int> q ;



void bfs(int v)
{
	q.push(v);
	vis[v]=true;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(auto u : adj[x])
		{
			if(!vis[u])
			{
				vis[u]=true;
				q.push(u);
				d[u] = d[v] + 1;
			}
		}
	}
}
void dfs(int v)
{
	vis[v]=true;
	for(auto u : adj[v])
	{
		if(!vis[u])
			dfs(u);
	}
}

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

	vector< pair<int,int> > ar ;

	for(int i=0 ; i<n ; ++i)
	{
		int a,b;
		cin>>a>>b;
		ar.push_back(make_pair(a,b));
	}
	bool ans=false ;

	for(int i=2 ; i<n ; ++i)
	{
		if(ar[i].first==ar[i].second && ar[i-1].first==ar[i-1].second && ar[i-2].first==ar[i-2].second )
		{
			ans=true;
			break;
		}
	}
	if(ans)
		cout<<"Yes";
	else
		cout<<"No";
}

int32_t main()
{ 
	inputoutput() ;
	solve();


	return 0;
}


Measured memory_bytes: 6040
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int sum = 0;
    int max = 0;
    for (int i=0; i<N; i++) {
      int a = sc.nextInt();
      max = Math.max(max, a);
      sum += a;
    }

    sum -= max / 2;

    System.out.println(sum);

  }
}

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

int d, s, t;

int main() {
  cin >> d >> s >> t;
  cout << (d <= s*t ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
inline ll read()  
{  
    bool f=0;ll x=0;char ch=getchar();  
    while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}  
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}  
    return f?-x:x;  
}  
inline void write(ll x)     
{     
    if(x<0)x=-x,putchar('-');     
    if(x>9)write(x/10);     
    putchar(x%10+48);     
}
ll n,p,tmp,a[51],c[51][51],ans1,ans2;
int num_of_ji,num_of_ou,sum;
int main(int argc,const char *argv[])
{
	n=read();
	p=read();
	for(int i=1;i<=n;i++)
	{
		tmp=read();sum+=tmp;
		if(tmp&1)num_of_ji++;
		else num_of_ou++;
	}
	c[0][0]=c[1][0]=c[1][1]=1;
	for(int i=2;i<=n;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	if((sum&1)==p)
		for(int i=0;i<=num_of_ji;i+=2)ans1+=c[num_of_ji][i];
	else for(int i=1;i<=num_of_ji;i+=2)ans1+=c[num_of_ji][i];
	for(int i=0;i<=num_of_ou;i++)ans2+=c[num_of_ou][i];
	write(ans1*ans2);
	return 0;
}

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

int main() {
    int x, y;
    for (int i = 0; i < 3000; i++) {
        cin >> x >> y;
        
        if (x == 0 && y == 0) break;
        
        if (x < y)
            cout << x << ' ' << y << endl;
        else
            cout << y << ' ' << x << endl;
    }
}


Measured memory_bytes: 2996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n;
    cin>>n;
    string s;
    map<std::string,int>mp;
    for(int i=0;i<n;i++){
        cin>>s;
    mp[s]+=1;
    }
    int max=0;
    int value[mp.size()+1];
    vector<string>key(mp.size());
    auto begin = mp.begin(), end = mp.end();
    int i=0;
    for (auto iter = begin; iter != end; iter++) {
        // first: key, second: value
        value[i]=iter->second;
        key[i]=iter->first;
        i++;
    }
    rep(i,mp.size()){
        if(max<value[i]){
            max=value[i];
        }
    }
    rep(i,mp.size()){
        if(value[i]==max){
            cout<<key[i]<<endl;
        }
    }
}

Measured memory_bytes: 27520
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define INF 11451419191810
using namespace std;

int main(){

	ll n, t; cin >> n >> t;
	ll t_t = t;
	ll ans = 0;
	ll kaku = 0;
	ll prev = 0;
	rep(i, n){
		ll temp; cin >> temp;
		kaku = temp - prev;
		//cout << i << " " << kaku << endl;
		if (kaku >= t) ans += t;
		else ans += kaku;
		prev = temp;
		//cout << "ans=" << ans << endl;
	}cout << ans+t << endl;

	return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

int h,w;
vs board;
vvi dist;

int bfs()
{
  queue<pii> que;
  rep(i,h)
  {
    vi tmp;
    rep(j,w) tmp.pb(INF);
    dist.pb(tmp);
  } 
  que.push(pii(0,0));
  dist[0][0]=0;
  while(!que.empty())
  {
    pii p=que.front(); que.pop();
    if(p.Fi==w-1&&p.Se==h-1) break;
    rep(i,4)
    {
      int nx=p.Se+dx[i], ny=p.Fi+dy[i];
      if(0<=nx&&nx<w&&0<=ny&&ny<h&&board[ny][nx]!='#'&&dist[ny][nx]==INF)
      {
        que.push(pii(ny,nx));
        dist[ny][nx]=dist[p.Fi][p.Se]+1;
      }
    }
  }
  return dist[h-1][w-1];
}

signed main() 
{
  cin>>h>>w;
  rep(i,h)
  {
    string s; cin>>s;
    board.pb(s);
  }
  int cnt=0;
  rep(i,h) rep(j,w)
  {
    if(board[i][j]=='#') cnt++;
  }
  int sum=h*w-cnt-bfs()-1;
  bfs()==INF?print(-1):print(sum);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    ll N, K; cin >> N >> K;
    vector<int> A(N), F(N); cin >> A >> F;
    sort(A.begin(), A.end(), greater<int>());
    sort(F.begin(), F.end());
    vector<ll> AxF(N); for (int i = 0; i < N; i++) AxF[i] = (ll)A[i] * F[i];

    ll l = -1, r = (ll)A.front() * F.back(), c, k;
    while (r - l > 1) {
        c = l + (r - l) / 2;
        k = K;
        for (int i = 0; i < N; i++) {
            ll d = AxF[i] - c;
            if (d > 0) {
                k -= (d + F[i] -1) / F[i];
                if (k < 0) break;
            }
        }
        if (k >= 0) {
            r = c;
        } else {
            l = c;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 3456
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N, M, X = ri_()
C = [0] * N
A = []
for i in range(N):
    tmp = ri_()
    C[i] = tmp[0]
    A.append(tmp[1:])
ans = 10 ** 8
for bit in range(2 ** N):
    d = [0] * M
    cost = 0
    for i in range(N):
        if ((bit & (1 << i))):
            cost += C[i]
            for j in range(M):
                d[j] += A[i][j]
    f = 1
    for j in range(M):
        if d[j] < X:
            f = 0
    if f:
        ans = min(ans, cost)
if ans == 10**8:
    ans = -1
print(ans)

Measured memory_bytes: 79184
#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>;
const int MAX = 200000;

bool is_prime(ll y){
    for (ll i = 2; i * i <= y; i++)
    {
        if (y % i == 0)
        {
            return false;
        }
        
    }
    return true;
}

int main() {
    ll X;
    cin >> X;
    
    for (ll i = X; ; i++)
    {
        if (is_prime(i))
        {
            cout << i << endl;
            return 0;
        }
        
    } 
  return 0;
}


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

using namespace std;

class node{
public:
	int id;
	node* left, * right;
	node*  parent;
	int sibling;
	int depth;
	int height;
};

bool operator<=(node a, node b) {
	return a.id <= b.id;
}
bool operator<(node a, node b) {
	return a.id < b.id;
}

bool operator==(node a, node b) {
	return a.id == b.id;
}

bool operator!=(node a, node b) {
	return a.id != b.id;
}

void add(node** root,int a) {
	node *newnode = new node;
	node* now = *root;
	newnode->id = a;
	newnode->left = NULL;
	newnode->right = NULL;
	if (now == NULL) {
		newnode->parent = NULL;
		*root = newnode;
		return;
	}
	while (1) {
		if (now->id > a) {
			if (now->left == NULL) {
				now->left = newnode;
				newnode->parent = now;
				return;
			}
			else {
				now = now->left;
			}
		}
		else {
			if (now->right == NULL) {
				now->right = newnode;
				newnode->parent = now;
				return;
			}
			else {
				now = now->right;
			}
		}
	}
}


string postorder(node* nod) {
	string msg="";
	if (nod->left->id != -1) {
		msg += postorder(nod->left);	
	}
	if (nod->right->id != -1) {
		msg += postorder(nod->right);	
	}
	msg += to_string(nod->id) + " ";
	return msg;
}

void preorder(node* root) {
	if (root == NULL)return;
	cout << " "<<root->id;
	preorder(root->left);
	preorder(root->right);
}

void inorder(node* root) {
	if (root == NULL)return;
	inorder(root->left);
	cout <<" "<< root->id;
	inorder(root->right);
}

bool find(node* root,int a) {
	if (root == NULL)return false;
	if (root->id == a)return true;
	if (root->id > a)return find(root->left, a);
	if (root->id < a)return find(root->right, a);
}



int main() {
	int n,tmp;
	string msg;
	cin >> n;
	node* root = NULL;
	for (int i = 0;i < n;i++) {
		cin >> msg;
		if (msg == "insert") {
			cin >> tmp;
			add(&root, tmp);
		}
		else if (msg == "print") {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else {
			cin >> tmp;
			if (find(root, tmp))cout << "yes\n";
			else cout << "no\n";
		}
	}
}






Measured memory_bytes: 28160
#include <stdio.h>

int n, m;
int p[64][1024];

int main(void) {
	while (scanf("%d%d", &n, &m) == 2 && (n|m) != 0) {
		int i, j;
		int gotiusa = 0, kinmoza;
		for (i = 0; i < m; i++) {
			for (j = 0; j < n; j++) {
				if (scanf("%d", &p[i][j]) != 1) return 1;
			}
		}
		for (i = 0; i < n; i++) {
			kinmoza = 0;
			for (j = 0; j < m; j++) {
				kinmoza += p[j][i];
			}
			if (kinmoza > gotiusa) gotiusa = kinmoza;
		}
		printf("%d\n", gotiusa);
	}
	return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,a=0,b=0,c=0,d=0,i;
  string s;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>s;
    if(s=="AC") a++;
    else if(s=="WA") b++;
    else if(s=="TLE") c++;
    else if(s=="RE") d++;
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}

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

lli n, p;

lli mypow(lli a, lli x){
	lli ret = 1;
	lli b = a;
	while(x > 0){
		if(x&1){
			ret*=a;
		}
		a*=a;
		x >>= 1;
	}
	return ret;
}

int main(void){
	cin >> n >> p;
	lli c, d;
	c = d = 0;
	rep(i, n){
		lli a;
		cin >> a;
		if(a&1) d++;
		else c++;
	}
	if(p == 1 && d == 0){
		cout << 0 << endl;
		return 0;
	}
	if(p == 0) cout << mypow(2, c)*mypow(2, d-1) << endl;
	else cout << mypow(2, c-1)*mypow(2, d) << endl;

	return 0;
}


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

namespace ConsoleApp44 {
    class Program {
        static void Main(string[] args) {
            string[] s = Console.ReadLine().Split(',').ToArray();

            Console.WriteLine(string.Join(" ", s));
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a; string s;
    cin >> a >> s;
    a < 3200 ? cout << "red" << endl : cout << s << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int house[4][3][10]={};int n,b,f,r,v;int count=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        house[b-1][f-1][r-1]+=v;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " " << house[i][j][k];
            }
            cout << endl;
        }
        if(count<3){
                cout << "####################" << endl;count++;
        }
    }
}



Measured memory_bytes: 3104
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy/MM/dd");
        Date date1 = sdFormat.parse(S);
        Date date2 = sdFormat.parse("2019/04/30");
        
        String ans = "Heisei";
        if( date2.compareTo(date1) == -1 ) ans = "TBD";
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 22096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,k;
  cin >> n >> k;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];
  int itrzero = lower_bound(all(x), 0) - x.begin();
  if (itrzero == 0) { //x < 0無し
    cout << x[k-1] << endl;
    return 0;
  }
  int left = 0, right = k-1;
  ll ans = 1LL<<60;
  while (right < n) {
    if (x[right] <= 0) chmin(ans, -x[left]);
    else if (x[left] >= 0) chmin(ans, x[right]);
    else {
      chmin(ans, -2*x[left]+x[right]); //左に行って右に行く
      chmin(ans, -x[left]+2*x[right]); //右に行って左にいく
    }
    left++; right++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

void sort(int l[], int n)
{
    for (int i = 0; i < n - 1; i++){
        for (int j = n - 1; j > i; j--){
            if (l[j] > l[j - 1]){
                int temp = l[j];
                l[j] = l[j - 1];
                l[j - 1] = temp;
            }
        }
    }
}

#include <stdio.h>

int count(int l[], int m1, int m2, int d)
{
    int p1 = m1, p2 = m2;
    while (p1 < p2){
        int c = (p2 + p1) / 2;
        if (l[c] > d){
            if (c == m2){
                return m2 - m1 + 1;
            }
            if (l[c + 1] > d){
                p1 = c + 1;
            }else{
                return c - m1 + 1;
            }
        }else{
            if (c == m1) return 0;
            p2 = c - 1;
        }
    }
    if (l[p1] > d){
        return p1 - m1 + 1;
    }else{
        return 0;
    }
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int l[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &l[i]);
    }
    sort(l, n);
    int ans = 0;
    for (int i = 0; i < n - 2; i++){
        for (int j = i + 1; j < n - 1; j++){
            ans += count(l, j + 1, n - 1, l[i] - l[j]);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	static double dp[][][];
	static int n, a;
	static double r[];

	public static double f(int left, int right, int bit) {
		if (0 < dp[left][right][bit]) {
			return dp[left][right][bit];
		}
		int k = check(bit);
		if (k == 1) {
			return dp[left][right][bit] = 2.0 * r[left];
		}
		if (k == 2) {
			return dp[left][right][bit] = r[left] + r[right] + 2.0 * Math.sqrt(r[left] * r[right]);
		}

		double min = Double.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			if (i == left || i == right || (bit & (1 << i)) == 0) {
				continue;
			}
			for (int j = 0; j < n; j++) {
				if (j == left || j == right || (bit & (1 << j)) == 0) {
					continue;
				}
				if (3 < k && i == j) {
					continue;
				}
				double sub = f(i, j, (bit ^ (1 << left)) ^ (1 << right));
				sub -= r[i] + r[j];
				sub += 2.0 * (Math.sqrt(r[left] * r[i]) + Math.sqrt(r[right] * r[j]));
				sub += r[left] + r[right];
				min = Math.min(min, sub);
			}
		}
		return dp[left][right][bit] = min;
	}

	public static int check(int bit) {
		int count = 0;

		for (int i = 0; i < 12; i++) {
			if (0 < (bit & (1 << i))) {
				count++;
			}
		}
		return count;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			String b[] = sc.nextLine().split(" ");
			a = Integer.parseInt(b[0]);
			n = b.length - 1;
			r = new double[n];
			dp = new double[n][n][1 << n];
			for (int i = 0; i < n; i++) {
				r[i] = Integer.parseInt(b[i + 1]);
			}
			double min = Double.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (n == 1 || i != j) {
						min = Math.min(min, f(i, j, (1 << n) - 1));
					}
				}
			}
			System.out.println(min <= a ? "OK" : "NA");
		}
	}
}

Measured memory_bytes: 62900
H = int(input())
H_start = H
cnt = 0
cnt_odd = 0
while H > 0:
  if H % 2 == 1:
    H -= 1

    cnt_odd += 1*2**cnt
  H = int(H/2)
  cnt += 1
print(2**cnt+H_start-cnt_odd-1)
  

Measured memory_bytes: 2940
INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

n,a,b = read_ints()
if (b-a)%2 == 1:
    print "Borys"
else:
    print "Alice"


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

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

  int b[n+1];
  int w[n+1];
  rep(i, n+1){
    b[i]=0;
    w[i]=0;
  }
  b[0]=0;
  w[0]=0;
  
  
  
  for(int i=1;i<=n;i++){
    if(s[i-1]=='#'){
        b[i]=b[i-1]+1;
    w[i]=w[i-1];}
    
    
    else{
        w[i]=w[i-1]+1;
    b[i]=b[i-1];}
    }

  
  int bc=b[n];
  int wc=w[n];
  
  int minc=10000000;
  rep(i, n+1){
    minc=min(i-w[i]+(n-i)-(bc-b[i]),minc);
  }
  
  cout<<minc<<endl;

}



Measured memory_bytes: 2180
n, m = map(int, input().split())
x = [None for _ in range(n)]
flag = True
for i in range(m):
    s, c = map(int, input().split())
    if x[s - 1] is None:
        x[s - 1] = c
    elif x[s - 1] != c:
        flag = False

if flag:
    ans = None
    start = 0 if n == 1 else 10 ** (n - 1)
    for k in range(start, 10 ** n):
        for ki, xi in zip(str(k), x):
            if xi is None:
                continue
            elif ki != str(xi):
                break
        else:
            ans = k
            break
    if ans is None:
        print(-1)
    else:
        print(ans)
else:
    print(-1)


Measured memory_bytes: 3064