akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

string r="keyence";
int main(){
	ios_base::sync_with_stdio(false);
	string s;cin>>s;
	ll n=s.size();
	if(s==r){
		cout<<"YES"<<endl;return 0;
	}
	For(i,0,n){
		For(j,i,n){
			string temp="";
			For(k,0,i){
				temp.pb(s[k]);
			}
			For(k,j+1,n){
				temp.pb(s[k]);
			}
			if(temp==r){
				cout<<"YES"<<endl;return 0;
			}
		}
	}
	
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new TreeMap<>();
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			if (map.get(s) == null) {
				map.put(s, 1);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		List<String> resultList = new ArrayList<>();
		int max = 0;
		for (Entry<String, Integer> entry : map.entrySet()) {
			if(entry.getValue() > max) {
				resultList = new ArrayList<>();
				resultList.add(entry.getKey());
				max = entry.getValue();
			} else if(entry.getValue() == max) {
				resultList.add(entry.getKey());
			}
		}
		Collections.sort(resultList);
		resultList.stream().forEach(s -> System.out.println(s));
	}
}

Measured memory_bytes: 89752
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  for (int i = 0; i < k && !(a < b && b < c); i++) {
    if (a >= b)
      b *= 2;
    else if (b >= c)
      c *= 2;
  }
  if (a < b && b < c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
n=int(input())
h=list(map(int,input().split()))

# nの足場までいく最小コストを a_n とする。
# a_1のコストは0,  a_2のコストは(h_1からの１通りなので)\h_1-h_2\
dp=[0]*n
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n % 2 == 0) {
    bool ok = true;
    rep(i, s.size()/2) {
      if(s[i] != s[s.size()/2+i]) {
        ok = false;
        break;
      }
    }
    if(ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    if s=='Sunny':
        print('Cloudy')
    elif s=='Cloudy':
        print('Rainy')
    else:
        print('Sunny')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3188
#include<stdio.h>
int A[10000000], n;

int binarySearch(int key){
 int left = 0;
 int right = n;
 int mid;
 while(left < right){
  mid = (left + right) / 2;
  if(key == A[mid]) return 1;
  if(key > A[mid]) left = mid + 1;
  else if(key < A[mid]) right = mid;
 }
 return 0;
}

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

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

 scanf("%d", &q);
 for(i = 0; i < q; i++){
  scanf("%d", &k);
  if(binarySearch( k )) sum++;
 }
 printf("%d\n", sum);

 return 0;
}


Measured memory_bytes: 2124
n = int(input())
k = list(map(int, input().split( )))

r = [-1]*n
l = [-1]*n
p = [-1]*n

for i in range(n):
    if 2*i+2<=n-1:
        r[i] = k[2*i+2]
    if 2*i + 1 <= n-1:
        l[i] = k[2*i+1]
    p[i] = k[(i-1)//2]
for i in range(n):
    print(f"node {i+1}:","key =",k[i],end =", ")
    if i!=0:
        print("parent key =",p[i],end=", ")
    if 2*i + 1 <= n-1:
        print("left key =",l[i], end=", ")
    if 2*i+2<=n-1:
        print("right key =",r[i], end=", ")
    print()


Measured memory_bytes: 5728
#include <stdio.h>

typedef long long ll;

const int MAXN = 1000005;
const ll MOD = (ll)1e9 + 7;

ll d10[MAXN] = { 1 }, d9[MAXN] = { 1 }, d8[MAXN] = { 1 };

int main(void)
{
	int n, i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
	{
		d10[i] = d10[i - 1] * 10 % MOD;
		d9[i] = d9[i - 1] * 9 % MOD;
		d8[i] = d8[i - 1] * 8 % MOD;
	}

	printf("%lld", (d10[n] - d9[n] * 2 + d8[n] + MOD * 2) % MOD);
	return 0;
}

Measured memory_bytes: 25168
#include <iostream>
using namespace std;
#define swap(x,y) int (temp)=int (x);(x)=int (y);(y)=(temp);
#define ll long long
#define S string
#define len(a)	string (a).length()
#define arn 100000
#define forn(a,b) for(int (a)=1;a<=int (b);a++)
#define for3(a,b,c) for(int (a)=int (c); a<=int(b);a++)
int main()
{
	ll n,a;
	cin>>n>>a;
	if(n%500<=a)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
// C
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$c = 0;
for ($i = 0; $i < $n; $i++) {
    $c += abs($a[$i] - $a[$i - 1] ?? 0);
    $cut[] = abs($a[$i + 1] - $a[$i - 1] ?? 0) - (abs($a[$i] - $a[$i - 1] ?? 0) + abs($a[$i + 1] - $a[$i]));
}
$c += abs($a[$n - 1]);
for ($i = 0; $i < $n - 1; $i++) {
    $ans[] = $c + $cut[$i];
}
$ans[] = $c - abs($a[$n - 1]) - abs($a[$n - 1] - $a[$n - 2]) + abs($a[$n - 2]);
echo implode(PHP_EOL, $ans);

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

#define ll long long

#define pi 2*acos(0.0)

using namespace std;

int main(){

int day,asing;

cin>>day>>asing ;

int sum=0;

for(int i =0;i<asing;i++){

  int x;

  cin>>x;

  sum+=x;

}

if(sum>day){

cout<<"-1"<<endl;

}

else{

cout<<(day-sum)<<endl;

}

return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

void Factori(map<int64_t,int64_t> &P, int64_t n){
    for(int64_t i=2; i*i<=n; i++){
        if(n%i==0){
            while(n%i==0){
                P[i]++;
                n/=i;
            }
        }
    }
    if(n!=1) P[n]++;
}

int main(){
    int64_t N; cin>>N;

    map<int64_t,int64_t> P;
    Factori(P,N);

    int64_t ans=0;
    for(auto p:P){
        int64_t i=0,sumI=0;
        while(sumI+i+1<=p.second){
            i++;
            sumI+=i;
        }
        ans+=i;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;
typedef long long ll;
ll W, H;
char a[110][110];
ll sx, sy;
ll SUM;

void dfs(int x,int y, char cur) {
	if(a[y][x]==cur) {
		a[y][x] = '-';
	}else {
		return;
	}
	int dx[4] = { -1,1,0,0 };
	int dy[4] = { 0,0,-1,1 };
	for (int i = 0; i < 4;i++) {
		int px = x + dx[i];
		int py = y + dy[i];
		if (0 <= px && px < W && 0<=py && py<H) {
			dfs(px, py, cur);
		}
	}
}

int main() {
	vector<ll> res;
	do {
		memset(a, 0, sizeof(a));
		cin >> H >> W;
		SUM = 0;
		for (int i = 0; i < H; i++) {
			cin >> a[i];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W;j++) {
				if (a[i][j] != '-') {
					dfs(j,i,a[i][j]);
					SUM++;
				}
			}
		}
		res.push_back(SUM);
	} while (W != 0 && H != 0);
	for (int i = 0; i < res.size() - 1;i++) {
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2012
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
int nodes,u,v,degrees[100005]={},root;
long long arr[100005],totaledge[100005]={};
vector <int> node[100005];
bool ans=true;
void dfs(int titik,int par)
{
	for(int i=0;i<node[titik].size();i++)
		if(node[titik][i]!=par)
			dfs(node[titik][i],titik);
	long long edgetambahan=2*arr[titik]-totaledge[titik];
	if(edgetambahan<0)
		ans=false;
	if(edgetambahan>arr[titik])
		ans=false;
	if(titik!=root&&edgetambahan>arr[par])
		ans=false;
	totaledge[par]+=edgetambahan;
}
int main()
{
	scanf("%d",&nodes);
	for(int i=1;i<=nodes;i++)
		scanf("%lld",&arr[i]);
	for(int i=1;i<=nodes-1;i++)
	{
		scanf("%d%d",&u,&v);
		degrees[u]++;degrees[v]++;
		node[u].push_back(v);
		node[v].push_back(u);
	}
	if(nodes==2)
	{
		if(arr[1]==arr[2])
			printf("YES\n");
		else
			printf("NO\n");
		return 0;
	}
	for(int i=1;i<=nodes;i++)
	{
		if(degrees[i]==1)
			totaledge[i]+=arr[i];
		else
			root=i;
	}
	dfs(root,0);
	if(totaledge[0]!=0)
		ans=false;
	if(ans)
		printf("YES\n");
	else
		printf("NO\n");	
}

Measured memory_bytes: 13312
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    L = lmi_0()
    cnt = [0] * n
    for elm in L:
        cnt[elm] += 1
    for elm in cnt:
        print(elm)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32412
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int d,t,s;
   cin >> d >> t >> s;
   if(d <= s*t){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 3616
#include<iostream>

using namespace std;

int main(){
	int A,B;
  	cin >> A;
  	cin >> B;
  	int j = 1;
  	if(A > 8 || B > 8) j = 0;
  	if(j){
      cout << "Yay!" << endl;
    }else{
      cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

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

        // input
        int x = scan.nextInt();
        int a = scan.nextInt();

        // answer
        if(x < a){
            System.out.println(0);
        } else {
            System.out.println(10);
        }

    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll A,B,C,D,E;
    cin>>A>>B>>C>>D>>E;
    cout<<(C-A)*60+D-B-E<<endl;
}

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

using namespace std;

long long n;
long long a[200010];
long long x[200010];
long long y[200010];
map<long long, long long> m;
long long sum;

int main(void)
{
	scanf("%lld", &n);
	
	for(long long i = 1 ; i <= n ; i++)
	{
		scanf("%lld", &a[i]);
		x[i] = i - a[i];
		y[i] = i + a[i];
	}
	
	m[y[1]]++;
	
	for(long long i = 2 ; i <= n ; i++)
	{
		sum += m[x[i]];
		m[y[i]]++;
	}
	
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 31068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  h.push_back(INF);
  int cnt = 0;
  for(int i = 1; i <= n; i++){
    if(h[i - 1] >= h[i]){
      cnt++;
    }else{
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  vector<int> x(3,0);
  REP(i,3) cin>>x.at(i);
  if((x.at(0)*100+x.at(1)*10+x.at(2))%4) cout<<"NO";
  else cout<<"YES";
}

Measured memory_bytes: 256
#1_8_C
counts = {chr(cord): 0 for cord in range(ord('a'), ord('z') + 1)}
while True:
    try:
        word = input()
    except:
        break
    c2 = str.lower(word)
    for letter in c2:
        if letter in counts.keys():
            counts[letter] += 1
for letter, count in counts.items():
    print('{} : {}'.format(letter,count))


Measured memory_bytes: 5568
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
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;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll H,W;
int main(){ //srand((unsigned)time(NULL));
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0)break;
    for (int i = 0; i < H; i++) {
      for (int l = 0; l < W; l++) {
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

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

		int n= sc.nextInt();
		int[]w = new int[n];
		int sum = 0;
		
		
		for (int i=0;i<n;i++) {
			w[i]= sc.nextInt();
			sum+=w[i];
		}
		
		int ans = Integer.MAX_VALUE;
		int smallSum=0;
		for (int i=0;i<n;i++) {
			
			
			ans = Math.min(ans, Math.abs(sum-smallSum-smallSum));
			smallSum+=w[i];
		}
		
		System.out.println(ans);
	}
}


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

int main() {
    int n; cin >> n;
    vector<ll> a(n); REP(i, n) cin >> a[i];
    ll sum = 0; REP(i, n) sum += a[i];

    ll tmp = 0; int j = 0;
    while(tmp + a[j] <= sum / 2) {
        tmp += a[j]; ++j;
    }
    ll tmp2 = tmp + a[j];

    cout << min(sum - tmp * 2, tmp2 * 2 - sum) << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char ch[10];
int main()
{
	scanf("%s",&ch);
	for(int i=1;i<4;i++)
	{
		if(ch[i]==ch[i-1])
		{
			printf("Bad");
			return 0;
		}
	}
	printf("Good");
}

Measured memory_bytes: 128
// lcm、__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define ll long long
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll i,j,k,l,m,n,w,x,y,z,p,q,tmp,sum=0;
    string str;
    cin>>w>>x>>y>>z;
    while(1){
        y-=x;
        if(y<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        w-=z;
        if(w<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,k;
  string s;
  cin >> n >> k >> s;
  int sum = 0, cnt = 0, r = 0;
  int ans = 0;
  rep(l,n) {
    while (r < n) {
      if (s[r] == '1') sum++;
      else {
        if (cnt == k) break; //0の操作不可
        int zr = r;
        cnt++;
        while (zr < n) {
          if (s[zr] != '0') break;
          zr++; 
          sum++;
        }
        r = zr-1;
      }
      r++;
    }
    debug(l,r-1);
    chmax(ans, sum);
    sum--;
    if (l < n-1 && s[l] == '0' && s[l+1] == '1') cnt--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;

const int nmax=100005;
const int mod=1e9+7;


int ar1[nmax];
int ar2[nmax];


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

    int n,m;
    LL uttor1=0, uttor2=0;
    cin>>n>>m;
    for(int i=1; i<=n; i++) cin>>ar1[i];
    for(int i=1; i<=m; i++) cin>>ar2[i];

    for(LL i=1; i<n; i++){
        uttor1+=((i*(n-i))%mod * abs(ar1[i+1]-ar1[i])%mod)%mod;
        uttor1%=mod;
    }
    for(LL j=1; j<m; j++){
        uttor2+=((j*(m-j))%mod * abs(ar2[j+1]-ar2[j])%mod)%mod;
        uttor2%=mod;
    }



    cout<<((uttor1%mod)*(uttor2%mod))%mod;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>    // PBDS
#include <ext/pb_ds/tree_policy.hpp>        // PBDS

using namespace std;
using namespace __gnu_pbds;                 // PBDS

/* typedef starts */

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> PBDS_INT;               // PBDS for int
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> PBDS_LL;    // PBDS for long long

/* typedef ends */

/* macro starts */

#define PI acos(-1)
#define EPS 1e-9
#define fastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define sinD(degree) sin((degree * PI) / 180.0)
#define cosD(degree) cos((degree * PI) / 180.0)
#define tanD(degree) tan((degree * PI) / 180.0)
#define cotD(degree) (1.0 / tanD(degree))
#define secD(degree) (1.0 / cosD(degree))
#define cosecD(degree) (1.0 / sinD(degree))
#define asinD(value) (asin(value) * 180.0) / PI
#define acosD(value) (acos(value) * 180.0) / PI
#define atanD(value) (atan(value) * 180.0) / PI
#define forn(i,n) for(int i=0;i<n;i++)
#define min(a,b) a<b ? a:b
#define max(a,b) a>b ? a:b
#define value_at_index(x) find_by_order(x)
#define index_of(x) order_of_key(x)
#define pb push_back
#define set0(add) memset(add,0,sizeof(add));

/* macro ends */

/* function starts */

/// calculates n-th (0-based) Gray Code
template<typename dataType>
dataType nthGrayCode(dataType n)
{
    return (n ^ (n >> 1));
}

/// generates all possible subsets for the given set
template<typename dataType>
void generateAllSubset(vector<dataType> &data)
{
    int i, j, n;
    n = data.size();

    for (i = 0; i < (1 << n); i++) {
        for (j = 0; j < n; j++) {
            if (i & (1 << j)) {
                cout << data[j] << " ";
            }
        }
        cout << "\n";
    }
}


void swap(int a, int b){
	int temp;
	temp=a;
	a=b;
	b=temp;
}

int fact(int n){
	if(n<=1)
		return 1;
	else 
	return n*fact(n-1);
}

bool compare(const pair<int,int> &a,const pair<int,int> &b){
	return (a.second<b.second);
}



int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif

    fastIO;
    int a;
    cin >> a;
    
    int ac=0,wa=0,tle=0,re=0;
    forn(i,a){
    	string s;
    	cin >> s;
    	
    	if(s[0]=='A')ac++;
    	else if(s[0]=='W')wa++;
    	else if(s[0]=='T')tle++;
    	else if(s[0]=='R')re++;

    }

    cout << "AC x " << ac << endl ;

   cout << "WA x " << wa << endl ;

   cout << "TLE x " << tle << endl ;
   cout << "RE x " << re << endl ;
    
   return 0;
   
   
   	}
    


Measured memory_bytes: 3652
from collections import deque
s = input().replace("\n", "")
s = deque(list(s))
q = int(input())
r = 0
for _ in range(q):
    t = input().split()
    if t[0] == "1":
        r = (r + 1) % 2
    else :
        if t[1] == "1":
            if r == 0:
                s.appendleft(t[2])
            else:
                s.append(t[2])
        else:
            if r == 0:
                s.append(t[2])
            else:
                s.appendleft(t[2])

if r == 0:
    print("".join(s))
else:
    print("".join(list(s)[::-1]))


Measured memory_bytes: 73960
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

ans = 1
u = 10 ** 18
if A[-1] == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > u:
            ans = -1
            break
print(ans)

Measured memory_bytes: 84756
#解説参照
#隣接が異なる箇所を操作する必要がある
#max(i,n-i)の最小値がkの下限
#逆に上限であることは、異なる箇所から(右か左の)端までを反転させれば隣接が異なる箇所が減る

s = input()
ans = 10**6
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        ans = min(ans,max(i+1,len(s)-i-1))
if ans ==10**6:
    print(len(s))
else:
    print(ans)


Measured memory_bytes: 40048
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 11;
#define LL long long
int n;
LL a[N], f[N][2];
int main(){
    cin>>n;
    for(int i = 1;i <= n; i++){
        scanf("%lld", &a[i]);
    }
    memset(f, -127, sizeof f);
    f[0][0] = 0;
    for(int i = 0;i < n / 2; i++){
        for(int j = 0;j <= 1; j++){
            LL F = f[i][j];
            f[i+1][1] = max(f[i+1][1], F + a[i*2+2]);
            if(j != 1)f[i+1][0] = max(f[i+1][0], F + a[i*2+1]);
        }
    }
    if(n & 1){
        LL sum = a[n];
        LL ans = max(f[n/2][1], f[n/2][0]);
        for(int i = n - 2;i >= 1; i -= 2){
            ans = max(ans, sum + max(f[(i-1)/2][0], f[(i-1)/2][1]));
            sum += a[i];
        }
        cout<<ans<<endl;

    }
    else {
        printf("%lld\n", max(f[n/2][0], f[n/2][1]));
    }
    return 0;
}


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

signed main(){
	int H, W;
	scanf("%lld%lld", &H, &W);
	if(H == 1 || W == 1){
		printf("1\n");
	}
	else{
		printf("%lld\n", (H * W + 1) / 2);
	}
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
const int MOD = 998244353;

void dfs(string s, set<string>& st) {
	if (st.count(s)) return;
	st.insert(s);
	int N = s.length();
	rep(i, N - 1) if (s[i] != s[i + 1]) {
		string t = s;
		t[i] = t[i + 1] = 'a' + 'b' + 'c' - s[i] - s[i + 1];
		dfs(t, st);
	}
}

int f(string s) {
	set<string> st;
	dfs(s, st);
	return st.size();
}

int solve(string s) {
	int N = s.length();
	bool same = true, diff = true;
	rep(i, N - 1) {
		if (s[i] != s[i + 1]) same = false;
		else diff = false;
	}
	if (same) return 1;
	int ans = 1;
	rep(i, N - 1) ans = (ll)ans * 3 % MOD;
	int unko = 0;
	rep(i, N) unko = (unko + s[i] - 'a') % 3;
	vector<vector<int>> dp(3, vector<int>(3));
	dp[0][0] = dp[1][1] = dp[2][2] = 1;
	rep(i, N - 1) {
		vector<vector<int>> _dp(3, vector<int>(3));
		rep(x, 3) rep(y, 3) rep(z, 3) if (x != z)
			_dp[z][(y + z) % 3] = (_dp[z][(y + z) % 3] + dp[x][y]) % MOD;
		dp = _dp;
	}
	rep(x, 3) ans = (ans - dp[x][unko]) % MOD;
	if (diff) ans = (ans + 1) % MOD;
	return (ans + MOD) % MOD;
}

int main() {
	/*
	for (;;) {
		string s; cin >> s;
		cout << f(s) << ' ' << solve(s) << endl;
	}
	*/
	string s; cin >> s;
	if (s.length() < 10) {
		cout << f(s) << endl;
		return 0;
	}
	cout << solve(s) << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin>>n;
  double x;
  double dp[n+1];
  for(int i=0;i<=n;i++)
    dp[i] = 0;
  dp[0]=1;
  for(int i=1;i<=n;i++)
  {
    cin>>x;
    for(int j=i;j>0;j--)
    {
      dp[j] = x*dp[j-1] + (1-x)*dp[j]; 
    }
    dp[0] = (1-x)*dp[0];
  }
  double ans=0;
  for(int i=n/2+1;i<=n;i++)
  {
    ans+=dp[i];
  }
  cout<<fixed<<setprecision(10)<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N, M, x, y;
  cin >> N >> M;
  bool red[N];
  fill(red,red+N,false);
  red[0] = true;
  int C[N];
  fill(C,C+N,1);
  for(int i = 0; i < M; ++i){
    cin >> x >> y;
    --x;--y;
    --C[x];
    ++C[y];
    if(red[x]) red[y] = true;
    if(!C[x]) red[x] = false;
  }
  int ans = 0;
  for(int i = 0; i < N; ++i)
    if(red[i] && C[i]) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rui(n) scanf("%u",&n)
#define rui2(a,b) scanf("%u %u",&a,&b)
#define rui3(a,b,c) scanf("%u %u %u",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define ll long long
#define int64 __int64
#define ui unsigned int
 
using namespace std;
 
const ll mod = 1e9 + 7;
 
//Date:2018-8-11
//Author：HarryBlackCat

int arr[maxn];

void init(){
	mem(arr,0);
}

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	int n,k;
	while(~ri2(n,k)){
		init();
		
		int id = 0;
		for(int i = 0;i < n;i++){
			arr[id]++;
			id++;
			if(id == k)
				id = 0;
		}
		
//		for(int i = 0;i < k;i++){
//			printf("arr[%d]:%d ",i,arr[i]);
//		}
//		puts("");
		
		sort(arr,arr + k);
		
		pr(abs(arr[0] - arr[k - 1]));
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define	ll_int	long long int
#define	SIZE	29


int main()
{
	char str[5], moji[80];
	int n, t_n;
	int *t;
	ll_int *my_pow, num, bk;
	int tmp, count, x;
	int i, j;

	scanf("%d", &n);

	scanf("%d", &t_n);

	t = (int *)malloc(sizeof(int) * t_n);
	for(i = 0; i < t_n; i++)
		scanf("%d", &t[i]);

	// 2の累乗をあらかじめ計算
	my_pow = (ll_int *)malloc(sizeof(ll_int) * SIZE);
	my_pow[0] = 1;
	for(i = 1; i < SIZE; i++)
		my_pow[i] = my_pow[i - 1] * 2;

	// 全組み合わせの表示
	tmp = my_pow[t_n];
	for(i = 0; i < tmp; i++){
		num = count = 0;
		bk = i;
		strcpy(moji, "");
		for(j = 0; bk >= 1; j++){
			if(bk & 0x1){
				x = t[j];
				num += my_pow[x];
				sprintf(moji + count, " %d", x);
				if(x <= 9)
					count += 2;
				else
					count += 3;
			}
			bk >>= 1;
		}
		printf("%lld:%s\n", num, moji);
	}

	return 0;
}



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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;
struct edge{int to, cost;};

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

vector<int> par, depth;

void init(int n){
    par.resize(n); depth.resize(n);
    for(int i=0; i<n; i++){
        par[i]=i;
        depth[i]=0;
    }
}

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

void unite(int x, int y){
    x=find(x), y=find(y);
    if(x == y) return;
    if(depth[x] < depth[y]) par[x]=y;
    else{
        par[y]=x;
        if(depth[x] == depth[y]) depth[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

int main(){
    int N; cin >> N;
    vi a(3*N);
    for(auto &x : a)cin >> x;
 
    vector<ll> dpl(N+1, 0), dpr(N+1, 0);
    priority_queue<int, vi, greater<int>> pquel;
    priority_queue<int, vi, less<int>> pquer;
    for(int i=0; i<N; i++){
        pquel.push(a[i]);
        pquer.push(a[3*N-i-1]);
        dpl[0]+=a[i];
        dpr[0]+=a[3*N-i-1];
    }
    for(int i=N; i<2*N; i++){
        pquel.push(a[i]);
        dpl[i-N+1]=dpl[i-N]+a[i]-pquel.top();
        pquel.pop();
    }
    for(int i=2*N-1; i>N-1; i--){
        pquer.push(a[i]);
        dpr[2*N-i]=dpr[2*N-i-1]+a[i]-pquer.top();
        pquer.pop();
    }
    ll ans=-LINF;
    for(int i=0; i<=N; i++){
        ll score=dpl[i]-dpr[N-i];
        chmax(ans, score);
    }
    cout << ans << endl;
    return 0;
    return 0;
}

Measured memory_bytes: 7032
N = int(input())

m = 1
while N > 26**m:
    N -= 26**m
    m += 1
m -= 1

l = []
s = ''
while m > 0:
    l.append((N-1)//(26**m)+1)
    N = (N-1)%(26**m)+1
    m -= 1
l.append(N)

for i in l:
    s += chr(i+96)
print(s)

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

int d[100005];
unordered_map<int, int> m;
int n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> d[i];
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (m[d[i]] == 0) {
			ans++;
		}
		else {
			ans--;
		}
		m[d[i]] = 1 - m[d[i]];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vi a(n);
    cin>>a;
    vi cnt(8,0);
    int pro=0;
    REP(i,n)if(3200<=a[i]) pro++;else cnt[a[i]/400]++;
    int ans=0;
    REP(i,8) if(cnt[i]!=0) ans++;
    cout<<ans+(ans==0)<<" "<<ans+pro<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    vector<long long >v;
    vector<long long >t;
    vector<long long >f;
    set<long long>s;
    set<long long>::iterator it;
    map<long long,long long>m;
    for(int i=0;i<n;i++)
    {
        long long x;
        cin>>x;
        m[x]+=1;
       s.insert(x);
    }
    long long mx=0;
    for(it=s.begin();it!=s.end();it++)
    {
        if(m[*it]>=2)
        {
            t.push_back(*it);
        }
        if(m[*it]>=4)
        {
            f.push_back(*it);
        }
    }
    if(f.size()!=0)
    {
       mx=max(mx,f[f.size()-1]*f[f.size()-1]);
    }
     if(t.size()>=2)
    {
         mx=max(mx,t[t.size()-1]*t[t.size()-2]);
    }


cout<<mx<<endl;

}


Measured memory_bytes: 14356
#include <iostream>

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

  for (int i=1; i<=n;)
    {
      auto x = i;
      if (x%3==0)
          std::cout << " " << i++;
      //else if (x%10==3)
      //    std::cout << " " << i++;
      else
        {
          do {
            if (x%10==3){
              std::cout << " " << i;
              break;
            }
            x /= 10;
          } while (x != 0);
          i++;
        }
    }
  std::cout << std::endl;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
// #define int long long
int N;

signed main(){
    cin>>N;
    vector<int> A,B,C;
    int tmp;
    rep(i,N){
        cin>>tmp;
        A.pb(tmp);
    }
    rep(i,N){
        cin>>tmp;
        B.pb(tmp);
    }
    rep(i,N){
        cin>>tmp;
        C.pb(tmp);
    }
    
    sort(all(A));
    sort(all(B));
    sort(all(C));
    ll ans = 0;
    rep(i,N){
        auto IterA = lower_bound(all(A),B[i]);
        
        auto IterB = upper_bound(all(C),B[i]);
        ll j = IterA - A.begin();
        ll k = C.end() - IterB;
        
        ans += j*k;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1784
s = gets.chomp.to_i

MOD = 10 ** 9 + 7
# 繰り返し二乗法(x.pow(n, mod)でもOK)
def pow(x, n, mod = MOD)
  ans = 1
  # 下位ビットから繰り返し計算を行う
  while n > 0 do
    ans = ans * x % mod if n.odd? # 下位ビットが1かどうか
    x = x * x % mod
    n >>= 1 # 右ビットシフト
  end
  return ans
end

# (mod p)下での逆元
# フェルマーの小定理より a^(p-1) = 1 (mod p) (aは整数, pは素数, aとpは互いに素)
# a * a^(p-2) = 1 なので, aの逆元が a^(p-2) となる
def inv(a, mod = MOD)
  pow(a, mod - 2, mod)
end

# 階乗
# 再利用できるようグローバル変数化
$fact = [1] # 0! = 1
def fact(n, mod = MOD)
  # 計算済ならそれを返す
  return $fact[n] unless $fact[n].nil?

  # 階乗を求めながら$factへ格納
  f = $fact[-1]
  ($fact.size).upto(n) do |i|
    f = (f * i) % mod
    $fact << f
  end
  return $fact[n]
end

# 順列
def perm(n, r, mod = MOD)
  # n*(n-1)*(n-2)*...*(n-r+1)
  return n.downto(n - r + 1).reduce(1) {|ans, x| (ans * x) % mod }
end

# 組み合わせ
def comb(n, r, mod = MOD)
  return 0 unless 0 <= r && r <= n
  return 1 if r == 0 || r == n
  # nCk = n!/(n-k)! * 1/k!
  return perm(n, r, mod) * inv(fact(r, mod) % mod, mod) % mod
end

num = 1
count = 0
while s >= 3 do
  r = s - 3
  count += comb(num + r - 1, r, MOD)
  count %= MOD
  s = r
  num += 1
end
puts count


Measured memory_bytes: 14392
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))




int main(){
    ll a[4]={0,0,0,0};
    ll lmax=0,lmin=6;
    for(int i=0;i<6;i++){
        int b;
        cin >>b;
        a[b-1]++;
        lmax=max(lmax,a[b-1]);
        lmin=min(lmin,a[b-1]);
    }

    if(lmin>0 && lmax<3)cout <<"YES"<<endl;
    else cout <<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String s=scanner.next();
		if(s.charAt(0)==s.charAt(1)) {
			System.out.println(1+" "+2);
			return;
		}
		for(int i=0;i<s.length()-2;i++) {
			char c1=s.charAt(i);
			char c2=s.charAt(i+1);
			char c3=s.charAt(i+2);
			if(c1==c2) {
				System.out.println((i+1)+" "+(i+2));
				return;
			}else if(c1==c3) {
				System.out.println((i+1)+" "+(i+3));
				return;
			}else if(c2==c3) {
				System.out.println((i+2)+" "+(i+3));
				return;
			}
		}
		System.out.println(-1+" "+-1);
	}
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 24916
function F()
  X,K,D = parse.(BigInt,split(readline()))
  X = abs(X)
  if X >0
    a = Int(floor(X/D))
    
    if a > K
      println(abs(X-K*D))
    else
      
    x1 = X-a*D
    x2 = X-(a+1)*D
      
    if abs(x1)<abs(x2)
        
      x = x1
    else
      x = x2
        a = a+1
       
    end
    if (K-a)%2 == 0
      println(Int(abs(x)))
    else
      if abs(x+D)>abs(x-D)
        println(abs(x-D))
      else
        println(abs(x+D))
      end
    end
    end
    
 
    
  else
    if K%2==0
      println(0)
    else
      println(D)
    end
  end
  
    
  
end
F()

Measured memory_bytes: 186604
#include <stdio.h>

int main(void){
	int min,max,num,tmp;
	long sum=0;
	scanf("%d",&num);
	for(int i=0;i<num;i++){
		scanf("%d",&tmp);
		if(i==0){
		    min=tmp;
		    max=tmp;
		}
		sum= sum+tmp;
		if(min>tmp) min=tmp;
		if(max<tmp) max=tmp;
	}

	printf("%d %d %ld\n",min,max,sum);

	return 0;
	
}


Measured memory_bytes: 2744
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int ans[27],t[27];
int main()
{
	string s;
	int n;
	cin>>n;
	memset(ans,0x3f,sizeof(ans));
	while(n--)
	{
		cin>>s;
		memset(t,0,sizeof(t));
		for(int i=0;i<s.length();i++)
		t[s[i]-'a'+1]++;
		for(int i=1;i<=26;i++)
		if(t[i]<ans[i]) ans[i]=t[i];
	}
	for(int i=1;i<=26;i++)
	for(int j=0;j<ans[i];j++)
	cout<<(char)('a'+i-1);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int>X(N);
  rep(i,N){
    cin >> X[i];
  }
  sort(X.begin(),X.end());
  ll minx = 100000000000;
  for(int i=0; i<= 100; i++){ //0~100の座標Pについて
    ll a = 0;
    for(int j = 0; j< N; j++){ //消費体力を計算していく
      a += (X[j] - i) * (X[j] - i);
    }
    minx = min(minx,a); //最小値更新
  }
  cout << minx << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<string>
#include<time.h>
#include<unordered_map>
#include<random>
#include<unordered_set>
#include<forward_list>

#pragma GCC optimize("Ofast")

#define ll long long
#define int long long
#define endl "\n"
#define ld long double
#define si pair<string,int>
#define mp make_pair
#define ii pair<int,int>
#define is pair<int,string>
#define fi first
#define se second
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4996)


using namespace std;



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

	//freopen("08.in", "r", stdin);
	//freopen("output.txt", "w", stdout);

	//mt19937 gen{ std::random_device{}() };
	//gen();

	int k, n;
	cin >> k >> n;
	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int maxim = 0;
	for (int i = 0; i < n - 1; i++) {
		if (abs(a[i] - a[i + 1]) > maxim)maxim = abs(a[i] - a[i + 1]);
	}
	maxim = max(maxim, min(abs(a[0] - a[n - 1]),k-a[n-1] + a[0]));
	cout << k - maxim;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int n,dp[maxn+5];
char x[maxn+5];
int pw_p[maxn+5],pw_m[maxn+5];

void cal(int M,int pw[],int &rem)
{
    pw[0]=1%M;
    rep(i,1,n) pw[i]=pw[i-1]*2%M;

    rep(i,1,n) rem=(rem*2+(x[i]=='1'))%M;
}

int ans[maxn+5];

int main()
{
    dp[0]=0;
    rep(i,1,maxn) dp[i]=dp[i%__builtin_popcount(i)]+1;

    scanf("%d",&n);
    scanf("%s",x+1);
    int cnt=0;
    rep(i,1,n) cnt+=(x[i]=='1');
    int rem_p=0,rem_m=0;
    cal(cnt+1,pw_p,rem_p);
    if(cnt>1) cal(cnt-1,pw_m,rem_m);
    rep(i,1,n) 
    {
        if(x[i]=='0')
        {
            ans[i]=dp[(rem_p+pw_p[n-i])%(cnt+1)]+1;
        }
        else
        {
            if(cnt==1) ans[i]=0;
            else
            {
                ans[i]=dp[(rem_m-pw_m[n-i]+cnt-1)%(cnt-1)]+1;
            }
        }
    }
    rep(i,1,n) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 7056