akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
using vt = vector<T>;

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; }



int main() {
  int k;
  cin >> k;
  int ans = 0;
  FORe(i, 1, k) {
    FORe(j, 1, k) {
      int tmp = gcd(i, j);
      FORe(h, 1, k) {
        ans += gcd(tmp, h);
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3672
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<map>
#include<algorithm>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<string>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define For(i,N) for(ll i=0;i<N;i++)
int main()
{
    ll N;
    ll D;
    cin >> N >> D;
    ll s = 2 * D + 1;
    ll ans = N / s;
    if (N % s == 0)cout << ans;
    else cout << ans + 1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,j,sum=0,x,r;
	map<int, int>m;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		sum+=x;
		m[x]++;
	}
	long long int q,b,c;
	cin>>q;
	for(i=0;i<q;i++)
	{
		cin>>b>>c;
		r=c-b;
		sum=sum+m[b]*r;
		m[c]=m[c]+m[b];
		m[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 7996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N;
            int A[] = new int[20];
            int x[][] = new int[20][20];
            int y[][] = new int[20][20];

            N = in.nextInt();

            for (int i = 1; i <= N; i++)
            {
                A[i] = in.nextInt();
                for (int j = 1; j <= A[i]; j++)
                {
                    x[i][j] = in.nextInt();
                    y[i][j] = in.nextInt();
                }
            }
            int ans = 0;
            for (int bits = 1; bits < (1 << N); bits++)
            {
                boolean ok = true;
                for (int i = 1; i <= N; i++)
                {
                    if ((bits & (1 << (i - 1))) == 0) continue;
                    for (int j = 1; j <= A[i]; j++)
                    {
                        if ((((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) > 0) ok = false;
                    }
                }
                if (ok) ans = Math.max(ans, counter(bits));
            }
            out.print(ans);
        }

        int counter(int x)
        {
            if (x == 0) return 0;
            return counter(x >> 1) + (x & 1);
        }

    }
}



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

typedef long long ll;


#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int N,M; cin >> N >> M;
    vector<pair<int,int>> G(M);
    REP(i,M){
        int a,b; cin >> a >> b;
        G[i] = {b,a};
    }
    
    sort(ALL(G));
    

    int r = -1;//右端
    int ans = 0;
    REP(i,M){
        if(r<G[i].second || G[i].first<r){
            r = G[i].first-1;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

int gcd(int a, int b){
    if(!b) return a;
    return  gcd(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

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

    ll h, n, x;
    cin>>h>>n;
    ll a[n], b[n];
    fr(i, n) cin>>a[i]>>b[i];
    ll dp[h+1] = {0};

    rep(i, 1, h){
        dp[i] = mod;
        fr(j, n){
            dp[i] = min(dp[max(0ll, i-a[j])] + b[j], dp[i]);
        }
    }

    cout<<dp[h];
    return 0;
}



Measured memory_bytes: 384
use std::io::*;
use std::cmp::{min,max};

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n,m,d) = (v[0],v[1],v[2]);
    let mut ans: f64 = 0.0;
    if d == 0 {
        ans = (m-1) as f64 / n as f64;
    } else {
        ans = ((n-d) * 2 * (m-1)) as f64 / (n*n) as f64;
    }
    println!("{}",ans);
}


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

int main() {
	vector<int> bell(3);
    for(int i = 0;i < 3;i++){
      cin >> bell.at(i);
    }
    sort(bell.begin(),bell.end());
    cout << bell.at(0) + bell.at(1) << endl;
}

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

using namespace std;

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

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if (n % 2 == 0) {
        cout << (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1 << endl;
    } else {
        cout << b[(n - 1) / 2] - a[(n - 1) / 2] + 1 << endl;
    }
}


Measured memory_bytes: 4792
N, X, M = map(int, input().split())

used = [0] * M
a = []

A = X
for i in range(N):
    if used[A] != 0:
        break
    used[A] = 1
    a.append(A)
    A = A * A % M

for i in range(len(a)):
    if a[i] == A:
        break
j = i

if a[-1] != 0:
    result = sum(a[:j])
    a = a[j:]
    l = len(a)
    x = (N - j) // l
    y = (N - j) - x * l
    s = sum(a)
    result += s * x
    result += sum(a[:y])
    print(result)
else:
    s = sum(a)
    print(s)


Measured memory_bytes: 68960
#include<stdio.h>
#include<string.h>
int W,H,i,j;
char dp[71][71][71],g[2],tmp[71],res[71];

void ch(char x[],char y[])
{
	int s,t;
	while(x[0]=='0')
		memmove(x,x+1,strlen(x));
	while(y[0]=='0')
		memmove(y,y+1,strlen(y));
	s=strlen(x),t=strlen(y);
	if(s<t||(s==t&&strcmp(x,y)<0))
		strcpy(x,y);
}
int main()
{
	for(;scanf("%d%d\n",&W,&H),W;)
	{
		memset(dp,0,sizeof(dp));
		memset(res,0,sizeof(res));
		for(i=0;i<H;i++,getchar())
			for(j=0;j<W;j++)
			{
				tmp[0]=0;
				g[0]=getchar();
				if(g[0]<58)
				{
					if(i>0)
						ch(tmp,dp[i-1][j]);
					if(j>0)
						ch(tmp,dp[i][j-1]);
					sprintf(dp[i][j],"%s",strcat(tmp,g));
				}
				ch(res,dp[i][j]);
			}
		puts(res);
	}
	return 0;
}

Measured memory_bytes: 984
#include <stdio.h>
    int main()
    {
    	int X,Y,i,d=1;
    	while(~scanf("%d %d",&X,&Y))
		{
			for(i=1;i<=Y;i++) 
				d=d*2;
			printf("%d\n",(100*X+1800*Y)*d);
		}
    return 0;
    }


Measured memory_bytes: 128
MOD = 1000000007

N = int(input())
S = []
for i in range(2):
    S.append(input())
    

# make XYline
xy = ""
for i in range(len(S[0])):
    if S[0][i] == S[1][i]:
        xy += "X"
    elif i==len(S[0])-1:
        break
    elif S[0][i] == S[0][i+1]:
        xy += "Y"

# proceed
if xy[0] == "X":
    ans = 3
else:
    ans = 6

if len(xy)==1:
    pass
else:
    for i in range(1,len(xy)):
        if xy[i-1] == "X" and xy[i] == "X":
            ans *= 2
        elif xy[i-1] == "X" and xy[i] == "Y":
            ans *= 2
        elif xy[i-1] == "Y" and xy[i] == "X":
            ans *= 1
        elif xy[i-1] == "Y" and xy[i] == "Y":
            ans *= 3

        ans = ans%MOD
print(ans)

Measured memory_bytes: 3064
from math import *
def area(x):
    ret=0.
    theta = 360.
    for i in range(x-1):
        tmp=float(input())
        theta-=tmp
        tmp=tmp*pi/180.
        ret+=(sin(tmp/2)*cos(tmp/2))
    theta=pi*theta/180.
    ret+=sin(theta/2)*cos(theta/2);
    return ret;
while 1:
    m=int(input())
    if m==0:break
    a=area(m)
    b=area(int(input()))
    print(0 if a==b else (1 if a>b else 2))

Measured memory_bytes: 7856
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();
        char[][] map = new char[h][w];

        for(int i=0;i<h;i++){
            String s = sc.next();
            map[i] = s.toCharArray();
        }

        for(int i=0;i<h;i++)for(int j=0;j<w;j++){
            int mine = 0;
            if(map[i][j]=='.'){

                if(i>0){//上3つ
                    if(j>0)if(map[i-1][j-1]=='#')mine++;
                    if(map[i-1][j]=='#')mine++;
                    if(j<w-1)if(map[i-1][j+1]=='#')mine++;
                }
                if(i<h-1){//下３つ
                    if(j>0)if(map[i+1][j-1]=='#')mine++;
                    if(map[i+1][j]=='#')mine++;
                    if(j<w-1)if(map[i+1][j+1]=='#')mine++;
                }
                if(j>0&&map[i][j-1]=='#')mine++;
                if(j<w-1&&map[i][j+1]=='#')mine++;
                String temp = ""+mine;
                char[] temp2 = temp.toCharArray();
                map[i][j]=Character.valueOf(temp2[0]);
            }
        }

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                System.out.print(map[i][j]);
            }
            System.out.println();
        }



    }
}


Measured memory_bytes: 22356
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;
int main(){

  int A,B;
  cin>>A>>B;
  if(A==1){
    A+=13;
  }
  if(B==1){
    B+=13;
  }
  if(A==B) cout<<"Draw";
  else if(A>B) cout<<"Alice";
  else cout<<"Bob";
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

int main(void){
	char p[4];
	cin >> p;
  	char tmp = p[0];
	for (int i = 0; i < 3 ; i++){
      if (tmp == p[i+1]){
		cout << "Bad" << endl;
        return 0;
      }else{
		tmp = p[i+1];
      }
    }
  	cout << "Good" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	REP(i, 7) {
		int a, b; cin >> a >> b;
		cout << abs(a - b) << endl;
	}

	return 0;
}




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

int main() {
  int N;
  cin >> N ;
  int c=9999;
  int tmp=0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    while(a %2 ==0){
      tmp ++;
      a /= 2;
    }
    if(tmp<c){
      c=tmp;
    }
    tmp=0;
  }


  cout << c << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, m, ans = 0;
	int k[10];
	int s[10][10];
	int p[10];
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> k[i];
		for (int j = 0; j < k[i]; j++){
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		cin >> p[i];
	}

	bool sw[10];

	for (int i = 0; i < (1<<n); i++){
		int cou = 0;
		for (int j = 0; j < n; j++){
			if ((1<<j) & i) sw[j] = true;
			else sw[j] = false;
		}
		for (int j = 0; j < m; j++){
			int coun = 0;
			for (int l = 0; l < k[j]; l++){
				if (sw[s[j][l]-1]) coun++;
			}
			if (coun%2 == p[j]) cou++;
		}
		if (cou == m) ans++;
	}

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [A[0]]

for i in range(1, N):
    B.append(B[i - 1] + A[i])

BB = list(B)

# +, -
ans1 = 0
tmp1 = 0

for i in range(N):
    B[i] += tmp1
    # +
    if i % 2 == 0:
        if B[i] <= 0:
            ans1 += (1 - B[i])
            tmp1 += (1 - B[i])
            B[i] = 1
    # -
    else:
        if B[i] >= 0:
            ans1 += (B[i] + 1)
            tmp1 -= (B[i] + 1)
            B[i] = -1

# -, +
ans2 = 0
tmp2 = 0

for i in range(N):
    BB[i] += tmp2
    # -
    if i % 2 == 0:
        if BB[i] >= 0:
            ans2 += (BB[i] + 1)
            tmp2 -= (BB[i] + 1)
            BB[i] = -1
    # +
    else:
        if BB[i] <= 0:
            ans2 += (1 - BB[i])
            tmp2 += (1 - BB[i])
            BB[i] = 1

print(min(ans1, ans2))
if ans1 < 0 or ans2 < 0:
    raise("hoge")


Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int N, C, D[30][30], c[505][505];
int pre[3][30];
int main(void) {
  	cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> C;
    rep(y, C) rep(x, C) cin >> D[y][x];
    rep(y, N) rep(x, N) cin >> c[y][x], c[y][x]--;
 
    rep(col, C) rep(y, N) rep(x, N) pre[(y + x) % 3][col] += D[c[y][x]][col];
 
    int ans = INTINF;
    rep(c0, C) rep(c1, C) rep(c2, C) {
        if (c0 == c1) continue;
        if (c0 == c2) continue;
        if (c1 == c2) continue;
 
        chmin(ans, pre[0][c0] + pre[1][c1] + pre[2][c2]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main(){
	int a[3]={0,0,0},b,i=1;

	do{
		scanf("%d",&b);
		if(a[0]<b){
			a[2]=a[1];
			a[1]=a[0];
			a[0]=b;}
		else if(a[1]<b){
			a[2]=a[1];
			a[1]=b;}
		else if(a[2]<b)
			a[2]=b;

		i++;
	}while(i<=10);
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);

	return 0;
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	vi dp(k + 1);
	REP(i, min(k+1,v[0]))dp[i] = 0;
	FOR(i, v[0], k + 1) {
		bool f = false;
		REP(j, n) {
			if (i - v[j] >= 0 && dp[i - v[j]] == 0)f = true;
		}
		if (f)dp[i] = 1;
		else dp[i] = 0;
	}
	if (dp[k])cout << "First" << endl;
	else cout << "Second" << endl;
}

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

using namespace std;

typedef long long LL;
typedef double LF;

#define clr(x, y) memset(x, y, sizeof(x))

inline int read(){
	int r = 0, z = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') z = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9'){r = r * 10 + ch - '0'; ch = getchar();}
	return r * z;
}

void work(){
	int a = read(), b = read(), c = read();
	if(a > b) swap(a, b); if(c < b) swap(b, c); if(b < a) swap(a, b);
	printf("%d\n", c - b + (b - a) / 2 + ((b - a) % 2 ? 2 : 0));
}

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

Measured memory_bytes: 256
def main
  loop do
    n,h = gets.chomp.split(' ').map(&:to_i)
    break if (n|h) == 0
    puts get_non_hole_cubes_num(n, h)
  end
end
 
def get_non_hole_cubes_num n, h
  hole_cubes = {}
 
  h.times do
    c,a,b = gets.chomp.split(' ')
    case c
    when 'xy'
      1.upto(n) do |idx|
        hole_cubes["#{a.to_i} #{b.to_i} #{idx}"] = 1
      end
    when 'xz'
      1.upto(n) do |idx|
        hole_cubes["#{a.to_i} #{idx} #{b.to_i}"] = 1
      end
    when 'yz'
      1.upto(n) do |idx|
        hole_cubes["#{idx} #{a.to_i} #{b.to_i}"] = 1
      end
    end
  end
  n * n * n - hole_cubes.size
end

main

Measured memory_bytes: 15300
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;
set<ll> st;
void rec(string s){
	st.insert(stoll(s));
	if(s.size() == 10)return;

	int head = (int)(s[0] - '0');
	for(int i = -1;i <= 1;i++){
		if(head + i <= 9 && head + i >= 0){
			char c = (char)('0'+head+i);
			rec(c+s);
		}
	}
}
int main(){
	int k;
	cin >> k;
	for(int i = 0;i <= 9;i++){
		string s = "";
		s += (char)('0'+i);
		rec(s);
	}

	int cnt = 0;
	for(auto itr = st.begin();cnt <= k;itr++,cnt++){
		if(cnt == k){
			cout << *itr << endl;
			return 0;
		}
	}
}


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

int main(){
    int N;cin >> N;
    int ans = 0;
    int maxp = 0;
    rep(i,N){
        int p;cin >> p;
        ans += p;
        maxp = max(maxp,p);
    }
    ans -= maxp;
    maxp /= 2;
    ans += maxp;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

A = [map(int, raw_input().split()) for i in range(3)]
N = input()
for i in range(N):
    b = input()
    for j in range(3):
        for k in range(3):
            if b == A[j][k]:
                A[j][k] = 0
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        print "Yes"
        exit()
    if A[0][i] == A[1][i] == A[2][i] == 0:
        print "Yes"
        exit()
if A[0][0] == A[1][1] == A[2][2] == 0:
    print "Yes"
    exit()
if A[0][2] == A[1][1] == A[2][0] == 0:
    print "Yes"
    exit()
print "No"

Measured memory_bytes: 4268
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;

    rep(ni,N){
        cin >> ltmp;
        A.push_back(ltmp);
    }

    ll sump = 0;
    ll ans = 0;
    for( ll ni = 1 ; ni <N ; ni++ ){
        sump+=A[ni];
    }
    sump = sump + MOD;
    sump = sump % MOD;
    for( ll ni = 0 ; ni <N-1 ; ni++ ){
        ans += A[ni] *sump;
        ans = ans + MOD;
        ans = ans % MOD;

        sump = sump - A[ni+1];
        sump = sump + MOD;
        sump = sump % MOD;
    }
    cout << ans << endl;
    
    

}

Measured memory_bytes: 5320
import math, sys

N=int(input())
S=input()
R_count=0
if "R" not in S:
    print(0)
    sys.exit()
if "W" not in S:
    print(0)
    sys.exit()
if "R" not in S[S.index("W"):]:
    print(0)
    sys.exit()
for i in range(N):
    if S[i]=="R":
        R_count+=1

S=S[:R_count]
ans=S.count("W")
print(ans)

Measured memory_bytes: 65584
#include <iostream>
using namespace std;
long long n,p,sum=1; 
int main() {
	cin>>n>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	long long mx=p;
	for(int i=2;(long long)i*i<=p;i++){
		int t=0;
		while(p%i==0){
			p/=i;
			t++;
			if(t==n){
				sum*=i;
				t=0;
			}
		}
	}
	cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;
 
const long long N = 2e5 + 5;
long long a[N];
long long n;
long long ans = 0;
 
int main() 
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	if (a[0] != 0)
	{
		cout << -1;
		exit(0);
	}
	for (int i = 1; i < n; i++)
	{
		if (a[i] > a[i - 1] && a[i] - a[i - 1] > 1)
		{
			cout << -1;
			exit(0);
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] != 0)
		{
			if (a[i] == a[i - 1] || a[i] < a[i - 1])
			{
				ans += a[i];
			}
			else
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
}
	
            


 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;


signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout <<min(a,b)+min(c,d) << endl;
    
    return 0;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+21);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}


ll run() {
    int n;
    cin>>n;
    int h[n];
    int dp[n]={0};

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

    for(int i=1;i<n;i++) {
        int ans1 = 1e9, ans2 = 1e9;
        if (i - 1 >= 0)
            ans1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i - 2 >= 0)
            ans2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(ans1, ans2);
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {

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

	int[] moveX = {0,0,-1,1};
	int[] moveY = {-1,1,0,0};
	char[][] map;
	boolean[][] check;
	int ans = 0;
	int x, y;

	void calc () {
		Scanner sc = new Scanner(System.in);
		while (true) {
			x = sc.nextInt();
			y = sc.nextInt();
			if (x == 0) break;
			ans = 0;
			map = new char[y][x];
			check = new boolean[y][x];
			for (int i = 0; i < y; i++)
				map[i] = sc.next().toCharArray();
			main:
			for (int i = 0; i < y; i++) {
				for (int j = 0; j < x; j++) {
					if (map[i][j] == '@') {
						ans = 1;
						check[i][j] = true;
						dfs(i, j);
						break main;
					}
				}
			}
			System.out.println(ans);
		}
	}
	void dfs (int y, int x) {
		for (int i = 0; i < moveX.length; i++) {
			int nextX = x + moveX[i];
			int nextY = y + moveY[i];
			if (0 <= nextX && nextX < map[0].length &&
				0 <= nextY && nextY < map.length &&
				map[nextY][nextX] == '.' &&
				!check[nextY][nextX]) {
				ans++;
				check[nextY][nextX] = true;
				dfs(nextY,nextX);
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> mat(h);
  REP(i,h)cin>>mat[i];
  vector red(h, string(w, '.'));
  vector blue(h, string(w, '.'));
  REP(i,h) red[i].back() = '#';
  REP(i,h) blue[i].front() = '#';
  FOR(i,1,w) red.front()[i] = '#';
  REP(i,w-1) blue.back()[i] = '#';
  FOR(i,1,h-1)FOR(j,1,w-1) {
    if (mat[i][j] == '#') {
      red[i][j] = '#';
      blue[i][j] = '#';
    } else {
      if (i % 2) {
        red[i][j] = '#';
      } else {
        blue[i][j] = '#';
      }
    }
  }
  REP(i,h) cout<<red[i]<<"\n";
  cout<<"\n";
  REP(i,h) cout<<blue[i]<<"\n";

  return 0;
}


Measured memory_bytes: 4672
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // 2^0 + 2^1 +
    let l = io.read::<i64>();

    let mut n = 0;
    while 1 << n <= l {
        n += 1;
    }
    let mut ans = Vec::new();
    for i in 1..n {
        ans.push((i, i + 1, (1 << (i - 1))));
        ans.push((i, i + 1, 0));
    }

    let mut now = (1 << (n - 1)) - 1;

    for i in (1..n).rev() {
        if now == l - 1 {
            break;
        }
        let pl = 1 << (i - 1);
        if now + pl <= l - 1 {
            ans.push((i, n, now + 1));
            now += pl;
        }
    }

    println!("{} {}", n, ans.len());
    for a in ans.iter() {
        println!("{} {} {}", a.0, a.1, a.2);
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

using namespace std;

int main(){
  int N, tmp;
  string S;
  cin >> N;
  cin >> S;
  for(int i=0; i<S.length(); i++){
    tmp = (int)(S[i]) + N;
    if(tmp > 90) tmp -= 26;
    S[i] = (char)(tmp);
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

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

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	G := gcd(A, B)

	primeList := map[int]int{}
	for p := 2; p*p <= G; p++ {
		for G%p == 0 {
			G /= p
			primeList[p]++
		}
	}
	if G > 1 {
		primeList[G]++
	}

	fmt.Println(len(primeList) + 1)
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val w = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()

    if (a < b) {
        println(calc(a, b, w))
    } else {
        println(calc(b, a, w))
    }
}

fun calc(a: Int, b: Int, w: Int): Int {
    return Math.max(0, b - (a + w))
}


Measured memory_bytes: 31260
import java.util.*;

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

        int[] a = {sc.nextInt(),sc.nextInt(),sc.nextInt()};
        int tmp;

        for(int i = 0;i < a.length;i++){
            for(int j = i + 1;j < a.length;j++){
                if(a[i] > a[j]){
                    tmp = a[i];
                    a[i] = a[j];
                    a[j] = tmp;
                }
            }
        }

        for(int i = 0;i < a.length - 1;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length - 1]);
    }
}


Measured memory_bytes: 26408
#include<iostream>
using namespace std;
int main (){
 long N,i,z;
 cin>>N>>i;
			  for(int x=N;x>=0;x--) 
			 {
			 	if(x>=i)
			 	z++;
			 	else
			 	break;
			 }	
			 cout<<z<<endl;
			 return 0; 
}

Measured memory_bytes: 3548
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    if(n == (n / 2) * 2){
      System.out.println(n / 2);
    }else{
      System.out.println(n / 2 + 1);
    }
    
    sc.close();
     
  }
}


Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		 Scanner scan = new Scanner(System.in);
	     String str = scan.nextLine();
	     String[] chars = str.split(" ");
	     int N= Integer.valueOf(chars[0]);
	     int M;
	     for(int i=9;i>0;i--) {
	    	 if(N%i==0) {
	    		M = N/i;
	    		if(0<M&M<10) {
	    			System.out.println("Yes");
	    			return;
	    		}
	    	 }
	     }
	     System.out.println("No");
	}

}


Measured memory_bytes: 22996
import numpy as np

def main():
    args1, args2 = input().rstrip().split(' '), input().rstrip().split(' ')
    N, M = int(args1[0]), int(args1[1])
    items = np.array([int(val) for val in args2])
    items = np.sort(items)[::-1]
    items_sum = np.sum(items)
    bottom = items_sum / 4. / M
    
    if(items[M-1] >= bottom):
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
//typedef pair<int, ll> il;
const int MAXN = 100500;
const ll INF = 1e18, CASH = 1e15;

struct node{
    int first; ll second;
};
bool operator<(node a, node b){
    return a.ss > b.ss;
}

int n, m, s, t;
ll T;
vector<node> GY[MAXN], GS[MAXN];
ll DY[MAXN], DS[MAXN], S[MAXN], Ans[MAXN];

bool pass[MAXN];
void dijkstra(int src, vector<node> (&G)[MAXN], ll (&dist)[MAXN]){
    forn(i, MAXN)pass[i] = false;
    forn(i, MAXN)dist[i] = INF;
    priority_queue<node> Q;
    Q.push({src, 0}); dist[src] = 0;
    while(Q.size()){
        node act = Q.top(); Q.pop();
        int id = act.ff; ll d = act.ss;
//        printf("Proceso %d\n", id+1);
//        printf("Tiene distancia %lld\n", d);
        if(pass[id])continue; pass[id] = true;
        forn(i, G[id].size()){
            int nxt = G[id][i].ff; ll nd = d + G[id][i].ss;
//            printf("Puedo llegar a %d con %lld\n", nxt+1, nd);
            if(nd < dist[nxt]){
//                printf("Lo meto\n");
                dist[nxt] = nd;
                Q.push({nxt, nd});
            }
        }
    }
//    printf("Dist:");forn(i, n)printf(" %lld", dist[i]); puts("");
}

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d %d %d %d", &n, &m, &s, &t) >= 1){
        s--; t--;
        forn(i, MAXN){GS[i].clear(); GY[i].clear();}
        forn(i, m){
            int u, v;
            ll a, b;
            scanf("%d %d %lld %lld", &u, &v, &a, &b);
            u--; v--;
            GY[u].pb({v, a}); GY[v].pb({u, a});
            GS[u].pb({v, b}); GS[v].pb({u, b});
        }
        dijkstra(s, GY, DY); dijkstra(t, GS, DS);

        forn(i, n) S[i] = CASH - DS[i] - DY[i];
        Ans[n-1] = S[n-1]; dforn(i, n-1)Ans[i] = max(S[i], Ans[i+1]);
        forn(i, n){
            //if(i)printf(" ");
            printf("%lld\n", Ans[i]);
        }
    }
	return 0;
}


Measured memory_bytes: 20164
import java.util.*;
class Main{
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLIneをnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++) A[i] = sc.nextInt();

        int ans = 0;
        for(int i=1;i<N;i++){
            if(A[i] == A[i-1]){
                ans++;
                A[i]=-1; 
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 998244353;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};

vector<ll> V, C;

int main() {

	ll N;

	cin >> N;
	V.resize(N);
	C.resize(N);
	ll sum = 0;
	rep(i, N) {

		cin >> V[i];

	}
	rep(i, N)
		cin >> C[i];

	rep(i, N) {
		if (C[i] < V[i])
			sum += V[i] - C[i];

	}

	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int h,w;
  int i,j;



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


  return 0;
}

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

int main() {
	int N; cin >> N;
	vector<long long>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];

	bool flag = true;
	if (A[0])flag = false;
	for (int i = 1; i < N; i++)if (A[i] - A[i - 1] > 1)flag = false;

	if (flag == false) {
		cout << -1 << endl;
	}
	else {
		reverse(A.begin(), A.end());

		long long ans = 0;
		int pos = -1;
		int num = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] != num-(i-pos)) {
				ans += A[i];
				num = A[i];
				pos = i;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> s(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cin >> s.at(i).at(j);
  }
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s.at(i).at(j) == '#')continue;
      vector<vector<int>> unko(h,vector<int>(w,-1));
      unko.at(i).at(j) = 0;
      queue<pii> q;
      q.push(pii(i,j));
      while(q.size() != 0){
        pii p = q.front();
        q.pop();
        int px,py;
        tie(px,py) = p;
        set<pii> se;
        se.insert(pii(px-1,py));se.insert(pii(px+1,py));
        se.insert(pii(px,py-1));se.insert(pii(px,py+1));
        for(auto pp:se){
          int x,y;
          tie(x,y) = pp;
          if(0<=x && x<h && 0<=y && y<w && unko.at(x).at(y) == -1 && s.at(x).at(y) == '.'){
            unko.at(x).at(y) = unko.at(px).at(py) + 1;
            q.push(pii(x,y));
          }
        }
      }
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++)ans = max(ans,unko.at(k).at(l));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
ans = []
def bfs(s,tmp):
    if len(s)==n:
        ans.append(s)
        return
    for i in range(ord('a'),ord('a')+tmp+1):
        if i==ord('a')+tmp:
            bfs(s+chr(i),tmp+1)
        else:
            bfs(s+chr(i),tmp)
bfs('a',1)
print(*ans,sep='\n')

Measured memory_bytes: 14496
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long H = sc.nextLong();
		int N = sc.nextInt();
		long ans = 0;
		for( int i=0; i<N; i++ ){
			long a = sc.nextLong();
			ans += a;
		}
		System.out.println(ans>=H?"Yes":"No");
	}
}


Measured memory_bytes: 47044
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		
	Scanner sc =new Scanner(System.in);
	
	int a= sc.nextInt();
	int b= sc.nextInt();	
	int k= sc.nextInt();
	int c=0,d=0;
	
	for(int i=0;i<k;i++){
		
		if(i%2==0){
			if(a%2==1) a=a-1;
			//System.out.println(a);
			c=a;
			a=a-c/2;
			
			//System.out.println(a);
			b=b+c/2;
		}
		
		else if(i%2==1){
			if(b%2==1) b=b-1;
			
			d=b;
			a=a+d/2;
			b=b-d/2;
		}
	
			
	}
	
	System.out.print(a+" "+b);
	
	}

}

Measured memory_bytes: 23508
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50 == X:
                cnt += 1
print(cnt)


Measured memory_bytes: 3060
import java.util.*;

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

        System.out.println(recursive(n,r,count));
    }

    public static int recursive(int n, int r, int count) {

        if (n / r == 0) {
            count++;
            return count;
        }

        else {
            count++;
            return recursive(n/r,r,count);
        }
    }


}


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

int main(void)
{
	int n;
	while(cin >> n && n != NULL)
	{
		int i = 1;
		int q;
		while(1)
		{
			q = (1+i)*i;
			if(q&1)
				q = q/2 + 1;
			else
				q = q/2;
			if(q >= n)
				break;
			i++;
		}
		cout << i << endl;
	}
}

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

int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin >> n;
    
    vector<array<int, 2>> v;
    
    for (int i = 1; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }

    sort(v.begin(), v.end(), [](array<int, 2> a, array<int, 2> b) {
        return a[0] + a[1] > b[0] + b[1];
    });


    long long res = 0;
    for (int i = 0; i < v.size(); i++) {
        if (i % 2 == 0) {
            res += v[i][0];
        }
        else res -= v[i][1];
    }
    
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4120
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

LL n, a, b;

const LL mod = 1000000007;

LL exgcd(LL a,LL b,LL &x,LL &y)
{
    if(b==0)
    {          
        x=1;
        y=0;
        return a;
    }
    LL r=exgcd(b, a%b, x, y);
    LL t=y;
    y=x-(a/b)*y;    
    x=t;
    return r;
}
LL ny(LL x) {
	if (x == (LL)(0)) {
		return 1;
	}
	LL xx, yy;
	exgcd(x, mod, xx, yy);
	return xx;
}

LL getF(LL n) {
	if (n == (LL)(0)) {
		return 1;
	}
	LL res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
		res %= mod;
	}
	return res;
}

LL getC(LL n, LL k) {
	LL res = (LL)(1);
	for (LL i = n - k + 1; i <= n; i += (LL)(1)) {
		res *= i;
		res %= mod;
	}
	for (LL i = 1; i <= k; i += (LL)(1)) {
		res *= ny(i);
		res %= mod;
	}
	return res;
	/*LL res = getF(n);
	LL fk = getF(k);
	res *= ny(fk);
	res %= mod;
	LL fnk = getF(n - k);
	res *= ny(fnk);
	res %= mod;
	return res;*/
}

LL quickmod(LL a, LL b) {
	LL res = 1;
	while (b > (LL)(0)) {
		if (b % (LL)(2) != 0) {
			res = (res * a) % mod;
		}
		a = (a * a) % mod;
		b /= (LL)(2);
	}
	return res;
}

int main() {
	cin >> n >> a >> b;
	LL res = quickmod((LL)(2), n);
	LL resA = getC(n, a);
	LL resB = getC(n, b);
	res -= resA;
	res += mod;
	res -= resB;
	res -= (LL)(1);
	res += mod;
	res %= mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int mod=1000000007;


long long int n,k,q,a[60]={},b[5000],res,sum[2300]={},key=0;
queue<pair<long long ,long long > >que;
int main() {
    const long long int INF=99999999999999;
	map<long long int, long long int>mp;
    string str[550],red[550],blue[550];
    priority_queue<long long int>pq[4];
    priority_queue<long long int>tmp[4];
	cout << fixed << setprecision(10);
    cin>>k;
    cout<<50<<endl;
    for(int i=1;i<=min(k,50LL);i++){
        a[i]=50-i+1;
    }
    k-=50;
    if(k>0){
        for(int i=1;i<=50;i++){
            a[i]+=k/50;
        }
        k%=50;
        for(int i=1;i<=min(k,50LL);i++){
            a[i]++;
        }
    }
    for(int i=1;i<=50;i++){
        cout<<a[i]<<" ";
    }
} 


Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;

fn main() {
    let stdin = io::stdin();
    for line in stdin.lock().lines() {
        let uline = line.unwrap();
        let vec: Vec<&str> = uline.split_whitespace().collect();
        let h: usize = vec[0].parse().unwrap_or(0);
        let w: usize = vec[1].parse().unwrap_or(0);
        if h != 0 && w != 0 {
            for i in 0..h {
                for j in 0..w {
                    if (i + j) % 2 == 0 {
                        print!("#");
                    } else {
                        print!(".");
                    }
                }
                println!("");
            }
            println!("");
        }
    }
}


Measured memory_bytes: 5028
import collections
def C(n):
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
d = {}
sm = 0
for k,v in c.most_common():
    d[k] = v
    sm += C(v)
for a in A:
    print (sm - d[a] + 1)

Measured memory_bytes: 105548