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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	string S;
	string ans;

	cin >> S;

	ll num[2];
	rep(i,2) num[i] = stoi(S.substr(2*i, 2));

	bool is_year[2];
	bool is_month[2];
	rep(i, 2) {
		if (num[i] >= 1 && num[i] <= 12) {
			is_month[i] = true;
		}
		else {
			is_month[i] = false;
		}
	}

	if (is_month[1]){
		// YYMM
		if (is_month[0]) {
			ans = "AMBIGUOUS";
		}
		else {
			ans = "YYMM";
		}
	} else if (is_month[0]) {
		// MMYY
		ans = "MMYY";
	}
	else {
		ans = "NA";
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int K;
 string S;
 cin>>K>>S;
 int a=S.size();
 if(a<=K){
   cout<<S<<endl;
 }
 else{
   for(int i=0;i<K;i++){
     cout<<S.at(i);
   }
    cout<<"..."<<endl;
 }
}

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

using namespace std;

const int mod = 1e9 + 7;

int getMod(int n) {
    if(n % 6 == 0) return 1;
    if(n % 6 == 1) return 10;
    if(n % 6 == 2) return 9;
    if(n % 6 == 3) return 12;
    if(n % 6 == 4) return 3;
    return 4;
}

int main() {
    string S; cin >> S;
    int N = S.length();
    vector<vector<int>> dp(N+1, vector<int>(13,0));
    dp[0][0] = 1;

    for(int i=N-1;i>=0;i--) {
        int dig = i;
        int j = N-dig-1;
        if(S[dig] == '?') {
            for(int num=0;num<=9;num++) {
                for(int m=0;m<13;m++) {
                    int r = ((getMod(j) * num )%13 + m)%13;
                    dp[j+1][r] += dp[j][m] % mod;
                    dp[j+1][r] %= mod;
                }
            }
        } else {
            int num = S[dig] - '0';
            for(int m=0;m<13;m++) {
                int r = ((getMod(j) * num )%13 + m)%13;
                dp[j+1][r] += dp[j][m] % mod;
                dp[j+1][r] %= mod;
            }
        }
    }
    cout << dp[N][5] % mod << endl;
    return 0;
}


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

typedef long long ll;
ll MOD = 1e9+7;

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}

ll a[100000];
ll rui1[100001];
ll rui2[100001];
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	rui1[0]=a[0];
	rui2[0]=a[n-1];
	rui1[1]=gcd(a[0],a[1]);
	rui2[1]=gcd(a[n-1],a[n-2]);
	for(int i=2;i<n;i++)
	{
		rui1[i]=gcd(rui1[i-1],a[i]);
		rui2[i]=gcd(rui2[i-1],a[n-i-1]);
	}
	//a[0]を除く場合とa[n-1]を除く場合
	ans=max(rui2[n-2],rui1[n-2]);
	for(int i=1;i<n-1;i++)
	{
		ans=max(ans,gcd(rui1[i-1],rui2[n-i-2]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
int main()
{
  int a,b,c,d;
 char s[1000];
 while(~scanf("%s",s))
 {
   a=b=c=d=0;
  int l=strlen(s);
  for(int i=0;i<l;i++)
  {
  if(s[i]=='N')
   a++;
   if(s[i]=='S')
   b++;
   if(s[i]=='W')
   c++;
   if(s[i]=='E')
   d++;
  }
  if(a!=0&&b!=0&&c!=0&&d!=0)
  printf("Yes\n");
  else if(c!=0&&d!=0&&a==0&&b==0)
  printf("Yes\n");
  else if(a!=0&&b!=0&&c==0&&d==0)
  printf("Yes\n");
  else
  printf("No\n");
 }

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int x; cin >> x;
	int num = x / 100;
	int rem = x % 100;
	int fi, fo, th, tw, on;
	fi = rem / 5;
	rem %= 5;
	fo = rem / 4;
	rem %= 4;
	th = rem / 3;
	rem %= 3;
	tw = rem / 2;
	rem %= 2;
	on = rem;
	if (fi + fo + th + tw + on <= num)cout << 1 << endl;
	else cout << 0 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0,i<n,i++)
int main(){
long double a,b,c;cin>>a>>b>>c; string s;
long double x;
x=pow(4.0*a*b,0.5);
if(a+b>c){s="No";}
else{if(c-(a+b)>x){s="Yes";}
else{s="No";}}
cout<<s<<endl;
  return 0;}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int n;
    long long int a[10001]={0}; //100001個
    cin >> n;
    for(int i=0; i<n; i++){
       cin >> a[i];
    }
    long long int min=1000000,max=-1000000,sum=0;
    for(int i=0; i<n; i++){
        if(a[i]<min){
            min=a[i];
        }
        if(a[i]>max){
            max=a[i];
        }
        sum=sum+a[i];
    }
    cout << min << " " << max << " " << sum << endl;
}   



Measured memory_bytes: 3184
#include <stdio.h>

void insertionSort();
void output();

int main(){

  int i,j,N;
  int A[1000];

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

  output(N,A);
  insertionSort(N,A);

  return 0;
}

void insertionSort(int N, int A[]){
  //change the place

  int i, j, v;

  for(i=1; i <N;i++){
    
    v =A[i];
    j = i -1;
    while( j >=0 && A[j] >v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] =v;
    output(N,A);
  }
}

void output(int N,int A[]){
  //output

  int i;

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

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  string s; cin >>s;
  int N = s.size();
  vector<int> div(N+1, 0);
  // div[i] := [0, i) を10進法の整数として見たときの2019で割ったあまり
  // div[0] := 0とする
  vector<int> cnt(2019, 0);
  // cnt[i] := 余りがiであるものがいくつあったか
  // resに i * (i-1) を足す
  ll sum = 0;
  rep(i, N){
    sum += (s[i] - '0') * power(10LL, (ll)(N-1-i), 2019LL);
    sum %= 2019;
    div[i+1] = sum;
    // cout <<"div[" <<i <<"] = " <<div[i+1] <<endl;
    cnt[sum]++;
  }

  ll res = 0;

  for (int i=0; i<2019; i++){
    ll tmp = cnt[i];
    res += tmp * (tmp - 1) / 2;
    if (tmp * (tmp - 1)){
      // cout <<"cntdayo = " <<i <<", " <<cnt[i] <<endl;
    }
  }
  res += cnt[0];

  cout <<res <<endl;
}

Measured memory_bytes: 4368
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int a, b;
	cin >> a >> b;
	int x = ceil(1.0*(b-1)/(a-1));
	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip>

using namespace std;

class Dice
{
	const static int NUM_S = 6;
	int a[NUM_S];

public:
	Dice(void) {}

	void set(int _a[]) {
		a[0] = _a[0]; a[1] = _a[1];
		a[2] = _a[2]; a[3] = _a[3];
		a[4] = _a[4]; a[5] = _a[5];
	}

	int rs(void) {
		int tmp = a[1];
		a[1] = a[0]; a[0] = a[4];
		a[4] = a[5]; a[5] = tmp;
		return a[0];
	}

	int re(void) {
		int tmp = a[0];
		a[0] = a[3]; a[3] = a[5];
		a[5] = a[2]; a[2] = tmp;
		return a[0];
	}

	int rn(void) {
		int tmp = a[1];
		a[1] = a[5]; a[5] = a[4];
		a[4] = a[0]; a[0] = tmp;
		return a[0];
	}

	int rw(void) {
		int tmp = a[0];
		a[0] = a[2]; a[2] = a[5];
		a[5] = a[3]; a[3] = tmp;
		return a[0];
	}

};

int main()
{
	Dice dc;
	int st[6];
	cin >> st[0] >> st[1] >> st[2] >> st[3] >> st[4] >> st[5];

	dc.set(st);

	string od;
	cin >> od;
	int ans = st[0];
	for (unsigned int i = 0; i < od.length(); ++i) {
		switch (od[i]) {
			case 'N':
				ans = dc.rn();
				break;
			case 'S':
				ans = dc.rs();
				break;
			case 'E':
				ans = dc.re();
				break;
			case 'W':
				ans = dc.rw();
				break;
		}
	}

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



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    int h[100005];
    cin >> N >> K;
    int ans = 0;
    rep(i, N){
        cin >> h[i];
        if (h[i] >= K) ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	string s;
	cin >> s;
	N = s.size();
	UnionFind uf(N);
	for (int i = 0; i < N; i++) {
		if (s[i] == 'L')uf.Unite(i, i - 1);
		else uf.Unite(i, i + 1);
	}
	vector<int>v(N,-1);
	for (int i = 1; i < N; i++) {
		if (s[i] == 'L'&&s[i - 1] == 'R') {
			v[i] = i - 1;
			v[i - 1] = i;
		}
	}
	vector<pair<int,int>>p(N);
	for (int i = 0; i < N; i++) {
		if (v[i] < 0)continue;
		p[uf.Find(i)] = { i,v[i] };
	}
	vector<int>ans(N);
	for (int i = 0; i < N; i++) {
		if (p[uf.Find(i)].first % 2 == i % 2)ans[p[uf.Find(i)].first]++;
		else ans[p[uf.Find(i)].second]++;
	}
	for (auto i : ans)cout << i << " ";
	cout << endl;
}


Measured memory_bytes: 3024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in);) {
			
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			
			System.out.println(num1 * num2 + " " + (num1 + num2) * 2);
		}

	}

}


Measured memory_bytes: 26328
/**
 * @author: Mackenzie
**/

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX = 2e5 + 5;
int A[MAX];
int n, k;

int check(int x) {
    int cnt = 0;
    forn(i, n) {
        if(A[i] > x)cnt += A[i] / x;
    }
    return cnt;
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    cin >> n >> k;
    forn(i, n)cin >> A[i];
    sort(A, A + n);
    int lo = 1, hi = 1e9;
    forn(it, 70) {
        int m = (lo + hi) / 2;
        //cout << m << endl;
        if(check(m) <= k)hi = m;
        else lo = m;
    }
    cout << hi << endl;
    return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
    cin>>a>>b>>c;
  if(c<=a+b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<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) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;

int N, K;

ll sum(ll l, ll r) {
    return (l+r) * (r-l+1) / 2;
}

int main(){
    cin >> N >> K;
    ll ans = 0;
    for (int i=K; i<=N+1; i++) {
        ll mn = sum(0, i-1);
        ll mx = sum(N+1-i, N);
        ans += mx - mn + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("c.in", "r", stdin);
		freopen("c.out", "w", stdout);
	#endif
}

int k, n, a[N], ans = inf;

int main() {
	data();
	scanf("%d %d", &k, &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	a[n] = a[0] + k;
	for (int i = 0; i < n; ++i) {
		int pos1 = a[i];
		int pos2 = a[i + 1];
		ans = min(ans, k - (pos2 - pos1));
	}
	printf("%d", ans);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/


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

int main() {
  int n; cin >> n;
  vector<int> mochi(n);
  for (int i = 0; i < n; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  
  int cnt = 1;
  for (int i = 1; i < n; i++) {
    if (mochi.at(i) > mochi.at(i-1)) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

from functools import lru_cache


def main(): 
    a,b,c,d  = LI()

    print(max(a*b, c*d))

main()

Measured memory_bytes: 3572
n, m = map(int, input().split())
keys = []

for _ in range(m):
    cost, types = map(int, input().split())
    to_open = list(map(int, input().split()))
    keys.append([cost, to_open])

DP = [10**9] * (2 ** n)
DP[0] = 0

for cost, (to_open) in keys:
    openable = 0
    for open in to_open:
        openable |= 1 << (open-1)

    for i in range(2 ** n):
        pattern = i | openable
        DP[pattern] = min(DP[pattern], DP[i] + cost)

ans = DP[2**n - 1]

if ans == 10 ** 9:
    ans = -1

print(ans)

Measured memory_bytes: 44904
//すぬけ君の塗り絵 2 イージー
#include <bits/stdc++.h>
using namespace std;

int main(){
    int W,H,N;
    cin>>W>>H>>N;
    vector<vector<int>>input(N,vector<int>(3));
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin>>input.at(i).at(j);
        }
    }
    vector<int>w={0,W};
    vector<int>h={0,H};
    for(int i=0;i<N;i++){
        switch (input.at(i).at(2)){
            case 1://y軸方向下部を切り取り
                if(w.at(0)<input.at(i).at(0))   w.at(0)=input.at(i).at(0);
                break;
            case 2://y軸方向上部を切り取り
                if(w.at(1)>input.at(i).at(0))   w.at(1)=input.at(i).at(0);
                break;
            case 3:
                if(h.at(0)<input.at(i).at(1))   h.at(0)=input.at(i).at(1);
                break;
            case 4:
                if(h.at(1)>input.at(i).at(1))   h.at(1)=input.at(i).at(1);
                break;
            default:
            break;
        }
    }
    int S=0;
    if( w.at(0) > w.at(1) || h.at(0) > h.at(1) )    cout<<S<<endl;
    else{
        S=(w.at(1)-w.at(0))*(h.at(1)-h.at(0));
        cout<<S<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n) ]
b = [int(input()) for i in range(m)]
for i in range(n):
    bi = 0
    for j in range(m):
        bi += A[i][j] * b[j]
    print(bi) 


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

int main() {
	vector<int> num(3);
	cin >> num[0] >> num[1] >> num[2];
	sort(num.begin(),num.end());
	int K;
	cin >> K;
	for(int i = 0; i < K; i++){
		num[2] *= 2;
	}
	cout << num[0] + num[1] + num[2];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll n,k;
	cin>>n>>k;
	ll cnt=(n-1)*(n-2)/2;
	if(cnt<k){
		cout << -1;
		return 0;
	}
	cout << n-1+cnt-k<<endl;
	for(ll i=0;i<n-1;i++){
		cout << 1<<" "<<i+2<<endl;
	}
	ll now=cnt-k;
	if(now==0){
		return 0;
	}
	for(ll i=2;i<=n;i++){
		for(ll j=i+1;j<=n;j++){
			now--;
			cout << i<<" "<<j<<endl;
			if(now==0){
				return 0;
			}
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Abs(int x){
	return x>0?x:-x;
}
int main(){
//	freopen("A.in","r",stdin);
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	int v=Abs(a-b)+1;
	if(v%2) printf("Alice\n");
	else printf("Borys\n");
	return 0;
}


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

int main()
{
    int N;
    cin>>N;
    vector<vector<int>> E(N);
    vector<vector<int>> Ei(N);
    for (int i=0; i<N-1; i++)
    {
        int a, b;
        cin>>a>>b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }
    vector<int> c(N);
    for (int &t: c)
        cin>>t;
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());

    int ans = 0;
    for (int i=1; i<N; i++)
        ans += c[i];

    vector<int> ans2(N);

    function<void(int, int)> f = [&](int cur, int par)
    {
        for (int e: E[cur])
            if (e != par)
                f(e, cur);
        ans2[cur] = c.back();
        c.pop_back();
    };
    f(0, -1);

    cout<<ans<<endl;
    for (int i=0; i<N; i++)
        cout<<(i==0?"":" ")<<ans2[i];
    cout<<endl;
}


Measured memory_bytes: 1920
#include <stdio.h>

int main()
{
    int a, b, c, d;
    scanf("%d %d", &a, &b);
    c = a + b;
    d = c - 24;
    if (c < 24) {
        printf("%d", c);
    } else {
        printf("%d", d);
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  cout << vec.at(n/2) - vec.at(n/2-1) << endl;
}

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

int main() {
	int N; cin >> N;
	vector<int>L(N);
	
	int judge = 0; int maxN = 0;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		judge += L[i];
		maxN = max(maxN, L[i]);
	}
	cout << ((maxN - (judge - maxN)) < 0 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
ary = list(map(int, input().split()))
for i in range(n - 1):
  tmp_ary = list(map(int, input().split()))
  # 桁が大きいとceil, floorでは正しく判定ができない
  t_rate = (ary[0] - 1) // tmp_ary[0] + 1
  a_rate = (ary[1] - 1) // tmp_ary[1] + 1
  rate = max([t_rate, a_rate])
  ary = list(map(lambda x: x * rate, tmp_ary))
print(int(ary[0] + ary[1]))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define NUM_CASES (1001)

typedef struct {
	int id;
	short count;
	short flag;
} TradingCase;

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	char s[100];
	TradingCase data[NUM_CASES] = {{0}};
	int i, id, date;

	while (fgets(s, 100, stdin) != NULL) {
		if (s[0] < '0'|| '9' < s[0])
			break;

		sscanf(s, " %d,%d ", &id, &date);
		for (i = 0; i < NUM_CASES; i++) {
			if (data[i].id == 0) {
				data[i].id = id;
				data[i].count += 1;
				break;
			}
			else if (data[i].id == id) {
				data[i].count += 1;
				break;
			}
		}
	}

	while (scanf(" %d,%d ", &id, &date) != EOF) {
		for (i = 0; i < NUM_CASES; i++) {
			if (data[i].id == id) {
				data[i].flag = 1;
				data[i].count += 1;
				break;
			}
		}
	}

	qsort(data, NUM_CASES, sizeof(TradingCase), compare);
	for (i = 0; i < NUM_CASES; i++) {
		if (data[i].id && data[i].flag) {
			printf("%d %d\n", data[i].id, data[i].count);
		}
	}
	return 0;
}

Measured memory_bytes: 656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static long mod = 1000000007;   // 10^9 + 7

		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			double[] a = Console.ReadLine().Split().Select(double.Parse).ToArray();

			double sum = 0;
			foreach (double i in a) {
				sum += 1 / i;
			}

			Console.WriteLine(1 / sum);

		}
	}
}


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

int main(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  cin >> A.at(0);
  int ma=0;
  int dist;
  for(int i=1;i<N;i++){
    cin >> A.at(i);
    dist=A.at(i)-A.at(i-1);
    if(dist<0){
      dist+=K;
    }
    if(ma<dist){
      ma=dist;
    }
  }
  dist=A.at(0)-A.at(N-1);
  if(dist<0){
    dist+=K;
  }
  if(ma<dist){
    ma=dist;
  }
  cout << K-ma << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n, m;
int f[21][1048577];
int g[21][1048577];
char s[1048577];
int zi, zj;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; i++) {
		scanf("%s", s);
		for (int j = 0; j < 1 << i; j++) {
			f[i][j] = s[j] - '0';
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 1 << i; j++) {
			int p = i - 1, b = (j >> (i - 1)) & 1;
			while (p >= 0 &&  b == ((j >> p) & 1)) {
				p--;
			}
			g[i][j] = p;
		}
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 1; i + j <= n; j++) {
			for (int k = 0; k < 1 << (i + j); k++) {
				f[i][k >> j] += f[i + j][k];
				int p = g[j][k & ((1 << j) - 1)];
				if (p >= 0) {
					f[i + p + 1][(k & ((1 << (p + 1)) - 1)) | (k >> j << (p + 1))] += f[i + j][k];
				}
			}
		}
		for (int j = (1 << i) - 1; j >= 0; j--) {
			if (f[i][j] >= m) {
				zi = i;
				zj = j;
			}
		}
	}
	for (int i = zi - 1; i >= 0; i--) {
		printf("%d", zj >> i & 1);
	}
	printf("\n");
	return 0;
}

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


using namespace std;


template<typename T>
class UF
{
public:
	UF() {
		size = 0;
	}

	//値を挿入する
	void push( T a ) {
		M[a] = size;
		V.push_back( size );
		rank.push_back( 0 );
		C.push_back( 1 );
		size++;
	}

	//同じグループにする
	void unite( T a, T b ) {
		long long int x = find( M[a] );
		long long int y = find( M[b] );
		if( x == y )return;
		if( rank[x] < rank[y] ) {
			V[x] = y;
			C[y] += C[x];
		} else {
			V[y] = x;
			C[x] += C[y];
			if( rank[x] == rank[y] )rank[x]++;
		}
	}

	void merge( T a, T b ) {
		unite( a, b );
	}

	//同じグループにいるかどうか判定する
	bool same( T a, T b ) {
		return find( M[a] ) == find( M[b] );
	}

	//今何グループあるか数を返す
	long long int group() {
		set<long long int >S;
		for( long long int i = 0; i < V.size(); i++ ) {
			S.insert( find( V[i] ) );
		}
		return S.size();
	}

	//グループに属している数を返す
	long long int count( T a ) {
		return C[find( M[a] )];
	}


	//今属しているグループのIDを返す
	long long int groupID( T a ) {
		return find( M[a] );
	}
private:
	vector<long long int>
		C, V, rank;
	map < T, long long int>M;
	long long int size;

	//祖先までたどる
	long long int find( long long int x ) {
		if( V[x] == x )return x;
		else return V[x] = find( V[x] );
	}
};

int main() {
	long long int N, K, L;
	cin >> N >> K >> L;

	//UnionFind初期化
	UF<long long int>uf1, uf2;
	for( size_t i = 0; i < N; i++ ) {
		uf1.push( i );
		uf2.push( i );
	}

	//uf1は道路グループ
	for( size_t i = 0; i < K; i++ ) {
		long long int p, q;
		cin >> p >> q;
		p--; q--;
		uf1.merge( p, q );
	}

	//uf2は鉄道グループ
	for( size_t i = 0; i < L; i++ ) {
		long long int r, s;
		cin >> r >> s;
		r--; s--;
		uf2.merge( r, s );
	}

	map<long long int, map<long long int, long long int>>ansmap;
	for( size_t i = 0; i < N; i++ ) {
		ansmap[uf1.groupID( i )][uf2.groupID(i)]++;
	}

	for( size_t i = 0; i < N; i++ ) {
		cout << ansmap[uf1.groupID( i )][uf2.groupID( i )] << (i == N - 1 ? "\n" : " ");
	}
}

Measured memory_bytes: 62120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    ll N;
    cin >> N;
    cout << (N+1) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
long long n,k;
int main()
{
	scanf("%lld%lld",&n,&k);
	printf("%lld\n",min(n%k,abs(n%k-k)));
return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		long num = sc.nextLong();
		for(int i = 1; i < n; i++) {
			long num2 = sc.nextLong();
			num = gcd(num, num2);
		}
		out.println(num);
		
		out.close();
	}
	  //最大公約数を求めるメソッド
	  private static long gcd(long m, long n) {
		    if(m < n) return gcd(n, m);
		    if(n == 0) return m;
		    return gcd(n, m % n);
		}

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



Measured memory_bytes: 22224
import std.stdio, std.string, std.algorithm;

void main() {
     immutable s1 = readln.chomp;
     immutable s2 = readln.chomp;

     int[][] dp = new int[][](s1.length+1, s2.length+1);

     for( int i=0; i<=s1.length; ++i ) dp[i][0] = i;
     for( int i=0; i<=s2.length; ++i ) dp[0][i] = i;

     for( int i=1; i<=s1.length; ++i ) {
          for( int j=1; j<=s2.length; ++j ) {
               immutable cost = s1[i-1] == s2[j-1] ? 0 : 1;
               dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + cost);
          }
     }

     dp[$-1][$-1].writeln;
}

Measured memory_bytes: 6980
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
typedef long long  LL;
using namespace std;
const LL INF = 0x3f3f3f3f;

LL n,A,B;
LL d[100009];
bool judge(LL mid)
{
    LL ans=mid;
    for(int i = 1;i<=n;i++)
    {
        LL cn=d[i]-mid*B;
        if(cn>0)
        {
            LL temp=cn/(A-B)+(cn%(A-B)==0?0:1);//TEMP表示当一个怪物被所求值的B打后 是否还需要被A打   这里就差不多应该是来判断A具体攻击谁 攻击几次
            ans-=temp;//ans是一共A攻击的次数，如果A攻击次数归零 还没攻击完 说明这个次数是无法消灭全部的，所以返回falsh
            if(ans<0)
                return false;
        }

    }
    return true;
}

int main()
{


  cin>>n>>A>>B;

    LL l=0;
    LL r= INF;
    LL ans=INF;
   for(int i = 1;i<=n;i++)
        cin>>d[i];
    while(l<=r)
    {
        LL mid=(l+r)>>1;
        if(judge(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }

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

    return 0;


}


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

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

    // inputs
    lli a, b, c, d;
    cin >> a >> b >> c >> d;

    // solve
    lli ans = max(max(a * c, a * d), max(b * c, b * d));

    // output
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int len=s.size();
	int t=min(len,n);
	for(int i=0;i<t;i++)
	{
		cout<<s[i];
	}
    if(n<len)
    cout<<"...";   
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 5010, M = 210;

typedef long long LL;

int L[N], R[N];

LL val[N][N];

void add(int x1, int x2, int y1, int y2, int w){
	++x2, ++y2;
	val[x1][y1] += w, val[x1][y2] -= w, val[x2][y1] -= w, val[x2][y2] += w;
}

int n, m, w[N][M];
int stk[N], c;
LL d[N];

int main(){
	scanf("%d%d", &n, &m);
	For(i, 2, n) scanf("%lld", &d[i]), d[i] += d[i - 1];
	For(i, 1, n) For(j, 1, m) scanf("%d", &w[i][j]);

	For(j, 1, m){
		c = 0;
		For(i, 1, n){
			while(c && w[stk[c]][j] < w[i][j]) R[stk[c]] = i - 1, --c;
			L[i] = c ? stk[c] + 1 : 1;
			stk[++c] = i;
		}
		while(c) R[stk[c--]] = n;

		For(i, 1, n) add(L[i], i, i, R[i], w[i][j]);
	}

	For(i, 1, n) For(j, 1, n) val[i][j] += val[i - 1][j] + val[i][j - 1] - val[i - 1][j - 1];
	LL ans = 0;
	For(i, 1, n) For(j, i, n) ans = max(ans, val[i][j] - (d[j] - d[i]));
	printf("%lld\n", ans);

	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    set<int> ans;
    if(N == 3) ans = set<int>{2,5,63};
    else if(N == 4) ans = set<int>{2,5,20,63};
    else if(N == 5) ans = set<int>{2,5,20,30,63};
    else{
        int sum = 0;
        FOR(i,1,30001){
            if(i%6==0||i%6==2||i%6==3||i%6==4){
                ans.insert(i);
                sum += i;
            }
            if(ans.size() == N) break;
        }
        int last = *ans.rbegin()+1;
        if(sum%6 == 2){
            ans.erase(8);
            while(last%6 != 0) last++;
            ans.insert(last);
        }
        else if(sum%6 == 3){
            ans.erase(9);
            while(last%6 != 0) last++;
            ans.insert(last);
        }
        else if(sum%6 == 5){
            ans.erase(9);
            while(last%6 != 4) last++;
            ans.insert(last);
        }
    }

    for(int n : ans){
        cout << n << " ";
    }
    cout << endl;
    return 0;
}


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

/* prototype declaration */
int init();
long findMax();

int n;
int *a;

int main(int argc, const char *argv[])
{
	while(init())
		printf("%ld\n", findMax());

	return 0;
}

int init()
{
	int i;
	scanf("%d", &n);
	
	if(n){
		a = malloc(sizeof(int)*n);
		for(i=0; i<n; i++)
			scanf("%d", &a[i]);
		return 1;
	}else{
		free(a);
		return 0;
	}
}

long findMax()
{
	int i, j;
	long max = -100001, sum = 0;
	
	for(i=0; i<n; i++){
		for(j=i; j<n; j++){
			sum += a[j];
			if(max<sum) max = sum;
		}
		sum = 0;
	}
	return max;	
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
map<int,int> mp;

void calc(int a[],int n){
    for(int i = 0;i < 1<<n; ++i){
        int sum = 0;
        for(int j=0; j < n; ++j){
            if((i>>j)&1) sum += a[j];
        }
        mp[sum]++;
    }
    return;
}
bool check(int x){
   if(mp[x] == 0) return false;
   else return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int a[n]; for(int i = 0;i < n; ++i) cin >> a[i];
    calc(a,n);
    int q; cin >> q;
    for(int i = 0; i < q; ++i){
        int x; cin >> x;
        if(check(x)) puts("yes");
        else puts("no");
    }
    return 0;
}


Measured memory_bytes: 3124
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

	if (n==1) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}


	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cctype>

using namespace std;

char s[101], p[101];

int main(void) {

    cin >> s >> p;

    bool ok = false;
    for (int _ = 0,plen = strlen(p),slen = strlen(s); _ < slen; ++_) {
        if (!strncmp(p, s, plen)) {
            ok = true;
            break;
        }
        char s1 = s[0];
        for (int i = 1; i < slen; ++i) {
            s[i-1] = s[i];
        }
        s[slen - 1] = s1;
    }

    printf("%s\n", ok ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 1100
# -*- coding: utf-8 -*-
M, D = map(int, input().split())

ans = 0

for i in range(2,M+1):
    for j in range(21,D+1):
        if (j // 10) * (j % 10) == i and j % 10 >= 2:
            ans += 1

print(ans)

Measured memory_bytes: 2940
N, A, B = map(int, input().split())
numbers = range(A, N + 1)
somesums = 0
for i in numbers:
    p = i
    sums = 0
    while p >= 1:
        sums += p%10
        p //= 10
    if A <= sums <= B:
        somesums += i
print(somesums)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  string _s[h];
  for(int i=0;i<h;i++){
    cin >> _s[i];
  }

  int s[h][w];
  for(int k=0;k<h;k++){
    for(int j=0;j<w;j++){
      if (_s[k][j] == '#'){
        s[k][j] = 1;
      }
      else{
        s[k][j] = 0;
      }
    }
  }

  // check                                                                                                                      
  int flag = 0;
  for(int m=0;m<h;m++){
    for(int l=0;l<w;l++){
      int sum=0;
      if(s[m][l] == 1){
        if(m != 0){
          sum = sum + s[m-1][l];
        }
        if(m != (h-1)){
          sum = sum + s[m+1][l];
        }
        if(l != 0){
          sum = sum + s[m][l-1];
        }
        if(l != (w-1)){
          sum = sum + s[m][l+1];
        }
        if(sum == 0){
          flag = 1; // print 'No'                                                                                               
          // cout << m << " " << l << endl;                                                                                     
        }
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
right = input()
flag = 1
left = ""
for i in range(int(input())):
    t = input()
    if t == "1":
        flag ^= 1
        continue
    t, f, c = t.split(" ")
    if not ((f=="1")^flag):
        left += c
    else:
        right += c
ans = left[::-1] + right
if not flag:
    ans = ans[::-1]
print(ans)

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    char c=s[0];
    int ans=1;
    if(n==1){cout<<"1"<<endl;return 0;}
    for(int i=1;i<n;i++){
        if(s[i]!=c){
            c=s[i];
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
const int N = 1e5 + 3, MOD = 1e9 + 7;
int n, p[N], b[N], c[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", p + i);
	for (int i = 1; i <= n; ++i)
		scanf("%d", b + i);
	for (int i = 1; i < n; ++i)
		scanf("%d", c + i);
	int res = 0, prv = -1;
	for (int i = 1; i <= n; ++i) {
		res += b[p[i]];
		if (prv == p[i] - 1) 
			res += c[prv];
		prv = p[i];
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int P[10000];

// n個の頂点を初期化する
void init(int n) {
	for (int i = 0; i < n; i++) P[i] = i;
}

// 頂点の親の番号を返す
int root(int a) {
	if (P[a] == a) return a;
	return (P[a] = root(P[a]));
}

// 親(集合)が同じか判定する
bool is_same_set(int a, int b) {
	return root(a) == root(b);
}

// aとbを同一グループにまとめる
void unite(int a, int b) {
	P[root(a)] = root(b);
}

int main(void) {
	int n, q;
	cin >> n >> q;
	int com, x, y;
	init(n);
	while(q--) {
		cin >> com >> x >> y;
		if (com == 0) unite(x, y);
		else if (com == 1) cout << noboolalpha << is_same_set(x, y) << endl;
	}
}



Measured memory_bytes: 3244
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int coun[200000];

int main(){
  int n,data,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>data;
    coun[data]++;
  }
  for(int i=0;i<=99998;i++){
    ans=max(ans,coun[i]+coun[i+1]+coun[i+2]);
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 640
A,B = map(int,input().split())
import math
import fractions
def factorization(n):
    arr = []
    temp = n
    if n!=1:
      for i in range(2, int(-(-n**0.5//1))+1):
          if temp%i==0:
              cnt=0
              while temp%i==0:
                  cnt+=1
                  temp //= i
              arr.append([i, cnt])

      if temp!=1:
          arr.append([temp, 1])

      if arr==[]:
          arr.append([n, 1])

      return len(arr)
    else:
      return 0
print(factorization(fractions.gcd(A,B))+1)

Measured memory_bytes: 5048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int h, w, k;
    cin >> h >> w >> k;
    VVI a(h, VI(w));
    REP(i,h){
        string s;
        cin >> s;
        REP(j,w) a[i][j] = (s[j] - '0');
    }
    int ans = 1e9;
    REP(mask,1<<(h-1)){
        VI g(h);
        int p = 0;
        REP(i,h){
            g[i] = p;
            if ((mask >> i) & 1) p++;
        }
        p++;
        VI cnt(p);
        bool ok = true;
        int x = p - 1;
        REP(j,w){
            VI cnt2(p);
            REP(i,h) cnt2[g[i]] += a[i][j];
            bool f = false;
            REP(i,p) {
                if (cnt[i] + cnt2[i] > k) f = true;
                if (cnt2[i] > k) ok = false;
            }
            if (f){
                x++;
                cnt = cnt2;
            }else{
                REP(i,p) cnt[i] += cnt2[i];
            }
        }
        if (ok) chmin(ans, x);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# import itertools
# import math
import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# X, K, D = map(int, input().split())
# A = list(map(int, input().split()))
# C = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
C = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)


a = C.count("R")
b = C[:a].count("R")
print(a - b)

Measured memory_bytes: 9444
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli a,b;
	cin>>a>>b;

	string ab,ba;

	REP(i,0,b)ab+=(char)(a+'0');
	REP(j,0,a)ba+=(char)(b+'0');

	cout<<min(ab,ba)<<endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
AA = map(int,input().split())
AAA = list(AA)
ans = sum(AAA)/N
ans1 = 0
avg = abs(AAA[0] - ans)
for i in range(N):
  if avg > abs(AAA[i]-ans):
    ans1 = i
    avg = abs(AAA[i]-ans)
    
print(ans1)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;cin >>n>>k;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    for (int i =k; i <n; ++i) {
        if(a[i]>a[i-k])puts("Yes");
        else puts("No");
    }
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

void solve(vector<int>& A) {
    int n = A.size();
    multiset<int> S;
    for (auto a: A)
        S.insert(a);
    for (auto a: A) {
        S.erase(S.find(a));
        cout << *S.rbegin() << '\n';
        S.insert(a);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    vector<int> A;
    cin >> n;
    A.resize(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    solve(A);
    return 0;
}


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

l = [0] * n

for i in range(1, n):
    for j in range(i + 1 , n + 1):
        minimum = min(abs(j-i), abs(x-i) + 1 + abs(y-j), abs(x-j) + 1 + abs(y-i))
        l[minimum] += 1  

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

Measured memory_bytes: 3444