akhauriyash/Code-Regression huggingface dataset:
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>x>>y)
    {
        if(x==2&&y==2) cout<<"Yes"<<en;
        else if(x==2||y==2) cout<<"No"<<en;
        else if(x==4||x==6||x==9||x==11)
        {
            if(y==4||y==6||y==9||y==11) cout<<"Yes"<<en;
            else cout<<"No"<<en;
        }
        else
        {
            if(y==4||y==6||y==9||y==11) cout<<"No"<<en;
            else cout<<"Yes"<<en;
        }
    }
}



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

int F[100][10];
int P[100][11];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];
    }
  }
  int max = -10000000000;
  for (int i = 1; i < (1<<10); i++) {
    int sum = 0;
    for (int k = 0; k < N; k++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if ((i & (1<<j)) && F[k][j]) c++; 
      }
      sum += P[k][c];
    }
    max = max > sum ? max : sum;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace _7_A
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var m = s[0];
                var f = s[1];
                var r = s[2];
                var ave = m + f;
                if (m == -1 && f == -1 && r == -1) break;
                if (m == -1 || f == -1)
                {
                    Console.WriteLine("F");
                }
                else
                {
                    if (ave >= 80)
                    {
                        Console.WriteLine("A");
                    }
                    else if (ave >= 65 && ave < 80)
                    {
                        Console.WriteLine("B");
                    }
                    else if ((ave >= 50 && ave < 65) || (ave >= 30 && ave < 50 && r >= 50))
                    {
                        Console.WriteLine("C");
                    }
                    else if (ave >= 30 && ave < 50 && r < 50)
                    {
                        Console.WriteLine("D");
                    }
                    else if (ave < 30)
                    {
                        Console.WriteLine("F");
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 13892
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int N;
// A, B, Cを配列でもつことで、ループ処理を可能にする
vector<int> len(3);
int ans = INF;
// 総長さ、本数をpairで持つ
vector<pair<int, int>> now(4, pair<int, int>(0, 0));
void dfs(int depth, vector<int> &l){
    if(depth < N){
        // 各竹について、4つのグループに入る可能性がある
        for(int i=0; i<4; i++){
            now[i].first += l[depth];
            now[i].second += 1;
            dfs(depth+1, l);
            // 抜けたら選択をもどす
            now[i].first -= l[depth];
            now[i].second -= 1;
        }
    }else{
        int tmp = 0;
        for(int i=0; i<3; i++){
            if(now[i].second == 0) return;
            // 目的の長さとの差 + くっつけるMP
            tmp += abs(len[i]-now[i].first)+10*(now[i].second-1);
        }
        ans = min(ans, tmp);
    }
}


int main(){
    cin >> N;
    for(int i=0; i<3; i++) cin >> len[i];
    vector<int> l(N);
    for(int i=0; i<N; i++) cin >> l[i];
    dfs(0, l);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  int N;  cin >> N;
  vector<int> T(N);
  int tSum = 0;
  rep(i, 0, N)  {
    cin >> T[i];
    tSum += T[i];
  }
  int M;  cin >> M;
  vector<int> P(M), X(M);
  rep(i, 0, M)  {
    cin >> P[i] >> X[i];
    cout << tSum - (T[P[i]-1]-X[i]) << endl;
  }
  return 0;
}


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

int main()
{
    int N,W;
    cin >> N >> W;
    
    ll dp[110][110000];
    dp[0][0]=0;
    
    ll w[110],v[110];
    
    
    for(int i=1;i<=N;++i)
    {
        int  weight,value;
        cin >> weight >> value;
        for(int j=W;j>=0;--j)
        {
            dp[i][j]=dp[i-1][j];
            if(j+weight<=W)
            dp[i][j+weight]=max(dp[i][j+weight],dp[i-1][j]+value);
        }
    }
    cout << dp[N][W] << endl;
    
    return 0;
}

Measured memory_bytes: 82004
n = int(input())
countmax=0
anslist=[]
dic={}
for i in range(n):
    a=input()
    if a in dic:
        dic[a]+=1
    else:
        dic[a]=1
    if dic[a]>countmax:
        countmax=dic[a]
for j in dic.keys():
    if dic[j]==countmax:
        anslist.append(j)
b=sorted(anslist)
for i in b:
    print(i)


Measured memory_bytes: 93696
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll n = 0;
    cin >> n;

    dll a;
    if(n%2==0){
        ll d =0; 
        REP(i,n){
        ll d =0; 
        cin >> d;
            if(i%2==1){
                a.push_front(d);
            }
            if(i%2==0){
                a.push_back(d);
            }
        }
    }
    if(n%2==1){

        REP(i,n){
        ll d =0; 
        cin >> d;
            if(i%2==0){
                a.push_front(d);
            }
            if(i%2==1){
                a.push_back(d);
            }
        }
    }


    //本文
    //出力
    REP(i,n){
    cout << a.at(i) << " ";}
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 5284
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;
const double EPS = 1e-9;
void solve(){
	int n;
	cin >> n;
	vector<int> div(n,0);
	for(int i = 1; i < n; ++i){
		for(int j = 1; j*i < n; ++j){
			div[i*j]++;
		}
	}
	int sum = 0;
	for(int i = 1; i < n; ++i)sum += div[i];
	cout << sum << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 11048
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector< pair<int,int> > a(n);
    for(int i=0; i<n; i++){
        cin >> a[i].first;
        a[i].second=i+1;
    }
    sort(a.begin(),a.end());
    for(int i=0; i<n-1; i++){
        cout << a[i].second << " ";
    }
    cout << a[n-1].second << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,a[1000]={0},c1=0,c,b,a1,d;
	scanf("%d %d %d %d",&a1,&b,&c,&d);
	for(i=0;i<=100;i++)
	{
		if(i>=a1 && i<=b)
		a[i]++;
		if(i>=c && i<=d)
		a[i]++;
		if(a[i]==2)
		c1++;
		//printf("%d ",i);
	}
	printf("%d",max(0,c1-1));
	
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
//namespace
using namespace std;
//#define , typedef, const
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)

#define all_range(C) begin(C), end(C)

typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//main.cpp----------------------------

void solve();
bool dfs(int);

string s[3];  //0-a , 1-b, 2-c
int len[3];
int card[3] = {};

int main() {
  rep(i, 3) cin >> s[i];
  rep(i, 3) len[i] = (int)(s[i].length());

  solve();

  return 0;
}

void solve() {
  int now = 0; //aさん
  int before;

  while(!(dfs(now))) {
    before = now;

    if(s[now][card[now]]=='a') now = 0;
    else if(s[now][card[now]]=='b') now = 1;
    else if(s[now][card[now]]=='c') now = 2;

    card[before] += 1;

  }

}

bool dfs(int now) {

  if(card[now]==len[now]) {
    if(now==0) cout << 'A';
    if(now==1) cout << 'B';
    if(now==2) cout << 'C';
    return true;
  }

  return false;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long div = 1e9 + 7;
  long N;
  long K;
  cin >> N >> K;
  long Kdiv1 = K % div;
  long Kdiv2 = (K * (K - 1)) / 2 % div;
  vector<int> A(N);
  for (int i = 0; i < N; i ++) {
    cin >> A[i];
  }
  long result = 0;
  for (int i = 0; i < N; i ++) {
    long offset = 0;
    for (int j = i + 1; j < N; j ++) {
      if (A[i] > A[j]) {
        offset += 1;
      }
    }
    long count = offset;
    for (int j = 0; j < i; j ++) {
      if (A[i] > A[j]) {
        count += 1;
      }
    }
    result = (result + offset * Kdiv1 + count * Kdiv2) % div;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}


ll RoundedUp(ll x)
{
	return (x + 9) / 10 * 10;
}


ll remtime(ll x)
{
	return RoundedUp(x) - x;
}


int main()
{
	ll a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;

	ll sum = RoundedUp(a) + RoundedUp(b) + RoundedUp(c) + RoundedUp(d) + RoundedUp(e);

	ll m = max({remtime(a), remtime(b), remtime(c), remtime(d), remtime(e)});

	cout << sum - m << endl;
	

}

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

string ask(int x){
    cout << x << endl << flush;
    string ret;
    cin >> ret;
    if(ret == "Vacant") exit(0);
    return ret;
}

int main(){
    int n;
    cin >> n;
    string l = ask(0), r = ask(n-1);
    int li = 0, ri = n-1;
    while(1){
        int mid = (li+ri)/2;
        string tmp = ask(mid);
        if( (mid%2 == li%2 && l != tmp) || (mid%2 != li%2 && l == tmp) )   r = tmp, ri = mid;
        else l = tmp, li = mid;
    }
}

Measured memory_bytes: 852
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

main = do
  [x] <- getInts
  print $ (x `div` 11) * 2 + if (x `mod` 11 == 0) then 0 else if (x `mod` 11) <= 6 then 1 else 2

-- util
getInts :: IO [Integer]
getInts = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine

substr :: Int -> Int -> B.ByteString -> B.ByteString
substr b l s = B.take l $ B.drop b s


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


int main() {

    ll l, r;
    cin >> l >> r;
    r = min(r, l+4038);
    int ans = 2018;
    for (ll i = l; i <= r; i++) {
        for (ll j = i+1; j <= r; j++) {
            int x = i*j % 2019;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n,m,d;
  cin >> n >> m >> d;

  double c;
  if(d == 0){
    c = 1;
    printf("%.10lf\n",(double)(m-1)/n);
    return 0;
  }else{
    c = (n-d) * 2;
  }
  c *= (m-1);
  c /= n;
  c /= n;
  printf("%.10lf\n",c);
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
a = [int(i) for i in input().split()]

c = [0,0,0]

for i in a:
    if i%2==1:
        c[0]+=1
    elif i%4!=0:
        c[1]+=1
    else:
        c[2]+=1
b = []

last = None

isPossible = True

while (sum(c)):
    mn = 0
    if len(b) and b[-1]==1:
        mn = 1
    if len(b) and b[-1]==0:
        mn = 2

    n = -1
    for i in range(mn, 3):
        if c[i]:
            n = i
            break
    if n==-1:
        isPossible = False
        break

    c[n]-=1
    b.append(n)

if isPossible:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 15020
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    ll a = 0, b = 0, c = 0, three = 1;
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'A'){
            // a += three * b;
            a += b;
        }else if(s[i] == 'B'){
            // b += three * c;
            b += c;
        }else if(s[i] == 'C'){
            c += three;
            // c++;
        }else if(s[i] == '?'){
            a = a * 3 + b;
            b = b * 3 + c;
            c = c * 3 + three;
            three *= 3;
            // a = a * three + b;
            // b = b * three + c;
            // c = c * three + 1;
            // a = a * 3 + b;
            // b = b * 3 + c;
            // c = c * 3 + 1;
            // a *= 3;
            // b *= 3;
            // c *= 3;
            // a += b;
            // b += c;
            // c++;
        }
        a %= M;
        b %= M;
        c %= M;
        three %= M;
        printde(a, b, c);
    }
    cout << a << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
	int n,k;
	cin >>n>>k;
	vector<int>h(n);
	rep(i,n)
		cin >>h[i];
	sort(h.begin(),h.end());
	int ans=h[k-1]-h[0];
	rep(i,n-k+1){
		ans=min(ans,h[i+k-1]-h[i]);
	}
	cout <<ans;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = -b;
    for(int i = 1; i <= b-a; i++) {
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.split("")
len = s.length
j = 0
0.step(len-1, 2){|i|
if s[i] == "L"
    j = 1
    print "No"
    break
end

if s[i+1] == "R"
    j = 1
    print "No"
    break
end
}
if j == 0
    print "Yes"
end

Measured memory_bytes: 1788
N,M=map(int, input().split())
A=[[] for i in range(N)]
 
for i in range(M):
  p,y=map(int, input().split())
  A[p-1].append((y, i))
 
X=[0]*M
for i,d in enumerate(A):
  d.sort()
  for k,(y,j) in enumerate(d):
    X[j]=str(i+1).zfill(6)+str(k+1).zfill(6)
print(*X,sep='\n')

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    VL arr(n);
    fr(i,0,n)
        cin>>arr[i];
    ll ct=0;
    ll last=0;
    fr(i,0,n)
    {
        if(arr[i]<last)
        {
            ct+=(last-arr[i]);
            //last=arr[i];
        }
        else
        {
            last=max(last,arr[i]);
        }
    }
    cout<<ct<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
using namespace std;


int main()
{
    int num;
    cin >> num;
    //景品の種類が、すでに持っている景品の種類と一致しているかみて、一致していなければインクリメントする

    string temp;
    int ans = 0;

    //    vector<string> list(num+1, "111");

    // map<string, int> list;
    set<string> list;

    //くじ引き1つ1つについて確認
    for (int i = 1; i <= num; i++)
    {
        cin >> temp;

        if (list.count(temp) == 0)
        {
            list.insert(temp);
            ans++;
        }
    }

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

Measured memory_bytes: 19248
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
int main(){
	int i,j;
	int n1,n2;
	int ok=0;
	gets(t1);
	gets(t2);
	n1=strlen(t1);
	n2=strlen(t2);
	for(i=0;i<n1;i++){
		t1[i+n1]=t1[i];
	}
	n1*=2;
	for(i=0;i<n1-n2+1;i++){
		for(j=0;j<n2;j++){
			if(t1[i+j]!=t2[j]) break;
			if(j==n2-1) ok=1;
		}
	}
	if(ok) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 524
#[int(i) for i in input().split()]
import collections
n = int(input())

dic = collections.defaultdict(int)
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            dic[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i] += 1

for i in range(1,n+1):
    print(dic[i])


Measured memory_bytes: 72420
n,m,x,y=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
pm=max(p)
qm=min(q)
a='War'
if x<y and pm<qm:
  for i in range(x+1,y+1):
    if pm<i and i<=qm:
      a='No War'
      break
print(a)

Measured memory_bytes: 3060
from collections import defaultdict

def main():
    N = int(input())
    m = defaultdict(int)
    for _ in range(N):
        m[input()] += 1
    print('AC x', m['AC'])
    print('WA x', m['WA'])
    print('TLE x', m['TLE'])
    print('RE x', m['RE'])

if __name__ == '__main__':
    main()

Measured memory_bytes: 69976
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>

using namespace std;

bool ok(string s) {
  if (s[0] != 'A') return false;
  if (count(s.begin() + 2, s.end() - 1, 'C') != 1) return false;
  for (char c : s) {
    if (c != 'A' && c != 'C' && isupper(c)) return false;
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  cout << (ok(s) ? "AC" : "WA") << endl;
}


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

int main() {
  int n,m,x,y;cin>>n>>m>>x>>y;
  vector<int>a(n),b(m);
  rep(i,n)cin>>a[i];
  rep(i,m)cin>>b[i];
  sort(all(a));
  sort(all(b));
  if(a[n-1]<b[0]&&x<b[0]&&a[n-1]<y)cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}

Measured memory_bytes: 3568
use std::io;


/// https://beta.atcoder.jp/contests/abc077/tasks/abc077_b
fn main() {
    let n = read_one::<usize>();
    let root = (n as f64).sqrt().floor();
    println!("{}", root * root);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll A,B,C; cin>>A>>B>>C;
  cout<<min(A+B+1,C)+B<<endl;
}

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


int main()
{
int N;
cin>>N;
int A[N+1]={};
int a=0;
int b=0;
int Ans=0;

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

sort(A,A+N);

for(int i=0;2*i<N;++i)
{
a=a+A[N-1-2*i];
  if(N-2-2*i>-1){
    b=b+A[N-2-2*i];
  }
}

Ans=a-b;


cout<<Ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;

ll dp[410][410]={};



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

  for(int i=1;i<n;i++){
    for(int j=0;j<n-i;j++){
      ll tmp=1000000000000000;
      ll sum=0;
      for(int k=j;k<j+i;k++){
        tmp=min(tmp,dp[j][k]+dp[k+1][j+i]);
        sum+=a[k];
      }
      sum+=a[j+i];//a[j]~a[j+i]まで足す
      dp[j][j+i]=tmp+sum;
    }
  } 
  cout << dp[0][n-1] << endl;
}


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

int main()
{
	int cards, res, tScore = 0, hScore = 0;
	std::string Taro, Hanako;
	std::cin >> cards;
	for (int i = 0; i < cards; i++) {
		std::cin >> Taro >> Hanako;
		
		/*switch (Taro.compare(Hanako)) {
		case -1:
			hScore += 3;
			break;
		case 0:
			tScore++;
			hScore++;
			break;
		case 1:
			tScore += 3;
		}*/

		res = Taro.compare(Hanako);
		if (res < 0)
			hScore += 3;
		else if (res > 0)
			tScore += 3;
		else if (res == 0) {
			tScore++;
			hScore++;
		}
	}
	std::cout << tScore << ' ' << hScore << "\n";

    return 0;
}



Measured memory_bytes: 3208
#include <stdio.h>
#define N 1000
#define WHITE 0
#define BLACK 1
#define GRAY 2

int A[N][N],color[N],d[N],f[N],k[N];
int n,u,time;


void visit(int r){

  int i;

  color[r] = GRAY;
  d[r] = ++time;
  for(i=1;i<=k[r];i++){
    if(color[A[r][i]] == WHITE){
      visit(A[r][i]);
    }
  }
  color[r] = BLACK;
  f[r] = ++time;
}

void dfs(void){
  
  int i;
  
  for(i=1;i<=n;i++){
    color[i] = WHITE;
  }
  time = 0;
  for(i=1;i<=n;i++){
    if(color[i] == WHITE){
      visit(i);
    }
  }
}


int main(void){

  int i,j;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k[i]);
    for(j=1;j<=k[i];j++){
      scanf("%d",&A[i][j]);
    }
  }
  dfs();
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> tree(N+1, vector<int>());
    for (int i = 0; i < N-1; i++) {
    	int a, b;
        scanf("%d%d", &a, &b);
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<int> counter(N+1, 0);
    for (int i = 0; i < Q; i++) {
    	int p, x;
        scanf("%d%d", &p, &x);
        counter[p] += x;
    }
    queue<int> q;
    q.push(1);
    vector<bool> check(N+1, false);
    int now;
    while (!q.empty()) {
        now = q.front();
        q.pop();
        check[now] = true;
        for(int nxt : tree[now]) {
            if (!check[nxt]) {
                q.push(nxt);
                counter[nxt] += counter[now];
            }
        }       
    }
    for (int i = 1; i <= N; i++) {
        printf("%d ", counter[i]);
    }
}

Measured memory_bytes: 15604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int flag = 0;
		int count = 0;
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		while(flag == 0) {
			for(int i = 0; i < n; i++) {
				if(a[i] % 2 == 0) {
					a[i] /= 2;
				} else {
					flag = 1;
					break;
				}
			}
			if(flag != 1) {
				count += 1;
			}
		}
		
		System.out.println(count);
		
	}

}

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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 1 * 1e5 + 2;

int a, b, c, k;

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> a >> b >> c >> k;
  int sum = 0;
  sum += min(a, k);
  k -= a;
  k -= b;
  if(k > 0) sum -= k;
  cout << sum << '\n';

	return 0;
}


Measured memory_bytes: 3652
/*
   Author A.G.Maruf
   9 th sem :P
   code written 2019-12-08-10.44()
*/
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cctype>
#define gc              getchar
#define pc              putchar
#define pb              push_back
#define Sort_arr(n,x)   sort(n,n+x);
#define Sortr_arr(arr,x)  sort(arr, arr+n,greater<int>());
#define SortS(s)        sort(s.begin(), s.end());
#define SortRS(s)       sort(s.rbegin(), s.rend());
#define all(s)          s.begin(), s.end()a
#define GCin(a)         getline(cin,a);
#define Sz(a)           a.size()
#define arr_rev(n)      sort(n.begin(), n.end(), greater<int>());
#define Gin(a)          getline(cin,a);
#define input(a)        scanf("%d",&a);
#define Sz(a)           a.size()
#define input2(a,b)     scanf("%d %d",&a,&b);
#define input3(a,b,c)   scanf("%d %d %d",&a,&b,&c);
#define input4(a,b,c,d) cin>>a>>b>>c>>d;
#define rep(n)          for(int i=1;i<n;i++)
#define Fast_read       ios_base::sync_with_stdio(false);
#define Unique(n)       sort(Search(n)),n.erase(unique(Search(n)),n.end());
#define PI              3.1415926535897932384626433832795l
#define Ignore          cin.ignor3e();
#define out(n)          cout<<n<<endl;
#define mem(n,i)        memset(n,i,sizeof n);
#define square(n)       (n*n)
#define cube(n)         (n*n*n)
#define F               first
#define S               second
#define mxin            -INFINITY
#define mnin            INFINITY
#define el              <<endl
#define MAXC 1000
//#define N 1000000
using namespace std;

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
//ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
//ll lcm(ll a,ll b){return a/__gcd(a,b)*b;}
//ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

//typedef pair <ll, ll> pll;
typedef long long int ll;
const int Max = 1e4 + 10;
const int MOD = 1e9 + 7;


int main (){


    string ss;
    cin>>ss;
    int c=0;
    for (int i=0,j=ss.size()-1;i<ss.size()/2;i++,j--){
        if (ss[i]!=ss[j])c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string st[123456];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++){
		cin>>st[i];
		sort(st[i].begin(),st[i].end());
	}
	sort(st,st+n);
	long long cnt=0,cur=1;
	for(int i=1;i<n;i++){
		if(st[i]!=st[i-1]){
			cnt+=cur*(cur-1)/2;
			cur=1;
		}else{
			cur++;
		}
	}
	cnt+=cur*(cur-1)/2;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int  k,t,a[101],s,maxa=0;
int main(){
	cin>>k>>t;
	for(int i=1;i<=t;i++){
		cin>>a[i];
		maxa=max(maxa,a[i]);
		s+=a[i];
	}
	if(s-maxa>=maxa-1)cout<<0<<endl;
	else cout<<maxa-s+maxa-1<<endl;
}

Measured memory_bytes: 256
#include<cstdio>

const int mod=1000000007;
const int inv2=(mod+1)/2;
int n,m,a[5010],x,y,i,j;

long long p[5010][5010],t;
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)p[i][j]=a[i]>a[j];
	for (int k=0;k<m;k++) {
		scanf("%d%d",&x,&y);
		p[x][y]=p[y][x]=(p[x][y]+p[y][x])*inv2%mod;
		for(i=1;i<=n;++i)if(i!=x&&i!=y) p[i][x]=p[i][y]=(p[i][x]+p[i][y])*inv2%mod,
			p[x][i]=p[y][i]=(p[x][i]+p[y][i])*inv2%mod;
	}
	for(i=1;i<=n;++i)for(j=n;j>i;--j)t=(t+p[i][j])%mod;
	for (i=0;i<m;++i) t=t*2%mod;
	printf("%lld\n",t);
}

Measured memory_bytes: 118400
import itertools
n,y = map(int,input().split())
z = y//1000

list = list(range(n+1))
for a,b in itertools.product(list,list):
    c = n - a - b
    if c>=0:
        v = 10*a + 5*b + c
        w = a + b + c
        if v == z and w == n:
            break
else:
    a = -1
    b = -1
    c = -1

print(str(a),str(b),str(c))


Measured memory_bytes: 73736
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] dir = new char[n];
        sc.close();
        dir = s.toCharArray();

        int minCount = 0;
        for(int i = 1; i < n; i++){
            if(dir[i] == 'E'){
                minCount++;
            }
        }

        int count = minCount;
        for(int j = 1; j < n; j++){
            if(dir[j-1] == 'W'){
                count++;
            }
            if(dir[j] == 'E'){
                count--;
            }
            if(count < minCount){
                minCount = count;
            }
        }
        System.out.println(minCount);
    }

}


Measured memory_bytes: 30024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 998244353
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll N = C - A;
	ll M = D - B;
	vector<vector<pll>> DP(N + 1);
	rep(i, N + 1)
		DP[i].resize(M + 1, make_pair(0, 0));
	DP[0][0].first = 1; // prev=U
	DP[0][0].second = 0; // prev=R
	rep(i, N + 1) {
		rep(j, M + 1) {
			if (i != 0) {
				DP[i][j].first += DP[i - 1][j].first * (B + j);
				DP[i][j].first += DP[i - 1][j].second;
			}
			if (j != 0) {
				DP[i][j].second += DP[i][j - 1].first * (A + i);
				DP[i][j].second += DP[i][j - 1].second * (A + i);
			}
			DP[i][j].first %= mod;
			DP[i][j].second %= mod;
		}
	}
	ll ans = DP[N][M].first + DP[N][M].second;
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 144236
#include <stdio.h>
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int min(int a,int b){
    if(a>b)return b;
    return a;
}
int main(){
    int n,top,bot,tot,temp;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        scanf("%d",&top);
        tot=bot=top;
        for(int i=1;i<n;i++){
            scanf("%d",&temp);
            tot+=temp;
            top=max(top,temp);
            bot=min(bot,temp);
        }
        printf("%d\n",(tot-top-bot)/(n-2));
    }
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 3e3 + 3;
int dp[T][T];
int choose[T][T];
int n,m;
string a,s,t;

int solve(int i, int j) {
    if(i == n or j == m) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    int a = 0, b = 0, c = 0;
    a = solve(i+1, j);
    b = solve(i,j+1);

    if(s[i] == t[j]) c = solve(i+1,j+1)+1;
    if(a >= b and a >= c) choose[i][j] = 0;
    else if(b >= c and b >= a) choose[i][j] = 1;
    else choose[i][j] = 2;
    return dp[i][j] = max({a,b,c});
}

void build(int i, int j) {
    if(i == n or j == m) return;
    if(choose[i][j] == 2) a += s[i], build(i+1,j+1);
    else if(choose[i][j] == 1) build(i,j+1);
    else build(i+1,j);
}

int main() {
    ios_base::sync_with_stdio(false);
    memset(dp, -1, sizeof dp);
    cin >> s >> t;
    n = s.size(); m = t.size();
    solve(0,0);
    build(0,0);
    cout << a << endl;
    return 0;
}



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

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int N, x;
		cin >> N >> x;

		vector<int> a( N );
		for( auto& v: a ) { cin >> v; }

		sort( a.begin(), a.end() );

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

		cout << ans - (x > 0) << endl;
	}
};

int main() {
	Solver().solve();
	return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  int H, A;
  cin >> H >> A;
  cout << (H+A-1) / A << endl;

  return 0;
};


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll x = n / (a + b);
  ll y = n % (a + b);
  ll ans;
  if(y > a) {
    ans = a * x + a;
  }else{
    ans = a * x + y;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,ans,i,j,cnt_1,cnt_2;
  char A[100],B[100],C[100];
  scanf("%d",&N);
  scanf("%s",A);
  scanf("%s",B);
  scanf("%s",C);
  cnt_1=0;cnt_2=0;
  for(i=0;i<N;i++){
    if(A[i]==B[i] && B[i]!=C[i])cnt_1++;
    if(B[i]==C[i] && A[i]!=B[i])cnt_1++;
    if(A[i]==C[i] && B[i]!=C[i])cnt_1++;
    if(A[i]==B[i] && B[i]==C[i] && A[i]==C[i])cnt_2++;
  }
  printf("%d\n",2*N-cnt_1-2*cnt_2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
  ll ar[n];
  rep(i,0,n) cin>>ar[i];
  rep(i,0,n)
  {
    /*k=0;
     while(s[i]=='R'){i++;k++;}
     m=max(m,k*/
       rep(j,i+1,n)
       {
         rep(k,j+1,n)
         {
           if(ar[i]!=ar[j] && ar[j]!=ar[k] && ar[i]!=ar[k] && 
           ar[i]+ar[j]>ar[k] && 
           ar[i]+ar[k]>ar[j] && ar[j]+ar[k]>ar[i]) {m++;
          // cout<<ar[i]<<" "<<ar[j]<<" "<<ar[k]<<endl;
          }
         }
       }
     }
  cout<<m<<endl;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

int main(){
  string a,b;
  cin >> a>>b;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  if(a<b) cout <<"Yes" << endl;
  else cout <<"No" << endl;
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
a=deque(map(int,input().split()))
b=deque()
for i in range(n):
  if i%2==0:
    b.append(a[i])
  else:
    b.appendleft(a[i])
if n%2==1:
  b.reverse()
l=[str(i) for i in b]
print(" ".join(l))

Measured memory_bytes: 33140
N=int(input())
H=list(map(int, input().split()))


ans = 0
hoge = 0

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

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

int main(void){

    int N;

    scanf("%d", &N);

    long long a[N];

    long long sum = 0;

    for(int i = 0; i < N; i++){
        scanf("%lld", &a[i]);
        sum += a[i];
    }

    long long x = 0, y;
    long long min = 100000000000000000;

    for(int i = 0; i < N-1; i++){
        x += a[i];
        y = sum - x;
        if(llabs(x-y) < min){
            min = llabs(x-y);
        }
    }

    printf("%lld\n", min);

    return 0;
}

Measured memory_bytes: 3220
import math
N,M = input().split(' ')
N = int(N)
M = int(M)
if abs(N-M) >= 2:
    print(0)
elif N == M:
    kai = math.factorial(N)
    print(kai*kai*2 % 1000000007)
else:
    L = max(N, M)
    kai = math.factorial(L-1)
    print(kai*kai*L % 1000000007)

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

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

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

fac = [-1] * (10**7+1)
finv = [-1] * (10**7+1)
inv = [-1] * (10**7+1)

fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

dp = [[0 for _ in range(2001)] for __ in range(2001)]

def initSplitNintoKMod():
    for j in range(2001):
        dp[0][j] = 1

    for i in range(1, 2001):
        for j in range(1, 2001):
            if i - j >= 0:
                a = dp[i-j][j]
            else:
                a = 0
            dp[i][j] = dp[i][j-1] + a
            dp[i][j] %= mod

def splitNintoKMod(n, k):
    # at least 1 ball for each k boxes
    if n < k:
        return 0
    n = n - k
    if n <= 0 or k <= 0:
        return 0
    return dp[n][k]

initNCMMod(4000)

def main():
    N, K = LI()
    for i in range(1, K+1):
        ans = NCMMod(N-K+1, i) * NCMMod(K-1, i-1) % mod
        print(ans)

main()



Measured memory_bytes: 273836
#include <stdio.h>

int main(void)
{
    int H, W, i, j;

    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) {
            break;
        }
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                if ((i % 2 == 0 && j % 2 == 0) || 
                    (i % 2 == 1 && j % 2 == 1)) {
                    fputc('#', stdout);
                } else {
                    fputc('.', stdout);
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576