akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;
int dp[gf];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int h[n + 1];
	rep(i, 1, n)
	{
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);

	rep(i, 3, n)
	{
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n] << en;


	return 0;
}




Measured memory_bytes: 5136
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define mod 1000000007

int main(){
	long long n;
	cin >> n;
	vector<long long> a(n);
	long long p=0,m=0;
	long long sp=0,sm=0;
	for(long long i = 0;i < n;i++){
		cin >> a[i];
	}
	if(a[0] > 0){
		sp = a[0];
		sm = -1;
		m = a[0]+1;
	}
	else if(a[0] < 0){
		sm = a[0];
		sp = 1;
		p = 1-a[0];
	}
	else{
		sp = 1;
		sm = -1;
		p = 1;
		m = 1;
	}
	for(long long i = 1;i < n;i++){
		if(sp > 0){
			sp += a[i];
			if(sp > -1){
				p += sp+1;
				sp = -1;
			}
			sm += a[i];
			if(sm < 1){
				m += 1-sm;
				sm = 1;
			}
		}
		else{
			sp += a[i];
			if(sp < 1){
				p += 1-sp;
				sp = 1;
			}
			sm += a[i];
			if(sm > -1){
				m += sm+1;
				sm = -1;
			}
		}
	}
	if(p > m) cout << m << endl;
	else cout << p << endl;
}


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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int a, b, one, two, three;
  cin >> a >> b;
  one = a + b;
  two = a - b;
  three = a * b;
  cout << max(three, max(one, two)) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int n, k, lod[50], cnt, ans = 0, tmp;

    std::cin >> n >> k;
    for(int i = 0;i < n;i++){
        std::cin >> lod[i];
    }

    while(1){
        cnt = 0;
        for(int i = 0;i < n - 1;i++){
            if(lod[i] < lod[i + 1]){
                tmp = lod[i];
                lod[i] = lod[i + 1];
                lod[i + 1] = tmp;

                cnt++;
            }
        }

        if(cnt == 0){
            break;
        }
    }
    for(int i = 0;i < k;i++){
        ans +=lod[i];
    }    

    std::cout << ans;
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 20200
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}

int n,a[MAX],b[MAX];

int main()
{
    n=read();
    for(int i=1;i<=n;++i)a[i]=i*(n+1),b[i]=(n-i+1)*(n+1);
    for(int i=1;i<=n;++i)a[read()]-=(n-i+1);
    for(int i=1;i<=n;++i)printf("%d ",a[i]);puts("");
    for(int i=1;i<=n;++i)printf("%d ",b[i]);puts("");
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M,K;
int dp[4005][2005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);read(M);read(K);
    if(!M || !N) {puts("1");return;}
    int t = (N + M - 1) / (K - 1) - 1;
    dp[t + 1][0] = 1;
    int ans = 0;
    for(int i = t ; i >= 0 ; --i) {
        for(int k = 0 ; k <= M ; ++k) {
            for(int j = 0 ; j < K - 1 ; ++j) {
                if(j > k) break;
                update(dp[i][k],dp[i + 1][k - j]);
            }
            if(k != M) {
                int o = (t - i + 1) * (K - 1) - k;
                if((M - k - 1) % (K - 1) == 0 && N >= o && (N - o) % (K - 1) == 0) {
                    update(ans,dp[i][k]);
                }
            }
            if(k >= (K - 1)) update(dp[i][k],dp[i + 1][k - (K - 1)]);
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 31616
# https://img.atcoder.jp/abc114/editorial.pdf
N = int(input())


def dfs(s):  # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0  # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret


print(dfs('0')) # 本当は dfs('') と書きたいが 6 行目でのエラーを防ぐため仕方なく


Measured memory_bytes: 2940
var input = [];
var dataCount;
var data;
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on('data', function(chunk){
   input = chunk.toString("utf8").split("\n");
});
process.stdin.on('end', function(){
    dataCount = parseInt(input.shift());
    for (var i = 0; i < dataCount; i++) {
        data = input[i].split(" ").map(Number).sort(function(a,b){
            if (a < b) return -1;
            if (a > b) return 1;
            return 0;
        });
        if (Math.pow(data[0],2) + Math.pow(data[1],2) == Math.pow(data[2],2)) {
            console.log("YES")
        }else{
            console.log("NO")
        }
    }
});

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

int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans;
	ans = w * h / 2;
	int num = 0;
	if (x == w / 2 && y == h / 2) {
		num = 1;
	}
	cout << ans << " " << num << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	x := nextInts(5)

	ans := 0
	for i := 0; i < 5; i++ {
		if x[i] == 0 {
			ans = i + 1
			break
		}
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;

int main()
{
    int N,X;
    cin >> N;
    int f = 0;
    int ans = 0, amari;

    X = N;

    while (N != 0)
    {
        amari = N % 10;
        f += amari;
        N = N / 10;
    }

    if (X % f==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    

    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  int white_cnt=0;
  cin >> n >> m;
  vector<vector<int>> k(m,vector<int>(n,1));
  rep(i,n){
    rep(j,m){
      int tmp;
      char t;
      cin >> t;
      if(t=='#'){
        k.at(j).at(i)=0;
      }
      else white_cnt++;
    }
  }
  queue<pair<int,int>> u;
  vector<vector<int>> ans(m,vector<int>(n,-1));
  pair<int,int> st;
  st=make_pair(0,0);
  u.push(st);
  ans.at(0).at(0)=0;
  while(u.size()!=0){
    pair<int,int> tmp=u.front();
    u.pop();
    int a,b;
    tie(a,b)=tmp;
    int tmp_ans=ans.at(a).at(b);
    if (a<m-1){
      if(k.at(a+1).at(b)==1&&ans.at(a+1).at(b)==-1){
        ans.at(a+1).at(b)=tmp_ans+1;
        pair<int,int> z=make_pair(a+1,b);
        u.push(z);
      }
    }
    if(a>0){
      if(k.at(a-1).at(b)==1&&ans.at(a-1).at(b)==-1){
        ans.at(a-1).at(b)=tmp_ans+1;
        pair<int,int> z=make_pair(a-1,b);
        u.push(z);
      }
    }
    if(b<n-1){
      if(k.at(a).at(b+1)==1&&ans.at(a).at(b+1)==-1){
        ans.at(a).at(b+1)=tmp_ans+1;
        pair<int,int> z=make_pair(a,b+1);
        u.push(z);
      }
    }  
    if(b>0){
      if(k.at(a).at(b-1)==1&&ans.at(a).at(b-1)==-1){
        ans.at(a).at(b-1)=tmp_ans+1;
        pair<int,int> z=make_pair(a,b-1);
        u.push(z);
      } 
    }
  }
  if (ans.at(m-1).at(n-1)!=-1) cout << white_cnt-ans.at(m-1).at(n-1)-1 << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 256
P,Q,R = map(int,input().split())
pql = [P,Q,R]
mpath = 400

for i in range(3):
    for j in range(3):
        if i == j:
            pass
        else:
            path_len = pql[i]*2 + pql[j]
            if path_len < mpath:
                mpath = path_len
            path_len = pql[i] + pql[j]
            if path_len < mpath:
                mpath = path_len
                
print(mpath)
    
    


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 f[10005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int x = 1; x*x <= n; ++x){
        for(int y = 1; x*x + y*y + x*y <= n; ++y){
            for(int z = 1; x*x + y*y + z*z + x*y + y*z + z*x <= n; ++z){
                ++f[x*x + y*y + z*z + x*y + y*z + z*x];
            }
        }
    }
    for(int i = 1; i <= n; ++i) cout << f[i] << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define M 1000000007
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    ll n;
    cin>>n;
    ll a[3*n],l[n+1],r[n+1];
    rep(i,0,3*n)
    cin>>a[i];
    priority_queue<ll,vector<ll>,greater<ll>>pq;
    priority_queue<ll>pq2;
    ll sum=0,ans=LLONG_MIN;
    rep(i,0,2*n)
    {
        sum+=a[i];
        pq.push(a[i]);
        if(pq.size()>n)
        {
            sum-=pq.top();
            pq.pop();
        }
        if(pq.size()==n)
        l[i-n+1]=sum;
    }
    sum=0;
    for(ll i=3*n-1;i>=n;i--)
    {
        sum+=a[i];
        pq2.push(a[i]);
        if(pq2.size()>n)
        {
            sum-=pq2.top();
            pq2.pop();
        }
        if(pq2.size()==n)
        r[2*n-i]=sum;
    }
    rep(i,0,n+1)
    ans=max(ans,l[i]-r[n-i]);
    cout<<ans;
}



Measured memory_bytes: 6388
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

w = input()
l = Counter(w)
for i,j in l.items():
    if not j % 2 == 0:
        print("No")
        exit()
print("Yes")


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

/*
void Method1(){
    ll V, E;

    cin >> V >> E;
    vector<vector<int>> graph(V);
    vector<int> incoming(V);

    REP(i, E){
        ll s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        incoming[t]++;
    }

    queue<int> zero_queue;
    REP(i, V){
        if(incoming[i] == 0){
            zero_queue.push(i);
        }
    }

    while(!zero_queue.empty()){
        ll cur = zero_queue.front();
        zero_queue.pop();
        cout << cur << endl;
        REP(i, graph[cur].size()){
            incoming[graph[cur][i]]--;
            if(incoming[graph[cur][i]] == 0 ){
                zero_queue.push(graph[cur][i]);
            }
        }
    }

}
*/

bool DFS(vector<vector<int>>& graph, int v, vector<int>& visited, vector<int>& done, stack<int>& sorted){
    if( visited[v] ){
        return false;
    }
    if( done[v]) {
        return true;
    }

    visited[v] = true;
    REP(i, graph[v].size() ){
        if( !DFS(graph, graph[v][i], visited, done, sorted) ){
            return false;
        }
    }
    visited[v] = false;
    done[v] = true;
    sorted.push(v);

    return true;
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll V, E;
    cin >> V >> E;
    vector<vector<int>> graph(V);
    vector<int> incoming(V);

    REP(i, E){
        ll s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        incoming[t]++;
    }

    vector<int> visited(V, false);
    vector<int> done(V, false);
    stack<int> sorted;
    REP(i,V){
        if(!DFS(graph, i, visited, done, sorted) ){
            cout << "not DAG" << endl;
            return 0;
        }
    }

    while(!sorted.empty()){
        cout << sorted.top() << endl;
        sorted.pop();
    }
}



Measured memory_bytes: 3680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
    sc.Scan()
    return sc.Text()
}

func toInt(value string) int {
    num, _ := strconv.Atoi(value)
    return num
}

func splitWithInt(value string) []int {
    vals := strings.Split(value, " ")
    nums := make([]int, len(vals))
    for index, elem := range vals {
        nums[index] = toInt(elem)
    }
    return nums
}

// C
func main() {
    inputs := splitWithInt(gets())
    n, k := inputs[0], inputs[1]
    var result, tmp float64
    for i := 1; i <= n; i++ {
        tmp = 0
        for j := i; j < k; j *= 2 { tmp++ }
        result += math.Pow(0.5, tmp)
    }
    fmt.Println(result / float64(n))
}


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

typedef long long ll;

ll N, M;

ll lcm(ll number1, ll number2){
	return number1 * number2 / std::__gcd(number1, number2);	
}

int f(int x) {
    int ans = 0;
    while (x % 2 == 0 && x > 0) {
        x /= 2;
        ans++;
    }

    return ans;
}

int main() {
    // cout << (14 >> 2) << endl;
    // return 0;
    // int d = f(0);
    // int d2 = f(12);
    // cout << d << endl;
    // cout << d2 << endl;
    // return 0;

    cin >> N >> M;
    vector<ll> a(N);

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

    rep(i, N) {
        a[i] /= 2;
    }

    // 奇数で計算できるようにするため 2で何回割れるか数える    
    int t = f(a[0]);
    for (int i = 0; i < a.size(); i++) {
        int tmp = f(a[i]);    
        if (t != tmp) {
            cout << 0 << endl;
            return 0;
        }

        a[i] >> t;
    }
    M >> t;

    int num = a[0];
    for (int i = 1; i <= a.size() - 1; i++) {
        if (num > M) {
            cout << 0 << endl;
            return 0;
        }
        num = lcm(num, a[i]);    
    }

    int x = M / num;
    cout << (x + 1) / 2 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>


using namespace std;
 
class dice{

public:
  int m[6];
  int Set();
  int R(char c);

};
 
 
int main(){

  int i,j,n,a=1;
  dice dice[2];
  string s1 = "SSSSWSSSSWSSSS";
  string s2 = "ssss";

 
  cin >> n;
  dice[0].Set();
  for(i=1;i<n;i++){
    dice[1].Set();

    for(j =0;j<s1.size();j++){
      if(dice[0].m[0]==dice[1].m[0] && dice[0].m[5]==dice[1].m[5]) break;
      else{ dice[1].R(s1[j]); }
    }

    for(j=0;j<s2.size();j++){
      if(dice[0].m[1]==dice[1].m[1] && dice[0].m[2]==dice[1].m[2] && dice[0].m[3]==dice[1].m[3] && dice[0].m[4]==dice[1].m[4]) break;
      else{ dice[1].R(s2[j]); }
    }
 
    if(dice[0].m[0]==dice[1].m[0] && dice[0].m[1]==dice[1].m[1] && dice[0].m[2]==dice[1].m[2] && dice[0].m[3]==dice[1].m[3] && dice[0].m[4]==dice[1].m[4] && dice[0].m[5]==dice[1].m[5]) a = 0;
    
  }
     
  if(a==1)cout <<"Yes" <<endl;
  else{ cout <<"No" <<endl; }
 
  return 0;
}

int dice::Set(){

  int i;

  for (i=0;i<6;i++){
    cin >>m[i];
  }

  return 0;
}
 
int dice::R(char c){

  int t=0;

   if(c=='N'){
     t=m[0];
     m[0]=m[1];
     m[1]=m[5];
     m[5]=m[4];
     m[4]=t;
   }
   else if(c=='S'){
     t=m[0];
     m[0]=m[4];
     m[4]=m[5];
     m[5]=m[1];
     m[1]=t;
   }
   else if(c=='W'){
     t=m[0];
     m[0]=m[2];
    m[2]=m[5];
    m[5]=m[3];
    m[3]=t;
  }
  else if(c=='E'){
    t=m[0];
    m[0]=m[3];
    m[3]=m[5];
    m[5]=m[2];
    m[2]=t;
  }
  else{
    t=m[1];
    m[1]=m[2];
    m[2]=m[4];
    m[4]=m[3];
    m[3]=t;
  }

  return 0;
}
 

Measured memory_bytes: 1200
<?php
# 入力部
// fscanf(STDIN, "%d", $a);
// fscanf(STDIN, "%d %d %d", $n, $x, $t);
// fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%d", $x);

# 処理部
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
$s = "No";
if ($x >= 30) {
  $s = "Yes";
}

# 出力部
// echo $r . "\n";
echo $s . "\n";


Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count = 0;
  int i;
  string s;
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
   	  count++;
    }
  }
  cout << count << endl;
}

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

int main() {
  
  string A, B;
  cin >> A >> B;
  
  if(A.size() > B.size()){
    cout << "GREATER" << endl;
  }
  else if(A.size() < B.size()){
    cout << "LESS" << endl;
  }
  else if(A.size() == B.size()){
    vector<string> num(2);
    num.at(0) = A;
    num.at(1) = B;
    sort(num.begin(), num.end());
    
    if(num.at(0) == A){
      for(int i=0; i < A.size(); i++){
        if(A.at(i) == B.at(i)){
          if(i == A.size() - 1){
            cout << "EQUAL" << endl;
          }
          continue;
        }
        else{
          cout << "LESS" << endl;
          break;
        }
      }  
    }
    else{
      cout << "GREATER" << endl;
    }
  }

}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  string s;cin>>s;
  string t;
  for(i=0;i<s.size();i++){
    switch(s[i]){
      case '0':t+='0';
      break;
      case '1':t+='1';
      break;
      case 'B':
      if(t.size()!=0){
        t.pop_back();
      }
      break;
    }
  }
  cout<<t<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
using T3=tuple<int64_t,int64_t,int64_t>;

int main(){
    int N,M;
    cin>>N>>M;
    vector<T3> V(N);
    for(int i=0;i<N;i++){
        int64_t x,y,z;
        cin>>x>>y>>z;
        V[i]=T3(x,y,z);
    }
    int64_t ans=0,sum;
    vector<int64_t> VI(N);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=x+y+z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=-x+y+z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=x-y+z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=-x-y+z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=x+y-z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=-x+y-z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=x-y-z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

    for(int i=0;i<N;i++){
        int64_t x,y,z;
        tie(x,y,z)=V[i];
        VI[i]=-x-y-z;
    }
    sort(VI.begin(), VI.end(),greater<int64_t>());
    sum=0;
    for(int i=0;i<M;i++) sum+=VI[i];
    ans=max(ans,sum);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,b=0;
  string a,t;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
  }
  b=n/2;
  for(int i=0;i<b;i++){
    t+=a[i];
  }
  if(a==t+t){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define maxn 1000010
char mp[maxn],line[maxn];
int d[maxn],r1,c1,r2,c2,H,W,K,next[][2]={{-1,0},{1,0},{0,-1},{0,1}},in[maxn];//UP,DOWN,LEFT,RIGHT,in[]用于记录节点是否在队列中
struct node{
	int r,c;
}q[maxn*10];
int main(){
	int i,j,h,t,r,c,nr,nc,p,np;
	scanf("%d%d%d",&H,&W,&K);
	scanf("%d%d%d%d",&r1,&c1,&r2,&c2),r1--,c1--,r2--,c2--;
	for(i=0;i<H;i++){
		scanf("%s",line);
		for(j=0;j<W;j++)mp[i*W+j]=line[j];
	}
	for(i=0;i<H;i++)
		for(j=0;j<W;j++)d[i*W+j]=maxn;
	d[r1*W+c1]=0,h=t=1,q[t].r=r1,q[t].c=c1,t++,in[r1*W+c1]=1;
	while(h<t){
		r=q[h].r,c=q[h].c,in[r*W+c]=0;
		if(r==r2&&c==c2)return 0*printf("%d\n",d[r*W+c]);
		for(i=0;i<4;i++)
			for(j=1;j<=K;j++){
				nr=r+next[i][0]*j,nc=c+next[i][1]*j;
				if(0<=nr&&nr<H&&0<=nc&&nc<W){
					p=r*W+c,np=nr*W+nc;
					if(mp[np]=='@'||d[np]<=d[p])break;
					if(d[np]>=d[p]+1){
						d[np]=d[p]+1;
						if(!in[np])q[t].r=nr,q[t].c=nc,t++,in[np]=1;
					}
				}else break;
			}
		h++;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 14508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long commonvalue(long a,long b);

int main(void){
  int N,i;
  long X,x[100005],R;
  char str[1100000],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  X=atol(p);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  x[0]=atol(p);
  x[0]=labs(x[0]-X);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    x[i]=atol(p);
    x[i]=labs(x[i]-X);
  }
  
  for(i=1,R=x[0];i<N;i++){
    R=commonvalue(R,x[i]);
  }
  
  printf("%ld\n",R);
  
  return 0;
}

long commonvalue(long a,long b){
  long r,buff;
  
  if(a<b){
    buff=a,a=b,b=buff;
  }
  r=a%b;
  
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  
  return b;
}

Measured memory_bytes: 1920
/*
   name(i)と処理時間time(i)を持つｎ個のプロセスが並んでいる。
   cpuがプロセスを順番に処理する。
   各プロセスは最大qmsの処理を行い、プロセスが完了しなければ、
   そのプロセスは列の最後尾に移動し、cpuは次のプロセスを処理する。

   ラウンドロビンススケジューリングと呼ばれる処理方法で、各プロセス
   が完了した順にプロセス名と終了時刻を出力する

   input:
   5 100
   p1 150
   p2 80
   p3 200
   p4 350
   p5 20

   output:
   p2 180
   p5 400
   p1 450
   p3 550
   p4 800
*/

#include <stdio.h>
#include <string.h>

#define LEN 100005

typedef struct pp {
   char name[100];
   int t;
}P;

//キューを確保
P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
   Q[tail] = x;
   tail = (tail + 1) % LEN;
}

P dequeue(){
   P x = Q[head];
   head = (head + 1) % LEN;
   return x;
}

int min(int a, int b) { return a < b ? a : b; } //最小値を返す

int main(){
   int elaps = 0, c;
   int i,q;
   P u;

   scanf("%d %d", &n, &q);

   //キューに追加
   for (i = 1; i <= n; i++) {
     scanf("%s", Q[i].name);
     scanf("%d", &Q[i].t);
   }

   head = 1; 
   tail = n+1;

   //計算
   while (head != tail) {
      u = dequeue();
      c = min(q, u.t); //q,またはu.tだけ処理を行う
      u.t -= c;        //残りの時間を計算
      elaps += c;      //かかった総時間を計算

      if (u.t > 0)
         enqueue(u);   //処理が完了しなければキューに追加
      else {
         printf("%s %d\n", u.name, elaps); //完了した順に出力
      }
   }

   return 0;
}


Measured memory_bytes: 11888
unittest
{
	assert( [ "4 1 2 5" ].parse.expand.solve == 40 );
	assert( [ "2 5 6 0" ].parse.expand.solve == 1 );
	assert( [ "90081 33447 90629 6391049189" ].parse.expand.solve == 577742975 );
	
	assert( [ "300000 1 1 300000" ].parse.expand.solve == 194739877 );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nabk = input.front.split.to!( long[] );
	
	return tuple( nabk[ 0 ], nabk[ 1 ], nabk[ 2 ], nabk[ 3 ] );
}

auto solve( long n, long a, long b, long k )
{
	// 緑は赤＋青と同じ
	// つまり、緑は気にせずに赤と青の組み合わせだけ考えればよい
	auto ans = 0L;
	foreach( na; 0L .. n + 1 )
	{
		// na個を赤に塗ったときの点数を計算
		auto ka = na * a;
		if( k < ka ) break;
		
		// 不足している点数を青で補完する場合の必要な点数と個数を計算
		auto kb = k - ka;
		if( kb % b != 0 ) continue;
		auto nb = kb / b;
		if( n < nb ) continue;
		
		// 赤パターンと青パターンの組み合わせ数を計算
		ans = ( ans + n.combinationMod( na ) * n.combinationMod( nb ) ) % MOD;
	}
	return ans;
}

const MOD = 998244353L;

// 割り算
auto divMod( long n, long d )
{
	return n * d.powMod( MOD - 2 ) % MOD;
}

// べき乗
long powMod( long n, long p )
{
	static long[ long ][ long ] memo;
	if( n !in memo      ) memo[ n ][ 0 ] = 1;
	if( p !in memo[ n ] ) memo[ n ][ p ] = ( n.powMod( p / 2 ) ^^ 2 % MOD ) * ( n ^^ ( p % 2 ) ) % MOD;
	return memo[ n ][ p ];
}

// 階乗
auto factorialMod( long n )
{
	static memo = appender( [ 1L, 1L ] );
	while( memo.data.length <= n ) memo.put( memo.data[ $ - 1 ] * memo.data.length % MOD );
	return memo.data[ n ];
}

// 組み合わせ数
auto combinationMod( long n, long r )
{
	return n.factorialMod.divMod( r.factorialMod * ( n - r ).factorialMod % MOD );
}


Measured memory_bytes: 412924
N=int(input())
a=list(map(int,input().split()))
a=[bin(a[i])[2:].zfill(20) for i in range(N)]
ans=0
x=[[-1,-1] for i in range(20)]

for i in range(N):
    for j in range(20):
        if a[i][j]=="1":
            x[j]=[x[j][1],i]
    ans+=i-max([ x[j][0] for j in range(20) ])

print(ans)

Measured memory_bytes: 26776
x,y = map(int,input().split())


money = 0
if x == 1:
  money += 300000
elif x == 2:
  money += 200000
elif x == 3:
  money += 100000
  
if y == 1:
  money += 300000
elif y == 2:
  money += 200000
elif y == 3:
  money += 100000
  
if x == 1 and y == 1:
  money += 400000
  
print(money)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
int main()
{
	int n;
	cin >> n;
	vector<vector<int>> d(n,vector<int>(2));
	rep(i,n){
		rep(j,2){
			cin >> d[i][j];
		}
	}
	int count = 0;
	bool ans = false;
	rep(i,n){
		bool ren = false;
		if(d[i][0] == d[i][1]) ren = true;
		if(ren){
			count ++;
		} else {
			count = 0;
		}
		if(count >= 3) ans = true;
	}
	if(ans){
		coY();
	} else coN();
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#define REP(i,a,n) for(int i=a;i<=n;++i)
using namespace std;
typedef long long ll;
const int P = 1e9+7, INF = 0x3f3f3f3f;
const int N = 410;
int n, c, a[N], b[N], dp[N][N];
int po[N][N], sum[N][N];

int main() {
	REP(i,1,N-1) { 
		po[i][0] = 1;
		REP(j,1,N-1) po[i][j] = (ll)po[i][j-1]*i%P;
	}
	REP(i,0,N-1) { 
		sum[i][0] = 1;
		REP(j,1,N-1) sum[i][j] = (sum[i][j-1]+po[j][i])%P;
	}
	cin>>n>>c;
	REP(i,1,n) cin>>a[i];
	REP(i,1,n) cin>>b[i];
	dp[0][0] = 1;
	REP(i,1,n) REP(x,0,c) REP(y,0,x) {
		int ret = sum[x-y][b[i]]-sum[x-y][a[i]-1];
		dp[i][x] = (dp[i][x]+(ll)dp[i-1][y]*ret)%P;
	}
	int ans = dp[n][c];
	if (ans<0) ans += P;
	printf("%d\n", ans);
}









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

int main() {
    int n, T; cin >> n >> T;
    vector<int> c(n), t(n);
    rep(i, n) cin >> c.at(i) >> t.at(i);

    int res = 1001;
    rep(i, n){
        if(t.at(i)<=T) res = min(res, c.at(i));
    }

    if(res==1001) cout << "TLE" << endl;
    else cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
   int N; cin >> N;
   vector<int> v(N);
   rep(i,N){
       cin >> v[i];
   }
   vector<Pi> num1(100100);
   repr(i,1,100100){
       num1[i].second = num1[i-1].second + 1;
   }
   for(int i = 0; i < N; i+=2){
       num1[v[i]].first++;
   }
   sort(num1.begin(),num1.end(),greater<Pi>());

   vector<Pi> num2(100100);
   repr(i,1,100100){
       num2[i].second = num2[i-1].second + 1;
   }
   for(int i = 1; i < N; i+=2){
       num2[v[i]].first++;
   }
   sort(num2.begin(),num2.end(),greater<Pi>());

   int ans = 0;
   
   if(num1[0].second != num2[0].second){
       ans = N - num1[0].first - num2[0].first;
   }
   else{
       ans = min(N - num1[0].first - num2[1].first,N - num1[1].first - num2[0].first);
   }
   cout << ans << endl;

}
   

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

int x,m,k,y,z,dp[10000000],ar[10000000];

int main() {
	scanf("%d%d",&x,&y);
	for (int a = 1; a <= x; a++) {
		scanf("%d",&ar[a]);
	}
	dp[1] = 0;
	for (int a = 2; a <= x; a++) {
		dp[a] = 1e9;
		for (int b = 1; b <= y && a-b > 0; b++) {
			dp[a] = min(dp[a],dp[a-b]+abs(ar[a]-ar[a-b]));	
		}
	}
	cout << dp[x] << "\n";
	return 0;
} 

Measured memory_bytes: 2688
H, W = map(int, input().split())

grid = []
for i in range(H):
    grid.append(input())

grid_h = list(filter(lambda h: any([_ == '#' for _ in h]), grid))
remove_list = []
for w in range(W):
    for i, g in enumerate(grid_h):
        if g[w] == '#':
            break
        if i == len(grid_h) - 1:
            remove_list.append(w)
grid_hw = []
for g in grid_h:
    s = ''
    for i, c in enumerate(g):
        if i not in remove_list:
            s += c
    grid_hw.append(s)
for g in grid_hw:
    print(g)

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

int main()
{
    double n;
    double k;
    double result = 0;
    int i;
    int j;
    int count = 0;
    
    scanf("%lf %lf", &n, &k);
 
    for(i = 1; i <= n; i++){
        count = 0;
        for(j = i; j < k; j = j * 2){
            count++;
        }
        result += (1 / n) * pow(0.5, count);
    }
    
    printf("%.10lf", result);

    return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let K: usize = sc.get();
    println!("{}", min(N%K, K - N%K));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

char S[15];

int main(){

	scanf("%s",S);

	int len=strlen(S);

	int i;

	int cnt=0;

	for(i=2;i<=len-2;i++){
		if(S[i]=='C'){cnt++;}
	}

	int cnt2=0;

	for(i=0;i<len;i++){
		if('a'<=S[i]&&S[i]<='z'){cnt2++;}
	}

	if(S[0]=='A'&&cnt==1&&cnt2==len-2){
	printf("AC\n");
	}
	else{printf("WA\n");}

	return 0;
}

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

typedef complex<double> P;
#define EPS 1e-10
#define PI acos(-1)

bool isParallel(P a, P b)
{
	double aa = arg(a);
	if (aa < 0) aa = arg(-a);
	if (aa < EPS) aa = PI;

	double ba = arg(b);
	if (ba < 0) ba = arg(-b);
	if (ba < EPS) ba = PI;

	if (abs(aa - ba) < EPS)
		return true;
	else
		return false;
}

int main()
{
	int N; cin >> N;
	if (N % 2 == 1)
	{
		cout << "NA" << endl;
		return 0;
	}

	vector<P> xy(N);
	rep(i, 0, N)
	{
		double x, y; cin >> x >> y;
		xy[i] = P(x, y);
	}

	rep(i, 0, N / 2 - 1)
	{
		P va = xy[i] - xy[i + 1];
		P vb = xy[i + N / 2] - xy[i + N / 2 + 1];

		if (!(abs(abs(va) - abs(vb)) < EPS))
		{
			cout << "NA" << endl;
			return 0;
		}
		if (!isParallel(va, vb))
		{
			cout << "NA" << endl;
			return 0;
		}
	}

	double ans_x = (real(xy[0]) + real(xy[N / 2])) / 2.0;
	double ans_y = (imag(xy[0]) + imag(xy[N / 2])) / 2.0;

	printf("%.10f %.10f\n", ans_x, ans_y);
}

Measured memory_bytes: 3480
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	int x = 0;
	int record = 0;
	for (int i = 0;i < N;++i) {
		if (S[i] == 'I') {
			x += 1;
		}
		else {
			x -= 1;
		}
		if (x > record) {
			record = x;
		}
	}
	cout << record << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque

n,g = map(int, stdin.readline().split())
processes = deque([(name,int(time)) for name,time in [stdin.readline().split() for _ in range(n)]])
total_time = 0
while len(processes) > 0:
    name,left_time = processes.popleft()
    if left_time > g:
        total_time += g
        left_time -= g
        processes.append((name,left_time))
    else:
        total_time += left_time
        print(name, total_time)


Measured memory_bytes: 20632
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const map<T, S> m) { for (pair<T, S> p: m) s << p << endl; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

int N;
bool check(int m, VI& A) {
  if (m == 1) {
    // 狭義単調増加かどうか
    REP (i, N - 1) {
      if (A[i + 1] <= A[i]) {
        return false;
      }
    }
    return true;
  }
  map<int, int> mp;
  REP (i, N) {
    if (i == 0 || A[i] > A[i - 1]) continue;
    int k = A[i];
    mp[k]++;
    while (mp[k] >= m) {
      if (k == 1) {
        return false;
      }
      mp.erase(mp.find(k));
      k--;
      mp[k]++;
    }
    while (!mp.empty() && mp.rbegin()->fi > A[i]) {
      mp.erase(prev(mp.end()));
    }
  }
  return true;
}
signed main() {
  cin >> N;
  VI A = VI(N);
  REP (i, N) cin >> A[i];
  int l = 0, r = N;
  while (r - l > 1) {
    int m = (l + r) / 2;
    (check(m, A) ? r : l) = m;
  }
  cout << r << endl;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> a4, ae, ao;
	rep(i,N){
		int a;
		cin >> a;
		if (a%4 == 0) a4.push_back(a);
		else if (a%2 == 0) ae.push_back(a);
		else ao.push_back(a);
	}
	if (N%2 == 0) {
		if (a4.size() < ao.size()) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	else {
		if (a4.size() < ao.size()-1) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}



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

int main()
{
	int H, W;
	cin >> H >> W;

	vector<vector<char>> s(H, vector<char>(W, '\0'));

	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> s[i][j];
		}
	}

	bool isAble = true;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (s[i][j] == '#')
			{
				if (i > 0 && s[i-1][j] == '#')
				{
					continue;
				}
				else if (j > 0 && s[i][j-1] == '#')
				{
					continue;
				}
				else if (i < H-1 && s[i+1][j] == '#')
				{
					continue;
				}
				else if (j < W-1 && s[i][j+1] == '#')
				{
					continue;
				}

				isAble = false;
				break;
			}
		}

		if (!isAble)
		{
			break;
		}
	}

	if (isAble)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200010;
int n,K,a[N];
bool vis[N];

int main()
{
	n=rd();K=rd();
	fo(i,1,n)a[i]=rd();
	int ans=n-K+1;
	int hh=1;bool flag=0;
	fo(i,2,n){
		if(a[i]>a[i-1])++hh;
		else hh=1;
		if(hh>=K)--ans,flag=1,vis[i]=1;
	}ans+=flag;
	set<int>s;s.clear();
	fo(i,1,K)s.insert(a[i]);
	fo(i,K+1,n){
		s.insert(a[i]);
		if((*(s.begin()))==a[i-K]&&(*(s.rbegin()))==a[i]&&!vis[i])--ans;
		s.erase(a[i-K]);
	}
	cout<<ans;
	return 0;
}


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


int sun_factors(int n){
	if(n<=1)return 0;
	int i,s=1;
	for(i=2;i*i<n;i++)
		if(n%i==0)s+=i+n/i;
	if(i*i==n&&n%i==0)s+=i;
	return s;
}


int main(){
	int n;
	while(cin>>n&&n){
		int s=sun_factors(n);
		if(s<n)cout<<"deficient number"<<endl;
		else if(s==n)cout<<"perfect number"<<endl;
		else cout<<"abundant number"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152