akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<class T,class F>
struct segtree{
  int n;
  T e;
  F f;
  std::vector<T> dat;

  segtree(){}
  segtree(int sz,T _e,F _f):e(_e),f(_f){
    n = 1;
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
  }
  segtree(std::vector<T> const& v,T _e,F _f):e(_e),f(_f){
    build(v);
  }
  void build(std::vector<T> const& v){
    n = 1;
    int sz = v.size();
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
    for(int i=0;i<sz;++i){
      dat[i+n] = v[i];
    }
    for(int i=n-1;i>0;--i){
      dat[i] = f(dat[i<<1],dat[i<<1|1]);
    }
  }
  void set(int p,T v){
    for(dat[p+=n]=v;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  T query(int l,int r){
    T res = e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l&1){
        res = f(res,dat[l]);
        l++;
      }
      if(r&1){
        r--;
        res = f(res,dat[r]);
      }
    }
    return res;
  }
  T operator[](int k){
    return query(k,k+1);
  }
};

int main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  auto sum = [](auto a,auto b){return a+b;};
  segtree<ll,decltype(sum)> seg(n,0,sum);

  ll ans = 0;
  rep(i,n){
    if(seg.query(0,a[i])==0){
      ans++;
    }
    seg.set(a[i],1);
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 5888
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int len = sc.nextInt();
      Long[] goukei = new Long[len];
      Long kouhuku = new Long(0);
      for(int i = 0; i < len; i++){
        Long a = sc.nextLong();
        Long b = sc.nextLong();
        goukei[i] = a + b;
        kouhuku -= b;
      }
      Arrays.sort(goukei,Collections.reverseOrder());
      for(int i = 0; i < len; i = i + 2){
        kouhuku += goukei[i];
      }
      System.out.println(kouhuku);
	}
}


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

int main()
{
	int N = 0, x = 0;
	cin >> N >> x;
	int a[N];
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	long long ans = 0;
	for(int i = 0; i < N - 1; i++){
		if(a[i] + a[i + 1] > x){
			int operation = a[i] + a[i + 1] - x;
			a[i + 1] = max(a[i + 1] - operation, 0);
			int diff = operation - a[i + 1];
			a[i] -= diff;
			ans += operation;
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
  ll L,R;cin>>L>>R;
  ll d;cin>>d;
  ll cnt=0;
  for(int i=L;i<=R;++i){
    if(i%d==0)cnt++;
  }
  cout<<cnt<<endl;
}

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

int main() {
	string S;
	cin >> S;
	
	bool judge = false;
	
	for(int i = 0; i < S.length(); i++){
		for(int j = i + 1; j < S.length(); j++){
			if(S[i] == S[j]){
				judge = true;
				break;
			}
		}
		if (judge == true)
			break;
	}
	
	if (judge == true){
		cout << "no" << endl;
	}
	
	if (judge == false){
		cout << "yes" << endl;
	}
	return 0;
}

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

a=[]
s=[]

for i in range(1,n+1):

    if i % 15 == 0:

        a.append("FizzBuzz")

    elif i % 3 == 0:

        a.append("Fizz")

    elif i % 5 == 0:

        a.append("Buzz")

    else: s.append(i)

print(sum(s))


Measured memory_bytes: 33580
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int A[1000000], n;

int main()
{
    int q, k, sum = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    cin >> q;
    for (int i = 0; i < q; i++) {
        scanf("%d", &k);
        // 標準ライブラリの lower_bound を使用
        if (*lower_bound(A, A + n, k) == k) sum++;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int arr[a];
	for(int i=0; i<a; i++)
		cin >> arr[i];
	int dp[a] = {0};
	for(int i=1; i<a; i++)
	{
		if(i == 1) dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
		else
			dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]));
	}
	printf("%d\n",dp[a - 1]);
	return 0;
} 

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,i,ans=0;
    scanf("%lld",&n);
    ll a[n],div=0;
    for(i=0;i<n;i++){
        div=0;
        scanf("%lld",&a[i]);
        while(a[i]%2==0){
            a[i]/=2;
            div++;
        }
        ans+=div;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
const ll mod = 1e9+7;

mat mul(mat& A, mat& B){
  mat C(A.size(), vec(B[0].size(),0));
  rep(i, A.size()){
    rep(j, B[0].size()){
      rep(k, A[0].size()){
        C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod;
      }
    }
  }
  return C;
}

mat pow(mat& A, ll n) {
  mat B(A.size(), vec(A.size(), 0));
  rep(i, A.size()) B[i][i] = 1;
  while(n > 0){
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

int main(){
  ll n, k;
  cin >> n >> k;
  mat a(n,vector<ll>(n));
  rep(i,n) {
    rep(j,n) cin >> a[i][j];
  }
  mat b = pow(a,k);
  ll ans = 0;
  rep(i,n){
    rep(j,n) (ans += b[i][j]) %= mod;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int a[3];
  
  for(int i=0;i<3;i++){
    cin >> a[i];
  }
  
  sort(a,a+3);
  
  for(int i=0;i<3;i++){
    cout << a[i];
    if(i!=2){
      cout << ' ';
    }
  }
  
  cout << endl;
  
  return 0;

}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int n;
	cin >> n;
	map<int, int> m;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		m[x]++;
	}

	int ans = 0;
	for(auto v : m){
		if(v.second < v.first) ans += v.second;
		else ans += abs(v.first - v.second);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4736
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

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>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    Int a, b, c, k; cin >> a >> b >> c >> k;
    if(a >= k) {
        println(k);
    } else if(a + b >= k) {
        println(a);
    } else {
        Int d = k - a - b;
        println(a - d);
    }

    return 0;
}


Measured memory_bytes: 3636
import java.lang.Math.*


fun main(args: Array<String>) {
    val (n, a, b) = readIntList()
    println(min(n * a, b))
}


fun readList() = readLine()!!.split(' ')
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n), f(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];

  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  ll l = -1, r = 1e12;
  while (l + 1 < r) {
    ll c = (l + r) / 2;
    bool ok = [&]() {
      ll s = 0;
      rep(i, n) { s += max(0ll, a[i] - c / f[i]); }
      return s <= k;
    }();
    if (ok)
      r = c;
    else
      l = c;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
#import numpy as np
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]

rowIndex=[False]*h
colIndex=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            rowIndex[i]=True
            colIndex[j]=True
    
for i in range(h):
    if rowIndex[i]:
        for j in range(w):
            if colIndex[j]:
                print(a[i][j],end='')
        print()

Measured memory_bytes: 9212
#include<stdio.h>
int main(){
  int n,i,j,l,min,max,a[1000][1000];
  char d[1000][1000];
  while(scanf("%d",&n),n){
    for(i=0;i<n;i++){
      for(j=l=0;j<n;j++){
	scanf(" %c",&d[i][j]);
	if(d[i][j]=='.')a[i][j]=++l;
	if(d[i][j]=='*')a[i][j]=l=0;
      }
    }
    for(i=max=0;i<n;i++){
      for(j=l=0;j<n;j++){
	if(d[j][i]=='.')l++;
	if(d[j][i]=='*')l=0;
	min=a[j][i];
	if(min>l)min=l;
	if(j&&i&&min>a[j-1][i-1]+1)min=a[j-1][i-1]+1;//printf("%d ",min);
	a[j][i]=min;
	if(max<min)max=min;
      }//printf("\n");
    }
    printf("%d\n",max);
  }
  return 0;
}

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

int main(){
    int N;cin>>N;
    map<int,int> zyosi;
    for(int i=1;i<=N;i++){
        zyosi[i]=0;
    }
    for(int i=2;i<=N;i++){
        int k;cin>>k;
        zyosi[k]++;
    }
    auto begin=zyosi.begin();
    auto end=zyosi.end();
    for(auto i=begin;i!=end;i++){
        cout<<i->second<<endl;
    }
}

Measured memory_bytes: 12980
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;


int main(){
  int n,m;cin >> n >> m;
  map<int,int> mp;
  mp[0]++;
  vector<ll> a(n+1,0);
  rep(i,n){
    cin >> a[i+1];
    a[i+1] += a[i];
    mp[a[i+1]%m]++;
  }
  ll ans = 0;
  for(auto p:mp){
    ans += ll(p.second)*ll(p.second-1)/2;
  }

  cout << ans << endl;
}

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

using namespace std;

int main()
{
	int N, K, S;
	cin >> N >> K >> S;
	vector<int> vv(N);

	for (int i = 0; i < K; i++)
		vv[i] = S;

	for (int j = K; j < N; j++)
	{
		if (S == 1000000000)
			vv[j] = 1;
		else
			vv[j] = S + 1;
	}
	

	for (int k = 0; k < N; k++)
		cout << vv[k] << " ";
	return 0;
}

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

int		main(void)
{
	int n, m, x, y;

	scanf("%d%d%d%d", &n, &m, &x, &y);
	string ans = "No War";
	set<int> a;
	set<int> b;

	a.insert(x);
	for (int i = 0; i < n; i++)
	{
		int tmp;

		cin >> tmp;
		a.insert(tmp);
	}
	b.insert(y);
	for (int i = 0; i < m; i++)
	{
		int tmp;

		cin >> tmp;
		b.insert(tmp);
	}
	if (*rbegin(a) >= *begin(b))
		ans = "War";	
	cout << ans << endl;
}



Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n;
		scanf("%d",&n);
		for (int i=1 ; i<10 ; i++)
		{
			if(n%i==0 && n/i<10)
			{
				printf("Yes");
				return 0;
			}
		}
		printf("No");
		return 0;
}  


Measured memory_bytes: 3848
a, b, c, x, y = map(int, input().split())
ans = 0
if c * 2 <= a and c * 2 <= b:
    ans = max([x, y]) * 2 * c
elif c * 2 <= a:
    if x >= y:
        ans += x * 2 * c

    else:
        ans += x * 2 * c
        ans += (y-x) * b

elif c * 2 <= b:
    if y >= x:
        ans += y * 2 * c

    else:
        ans += y * 2 * c
        ans += (x - y) * a

elif c * 2 <= a + b:
    if x >= y:
        ans += y * 2 * c
        ans += (x - y) * a

    else:
        ans += x * 2 * c
        ans += (y - x) * b

else:
    ans = a * x + b * y

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	var count int

	isPalindromic := func (x int) bool {
		reverse := 0
		tmp := x
		for ; tmp != 0; {
			remaind := tmp % 10
			reverse = reverse * 10 + remaind
			tmp /= 10
		}
		if reverse == x {
			return true
		} else {
			return false
		}
	}

	for i := a; i <= b; i++ {
		if isPalindromic(i) {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    val e = sc.nextInt()
    val k = sc.nextInt()
    println(if (e - a <= k) "Yay!" else ":(")
}

Measured memory_bytes: 31272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define BIG 100000000

ll  lcm(ll a,ll b)
{
    ll GCD=__gcd(a,b);
    ll lcm=(a*b)/GCD;
    return lcm;
}
ll dp[1000005];
ll weight[1000005];
ll total,val;
int main()
{
    cin>>total>>val;
    for ( int i = 1; i <=total; i++ )
        cin>>weight[i];

    weight[0]=1e9;
    for(int i=2; i<=total; i++)
    {
        dp[i]=1e18;
        for(int j=1; j<=val; j++)
            if(i-j>=1)
                dp[i]=min(dp[i],abs(weight[i]-weight[i-j])+dp[i-j]);

    }
    cout<<dp[total]<<endl;
    return 0;
}



Measured memory_bytes: 5120
# coding: utf-8
# Your code here!
import itertools
N,M=map(int,input().split())
path=[[False]*N for _ in range(N)]
for i in range(M):
    a,b=[int(j) for j in input().split()]
    path[a-1][b-1]=True
    path[b-1][a-1]=True
ans=0
for junjo in itertools.permutations(range(1,N)):
    nexts=list(junjo)
    if path[0][nexts[0]]==False:continue
    if all([path[nexts[i]][nexts[i+1]] for i in range(N-2)]):
        ans+=1
print(ans)

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

using namespace std;

int main() {
	//入力
	int a, b, x;
	cin >> a >> b >> x;

	if (a > x) cout << "NO" << endl;
	else {
		if (a + b < x) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

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

int main()
{
    //freopen("3.txt","r",stdin);
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ans=0;
	while((a>0&&(a%2==0))&&(b>0&&(b%2==0))&&(c>0&&(c%2==0)))
	{
		int A=0,B=0,C=0;
		ans++;
		if(ans>=1000000) break;
		if((a%2)==0) 
		{
			B+=a/2;
			C+=a/2;
		}
		if((b%2)==0) 
		{
			A+=b/2;
			C+=b/2;
		}
		if((c%2)==0) 
		{
			A+=c/2;
			B+=c/2;
		}
		a=A;
		b=B;
		c=C;
	}
	if(ans<1000000) printf("%d\n",ans);
	else printf("-1\n");
    return 0;
}

Measured memory_bytes: 256
import collections
S = collections.deque(list(input()))
Q=int(input())

q=[0]*Q
turn=0
houkou=['']*2
for i in range(Q):
    q[i]=input()

    if(q[i][0]=='1'):
        turn=not turn

    else:
        if(turn==0):
            if(q[i][2]=='1'):
                S.appendleft(q[i][4])

            else:
                S.append(q[i][4])
        else:
            if(q[i][2]=='1'):
                S.append(q[i][4])

            else:
                S.appendleft(q[i][4])



if(turn==0):
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))


Measured memory_bytes: 116388
<?php

const MOD = 1000000007;

fscanf(STDIN, "%d", $n);
$a_list = array_map('intval', explode(' ', trim(fgets(STDIN))));

$a_max = max($a_list);

$numbers = range(3, 1000, 2);
$prime_numbers = [2];
while (count($numbers) > 0) {
    $prime = array_shift($numbers);
    $prime_numbers[] = $prime;
    foreach ($numbers as $key => $number) {
        if ($number % $prime === 0) {
            unset($numbers[$key]);
        }
    }
}

$prime_factorized_lcm = [];
foreach ($a_list as $a) {
    foreach ($prime_numbers as $prime_number) {
        $expo = 0;
        while ($a % $prime_number === 0) {
            ++$expo;
            $a /= $prime_number;
        }

        if (!isset($prime_factorized_lcm[$prime_number]) || $expo > $prime_factorized_lcm[$prime_number]) {
            $prime_factorized_lcm[$prime_number] = $expo;
        }

        if ($a === 1) {
            break;
        }
    }

    if ($a > 1) {
        $prime_factorized_lcm[$a] = 1;
    }
}

$lcm = 1;
foreach ($prime_factorized_lcm as $prime_number => $expo) {
    $lcm = ($lcm * ($prime_number ** $expo)) % MOD;
}

$inv_numbers = [null, 1];
for ($i = 2; $i <= $a_max; ++$i) {
    $inv_numbers[$i] = MOD - $inv_numbers[MOD % $i] * intdiv(MOD, $i) % MOD;
}

$answer = 0;
foreach ($a_list as $a) {
    $answer = ($answer + $lcm * $inv_numbers[$a] % MOD) % MOD;
}

echo $answer;


Measured memory_bytes: 41456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n];

    int max_move = 0, current_move = 0, pre_h, cur_h, index=1;
    cin >> pre_h;
    while (index < n){
        cin >> cur_h;
        if (cur_h <= pre_h){
            current_move++;
        }
        else{
            max_move = max(current_move, max_move);
            current_move = 0;
        }
        pre_h = cur_h;
        index++;
    }
    max_move = max(max_move, current_move);
    cout << max_move << endl;
    return 0;
}

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

typedef long long ll;
using namespace std;
const int maxn = 1e6+5;
void tlfclwx()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}


int main()
{
    string a, b;
    int n, m;
    cin >> n >> m;
    if(n > m) {
        for(int i = 0; i < n; i++) {
            cout << m;
        }
    }
    else {
        for(int i = 0; i < m; i++) {
            cout << n;
        }
    }
}


Measured memory_bytes: 256
using System;

namespace CardGame
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {

                int length = Convert.ToInt32(Console.ReadLine(), 10);

                if (length == 0) break;

                Player A = new Player(length);
                Player B = new Player(length);

                for (int i = 0; i < length; i++)
                {
                    String[] inputs = Console.ReadLine().Split(' ');

                    A.Cards[i] = Convert.ToInt32(inputs[0], 10);
                    B.Cards[i] = Convert.ToInt32(inputs[1], 10);
                }

                for (int i = 0; i < length; i++)
                {
                    if (A.Cards[i] > B.Cards[i])
                    {
                        A.Score += A.Cards[i] + B.Cards[i];
                    }
                    else if (A.Cards[i] < B.Cards[i])
                    {
                        B.Score += A.Cards[i] + B.Cards[i];
                    }
                    else if (A.Cards[i] == B.Cards[i])
                    {
                        A.Score += A.Cards[i];
                        B.Score += B.Cards[i];
                    }
                }

                Console.WriteLine(A.Score + " " + B.Score);
            }

        }
    }

    public struct Player
    {
        public int[] Cards;
        public int Score;

        public Player(int len)
        {
            Cards = new int[len];
            Score = 0;
        }
    }
}

Measured memory_bytes: 6064
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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

    double acc = accumulate(A.begin(), A.end(), 1, [](double a, double b){return a * b;});
    double tmp = 0;
    for(int i = 0; i < N; ++i){
        tmp += acc / A[i];
    }
    cout << acc / tmp << endl;


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

int main()
{
    int A[5], k;

    for (int i = 0; i < 5; i++)
    {
        cin >> A[i];
    }
    cin >> k;


    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if ((A[i] - A[j]) > k) {
                cout << ":("<<  endl;
                return 0;
            }
        }
    }

                cout << "Yay!" << endl;

    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    string ans = "YES";
    for (int i = 0; i < n-1; i++) {
        if (a[i] == a[i+1]) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }



ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const ll MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<long long> nCr;


ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     
        IsPrime.resize(max+1,true); 
    } 
    IsPrime[0] = false; 
    IsPrime[1] = false; 

    for(size_t i=2; i*i<=max; ++i) 
        if(IsPrime[i]) 
            for(size_t j=2; i*j<=max; ++j) 
                IsPrime[i*j] = false;      
}

struct UnionFind {
    vector<int> par; 

    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        par[rx] = ry; 
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i = 0; i < n; i++){
        cin>>h[i];
    }
    sort(h,h+n);
    ll ans = 0;
    for(int i = 0; i < n-k; i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

    // int n,m;
    // int a,b,c;
    string s,t;
    
    cin >> s;

    if(s.size()%2 != 0){
        cout << "No" << endl;
    }else{
        rep(i,s.size()/2){
            if(s[2*i] == 'h' && s[2*i+1] == 'i'){

            }else{
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://hitachi2020.contest.atcoder.jp/tasks/hitachi2020_a

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

int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  int mcnt=0;
  for(int i=0; i<n; i++){
    long aa;
    cin >> aa;
    a[i]=abs(aa);
    if(aa<0)mcnt++;
  }
  sort(a.rbegin(), a.rend());
  long ret=accumulate(a.begin(), a.end(), 0L);
  if(mcnt%2==1)ret-=2*a[n-1];
  cout << ret;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
int main(){
	scanf("%d%d%d", &n, &a, &b);
  	for(int i=a; i<=b; i++){
      if(i%n == 0){
        printf("OK");
        return 0;
      }
    }
  	printf("NG");
}

Measured memory_bytes: 3824
#include<stdio.h>
#define N 100000
 
typedef struct Ki{
  int p;
  int r;
  int l;
  int h;
}tree;
 
int n;
tree T[N];
 
void sibling(int i){
  int j;
  for(j=0;j<n;j++){
    if(T[i].p == -1){
      printf("-1");
      break;
    }
    else if(T[i].p==T[j].p&&i != j){
      printf("%d",j);
      break;
    }
    if(j==n-1)printf("-1");
       
  }
}
 
 
 
int depth(int i){
  int count=0,iNoOya;
  iNoOya=i;
  while(1){
    if(T[iNoOya].p==-1) break;
    iNoOya=T[iNoOya].p;
    count++;
     
  }
  return count;
}
 
void hantei(int i){
  if( T[i].p == -1)printf("root");
  else if(T[i].p!=-1 && T[i].h==0) printf("leaf");
  else printf("internal node");
  printf("\n");
}
 
int degree(int i){
  int j,count=0;
  for(j=0;j<n;j++){
    if(T[j].p==i) count++;
  }
  return count;
}
 
int height(int i){
  int j,left,right,a,b;
  if(T[i].h==-1){
    if(T[i].l==-1 && T[i].r==-1){
      T[i].h=0;
    }
    else{
       
      if(T[i].l!=-1){
    left = T[i].l;
    a = height(left);
      }
       
      else a = 0;
       
      if(T[i].r!=-1){
    right = T[i].r;
    b = height(right);
      }
      else b = 0; 
       
      if(a==b) T[i].h = a+1;
      if(a>b) T[i].h = a+1;
      if(a<b) T[i].h = b+1;
    }
  }
  return T[i].h;
}
 
 
 
 
int main(){
  int i,id,left,right;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
    T[i].h = -1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].r = right;
    T[right].p = id;
    T[id].l = left;
    T[left].p = id;
  }
   
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = ",i,T[i].p);
    sibling(i);
    printf(", degree = %d, depth = %d, height = %d, ",degree(i),depth(i),height(i));
    hantei(i);
  }
  return 0;
}

Measured memory_bytes: 1808
def nsum(n):
  if n%2==0:
    return (n+1)*(n/2)
  else:
    return (n+1)*((n-1)/2)+((n+1)/2)
S=input()
count=0
flag=-1
code=[]
for i in S:
  if count == 0:
    count+=1
    flag=i
  elif flag==i:
    count+=1
  else:
    code.append([flag,count])
    count=1
    flag=i
code.append([flag,count])
#print(code)
ans=0
if code[0][0]=='>':
  ans+=nsum(code[0][1])
if code[-1][0]=='<':
  ans+=nsum(code[-1][1])
for a in range(len(code)-1):
  if code[a][0]=='>':
    continue
  else:
    a1=code[a][1]
    a2=code[a+1][1]
    if a1<a2:
      a1,a2=a2,a1
    ans+=nsum(a1)+nsum(a2-1)
print(int(ans))

Measured memory_bytes: 29084
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;

}
int KH[300001], KW[300001];
int h[300001], w[300001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H = getint(), W = getint(), M = getint();

	rep(i, M) {
		KH[h[i] = getint()]++;
		KW[w[i] = getint()]++;
	}

	int saidaih = -1, hh = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			hh = 1;
		}
		else if (saidaih == KH[i]) hh++;
	}
	int saidaiw = -1, ww = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			ww = 1;
		}
		else if (saidaiw == KW[i]) ww++;
	}

	ll are = ll(hh) * ww;

	int kazu = 0;
	rep(i, M) {
		kazu += (KH[h[i]] == saidaih && KW[w[i]] == saidaiw);
	}

	printf("%d\n", saidaih + saidaiw - (kazu == are));

	Would you please return 0;
}

Measured memory_bytes: 6388
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		for (int i=0;i<n;i++) {
			System.out.println(sc.nextLine().replace("Hoshino","Hoshina"));
		}
	}
}

Measured memory_bytes: 17436
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    ll N,M;
    cin >> N >> M;
    if(N != 1){
        N -= 2;
    }
    if(M != 1){
        M -= 2;
    }
    cout << N * M << endl;



    return 0;
}


Measured memory_bytes: 888
from collections import deque

H, W = map(int, input().split())
grid = []
for _ in range(H):
  grid.append(input())

def get_adj(pos):
  ans = []
  for v in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
    adj = (pos[0] + v[0], pos[1] + v[1])
    if adj[0] >= 0 and adj[0] < H and adj[1] >= 0 and adj[1] < W:
      ans.append(adj)
  return ans

start = (0, 0)
goal = (H-1, W-1)

q = deque()
q.append((start, 1))
visited = {}

while q:
  pos, dist = q.popleft()
  if grid[pos[0]][pos[1]] == '#':
    continue
  if pos in visited:
    continue
  visited[pos] = dist
  if pos == goal:
    break
  for adj in get_adj(pos):
    q.append((adj, dist+1))

cnt_walls = sum([row.count('#') for row in grid])

if goal in visited:
  print(H*W-visited[goal]-cnt_walls)
else:
  print(-1)

Measured memory_bytes: 9384
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
#include<tuple>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int sum = a+b;

  if(sum % 2 == 0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;

}


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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  rep(i,N) {
    cin >> A[i];
  }
  int total = N + X;
  for (int i = 0; i < N; i++) {
    int j = 1;
    while (j*A[i]+1 <= D) {
      total++;
      j++;
    }
  }

  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define next fuck
#define se second
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for(int i = 0;i<k;i++)
    {
        if(i % 2 == 0)
        {
            b += a/2;
            a = a/2;
        }
        else
        {
            a += b/2;
            b = b/2;
        }
        //cout<<a<<' '<<b<<endl;
    }
    cout<<a<<' '<<b<<endl;
    return 0;
}


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

string s;
bool ok=1;

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>s;
    if (s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) ok=0;
    cout<<(ok?"Good":"Bad")<<'\n';
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans;
struct Edge { Pll to; LL cost; };
bool f;
vector<Edge>vec[100][100];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	if (n % 500 <= m)
		f = 1;
	yn(f);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll x, n;
  cin >> x >> n;
  vl p(n);
  rep(i,n){
    cin >> p[i];
  }
  ll a1, a2;
  for (ll i = x; i <= x; i--){
    bool z = true;
    rep(j,n){
      if(p[j]==i){
        z = false;
      }
    }
    if(z){
      a1 = i;
      break;
    }
  }
  for (ll i = x; i >= x; i++){
    bool z = true;
    rep(j,n){
      if(p[j]==i){
        z = false;
      }
    }
    if(z){
      a2 = i;
      break;
    }
  }
  ll ans;
  if(x-a1<=a2-x){
    ans = a1;
  }
  else{
    ans = a2;
  }
  print(ans);
}


Measured memory_bytes: 3532
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int h, n;
	cin >> h >> n;
	int a[100003];

	rep(i, n) {
		cin >> a[i];
	}

	rep(i, n) {
		h -= a[i];
	}
	if (h <= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
	
int N;
scanf("%d",&N);

int A,B;
scanf("%d %d",&A,&B);
for (A==A;A<=B;A++){
    if(A%N==0){
        printf("OK");
        return 0;
    }
    else{
        continue;
    }
}
printf("NG");
return 0;
}

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

typedef long long ll;
const int MOD = 1000000007;

int n, m, p[410], G[20][20];
int c[1 << 15], d[1 << 15], f[3][1 << 15];

int main()
{
	p[0] = 1; for(int i = 1; i < 410; ++i) p[i] = 2ll * p[i - 1] % MOD;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; ++i)
	{
		int u, v; scanf("%d %d", &u, &v);
		++G[u][v];
	}
	int cnt = (1 << n) - 1;
	for(int i = 0; i <= cnt; ++i)
		for(int j = 1; j <= n; ++j)
			for(int k = 1; k <= n; ++k) if(G[j][k])
			{
				if(((i >> j - 1) & 1) && ((i >> k - 1) & 1)) c[i] += G[j][k];
				if(((i >> j - 1) & 1) || ((i >> k - 1) & 1)) d[i] += G[j][k];
			}
	for(int k = 1; k <= 2; ++k)
		for(int i = 0; i <= cnt; ++i)
		{
			if(!((i >> k - 1) & 1)) continue;
			f[k][i] = p[c[i]];
			for(int j = (i - 1) & i; j; j = (j - 1) & i)
			{
				if(!((j >> k - 1) & 1)) continue;
				f[k][i] = ((f[k][i] - (ll)f[k][j] * p[c[i - j]] % MOD) % MOD + MOD) % MOD;
			}
		}
	int ans = p[m];
	for(int i = 0; i <= cnt; ++i)
	{
		if(!(i & 1) || ((i >> 1) & 1)) continue;
		for(int j = cnt - i; j; j = (j - 1) & (cnt - i))
		{
			if(!((j >> 1) & 1) || c[i] + c[j] < c[i + j]) continue;
			ans = ((ans - (ll)f[1][i] * f[2][j] % MOD * p[m - d[i + j]] % MOD) % MOD + MOD) % MOD;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 768
// https://atcoder.jp/contests/abc100/tasks/abc100_b

package main

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

func main() {
  io := NewIo()
  D := io.NextInt()
  N := io.NextInt()

  order := N

  if N == 100 {
    order++
  }

  result := order * int(math.Pow(100,float64(D)))

  fmt.Println(result)
}

type Io struct {
  reader *bufio.Reader
  writer *bufio.Writer
  tokens []string
  nextToken int
}

func NewIo() *Io {
  return &Io{
    reader: bufio.NewReader(os.Stdin),
    writer: bufio.NewWriter(os.Stdout),
  }
}

func (io *Io) Next() string {
  if io.nextToken >= len(io.tokens) {
    line := io.NextLine()
    io.tokens = strings.Fields(line)
    io.nextToken = 0
  }

  res := io.tokens[io.nextToken]
  io.nextToken++
  return res
}

func (io *Io) NextInt() int {
  res, err := strconv.Atoi(io.Next())
  if err != nil {
    panic(err)
  }
  return res
}

func (io *Io) Println(a ...interface{}) {
  var values []string
  for i := 0; i < len(a); i++ {
    values = append(values, "%v")
  }
  io.Printfln(strings.Join(values, " "), a...)
}

func (io *Io) Printfln(format string, a ...interface{}) {
  fmt.Fprintf(io.writer, format+"\n", a...)
}

func (io *Io) NextLine() string {
  if io.nextToken < len(io.tokens) {
    panic("io.nextToken < len(io.tokens)")
  }

  var buffer bytes.Buffer

  for {
    line, isPrefix, err := io.reader.ReadLine()
    if err != nil {
      panic(err)
    }
    buffer.Write(line)
    if !isPrefix {
      break
    }
  }

  return buffer.String()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define int long long
#define REP(i,l,r) for(int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
int cnt2[100000];
signed main(){
    int n,k,cnt1,cnt22=0,cnt3;
    string s;
    cin>>n>>k>>s;
    cnt2[0]=1;
    rep(i,n){
        if(i==0&&s[i]=='0')cnt1=1;
        else if(i==0) cnt1=0;
        else{
            if(s[i]!=s[i-1]){
                cnt22++;
                cnt2[cnt22]=1;
            }
            else cnt2[cnt22]++;
        }
    }
    if(s[n-1]=='0')cnt3=1;
    else cnt3=0;
    int ans=0;
    int l=0,r=0;
    if(cnt22<k*2){
        cout<<n<<endl;
        return 0;
    }
    if(cnt1){
        l=1;
        int cnt=0;
        rep(i,k*2){
            cnt+=cnt2[i];
        }
        ans=cnt;
    }
    if(cnt3){
        r=1;
        int cnt=0;
        rep(i,k*2){
            cnt+=cnt2[n-1-i];
        }
        ans=max(ans,cnt);
    }
    rep(i,(n-l-r-k*2+1)/2+1){
        int cnt=0;
        rep(j,k*2+1){
            cnt+=cnt2[i*2+l+j];
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1280
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String []s=br.readLine().split(" ");
		int evc=0,app=0;
		
		for(int i=0;i<N;i++)
		{
			int x= Integer.parseInt(s[i]);
			
			//if even then check 3 or 5
			if((x&1)!=1)
			{
				evc++;
				if(x%3==0 || x%5==0)
					app++;		
			}	
		}
		
		if(evc==app)
			out.println("APPROVED");
		else
			out.println("DENIED");
	
	}
}




Measured memory_bytes: 23252