akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
#define rep(i, n) for (int i = 0; i < (int)n; i++)
ll inf = 1e10;

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

int main(){
  int n;
  cin >> n;
  vector<int> dp(n+1);
  dp[0] = 0;
  dp[1] = 1;
  for(int i = 2; i <= n; ++i){
    int sixpow = 1;
    int ninepow = 1;
    while(i >= sixpow*6){
    sixpow *= 6;
    }
    while(i >= ninepow*9){
      ninepow *= 9;
    }
    dp[i] = min(1+dp[i-sixpow], 1+dp[i-ninepow]);
  }
  cout << dp[n] << endl;
  
}

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

int N;
int P[100];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int z;
        cin >> z;
        P[i] = z;
    }
    int ans = 0;
    for (int i = 1; i < N - 1; ++i) {
        int p = P[i];
        int s[3] = { P[i-1], P[i], P[i+1] };
        sort(s, s + 3);
        if (s[1] == p) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}
#endif

Measured memory_bytes: 256
N,M=map(int,input().split())
L=[]
MM=[]
for i in range(0,M):
  l,m=map(int,input().split())
  L.append(l)
  MM.append(m)
ma=min(MM)
mi=max(L)
ans=ma-mi+1

if ans>0:
  print(ans)
else:
  print("0")

Measured memory_bytes: 10996
#include<iostream>
#include<set>
#include<string>
using namespace std;
set<string>data;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		data.insert(str);
	}
	int m;
	cin>>m;
	int now=1;
	for(int i=0;i<m;i++){
		string str;
		cin>>str;
		if(data.find(str)!=data.end()){
			if(now==1)cout<<"Opened by "<<str<<endl;
			else cout<<"Closed by "<<str<<endl;
			now*=-1;
		}
		else cout<<"Unknown "<<str<<endl;
	}
}

Measured memory_bytes: 1232
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::cmp::min;

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let ans = (n / (a + b)) * a + min(n % (a + b), a);
    println!("{}", ans);
}


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

int main(){
    while(true){
        int h,w;
        cin >>h>>w;
        if(h==0&&w==0){
            break;
        }
        for (int j = 0; j < h; j++){
            for (int i = 0; i < w; i++){
                if((i+j)%2==0){
                    cout <<'#';
                }else{
                    cout <<'.';
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define FF first
#define SS second
#define pii pair<int,int>
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
#define mp make_pair
#define Mod 1000000007
typedef long long int ll;

// dp[i] -> store result whether present player playing the tuen is able to win or not if i stones left

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// #endif

	int n, k, i;
	cin >> n >> k;
	vector<int> stones(n);
	vector<bool> dp(k+1, false);

	for(int &x : stones)
		cin >> x;

	for(i = 1; i <= k; i++)
		for(int x : stones)
			if(i >= x && !dp[i-x])
				dp[i] = true;

	cout<<(dp[k]?"First":"Second");
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),k=sc.nextInt(),sum=0;
    int[] l=new int[n];
    for(int i=0;i<n;i++){
      l[i]=sc.nextInt();
    }
    Arrays.sort(l);
    for(int i=1;i<=k;i++){
      sum+=l[n-i];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<i64,i64>;

int main(){
    string S;
    cin >> S;
    string ans = "Yes";
    rep(i,S.size()){
        if(i%2 == 0 && S[i] == 'L') ans = "No";
        if(i%2 == 1 && S[i] == 'R') ans = "No"; 
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class t,class u>
ostream& operator << (ostream& os,pair<t,u> p){
	return os << p.fi << ',' << p.sec;
}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int N;
ll A,B,C,D;
int main(){
	cin >> N >> A >> B >> C >> D;
	N--;
	if(A>B)swap(A,B);
	ll diff = B-A;
	if(C==0){
		if(D*N>=diff){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
		return 0;
	}
	if(C==D){
		if(diff%C==0ll&&diff/C<=N){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
		return 0;
	}
	for(ll i=0;i<=N;i++){
		ll low = diff-(D-C)*i;
		ll high = diff+(D-C)*(N-i);
		if(low<=C*(2ll*i-N)&&C*(2ll*i-N)<=high){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
S,H,C,D = set(),set(),set(),set()
W = set([1,2,3,4,5,6,7,8,9,10,11,12,13])
n = int(input())
for i in range(n):
    N = input().split()
    if N[0] == 'S':
        S.add(int(N[1]))
    elif N[0] == 'H':
        H.add(int(N[1]))
    elif N[0] == 'C':
        C.add(int(N[1]))
    elif N[0] == 'D':
        D.add(int(N[1]))
s,h,c,d = [],[],[],[]
st = W - S
while st != set():
  s.append(st.pop())
s.sort()
ht = W - H
ct = W - C
dt = W - D
while ht != set():
  h.append(ht.pop())
h.sort()
while ct != set():
  c.append(ct.pop())
c.sort()
while dt != set():
  d.append(dt.pop())
d.sort()

for i in s:
    print('S {0}'.format(i))
for i in h:
    print('H {0}'.format(i))
for i in c:
    print('C {0}'.format(i))
for i in d:
    print('D {0}'.format(i))

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    sort(all(p));
    p[n-1]/=2;
    ll sum=0;
    rep(i,n) sum+=p[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3604
A, B, C, K = map(int, input().split())

if K%2 == 0:
    value = A - B
    if abs(value) >= 10**18:
        print("Unfair")
    else:
        print(value)
    
else:
    value = B - A
    if abs(value) >= 10**18:
        print("Unfair")
    else:
        print(value)

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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//########################################################################




int main()
 {
	int n,k; cin>>n>>k;
	int a[n];
	input_array(a,n);
	int count=0;
	loop1(i,0,n)
	{
	    if(a[i]>=k)count++;
	}
	cout<<count;
	return 0;
}

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

using namespace std;

int main()

{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++){
        // cout<<s[i]<<"\n";
        sum+=(s[i]-'0');
        // cout<<"sum "<<sum<<"\n";
    }
    // cout<<sum<<"\n";
    if(sum%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}



Measured memory_bytes: 3752
//
// Created by 中野誠大 on 2019-02-10.
//

#include<iostream>

#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

void erase(int *ptr, int *last);

void erase(int *ptr, int *last) {
    while ( ++ptr < last )
        *(ptr - 1) = *ptr;       //  要素をひとつ前にずらす
}


int main() {
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    int a[n];
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    int ind=0;
    int matrix[h][w];
    for (int i=0;i<h;i++){
        if (i%2==0){
            for (int j = 0; j < w; ++j) {
                while (a[ind] == 0) ind += 1;
                matrix[i][j] = ind + 1;
                a[ind]--;
            }
        }
        else{
            for (int j = w-1; j >= 0; --j) {
                while (a[ind] == 0) ind += 1;
                matrix[i][j] = ind + 1;
                a[ind]--;
            }
        }
    }

    for (int i=0;i<h;i++) {
        for (int j = 0; j < w; ++j) {
            cout << matrix[i][j] << " ";
        }
        cout << endl;
    }







    /*
    pair<int,int> a[n];

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

    sort(a,a+n);


    int c[n][2];
    for (int i=0;i<n;i++){
        c[i][0]=a[0].first;
        c[i][1]=a[0].second;
    }

    //for (int i=0;i<n;i++) cout << a[i].first <<" "<< a[i].second <<endl;

    while ([0].first==0) a.erase(a.begin());
    int matrix[h][w];
    for (int i=0;i<h;i++){
        if (i%2==0) {
            for (int j = 0; j < w; j++) {
                matrix[i][j]=a[0].second;
                a[0].first --;

                if (a[0].first == 0) a.erase(a.begin());
            }
        }

        if (i%2==1){
            for (int j = w-1; j >= w; j--) {
                matrix[i][j] = a[0].second;
                a[0].first--;

                if (a[0].first == 0) a.erase(a.begin());
            }
        }

    }

    for (int i=0;i<h;i++){
        for (int j = 0; j < w; ++j) {
            cout << matrix[i][j] << " ";

        }
        cout << endl;
    }*/


/*
    using item = pair<int,int>;
    sort((item*)a[0], (item*)a[4], []( item x, item y ) { return x.first < y.first; });

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << Square[i][j] << ' ';
        }
        cout << endl;
    }*/


    return 0;

}





Measured memory_bytes: 384
n = int(input())

if n == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans = factorization(n)
s= 0
for i in range(len(ans)):
    now = 1
    while(ans[i][1] >= 0):
        ans[i][1] -= now
        #print(ans[i][0],now)
        s += 1
        now += 1
    s -= 1
print(s)


Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


int main(void){
	int n,b,f,r,v;
	cin >> n;
	int A[4][3][10];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				A[i][j][k] = 0;
			}
		}
	}
	for(int i = 0; i < n; i++){
		cin>>b>>f>>r>>v;
		A[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 << " " << A[i][j][k];
			}
		cout << "\n";
		}
		if(i != 3)cout << "####################\n";
	}
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int l,r;
    cin >> l >> r;
    int ans = INF;
    if(r - l >= 2019){
        ans = 0;
    }else{
        for(int i = l; i < r; i++){
            for(int j = i + 1; j < r + 1; j++){
                ans = min(ans,i * j % 2019);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define pi 3.14159265358979323846

using namespace std;

int main(){
	int n;	cin >> n;
	vector<int> p(n);
	for( int i = 0; i < n; i++ )	cin >> p[i];
	int ans = 1;
	int min = p[0];

	for( int i = 1; i < n; i++ ){
		if( p[i] < min ){
			ans++;
			min = p[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 100000 + 5
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, l, q, a, b, tot, siz, x[N], nxt[N], last[N], cntb[N], block[N];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int main(){
    n = read(), siz = sqrt(n), tot = ceil(1.0 * n / siz);
    rep(i, 1, n) x[i] = read();
    l = read(); 
    rep(i, 1, n){
        int pos = upper_bound(x + 1, x + n + 1, x[i] + l) - x;
        if(x[pos] < x[i] + l) last[i] = n + 1;
        else last[i] = pos - 1;
    }
    block[n + 1] = tot + 1;
    rep(i, 1, n) block[i] = i / siz + 1;
    rep(i, 1, n){
        int pos = i, cnt = 0;
        while(block[pos] == block[i]) pos = last[pos], ++cnt;
        cntb[i] = cnt, nxt[i] = pos;
    }
    q = read();
    while(q--){
        a = read(), b = read(); if(a > b) swap(a, b);
        int pos = a, ans = 0;
        while(block[pos] < block[b]) ans += cntb[pos], pos = nxt[pos];
        while(pos < b) pos = last[pos], ++ans;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 5660
from collections import Counter
from scipy.misc import comb
 
N, M = map(int, input().split())
A = list(map(int, input().split()))
X = [0]
for a in A:
    X.append((X[-1] + a) % M)
 
X = Counter(X)
ans = 0
for num in X.values():
    ans += comb(num, 2, 1)
 
print(ans)

Measured memory_bytes: 27120
#include <stdio.h>

void sort(int *s, int *e);

int main(void){
	int num[3];

	scanf("%d %d %d", num, num+1, num+2);
	sort(num, num+3);
	printf("%d %d %d\n", num[0], num[1], num[2]);

	return 0;
}

void sort(int *s, int *e){
	int i, j, n = e-s-1;

	for(i = 0; i < n; i++)
		for(j = 0; j < n-i; j++)
			if(s[j] > s[j+1]){
				s[j] ^= s[j+1];
				s[j+1] ^= s[j];
				s[j] ^= s[j+1];
			}
}



Measured memory_bytes: 2040
N = input()
if int(N[0]) < int(N[1]):
  print(str(int(N[0])+1)*3)
elif int(N[0]) > int(N[1]):
  print(N[0]*3)
else:
  if int(N[1]) < int(N[2]):
    print(str(int(N[0])+1)*3)
  else:
    print(N[0]*3)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    Int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

x = readint()
if 400<=x<=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
elif 1800<=x<=1999:
    print(1)

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

typedef long long ll;

using namespace std;

int main(void) {
    int n; cin >> n;
    vector<int> p(n, 0);
    for (int i = 0; i < n; i++) { cin >> p[i]; }

    int count = 0;
    for (int i = 1; i < n - 1; i++) {
        int a = p[i-1], b = p[i], c = p[i+1];
        int mx = max(a, max(b, c));
        int mn = min(a, min(b, c));
        if (b != mx && b != mn)
            count++;
    }
    cout << count << endl;
}

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

template <typename T> int LIS(const vector<T> &a) {
    vector<T> dp(a.size(), numeric_limits<T>::max());
    for (int i = 0; i < (int)a.size(); ++i) {
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), numeric_limits<T>::max()) - dp.begin();
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << LIS(a) << endl;
}


Measured memory_bytes: 3576
<?php

fscanf(STDIN, "%d", $count);

for( $i = 0; $i < $count; $i++){

fscanf(STDIN, "%d %d %d", $data[0], $data[1], $data[2]);

rsort($data);

$long = $data[0]*$data[0];
$other = $data[1]*$data[1] + $data[2]*$data[2];

if($long == $other){
echo "YES\n";
}

else{
echo "NO\n";
}
}

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

typedef long long ll;

ll pow (ll base, ll exp, ll mod) {
    if (exp == 0) return 1 % mod;
    if (exp == 1) return base % mod;
    if (exp % 2 == 0) return pow(base * base % mod, exp/2, mod);
    return base * pow(base * base % mod, exp/2, mod) % mod;
}

ll inv (ll x, ll mod) {
    return pow(x, mod - 2, mod);
}

ll factorial (ll n, ll mod) {
    ll x = 1;
    for (int i = 1; i <= n; i++)
        x = x * i % mod;
    return x;
}

int main() {
    ll x, y;
    cin >> x >> y;
    if ((2 * x - y) % 3) {
        cout << 0 << endl;
        return 0;
    }

    ll a = (2 * x - y)/3;
    ll b = x - a * 2;
    if (a * 2 + b != x || a + 2 * b != y) {
        cout << 0 << endl;
        return 0;
    }
    if (a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }

    ll mod = 1e9 + 7;
    ll abfac = factorial(a + b, mod);
    ll afac = factorial(a, mod);
    ll bfac = factorial(b, mod);

    ll res = abfac * inv(afac * bfac % mod, mod) % mod;
    cout << res << endl;
} 

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

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

	int A,B;
	cin >> A >> B;
	if (A == 1) {
		A = 14;
	}
	if (B == 1) {
		B = 14;
	}
	if (A > B) {
		cout << "Alice";
	}
	else if (A < B) {
		cout << "Bob";
	}
	else {
		cout << "Draw";
	}
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

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

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

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
int main(){
  long long n;
  cin >> n;
  long long i, sum1 = 0;
  for (i = 1; i < n+1; i ++){
    if (i % 3 == 0 || i % 5 == 0) {
      sum1 = sum1;
    }else{
      sum1 += i;
    }
  }
  cout << sum1 << endl;
}


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

int main(){
  long int a,b,c; cin >> a >> b >> c;
  long int r;
  if(a%2 == 0 || b %2 == 0 || c%2==0){
    r = 0;
  }else{
    long int ab = a*b;
    long int bc = b*c;
    long int ca = c*a;
    r = (ab<bc ? ab:bc);
    r = (r<ca ? r:ca);
  }
  cout << r << '\n';
}
  

Measured memory_bytes: 764
#include <bits/stdc++.h>  
using namespace std;  
typedef long long ll; 
typedef long double ld; 
const int INF = 0x3f3f3f3f;  
const int N = 100000 + 5;

int main()
{
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main
{
  public static void main(String[] args)
  {
    Scanner scan1 = new Scanner(System.in);
	String firstColor = scan1.next();
    String secondColor = scan1.next();
    
    scan1.nextLine();
 
	int redCount = scan1.nextInt();
	int blueCount = scan1.nextInt();
 
	String subtract = scan1.next();
 
	if(subtract.equals(firstColor))
	{
 	 redCount-=1;
	}
	else
    {
 	 blueCount-=1;
    }
 
	System.out.println(redCount + " " + blueCount);
  }
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    if A[i] < 0:cnt += 1
if cnt % 2 == 0:
    print(sum([abs(x) for x in A]))
else:
    a = [abs(x) for x in A]
    print(sum(a) - min(a)*2)

Measured memory_bytes: 14412
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,t=map(int,input().split())
    T=list(map(int,input().split()))
    ans=t # 最初は押された状態にしておく
    for i in range(n-1):
        ans+=min(t,T[i+1]-T[i])
    print(ans)
resolve()

Measured memory_bytes: 78964
N, x = map(int, input().split())
a_li = list(map(int, input().split()))
a_li.sort()
ans = 0
for a in a_li :
    if x >= a :
        ans += 1
        x -= a
    else :
        x = 0
        break
if x != 0 :
    ans -= 1
print(max(0, ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s, t;
  cin >> s >> t;
  if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}


Measured memory_bytes: 3604
#include<cstdio>
using namespace std;
long long a,b,c;
int main()
{
   
   scanf("%lld%lld%lld",&a,&b,&c);
   long long t=(c-a-b)*(c-a-b)-4*a*b;
   if(c-a-b>0&&t>0)
   printf("Yes");
   else
   printf("No");
}

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

struct die{
  int p[6];
  void init(){
    for(int i=0;i<6;i++)p[i]=i+1;
  }
  void roll(int a,int b,int c,int d){
    int tmp=p[a];
    p[a]=p[b];
    p[b]=p[c];
    p[c]=p[d];
    p[d]=tmp;
  }
  void ra(){
    roll(0,4,5,1);
  }
  void rb(){
    roll(0,3,5,2);
  }
  void rc(){
    roll(1,2,4,3);
  }
};

vector<die> t;

die G[4][4][4];

bool check(int a,int b){
  if(a==-1||b==-1)return true;
  else return (a+b==7);
}

vector<int> ans;

void rec(int x,int y,int z){
  if(x==4){
    rec(1,y+1,z);
    return;
  }
  if(y==4){
    rec(1,1,z+1);
    return;
  }
  if(z==4){
    int sum=0;
    for(int i=1;i<=3;i++)
      for(int j=1;j<=3;j++)
	sum+=G[3][i][j].p[3];
    ans.push_back(sum);
    return;
  }

  for(int i=0;i<24;i++){
    G[x][y][z]=t[i];
    if(!check(G[x][y][z].p[0],G[x][y][z-1].p[5]))continue;
    if(!check(G[x][y][z].p[3],G[x-1][y][z].p[2]))continue;
    if(!check(G[x][y][z].p[1],G[x][y-1][z].p[4]))continue;
    rec(x+1,y,z);
  }
}

void init(){
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      for(int k=0;k<4;k++)
	for(int x=0;x<6;x++)
	  G[i][j][k].p[x]=-1;
}

int main(){
  die d;
  d.init();
  for(int i=0;i<6;i++){
    if(i%2)d.ra();
    else d.rb();
    for(int j=0;j<4;j++){
      d.rc();
      t.push_back(d);
    }
  }
  
  int Tc;
  cin>>Tc;
  while(Tc--){
    init();

    int a;
    for(int i=1;i<=3;i++){
      for(int j=1;j<=3;j++){
	cin>>a;
	if(a==0)continue;
	G[j][0][i].p[4]=7-a;
      }
    }
    for(int i=3;i>=1;i--){
      for(int j=1;j<=3;j++){
	cin>>a;
	if(a==0)continue;
	G[j][i][0].p[5]=7-a;
      }
    }
    ans.clear();
    rec(1,1,1);
    if(ans.size()==0)cout<<0<<endl;
    else{
      sort(ans.begin(),ans.end());
      for(int i=0;i<(int)ans.size();i++){
	if(i&&ans[i]==ans[i-1])continue;
	if(i)cout<<' ';
	cout<<ans[i];
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    int mx = (n-1)*(n-2)/2;
    if (mx < k) {
        cout << -1 << endl;
        return 0;
    }
    vector<P> ans;
    rep(i,n-1) {
        ans.push_back(P(i+1,n));
    }
    int add = mx - k;
    vector<P> edge;
    rep(i,n-1) rep(j,i) edge.push_back(P(i+1,j+1));
    rep(i,add) ans.push_back(edge[i]);
	cout << ans.size() << endl;
    rep(i, ans.size()) {
        cout << ans[i].first << ' ' << ans[i].second << endl;
    }
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int items[200][2];
ll memo[200][200000];
int n;

ll dp(int idx, int cap){
    if(idx >= n || cap < 0){
        return 0;
    }
    ll &res = memo[idx][cap];
    if(res != -1){
        return res;
    }
    if(cap - items[idx][0] >= 0){
        res = max(res, dp(idx+1, cap-items[idx][0])+items[idx][1]);
    }
    res = max(res, dp(idx+1, cap));
    return res;
}

int main(){
    memset(memo, -1, sizeof memo);
    int w;
    scanf("%d %d", &n, &w);
    for(int i = 0; i < n; i++){
        scanf("%d %d", &items[i][0], &items[i][1]);
    }
    printf("%lld", dp(0, w));
    return 0;
}


Measured memory_bytes: 316316
//file_name:ABC44_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll n,s;
    cin >> n >> s;

    if(n<s){
        cout << "-1" << endl;
        return 0;
    }
    if(n==s){
        cout << n+1 << endl;
        return 0;
    }

    ll ans = 2222222222222;

    srep(i,2,400001){
        ll nn = n;
        ll x = 0;
        while(nn>0){
            x += nn%i;
            nn /= i;
        }
        if(x==s){
            cout << i << endl;
            return 0;
        }
    }

    srep(i,1,min((ll)400001,s+1)){
        ll ii = i;
        if((n-(s-ii))%ii==0){
            if((n-(s-ii))/ii>(s-ii)){
                ans = min((n-(s-ii))/ii,ans);
            }
        }
    }


    if(ans==2222222222222)ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  long long N;
  cin >> N;
  long long ans=1;
  for(int i=1;i<=N;i++){
    ans*=i;
    ans%=1000000007;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let item: HashSet<&String> = s.iter().collect();

    println!("{}", item.len());
}


Measured memory_bytes: 17396
#include<iostream>
using namespace std;
int a[110]={};
int ans[110]={};
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int count=1;
    int tmp_n=n;
    int buf;
    int max;
    bool judge=true;
    for(int i=1;i<=n;i++){
        int j=1;
        max=0;
        int tmp_j;
        count=1;
        while(j<=n){
            if(a[j]==count){
                max=count;
                tmp_j=j;
            }
            if(a[j]==0)count--;
            count++;
            j++;
        }
        if(max==0){
            judge=false;
            goto FINE;
        }
        ans[n-i]=max;
        a[tmp_j]=0;
    }
    FINE:
    if(judge){
     for(int i=0;i<n;i++){
         cout<<ans[i]<<endl;
     }   
    }
    else{
        cout<<"-1"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        BigDecimal sum = BigDecimal.ZERO;
        for (int i = 0; i < N; i++) {
            BigDecimal n = new BigDecimal(sc.next());
            n = BigDecimal.ONE.divide(n, 7, RoundingMode.HALF_EVEN);
            sum = sum.add(n, MathContext.UNLIMITED);
        }

        System.out.println(BigDecimal.ONE.divide(sum, 6, RoundingMode.HALF_EVEN).toPlainString());
        sc.close();
    }
}

Measured memory_bytes: 23892
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<long long> comb = vector<long long>(100 * 100,-1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}


int solveC() {
	long long L, R;
	cin >> L >> R;
	if (L % 2019 == 0 || R & 2019 == 0 || R - L >= 2018) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 2019;
	for (int i = L; i < R; i++) {
		for (int j = i + 1; j <= R; j++) {
			ans = min((i*j) % 2019, ans);
		}
	}
	cout << ans << endl;
}

int main() {
	int N, A, B; cin >> N >> A >> B;
	cout << min(N*A, B) << endl;
}


Measured memory_bytes: 384
def fibon(n):
    a, b = 0, 1
    while n>=0:
        if n==0:return a
        b += a
        n -= 1
        if n==0: return b
        a += b
        n -= 1

n, m = map(int, input().split())
a = [-1] + [int(input()) for i in range(m)] + [n+1]
ans = 1
for i in range(m+1):
    ans *= fibon(a[i+1]-a[i]-1)
print(ans%1000000007)

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

#define int long long
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; }

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

	int z = n % 10;
	if(z == 3){
		cout << "bon" << endl;
	}else if(z == 0 || z == 1 || z  == 6 || z == 8){
		cout << "pon" << endl;
	}else{
		cout << "hon" << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#define N 100

int min(int x, int y){return ((x>y)? y : x);}

int main(){
  int i, j, k, l, n, p[N+1], m[N+1][N+1];
  scanf("%d", &n);
  for(i=1;i<=n;i++) scanf("%d%d", &p[i-1], &p[i]);

  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=1e9;
      for(k=i;k<=j;k++) m[i][j]=min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
    }
  }
  printf("%d\n", m[1][n]);

  return 0;
}



Measured memory_bytes: 2108
n=int(input())
l=list(map(int,input().split()))
f=1
for i in range(n):
    if  l[i]%2==0:
        if l[i]%3 and l[i]%5 :
            f=0
            break
if f:
    print("APPROVED")
else:
    print("DENIED")
            


Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    res = [[] for _ in range(N)]
    for _ in range(M):
        p, s = LS()
        p = int(p)
        p -= 1
        res[p].append(s)
    seito = 0
    pena = 0
    for re in res:
        ac = False
        re_pena = 0
        for s in re:
            if s == 'AC':
                seito += 1
                ac = True
                break
            else:
                re_pena += 1
        if ac:
            pena += re_pena
    print(seito, pena)

main()



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

int main(){
    int n,m,a;
    int rope[1000][3];

    while(1){
        scanf("%d",&n);
        scanf("%d",&m);
        scanf("%d",&a);
        if(n==0)break;

        int height=0;
        for(int i=0;i<m;i++){
            scanf("%d",&rope[i][0]);
            scanf("%d",&rope[i][1]);
            scanf("%d",&rope[i][2]);

            if(rope[i][0]>height)height=rope[i][0];

        }

//        cout<<"Height :"<<height<<endl;
//        cout<<"Pos :"<<a<<endl;
//        cout<<endl;
        while(height>0){
//            cout<<"Height = "<<height<<endl;
            for(int j=0;j<m;j++){

                if(height==rope[j][0]){
                    int step=rope[j][1]+rope[j][2]-(a*2);

                    if(step==1){
                        a++;
//                        cout<<"Pos :"<<a<<endl;
                        break;
                    }else if(step==(-1)){
                        a--;
//                      cout<<"Pos :"<<a<<endl;
                        break;
                    }
                }
                
            }
            --height;
        }
        cout<<a<<endl;
    }
    return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s;
  for(int i=0; i<2; i++){
    if(s.at(i) == s.at(i+1) and s.at(i) == s.at(i+2)){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

// x:素数 -> 1
int judge(int x);

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

  int flag = judge(X);

  if(flag==0 && X%2==0)X++;
  flag = judge(X);

  while(flag==0){
    X += 2;
    flag = judge(X);
  }

  cout << X << endl;

  return 0;
}

int judge(int x){
  if(x==2) return 1;
  else{
    for(int i=2;i<=x/2;i++){
      if(x%i==0) return 0;
      if(i!=2)i++;
    }
  }
  return 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
#define MAXA 100000000
#define MAXB 100000000
#define MAXC 100000000
#define MAXD 100000000
#define MAXN 50
#define MAXM 50
int main(int argc,char const* argv[])
{
  int n,m;
  cin >> n >> m;
  int i,j,correctcheck[n];
  long long int studentx[n];
  long long int studenty[n];
  long long int checkx[m];
  long long int checky[m];
  long long int minMah,Mah;
  for(i=0;i<n;i++)
    {
      cin >> studentx[i] >> studenty[i];
    }
  for(i=0;i<m;i++)
    {
      cin >> checkx[i] >> checky[i];
    }
  for(i=0;i<n;i++)
    {
      minMah=LLONG_MAX;
      for(j=m-1;j>=0;j--)
	{
	  Mah=abs(studentx[i]-checkx[j])+abs(studenty[i]-checky[j]);
	  if(Mah<=minMah)
	    {
	      minMah=Mah;
	      correctcheck[i]=j+1;
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      cout << correctcheck[i] <<endl;
    }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        long R = 0;
        long G = 0;
        long B = 0;
        long ans;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'R') {
                R++;
            } else if (S.charAt(i) == 'G') {
                G++;
            } else if (S.charAt(i) == 'B') {
                B++;
            }
        }
        ans = R * B * G;

        for (int i = 0; i < N - 2; i++) {
            for (int j = i + 1; j < N - 1; j++) {
                if (2 * j - i >= N) {
                    continue;
                }
                if (S.charAt(i) != S.charAt(j) && S.charAt(i) != S.charAt(2 * j - i)
                        && S.charAt(j) != S.charAt(2 * j - i)) {
                    ans--;
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }
}

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

int main(int argc, char const *argv[])
{
	string s;
	while(cin>>s,s!="#")
	{
		int a,b,c;
		cin>>a>>b>>c;
		if(a>31||(a==31&&b>=5)) s="?",a-=30;
		cout<<s<<" "<<a<<" "<<b<<" "<<c<<endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int binpow(int a,int n){
	int res=1;
	while(n){
		if(n&1){
			res=a*res;
		}
		a=a*a;
		n>>=1;
	}
	return res;
}
bool pp(int n){
	for(int i=1;i*i<=n;i++){
		for(int j=2;j<=30;j++){
			if(binpow(i,j)==n){
				return true;
			}
		}
	}
	return false;
}
int main(){
	int x;
	cin>>x;
	for(int i=x;i>=1;i--){
		if(pp(i)){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  vector<string> s(n);
  for (auto &i : s) cin >> i;

  int64_t ans = 0;

  for (int a = 0; a < n; ++a) {
    bool f = true;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (s[i][(j + a) % n] != s[j][(i + a) % n]) f = false;
      }
    }
    if (f) ans += n;
  }

  cout << ans << endl;
}


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

int main() {
  int n, hikaku, ans;
  ans = 0;
  cin >> n;
  // ここにプログラムを追記
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    hikaku = 0;
    while (a > 1) {
      if (a % 2 == 0) {
        a /= 2;
        hikaku++;
      } else {
        break;
      }
    }
    if (hikaku == 0) {
      break;
    } else if (ans == 0 && hikaku > 0) {
      ans = hikaku;
    } else if (ans >= hikaku) {
      ans = hikaku;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256