akhauriyash/Code-Regression huggingface dataset:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from collections import deque

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n,q = map(int, sys.stdin.readline().split())
    que=deque([])

    for i in range(n):
        name, time = sys.stdin.readline().split()
        time=int(time)
        que.append([name,time])

    t=0
    while len(que)>0:
        atop=que.popleft()
        spend=min(atop[1],q)
        atop[1]-=spend
        t+=spend
        if(atop[1]==0):
            print(atop[0],t)
        else:
            que.append(atop)




Measured memory_bytes: 14792
# Try AtCoder
# author: Leonardone @ NEETSDKASU

n, m = gets.strip.split.map &:to_i

a = m.times.map{gets.strip.split.map(&:to_i).sort}

x = Hash.new 0

a.each do |z|
    x[z] += 1
end

y = x.select{|k,v|v.odd?}

e = Hash.new 0

y.each do |k, v|
    e[k[0]] += 1
    e[k[1]] += 1
end

puts e.any?{|k,v|v.odd?} ? :NO : :YES

Measured memory_bytes: 28156
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout << << endl;
typedef long long int ll;
typedef long double ld;



int main(){
    ll a,b;
    cin >> a >> b;
    if (a==1){
        a+=13;
    }
    if (b==1){
        b+=13;
    }
    if (a>b){
        cout << "Alice" << endl;
    }else if(a<b){
        cout << "Bob" << endl;
    }else{
        cout << "Draw" << endl;
    }
}


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

dp = [float("inf")]*(n)

dp[0] = 0

def chmin(a,b,index):
    if a > b:
        dp[index] = b

for i in range(n-1):
    for j in range(1,k+1):
        chmin(dp[i+j],dp[i] + abs(h[i] - h[i+j]),i+j)
        if i+j >= n-1:
            break
print(dp[n-1])

Measured memory_bytes: 55264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline void print(const T& a) { cout << a << "\n"; }

void MergeSort(VI& a, VI& tmp, int l, int r) {
    if (l + 1 == r)return;
    int m = l + r >> 1;
    MergeSort(a, tmp, l, m);
    MergeSort(a, tmp, m, r);
    int i = l, j = m, k = l;
    for (; i < m || j < r; ++k) {
        if (i == m)tmp[k] = a[j++];
        else if (j == r)tmp[k] = a[i++];
        else if (a[i] < a[j])tmp[k] = a[i++];
        else tmp[k] = a[j++];
    }
    for (k = l; k < r; ++k)
        a[k] = tmp[k];
}

void QuickSort(VI& a, int l, int r, int d, const int lim) {
    if (r - l <= 1)return;
    if (lim < d) {
        VI tmp(a.size());
        MergeSort(a, tmp, l, r);
        return;
    }
    int m = l + r >> 1, pvt = a[m], i = l;
    swap(a[m], a[r - 1]);
    for (int j = l; j < r - 1; ++j) {
        if (a[j] < pvt)swap(a[i++], a[j]);
    }
    swap(a[i], a[r - 1]);
    QuickSort(a, l, i, d + 1, lim);
    QuickSort(a, i + 1, r, d + 1, lim);
}

int main() {
    init();

    int n, k; cin >> n >> k;
    VI h(n); cin >> h;

    VI tmp(n);
    //MergeSort(h, tmp, 0, n);
    QuickSort(h, 0, n, 0, log2(n) * 2);

    int64_t ans = 0;
    FOR(i, 0, n - k)ans += h[i];
    print(ans);

    return 0;
}


Measured memory_bytes: 5720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long sum = 0;
        for(int i=1; i<=n; i++) {
            if(i%3!=0 && i%5!=0) {
                sum += i;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 35808
#include <stdio.h>

#define MAXSIZE 100000


int Partition(int A[], int p, int r){
    int x = A[r];
    int i = p - 1;
    int j, t;

    for(j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }

    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;

    return i + 1;

}

int main(){

    int A[MAXSIZE];
    int N;
    int i;
    int q; //index of pivot

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

    q = Partition(A, 0, N -1);

    for(int i = 0; i < N; i++){
        if(i > 0) printf(" ");
        if(i == q){
            printf("[%d]", A[i]);
        }else{
            printf("%d", A[i]);
        }
    }
    printf("\n");


    return 0;
}



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

long long a[10001],b[10001];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	long long s=0,s2=0;
	for(int i=1;i<=n;i++){
		if(a[i]<b[i]) s2+=ceil((b[i]-a[i])/2.0);
		s+=b[i]-a[i];
	}
	if(s2<=s) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    
    int ans = 1e9;
    for(auto i : v) {
        int cnt = 0;
        while(i % 2 == 0) {
            cnt++;
            i /= 2;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

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

#define int long long int
const int mxN = 3005;
int n, a[mxN], dp[2][mxN][mxN];

int calc(int st, int en, int x) {
    if(st > en) 
        return 0;

    if(dp[x][st][en])   
        return dp[x][st][en];
    if(x) {
        return dp[x][st][en] = max(a[st] + calc(st+1, en, !x), 
                                calc(st, en-1, !x) + a[en]);
    } else {
        return dp[x][st][en] = min(-a[st] + calc(st+1, en, !x), 
                                calc(st, en-1, !x) - a[en]);
    }
}

void solve() {
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];
    
    cout << calc(0, n-1, 1) << "\n";
}

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

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int R;
  cin >> R;
  cout << setprecision(12) << (double)R*2*3.14159265358979 << endl;
}


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

int N, x;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N >> x;
    unsigned long long ans = 0;
    int a, b;
    cin >> a;
    for(int i=1; i<N; i++){
        cin >> b;
        if(a + b > x){
            int temp = min(a + b - x, b);
            ans += temp;
            if(temp == b)
                ans += a - x;
            b -= temp;
        }
        a = b;
    }
    cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
use v5.18;
use warnings;
sub read_line { chomp(my $str = <STDIN>); $str }
sub splited_read_line { split / /, read_line }
my ($num1, $num2, $k) = splited_read_line;
my $limit = $num1 + int( ($num2 - $num1) / 2 );
{
  my $end = $num1 + $k - 1;
  $end = $end >= $limit ? $limit : $end;
  output($num1, $end);
}
{
  my $begin = $num2 - $k + 1;
  $begin = $begin <= $limit ? $limit + 1 : $begin;
  output($begin, $num2);
}

sub output {
  my ($begin, $end) = @_;
  for my $x ($begin .. $end) {
    say $x;
  }
}


Measured memory_bytes: 640
#define MOD 1000000007

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

long pow(long a, long b) {
	if (!b) return 1;
	long c = pow(a, b / 2);
	if (b % 2) c = a * c % MOD * c % MOD;
	else c = c * c % MOD;
	return c;
}

long mod(long a) {
	a %= MOD;
	if (a < 0) a += MOD;
	return a;
}

int main() {
	long n, a, b, c = 1, d = 1;
	cin >> n >> a >> b;
	for (long i = 0, j = n; i < a; i++, j--) {
		c *= j;
		c %= MOD;
	}
	for (long i = 0, j = n; i < b; i++, j--) {
		d *= j;
		d %= MOD;
	}
	vector<long> e(max(a, b) + 1, 1), f(max(a, b) + 1, 1);
	for (long i = 1; i <= max(a, b); i++) {
		e[i] = e[i - 1] * i % MOD;
		f[i] = pow(e[i], MOD - 2);
	}
	long g = c * f[a] % MOD, h = d * f[b] % MOD;
	cout << mod(mod(mod(pow(2, n) - g) - h) - 1);
}

Measured memory_bytes: 3328
N = int(input())
T = [int(_) for _ in input().split()]
M = int(input())
Total = sum(T)
output = []
for i in range(M):
    p, x = map(int, input().split())
    output.append(Total - (T[p-1] - x))
for i in range(M):
    print(output[i])

Measured memory_bytes: 3060
def resolve():
    Q, H, S, D = list(map(int, input().split()))
    N = int(input())
    ans = 0

    ls = [[0.25, Q, 8*Q, 0], [0.5, H, 4*H, 0], [1, S, 2*S, 0], [2, D, D, 0]]
    ls.sort(key=lambda x: x[2])

    for i in range(4):
        if N < ls[i][0]:
            continue

        ls[i][3] += int(N // ls[i][0])
        N -= ls[i][0] * ls[i][3]

        ans += ls[i][1] * ls[i][3]

    ans = int(ans)
    print(ans)
    return


resolve()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------
int n;
const int MX = 107;
int num[MX];
int main(){
	cin >> n;
	int sm = 0;
	FOR(i,1,n){
		int w; cin >>w;
		num[i] += w;
		sm += w;
	}
	int cur = 0;
	int b_cur =0;
	int idx = 0;
	FOR(i,1,MX){
		b_cur = cur;
		cur += num[i];
		if(cur > sm/2){
			idx = i;
			break;
		}
	}
	int now1 = abs(sm-cur-cur);
	//cur -= (idx-1) * num[idx-1];
	int now2 = abs(sm-b_cur-b_cur);
	cout << min(now1,now2) << endl;
    return 0;
}


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

int main (void){
    int a, b;
    cin >> a >> b;
    if(a + b <= a - b){
        if(a - b <= a * b){
            cout << a * b << endl;
        }else{
            cout << a - b << endl;
        }
    }else if(a - b <= a + b){
        if(a + b <= a * b){
            cout << a * b << endl;
        }else{
            cout << a + b << endl;
        }
    }else{
        if(a + b <= a - b){
            cout << a - b << endl;
        }else{
            cout << a + b << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3588
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

t = ins()
s = t.replace('?','D')
print(s)


Measured memory_bytes: 9360
#include <cstdio>
#include <algorithm>
using namespace std;
int N, A[100002], L[100002], R[100002], ans;
int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a%b);
}
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for(int i = 1; i <= N; ++i) {
    L[i] = gcd(L[i-1], A[i]);
    R[N-i+1] = gcd(R[N-i+2], A[N-i+1]);
  }
  for(int i = 1; i <= N; ++i) {
    ans = max(ans, gcd(L[i-1], R[i+1]));
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	long long sum = 0;
	for (int i = 0;i < n.length();i++) {
		sum += n[i] - 48;
	}

	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3716
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////
ll cnt[3];
string r="RGB";

int main(){fastio
    ll n;cin>>n;
    string s;cin>>s;
    
    rep(i,0,n-1){
        rep(j,0,2){
            if(s[i]==r[j])cnt[j]++;
        }
    }
    ll ans=cnt[0]*cnt[1]*cnt[2];
    rep(j,1,n-2){
        rep(len,1,n-1){
            ll i=j-len;
            ll k=j+len;
            if(i<0)continue;
            if(k>=n)continue;
            if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i])ans--;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3664
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long r = 0;
    for(String t:sc.next().replaceAll("BC","D").split("[BC]+")){
      long cnt = 0;
      for(int i=t.length()-1;i>=0;i--){
        if(t.charAt(i)=='D')cnt++;
        else r+=cnt;
      }
    }
    System.out.println(r);
  }
}

Measured memory_bytes: 34256
# D - We Like AGC

from collections import defaultdict

MOD = 10**9+7
N = int(input())
charactors = ['A', 'G', 'C', 'T']

# dp[l][s] := 長さがlで、末尾3文字がsである文字列の個数
dp = [defaultdict(int) for _ in range(N+1)]

# 無関係の文字で初期化しておく
dp[0]['ZZZ'] = 1

# NGケース: AGC, ACG, GAC, A?GC, AG?C
def check(s, c):
    if c=='C':
        if s[1:]=='AG' or s[1:]=='GA' or \
            (s[0]=='A' and (s[1]=='G' or s[2]=='G')):
            return False
        else:
            return True
    elif c=='G':
        if s[1:]=='AC':
            return False
        else:
            return True
    else:
        return True

for i in range(N):
    for s in dp[i].keys():
        for c in charactors:
            # NGケースに該当しなければ、カウントする
            if check(s, c): 
                dp[i+1][s[1:]+c] += dp[i][s]
                dp[i+1][s[1:]+c] %= MOD

print(sum(dp[N].values())%MOD)


Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int n;
    while(cin>>n){
        if(n==0)break;
        vector<int> list(24*3600 + 60 * 60 + 100,0);
        REP(i,n){
            string start;cin >> start;
            ll stime = ((start[0] - '0') * 10 + (start[1] - '0')) * 3600
                       +  ((start[3] - '0') * 10 +(start[4] - '0')) * 60
                       + ((start[6] - '0') * 10 + (start[7] - '0'));
            string endd;cin >> endd;
            ll etime = ((endd[0] - '0') * 10 + (endd[1] - '0')) * 3600
                       +  ((endd[3] - '0') * 10 +(endd[4] - '0')) * 60
                       + ((endd[6] - '0') * 10 + (endd[7] - '0'));
            list[stime]+=1;list[etime]-=1;
        }
        FOR(j,1,24*3600 + 60 * 60 + 100){
            list[j] += list[j-1];
        }
        cout << *max_element(ALL(list)) << endl;
    }
}


Measured memory_bytes: 3468
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <iomanip>

using namespace std;

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

// 入力
int N;
Graph G;

// res は答え
vector<int> res;

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 8960
L = list(input())

p = 0
for i in range(len(L)) :
    p += int(L[i])


if len(L) == 1 :
    ans = int(L[0])
else :
    if L.count("9") == len(L) :
        ans = 9*len(L)
    elif L[0] == "1" :
        ans = 9*(len(L)-1)
    else :
        ans = (int(L[0])-1) + 9*(len(L)-1)
print(max(p,ans))


Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto s = readln.chomp.split.to!(int[])[1];
  auto x = readln.chomp.split.to!(int[]);
  auto res = abs(x[0] - s);
  foreach (i; 1..x.length) {
    res = gcd(res, abs(x[i] - s));
  }

  res.writeln;
}


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

int main() {
    string S; cin >> S;
    ll N; cin >> N;
    list<char> l;
    for (int i = 0; i < S.size(); ++i) {
        l.push_back(S[i]);
    }
    bool rev = false;
    for (int i = 0; i < N; ++i) {
        ll type; cin >> type;
        if (type == 1) rev = !rev;
        else {
            ll place; cin >> place;
            char ch; cin >> ch;
            // 先頭に追加する
            // -> 反転状態で末尾
            if (rev && place == 2 || !rev && place == 1) {
                l.push_front(ch);
            }
            else {
                l.push_back(ch);
            }
        }
    }
    if (!rev) {
        list<char>::iterator itr;
        for(itr = l.begin(); itr != l.end(); ++itr) {
            cout << *itr;
        }
    }
    else {
        list<char>::reverse_iterator itr;
        for(itr = l.rbegin(); itr != l.rend(); ++itr) {
            cout << *itr;
        }
    }
    cout << endl;
}

Measured memory_bytes: 9984
#template
def inputlist(): return [int(k) for k in input().split()]
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template
S = input()
for i in range(8):
    k = base10to(i,2)
    if len(k) < 3:
        for j in range(3-len(k)):
            k = '0'+k
    tmp = int(S[0])
    for j in range(1,4):
        if k[j-1] == '0':
            tmp += int(S[j])
        else:
            tmp -= int(S[j])
    if tmp == 7:
        li = []
        for t in range(4):
            if t == 3:
                li.append(S[t])
            else:
                li.append(S[t])
                if k[t] == '0':
                    li.append('+')
                else:
                    li.append('-')
        li += ['=','7']
        print(''.join(li))
        exit()

Measured memory_bytes: 3064
A,B,H,M = map(int,input().split())

# 時針Aの進んだ角度 = 30 * H + (30/60) * M
# 分針Bの進んだ角度 = 6 * M

ra = -1
a_ra = 30 * H + (30/60) * M
b_ra = 6 * M
if a_ra < b_ra:
  ra = b_ra - a_ra
else:
  ra = a_ra - b_ra
  
if ra > 180:
  ra = 360 - ra

import math
ans = (A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(ra))) ** 0.5

print(ans)

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

L = [0] * (N + 2)
for i in range(1, N + 2):
    L[i] = L[i - 1] + abs(A[i] - A[i - 1])

R = [0] * (N + 2)
for i in range(1, N + 2):
    R[i] = R[i - 1] + abs(A[N - i + 1] - A[N - (i - 1) + 1])

R = R[::-1]

ans = []
for i in range(1, N + 1):
    ans.append(L[i - 1] + R[i + 1] + abs(A[i - 1] - A[i + 1]))
print(*ans, sep='\n')

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int x, y;
    cin >> x >> y;
    int m = (2*y-x)/3, n = (2*x-y)/3;
    if((x+y)%3!=0||m<0||n<0){
        cout << 0 << endl; 
        return 0;
    }
    COMinit();
    cout << COM(m+n,n) << endl;
}

Measured memory_bytes: 27028
import sys
from collections import Counter
N, M = map(int, input().split())
A    = list(map(int, input().split()))

ans = int(0)
count = int(0)
sumA = [0] * N
sumA[0] = A[0]
modsumA = A[0]%M

modcount = Counter()

modcount[0] = 1
count += modcount[modsumA]
modcount[modsumA] += 1
for i in range(N-1):
    sumA[i+1] = sumA[i] + A[i+1]
    modsumA = sumA[i+1]%M
    count += modcount[modsumA]
    modcount[modsumA] += 1

ans = count
print(ans)

Measured memory_bytes: 15368
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N,M;cin>>N>>M;
    vvi fr(N,vi(0));
    for(int i=0;i<M;i++){
        int A,B;cin>>A>>B;
        A--;B--;
        fr[A].push_back(B);
        fr[B].push_back(A);
    }
    vi cluster_id(N,0);
    int cur_id=1;
    int max_member=0;
    int cur_member=0;
    for(int i=0;i<N;i++){
        if(cluster_id[i]>0)continue;
        cluster_id[i]=cur_id;
        cur_member=1;
        queue<int> Q;
        Q.push(i);
        while(!Q.empty()){
            int qf=Q.front();
            Q.pop();
            int Lfr=fr[qf].size();
            for(int j=0;j<Lfr;j++){
                if(cluster_id[fr[qf][j]]==0){
                    cluster_id[fr[qf][j]]=cur_id;
                    Q.push(fr[qf][j]);
                    cur_member++;
                }
            }
        }
        cur_id++;
        max_member=max(max_member,cur_member);
    }
    cout<<max_member<<endl;
}

Measured memory_bytes: 15592
#include <iostream>
#include <algorithm>
using namespace std;
int i, a, k, n;
int main() {
cin>>n;
pair <int, int> a[n+1];
  for (i=1; i<=n; i++){
    cin>>a[i].first;
    a[i].second=i;
  }
  sort(a+1, a+n+1);
for(i=1; i<=n; i++)
  cout<<a[i].second<<" ";
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  
  int num=0;
  for ( int i = 0 ; i < 2 ; i++) {
    if (str.at(i) != str.at(i+1) ) {
      num = 1 ; 
      break;
    }
  }

  if ( num == 0  ) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    string s, ans;
    cin >> s;
    for (auto c : s) {
        if (c == '0' or c == '1')
            ans += c;
        else if (ans.size() != 0) {
            ans = ans.substr(0, ans.size() - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


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


int main() {
    int n;
    cin>>n;
    
    vector<int>Length(n);
    for(int i=0;i<n;i++) {
        cin>>Length.at(i);
        }

    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
               int len =Length.at(i)+Length.at(j)+Length.at(k);
               int ma = max(Length.at(i),max(Length.at(j),Length.at(k)));
               int rest = len-ma;
               if(ma<rest){
                   if(Length.at(i)!=Length.at(j) and Length.at(i)!=Length.at(k) and Length.at(j)!=Length.at(k)){
                       count++;
                   }
               }
                
            }
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 3628
from sys import stdin
N, M = [int(i) for i in stdin.readline().rstrip().split()]
ans_list = []
for m in range(M):
    ans_list.append([i for i in stdin.readline().rstrip().split()])
ac = 0
wa = 0
result_dict = {}
wa_count = {}
for n in range(1, N + 1):
    result_dict[n] = False
    wa_count[n] = 0
for q, r in ans_list:
    q_now = int(q)
    if result_dict[q_now] == False:
        if r == "WA":
            wa += 1
            wa_count[q_now] += 1
        if r == "AC":
            ac += 1
            result_dict[q_now] = True
for n in range(1, N + 1):
    if result_dict[n] == False:
        wa -= wa_count[n]
print(ac, wa)

Measured memory_bytes: 44292
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    const F f;
    const Monoid M1;
    int sz;
    vector<Monoid> dat;
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1), sz(1) {
        while (sz < n) sz <<= 1;
        dat.assign(sz * 2, M1);
    }
    void set(int k, const Monoid &x) { dat[k + sz] = x; }
    void build() {
        for (int k = sz - 1; k > 0; k--) {
            dat[k] = f(dat[2 * k], dat[2 * k + 1]);
        }
    }
    void update(int k, const Monoid &x) {
        dat[k += sz] = x;
        while (k >>= 1) dat[k] = f(dat[2 * k], dat[2 * k + 1]);
    }
    Monoid get(int a, int b) {  // [a, b)
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = f(L, dat[a++]);
            if (b & 1) R = f(dat[--b], R);
        }
        return f(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k + sz]; }
    friend ostream& operator<<(ostream& os, SegmentTree<Monoid> &seg) {
        for (int i = 0; i < seg.sz; i++) os << seg[i] << " ";
        return os;
    }
};

const int MAX = 2e5;
int main() {
    int n; cin >> n;
    vector<int> h(n); for (int &hi: h) cin >> hi;
    vector<int> a(n); for (int &ai: a) cin >> ai;
    using ll = long long;
    SegmentTree<ll> dp(MAX + 1, [](ll a, ll b) { return max(a, b); }, 0);
    for (int i = 0; i < n; i++) {
        dp.update(h[i], max(dp[h[i]], dp.get(0, h[i]) + a[i]));
    }
    cout << dp.get(0, MAX + 1) << endl;
    return 0;
}

Measured memory_bytes: 5888
n, m, x = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

left = 0
right = 0

a.each do |i|
  if i < x
    left+=1
  else
    right+=1
  end
end

if left < right
  puts left
else
  puts right
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int r, g, b;
    cin >> r >> g >> b;
    if ((r * 100 + g * 10 + b) % 4 == 0) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    E = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v = map(int,input().split())
        u -= 1; v -= 1;
        E[u].append(v)
        E[v].append(u)

    size = [1] * n
    stack = [(0, -1)]
    while stack:
        v, p = stack.pop()
        if v >= 0:
            for nv in E[v]:
                if nv == p:
                    continue
                stack.append((~nv, v))
                stack.append((nv, v))
        else:
            size[p] += size[~v]

    def rerooting(v, p):
        if p == -1:
            return
        size[p] -= size[v]
        size[v] += size[p]

    res = [None] * n
    stack = [(0, -1)]
    while stack:
        v, p = stack.pop()
        if v >= 0:
            rerooting(v, p)
            if res[v] is None:
                cnt = pow(2, n - 1, MOD)
                cnt -= 1
                for nv in E[v]:
                    cnt -= pow(2, size[nv], MOD) - 1
                res[v] = cnt % MOD
            for nv in E[v]:
                if nv == p:
                    continue
                stack.append((~nv, v))
                stack.append((nv, v))
        else:
            rerooting(p, ~v)

    print(sum(res) * pow(2, n * (MOD - 2) % (MOD - 1), MOD) % MOD)
resolve()

Measured memory_bytes: 121296
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int A, B;
  
  	cin >> A >> B;
  
  	int add, sub, multi;
  	add = A + B;
  	sub = A - B;
  	multi = A * B;
  
  	cout << max(max(add, sub), multi) << endl;
  
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>

int main()
{
    unsigned int H, W, K;
    std::cin >> H >> W >> K;
    char board[H][W];
    for(unsigned int i=0; i<H; i++){
        for(unsigned int j=0; j<W; j++){
            std::cin >> board[i][j];
        }
    }

    /*
    for(unsigned int i=0; i<H; i++){
        for(unsigned int j=0; j<W; j++){
            std::cout << board[i][j] << " ";
        }
        std::cout << std::endl;
    }
    */
    

    unsigned int black = 0, count = 0;

    for(int maskR=0; maskR<(1<<H); maskR++){
        for(int maskC=0; maskC<(1<<W); maskC++){

            black = 0;
            for(unsigned int i=0; i<H; i++){
                for(unsigned int j=0; j<W; j++){
                    if(maskR&(1<<i) || maskC&(1<<j)) continue;
                    if(board[i][j] == '#') black++;
                }
            }
            if(black == K){
                count++;
            }

        }
    }

    std::cout << count << std::endl;

    //int end;
    //std::cin >> end;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll fib(ll  n)
{
  ll f[100000];
  ll i;
  f[0] = 1;
  f[1] = 1;
  for (i = 2; i <= n; i++)
      f[i] = f[i-1] + f[i-2];

  return f[n];
}
int main(){
    ll i,j,k,l,n,m;
    cin>>m;
    cout<<fib(m)<<endl;
    return 0;
}


Measured memory_bytes: 3112
n,m = gets.chomp.split(" ").map(&:to_i)
def kaijou(a)
  tmp = 1
  for i in 2..a
    tmp *= i
    tmp %= 10**9+7
  end
  return tmp
end
if (n-m).abs >= 2
  puts "0"
elsif (n-m).abs == 1
  puts (kaijou(n)*kaijou(m))%(10**9+7)
else
  puts (kaijou(n)*kaijou(m)*2)%(10**9+7)
end

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

int main(){
  int n;
  set<int> S;
  cin>>n;
  int d[n];
  for(int i=0;i<n;i++){
    cin>>d[i];
    S.insert(d[i]);
  }
  cout<<S.size()<<endl;
}
  

Measured memory_bytes: 256
# X,Y = list(map(int, input().split()))
# for i in range(1,X+1):
# 	a = Y/(2*i)
# 	b = (Y - 2*a)/(4)
# 	# print(a,b)
# 	if(a == int(a) and b == int(b) and a+b == X):
# 		print('Yes')
# 		exit(0)
# print('No')

l = list(map(int, input().split()))
print(l.index(0)+1)

Measured memory_bytes: 9100
N=int(input())
H=list(map(int,input().split()))
temp=0
ans=0

for i in range(N-1):
    if H[i]>=H[i+1]:
        temp+=1
    else:
        if ans<temp:
            ans=temp
            temp=0
        else:
            temp=0

if temp>ans:
    ans=temp

print(ans)


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    int N, Q;
    cin >> N >> Q;
    vector<int> a(N);
    rep(i,0,N) cin >> a[i];
    atcoder::fenwick_tree<ll> ft(N); // binary index tree
    rep(i,0,N) ft.add(i, a[i]);
    rep(qi,0,Q) {
        int t;
        cin >> t;
        if (t == 0) {
            int p, x;
            cin >> p >> x;
            ft.add(p, x);
        } else {
            int l, r;
            cin >> l >> r;
            cout << ft.sum(l, r) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 10088
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;
const int MAXN = 100;

char tab[MAXN + 3][MAXN + 3];
int dp[MAXN + 3][MAXN + 3];

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++)
        scanf("%s", tab[i]+1);
    for(int i=1; i<=n; i++)
        dp[i][m+1] = INF;
    for(int i=1; i<m; i++)
        dp[n+1][i] = INF;
    for(int i=n; i>=1; i--)
        for(int j=m; j>=1; j--){
            if(tab[i][j] == '.')
                dp[i][j] = min(dp[i+1][j], dp[i][j+1]);
            else
                dp[i][j] = min(dp[i+1][j] + (int)(tab[i][j] != tab[i+1][j]), dp[i][j+1] + (int)(tab[i][j] != tab[i][j+1]));
        }
    printf("%d\n", dp[1][1]);
            
return 0;
}

Measured memory_bytes: 256
Blur = [
  [ [0, 0], [-1, 1], [0, 1], [1, 1], [-2, 2], [-1, 2], [0, 2], [1, 2], [2, 2], [-1, 3], [0, 3], [1, 3], [0, 4] ],
  [ [0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2] ],
  [ [0, 0], [-1, 1], [0, 1], [1, 1], [0, 2] ]
]
Blur_c = [[0, 2], [1, 1], [0, 1]]

def solve(fld, x, y, m)
  if m == $n
    if fld.flatten.all?{ |v| v == 0 }
      return true
    else return false
    end
  end

  3.times do |z|
    10.times do |i|
      10.times do |j|
        if fld[i][j] > 0
          return false if i < y || i == y && j < x
          if ps = ok(j, i, z)
            if ps.all?{ |x, y| fld[y][x] > 0 }
              nfld = fld.map(&:dup)
              ps.each{ |x, y| nfld[y][x] -= 1 }
              $ans[m] = [j + Blur_c[z][0], i + Blur_c[z][1], 3 - z]
              return true if solve(nfld, j, i, m + 1)
            end
          end
        end
      end
    end
  end
  false
end

def ok(x, y, z)
  ret = []
  Blur[z].each do |c, r|
    nx = x + c; ny = y + r
    return false unless 0 <= nx && nx < 10 && 0 <= ny && ny < 10
    ret << [nx, ny]
  end
  ret
end

$n = gets.to_i
$ans = $n.times.map { [] }
fld = 10.times.map { gets.split.map(&:to_i) }
solve(fld, 0, 0, 0)
$ans.each{ |a| puts a.join(' ') }

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int N;
int H;
vector<int> a;
vector<int> b;

int main(){
    cin >> N >> H;
    int a_max=0;
    a=vector<int>(N);
    b=vector<int>(N);
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i];
        a_max=std::max(a_max,a[i]);
    }
    sort(b.begin(),b.end());
    auto low=std::lower_bound(b.begin(),b.end(),a_max);
    int ans=0;
    for(int i=b.size()-1;i>=low-b.begin()&&H>0;i--,ans++){
        H-=b[i];
    }
    while(H>0){
        H-=a_max;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
use std::io;

macro_rules! get {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.parse::<$t>().unwrap()
        }
    };
    ($($t: ty), *) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            let mut inter = x.split_whitespace();
            (
                $(inter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

macro_rules! insert_vec {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.split_whitespace().map(|x| x.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

macro_rules! word_chars_vec {
    () => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.chars().collect::<Vec<_>>()
        }        
    };
}

macro_rules! two_vec {
    ($t: ty; $e: expr) => {
        {
            (0..$e).map(|_| insert_vec!($t)).collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (x , a) = get!(usize, usize);
    if x < a {
        println!("0");
    } else {
        println!("10");
    };
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
int d[10000];
 int A[10000][10000];
int main() {
 int N, K;
 cin >> N >> K;
 
 for(int i = 0; i < K; i++) {
   cin >> d[i];
   for(int j = 0; j < d[i]; j++) {
     cin >> A[i][j];
   }
 }
  ll sum = 0;
  vector<int> b(N);
 for(int i = 0; i < K; i++) {
   
   for(int j = 0; j < d[i]; j++) {
     b[A[i][j] - 1] += 1;
   }
 }

 for(int i = 0; i < N; i++) {
   if(b[i] == 0) sum++; 
 }



 cout << sum;
 return 0;
}



Measured memory_bytes: 4036
#include<stdio.h>
int main(void)
{
  int a,b;
  int i,n,co=0;
  scanf("%d %d",&a,&b);
  n=b-a;
  for(i=1;i<=n;i++){
	co=co+i;
  }
  printf("%d\n",co-b);
  return 0;
}


Measured memory_bytes: 128
# -*- coding utf-8 -*-
import copy
N = int(input())

A = [int(input()) for _ in range(N)]

m = max(A)
c = A.count(m)

for a in A:
    if a != m:
        print(m)
    else:
        if c > 1:
            print(m)
        else:
            l = copy.deepcopy(A)
            l.remove(m)
            print(max(l))


Measured memory_bytes: 14684
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n);
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

int
main(void){  
  string a, b;
  cin >> a >> b;

  if(a == b) cout << "H" << endl;
  else cout << "D" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let n = scan.next();
    let mut s = vec![0; n];
    for i in 0..n {
        s[i] = scan.next();
    }
    let q = scan.next();
    let mut t = vec![0; q];
    for i in 0..q {
        t[i] = scan.next();
    }

    s.sort();
    t.sort();
    let mut res = 0;
    let mut j = 0;
    for i in 0..q {
        while j < n && s[j] < t[i] {
            j += 1;
        }
        if j == n {
            break;
        }
        if s[j] == t[i] {
            res += 1;
        }
    }
    writeln!(out, "{}", res).ok();
}



Measured memory_bytes: 5060
#include <cstdio>
#include <cstring>
typedef long long int64;
static const int MAXN = 2e5 + 4;
static const int LOGL = 90;

int n, k;   // k = minimum period
char s[MAXN];
int pre[MAXN];
int s_sum[MAXN][26] = {{ 0 }};

int64 fib[LOGL];

int64 l, r;
int64 ans[26] = { 0 };

void count(int64 r, int mul)
{
    if (r <= n) {
        for (int i = 0; i < 26; ++i) ans[i] += s_sum[r][i] * mul;
    } else {
        int i;
        for (i = 0; fib[i + 1] * n + fib[i] * k <= r; ++i) ;
        --i;
        //printf("R = %lld | S * %lld + T * %lld + %lld\n", r, fib[i + 1], fib[i], r - (fib[i + 1] * n + fib[i] * k));
        for (int j = 0; j < 26; ++j)
            ans[j] += (fib[i + 1] * s_sum[n][j] + fib[i] * s_sum[k][j]) * mul;
        r -= (fib[i + 1] * n + fib[i] * k);
        count(r, mul);
    }
}

int main()
{
    scanf("%s", s);
    n = strlen(s) / 2;

    pre[0] = -1; pre[1] = 0;
    int last = 0;
    for (int i = 2; i <= n; ++i) {
        while (last > 0 && s[last] != s[i - 1]) last = pre[last];
        if (s[last] != s[i - 1]) pre[i] = 0;
        else pre[i] = ++last;
    }
    k = n - pre[n];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 26; ++j)
            s_sum[i + 1][j] = s_sum[i][j] + (s[i] == j + 'a');
    }

    fib[0] = 0; fib[1] = 1;
    for (int i = 2; i < LOGL; ++i) fib[i] = fib[i - 1] + fib[i - 2];

    scanf("%lld%lld", &l, &r);

    count(r, +1);
    count(l - 1, -1);
    for (int i = 0; i < 26; ++i) printf("%lld%c", ans[i], i == 25 ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main()
{
  ll n,k; cin >> n >> k;  
  cout << min({n, n % k, abs(n % k - k)}) << endl;
}

Measured memory_bytes: 3588
def solve(m1, d1, m2, d2):
    return m1 != m2


m1, d1 = [int(s) for s in input().split()]
m2, d2 = [int(s) for s in input().split()]

if solve(m1, d1, m2, d2):
    print('1')
else:
    print('0')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define PI 3.14159265359
 
int main(){
  ll N, M, sum = 0, a, i, ans;
  cin >> N >> M;
  rep(i, M){
    cin >> a;
    sum += a;
  }
  
  if(sum > N){
    ans = -1;
  } else {
    ans = N - sum;
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
   int W,H,x,y,r;
   cin >> W >> H >> x >> y >> r;
if ( x -r >=0  &&  x+r <= W ){

    if ( y -r >=0  &&  y+r <= H ) {  
    cout << "Yes"<< endl;
    }else {
   cout << "No"<< endl;
	}
    }else{
   cout << "No"<< endl;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>

int main(){
    int a,b,c,d,e,k,A,B,C,D,E;
    
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);
   
    
    if(abs(a-b)<=k && abs(a-c)<=k && abs(a-d)<=k && abs(a-e)<=k && abs(b-c)<=k && abs(b-d)<=k && abs(b-e)<=k && abs(c-d)<=k && abs(c-e)<=k && abs(d-e)<=k){
        printf("Yay!\n");
    }
    
    else{
        printf(":(\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
int main()
{
    int a,b,c,num;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=0;i<=1000;i++)
    {
        num=a*i;
        if(num%b==c)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128