akhauriyash/Code-Regression huggingface dataset:
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#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(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//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() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

ll count_mul(ll min_num, ll max_num, ll div)
{
    if (max_num < div)
        return 0;

    ll min_r = min_num % div;
    ll min_q = min_num / div;

    if (min_r == 0)
        min_q--;

    ll max_q = max_num / div;

    return max_q - min_q;
}

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

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll mul_c = count_mul(A, B, C);
    ll mul_d = count_mul(A, B, D);
    ll mul_lcm_cd = count_mul(A, B, lcm(C, D));

    ll ans = B - A + 1 - mul_c - mul_d + mul_lcm_cd;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef vector<int> VI;
int main() {
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	VI A(n);
	for (auto& x : A) cin >> x;
	if (n <= 2) {
		cout << 1;
		return 0;
	}
	int sol = 1;
	int i = 1;
	while (i < n && A[i] == A[i-1]) ++i;
	if (i >= n-1) {
		cout << 1;
		return 0;
	}
	int isup = (A[i] > A[i-1] ? 1 : 0);
	for (; i < n; ++i) {
		if (A[i] == A[i-1]) continue; 
		if (isup && A[i] > A[i-1]) continue; 
		if (!isup && A[i] < A[i-1]) continue;
		++sol;
		++i;
		while (i < n && A[i] == A[i-1]) ++i;
		if (i < n) isup = (A[i] > A[i-1] ? 1 : 0);
	}
	cout << sol;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;


int N=0;
int c[100003]={0};
int c2[100003]={0};
int c3[100003]={0};
int c4[100003]={0};
int bit[100003]={0};
long long ans=0LL;

int add(int i,int w){
	for (int x=i; x<=N; x += x&-x) bit[x] += w;
	return 0;
}

int sum(int i){
	int ret = 0;
		for (int x=i; x>0; x -= x&-x) ret += bit[x];
	return ret;
}

int num(int n){
	int low=0;
	int high=N;
	for(int i=0;i<30;i++){
		int mid=(low+high)/2;
		//cout<<low<<" "<<c4[low]<<" "<<high<<" "<<c4[high]<<" "<<mid<<" "<<c4[mid]<<endl;
		if(c4[mid] <= n) low=mid;
		else high=mid;
	}
	return low+1;
}

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>c[i];
		c4[i]=c[i];
	}
	sort(c4,c4+N);
	for(int i=0;i<N;i++){
		c[i]=num(c[i]);
	}
	for(int i=0;i<N;i++){
		if((c[i]%2) != ((i+1)%2)){
			ans=ans+1LL;
		}
	}
	cout<<(ans/2LL)<<endl;
	return 0;
}


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

int main(){
int N;
  cin >> N;
  int a[N + 2];
  a[0] = 0;
  a[N + 1] = 0;
  for(int i = 1;i < N + 1;i++) cin >> a[i];
  
  int sum = 0;
   for(int j = 1;j < N + 2;j++){
      sum += abs(a[j] - a[j - 1]);
    }

  for(int i = 1;i < N + 1;i++){
    int tum = sum;
      tum -= abs(a[i] - a[i - 1]);
      tum -= abs(a[i + 1] - a[i]);
      tum += abs(a[i + 1] - a[i - 1]);
    cout << tum << endl;
    tum = sum;      
  }
  
  return 0;
  
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  map<ll,ll>m;
  for(auto it:A)m[it]++;
  bool ok=true;
  for(auto it:m)if(it.second>=2)ok=false;
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
string N;
int dp[1010101][2];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	reverse(all(N));
 
	int n = N.length();
	rep(i, 0, n + 1) rep(d, 0, 2) dp[i][d] = inf;
	dp[0][0] = 0;
	rep(i, 0, n) rep(d, 0, 2) if (dp[i][d] != inf) {
		int c = N[i] - '0';
 
	
			if (d == 1) c++;
 
			chmin(dp[i + 1][0], dp[i][d] + c);
			chmin(dp[i + 1][1], dp[i][d] + 10 - c);
		
	}
 
	int ans = min(dp[n][0], dp[n][1] + 1);
	cout << ans << endl;
}
 
 


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

int main () {
    int a,b;
    string op;
    for (int i=0;i<i+1;i++) {
        cin >> a >> op >> b;
        if ( op == "+" ) {
            cout << a+b << endl;
        } else if ( op == "-" ) {
            cout << a-b << endl;
        } else if ( op == "*" ) {
            cout << a*b << endl;
        } else if ( op == "/" ) {
            cout << a/b << endl;
        } else {
            break;
        }
    }
}


Measured memory_bytes: 3108
#include <stdio.h>


int main()
{
	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);

	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}

	return 0;
}


Measured memory_bytes: 2124
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<int,int> P;
typedef complex<double> CP;
typedef long long ll;

int mer[10];
string s="14141212";
int tmp[10];
int peo[10];
vector< P > res;
vector<P> v;

int main(){
	rep(i,8){
		mer[i]=s[i]-'0';
	}
	rep(i,8){
		int sum=0;
		rep(j,8){
			int t=i+j;
			t%=8;
			sum*=10;
			sum+=mer[t];
		}
		P t;
		t.F = sum;  t.S = i;
		v.PB(t);
	}
	sort(ALL(v));
	/*
	rep(i,8){
		cout<<v[i].F<<" "<<v[i].S<<endl;
	}
	cout<<endl;
	*/
	while(cin>>tmp[0]){
		res.clear();
		rep(i,7){
			cin>>tmp[i+1];
		}
		rep(i,8){
			/*
			rep(j,8) cout<<tmp[j]<<" ";
			cout<<endl;
			*/
			int sum=0;
			rep(j,8){
				int t=i+j;
				t%=8;
				//peo[j]=tmp[t];
				if(tmp[j]-mer[t]<0){
				}
				else sum+=tmp[j]-mer[t];
				
				
				//cout<<mer[t]<<" ";
			}
			//cout<<endl;
			P t;
			t.F=sum; t.S=i;
			res.PB(t);
			//cout<<"sum= "<<sum<<endl<<endl;
		}
		sort(ALL(res));
		vector <P> ans;
		int k=res[0].F;
		rep(i,8){
			if(k==res[i].F){
				ans.PB(res[i]);
			}
			else break;
		}
		rep(i,8){
			bool f=false;
			rep(j,ans.size()){
				if(v[i].S==ans[j].S){
					res[0].S=ans[j].S;
					f=true;
				}
			}
			if(f) break;
			
		}
		
		rep(i,8){
			int t=i+res[0].S;
			t%=8;
			if(i!=0) cout<<" ";
			cout<<mer[t];
		}
		
		cout<<endl;
		
	}
			
			
			
	return 0;
}

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

int changeNumber(char number)
{
	int num = 0;
	for (char i = 48; i < 58; i++) {
		if (number == i) return num;
		num++;
	}
}

void puls(string number1, string number2)
{
	stack<int> s;
	int tmp = 0;
	for (int i = 1; i <= number1.size() && i <= number2.size(); i++) {
		tmp =  tmp + changeNumber(number1[number1.size() - i]) + changeNumber(number2[number2.size() - i]);
		s.push(tmp % 10);
		tmp /= 10;
	}
	for (int i = number2.size() + 1; i <= number1.size(); i++) {
		tmp = tmp + changeNumber(number1[number1.size() - i]);
		s.push(tmp % 10);
		tmp /= 10;
	}
	if (tmp > 0) s.push(tmp);
	if (s.size() > 80) cout << "overflow" << endl;
	else {
		while(0 < s.size()) {
			cout << s.top();
			s.pop();
		}
		cout  << endl;
	}
}

int main(void)
{
	string number1, number2;
	int count;

	cin >> count;
	for (int i = 0; i < count; i++) {
		cin >> number1 >> number2;
		if (number1.size() < number2.size()) puls(number2, number1);
		else puls(number1, number2);
	}
	
	return 0;
}

Measured memory_bytes: 1236
import sys
dishes = [int(input()) for _ in range(5)]
a = [(d%10,d) for d in dishes if d%10>0]
if a==[]:
    print(sum(dishes))
    sys.exit()
min_ = min(a)

ans = min_[1]
dishes.remove(min_[1])
for d in dishes:
    if d%10==0:
        ans += d
    else:
        ans += (d//10+1)*10
print(ans)


Measured memory_bytes: 3060
import math
import collections
def main():

    N, X, M = map(int, input().split())
    visited = dict()
    visited[X] = 0
    A = [X]
    v = X
    j = -1
    isperiod = False
    for i in range(1, N):
        v = (v * v) % M
        if v not in visited:
            visited[v] = i
            A.append(v)
        else:
            j = visited[v]
            isperiod = True
            break

    if isperiod:
        u = sum(A[:j])
        B = A[j:]
        p = len(B)
        u += ((N-j) // p) * sum(B) + sum(B[:(N-j) % p])
        return u
    return sum(A)



if __name__ == '__main__':
    print(main())

Measured memory_bytes: 78276
#include <iostream>
using namespace std;
int main()
{
    long long n,ans=1,a=1000000007;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        ans=ans*i;
        if (ans>a)
            ans=ans%a;
    }
    cout<<ans<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
def primes(n):
	bool_arr = [True] * (n+1)
	bool_arr[0] = False
	bool_arr[1] = False
	for i in range(2, len(bool_arr)):
		if bool_arr[i]:
			for j in range(i, n//i+1):
				bool_arr[i*j] = False
	return bool_arr

n = 1000000
ans = primes(n)
x = int(input())
for i in range(x, len(ans)):
	if ans[i]:
		print(i)
		break

Measured memory_bytes: 10868
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define chmin(x,y) x = min(x,y)

const int INF = 1001001001;
int dp[1000005][2];

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';
  int n = s.size();
  rep(i,n+1)rep(j,2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,n)rep(j,2) {
    int x = s[i]-'0';
    x += j;
    if (x < 10) chmin(dp[i+1][0], dp[i][j]+x);
    if (x > 0) chmin(dp[i+1][1], dp[i][j]+(10-x));
  }
  int ans = dp[n][0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9220
program one_per_cent
  implicit none
  integer :: i = 1
  integer(16) :: x, m = 100_16
  read(*,*) x
  do
    m = 101_16*m/100_16
    if (m >= x) then
      write(*,'(i0)') i
      stop
    end if
    i = i+1
  end do
end program one_per_cent

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MAX = 1010;
int n,c[MAX],w[MAX],sum[MAX],dp[MAX];
bool zukky[MAX][MAX];


void compute(){
  sum[0] = w[0];
  REP(i,1,n) sum[i] = w[i] + sum[i-1];
  rep(i,n) zukky[i][i] = true;
  REP(length,1,n+1) rep(left,n) if( zukky[left][left+length-1] ) {
    int wSum = sum[left+length-1] - ((left-1>=0)?sum[left-1]:0);
    if( left - 1 >= 0 && wSum <= c[left-1] ) zukky[left-1][left+length-1] = true;
    if( left+length < n && wSum <= c[left+length] ) zukky[left][left+length] = true;
  }
  rep(i,n) dp[i] = INT_MAX;
  rep(i,n) {
    int prev = (i-1>=0)?dp[i-1]:0;
    REP(j,i,n) if( zukky[i][j] ) dp[j] = min(dp[j],prev+1);
  }
  cout << dp[n-1] << endl;
}

int main(){
  cin >> n;
  rep(i,n) cin >> c[i] >> w[i];
  compute();
  return 0;
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
#define f(i,j,n) for(int i=j;i<=n;i++)
using namespace std;
const int S=(1<<21)+5;
char buf[S],*H,*T;
inline char Get() {
	if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
	if(H==T) return -1;
	return *H++;
}
const int N=2<<17+5;
struct Edge {
	int to,capa,next;
} e[N];
int h[N],sum=0,n,m;
bool vis[N];
int cmt,cnt,col[N],c[3];
bool falun;
inline int color(const int &x) {
	if(x>=3) return x-3;
	if(x<0) return x+3;
	return x;
}
void add_edge(int u,int v,int w) {
	e[++sum].to=v;
	e[sum].capa=w;
	e[sum].next=h[u];
	h[u]=sum;
}
void dfs(int u) {
	c[col[u]]++,vis[u]=1,cnt++;
	for(int tmp=h[u]; tmp; tmp=e[tmp].next) {
		cmt+=(e[tmp].capa==1);
		int v=e[tmp].to;
		if(!vis[v]) col[v]=color(col[u]+e[tmp].capa),dfs(v);
		else if(col[v]!=color(col[u]+e[tmp].capa)) falun=0;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin>>n>>m;
	f(i,1,m) {
		int u,v;
		cin>>u>>v;
		add_edge(u,v,1),add_edge(v,u,-1);
	}
	long long ans=0;
	f(i,1,n) {
		if(vis[i]) continue;
		memset(c,0,sizeof(c));
		cmt=cnt=0,falun=1,dfs(i);
		if(!falun) ans+=1ll*cnt*cnt;
		else if(c[0] and c[1] and c[2]) ans+=1ll*c[0]*c[1]+1ll*c[1]*c[2]+1ll*c[2]*c[0];
		else ans+=cmt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12032
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    M1,D1 = LMIIS()
    M2,D2 = LMIIS()
    if M1!=M2:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
using namespace std;
struct Node {
    int parent = -2;
    string type;
    vector<int> children;
};
int main() {
    int n;
    cin >> n;
    Node node[n];
    for (int i = 0; i < n; i++) {
        int id, k;
        cin >> id >> k;
        if (k == 0) { //no children
            node[id].type = "leaf";
        }
        if (node[id].parent == -2) {
            node[id].parent = -1;
        }
        int cnt3 = 0;
        for (int j = 0; j < k; j++) {
            int c;
            cin >> c;
            node[c].parent = id;
            node[id].children.push_back(c);
            cnt3++;
        }
        node[id].children.push_back(-2);
    }
    for (int i = 0; i < n; i++) {
        cout << "node " << i << ": parent = " << node[i].parent;
        cout << ", depth = ";
        int tmp = i;
        int cnt = 0;
        while (node[tmp].parent != -1) {
            tmp = node[tmp].parent;
            cnt++;
        }
        cout << cnt << ", ";
        if (node[i].parent == -1) {
            cout << "root";
        } else if (node[i].type == "leaf") {
            cout << "leaf";
        } else {
            cout << "internal node";
        }
        cout << ", [";
        int cnt2 = 0;
        while (1) {
            if (node[i].children[cnt2] == -2) { //最初に置かな最初の-2見逃す
                break;
            }
            if (cnt2) {
                cout << ", ";
            }
            cout << node[i].children[cnt2];
            cnt2++;
        }
        cout << "]" << endl;
    }
    return 0;
}




Measured memory_bytes: 14880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    k--;
    char c = s[k];
    rep(i,n) {
        if (s[i] != c) s[i] = '*';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int a = 1;
    while(n/a) {
        ans ++;
        a *= k;
    }
    
    
    
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  int M, D, c=0, i, j;
  cin >> M >> D;
  for(i=4; i<=M; i++)
    for(j=2; j<=D; j++)
      if(j%10>=2 && j/10>=2 && i==(j%10)*(j/10))
        c++;
  
  cout << c << endl;
}

Measured memory_bytes: 256
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x, y = map(int,input().split())
for i in a:
  if x == i:
    x = "a"
  if y == i:
    y = "a"
for i in b:
  if x == i:
    x = "b"
  if y == i:
    y = "b"
if x == y:
  print("Yes")
else:
  print("No")

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

const long long N = 1e3 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[1005][1005];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    cout << 24 + (24 - n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define forx(v) for(int x=0; x<v; x++)
#define ll long long
#define lll __int128
#define MAX (int)(4*pow(10,3) + 100)
#define pb(a) push_back(a)
#define ch (int)(4*pow(10,4) + 100)
#define ld long double
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = pow(10,9)+7 ;
double eps = 1e-9;
ifstream in;
ofstream out;
 


 
void deal(){
	vector<pair<ll, char> > all;
	string a;
	cin>>a;
	ll q;
	cin>>q;
	ll sum = a.length();
	fori(q){
		ll ty;
		cin>>ty;
		if(ty == 1){
			all.pb(mp(1,'0'));
		}
		else{
			ll fi;
			char f;
			cin>>fi>>f;
			--fi;
			all.pb(mp(fi,f));
			++sum;
		}
	}
	string ans(sum, '0');
	ll cnt = 0;
	ll bg = 0, nd = sum-1;
	for(ll i = q-1; i>-1; i--){
		auto cur = all[i];
		if(cur.ss == '0'){
			cnt=!cnt;
			continue;
		}
		cur.ff^=(cnt&1);
		if(cur.ff){
			ans[nd] = cur.ss;
			--nd;	
		}
		else{
			ans[bg] = cur.ss;
			++bg;
		}
	}
	if(!cnt){
		for(ll i = bg; i <= nd; i++){
			ans[i] = a[i-bg];
		}
	}
	else{
		for(ll i = nd; i>=bg; i--){
			ans[i] = a[nd-i];
		}
	}
	cout<<ans;
}
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

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

if __name__ == '__main__':
    n = int(input())
    v = list(map(int, input().split()))
    c = list(map(int, input().split()))
    
    ans = 0
    for x, y in zip(v, c):
        tmp = x - y
        if tmp > 0:
            ans += tmp

    print(ans)

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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b)  memset(a, b, sizeof(a))
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false)

const int MOD = 1e9 + 7;
const double EPS = 1e-6;

int main(){
	boost;
	ll n;
	cin >> n;
	ll ans = INT_MAX;
	for(ll i = 1; i <= sqrt(n); ++i){
		if(n % i == 0){
			ll a = i;
			ll b = n / a;
			// cout << a << " " << b << endl;
			int c1 = 0, c2 = 0;
			while(a){
				++c1;
				a /= 10;
			}
			while(b){
				++c2;
				b /= 10;
			}
			ll mx = max(c1, c2);
			if(ans > mx){
				ans = mx;
				// break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N, W; cin >> N >> W;
  
  long long dp[100001];
  for (int i=0; i <=W; i++) dp[i] = 0;

  for (int i=0; i<N; i++){
    int w, v; cin >> w >> v;
    for (int j=W; j>=w; j--){
      dp[j] = max(dp[j], dp[j-w]+v);
    }
  }
  cout << dp[W] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
int main() {
	ll A[5];
	for (ll i = 0; i < 3; i++) {
		cin >> A[i];
	}
	sort(A, A + 3);
	cout << A[2] - A[0] << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

int N;
int a[MAX];
int b[MAX];

void solve() {
	cin >> N;
	rep(i, N) cin >> a[i] >> b[i];
	int cur = 0;
	rrep(i, N) {
		int v = (a[i] + cur) % b[i];
		if (v != 0) {
			cur += b[i] - v;
		}
		if (test) dump(cur);
	}
	cout << cur << endl;
}

signed main() {
	cout << fixed << setprecision(20);
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	rep(i, (int)s.size()) {
		if (s[i] == 'a') a++;
		if (s[i] == 'b') b++;
		if (s[i] == 'c') c++;
	}
	if (abs(a - b) < 2 && abs(a - c) < 2 && abs(b - c) < 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3736
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [n,d] <- r'
    as <- replicateM n $ do
        [x,y] <- r'
        return $ x^2 + y^2
    print $ length $ filter (<= d^2) as


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e3 + 5);

int n;
vector<queue<int>> ques(MAX_N);

bool last_modified[MAX_N];
bool unavailable[MAX_N];

void reset() {
  fill(unavailable + 1, unavailable + n + 1, false);
}

void copy_modified() {
  for (int i = 1; i <= n; ++i) {
    last_modified[i] = unavailable[i];
  }
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n - 1; ++j) {
      int a;
      scanf("%d", &a);
      ques[i].push(a);
    }
  }

  reset();  // initialize

  bool poped = false;

  for (int i = 1; i <= n; ++i) {
    if (unavailable[i]) continue;

    if (ques[i].empty()) continue;

    int j = ques[i].front();

    if (unavailable[j]) continue;

    if (ques[j].empty()) continue;

    int other = ques[j].front();

    if (i == other) {
      // printf("i, j: %d %d\n", i, j);
      ques[i].pop();
      ques[j].pop();
      unavailable[i] = true;
      unavailable[j] = true;
      poped = true;
    }
  }

  copy_modified();

  reset();

  if (!poped) {
    printf("-1\n");
    return 0;
  }

  // check done
  bool done = true;
  for (int i = 1; i <= n; ++i) {
    done &= ques[i].empty();
    if (!done) {
      break;
    }
  }

  // check done
  if (done) {
    printf("%d\n", 1);
    return 0;
  }

  int ans;

  for (int day = 2;; ++day) {
    poped = false;

    for (int i = 1; i <= n; ++i) {
      if (!last_modified[i]) continue;

      if (unavailable[i]) continue;

      if (ques[i].empty()) continue;

      int j = ques[i].front();

      if (unavailable[j]) continue;

      if (ques[j].empty()) continue;

      int other = ques[j].front();

      if (i == other) {
        ques[i].pop();
        ques[j].pop();
        unavailable[i] = true;
        unavailable[j] = true;
        poped = true;
      }
    }

    copy_modified();
    reset();

    // check match
    if (!poped) {
      ans = -1;
      break;
    }

    // check done
    bool done = true;
    for (int i = 1; i <= n; ++i) {
      done &= ques[i].empty();
      if (!done) {
        break;
      }
    }

    // check done
    if (done) {
      ans = day;
      break;
    }
  }

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

  return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main()
{
int a,b,c;
  scanf("%d %d",&a,&b);
if(a==1 && b==1) c=0;
else if(a==1) c=b*(b-1)/2;
else if(b==1) c=a*(a-1)/2;
else c=b*(b-1)/2+a*(a-1)/2;
  
  printf("%d",c);
  
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string S;
    cin>>S;
    set<string> s;
    int n=S.length();
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    if(n==2){
        if(S[0]==S[1]){
            cout<<1<<endl;
        }
        else cout<<2<<endl;
        return 0;
    }
    
    int dp[n+1][2];
    dp[0][0]=1;
    dp[0][1]=0;
    if(S[0]==S[1]){
        dp[1][0]=1;
        dp[1][1]=1;
    }
    else{
        dp[1][0]=2;
        dp[1][1]=1;
    }
    for(int i=2;i<n;i++){
        if(S[i]!=S[i-1]){
            dp[i][0]=dp[i-1][0]+1;
            dp[i][1]=dp[i-2][0]+1;
        }
        else{
            dp[i][0]=dp[i-1][1]+1;
            dp[i][1]=dp[i-2][0]+1;
        }
    }
    cout<<max(dp[n-1][0],dp[n-1][1])<<endl;
}

Measured memory_bytes: 2180
open System

[<EntryPoint>]
let main argv =
    "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51".Split(',').[(Console.ReadLine() |> int) - 1] |> printfn "%s"
    0


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

bool is_month(int x) {
  if (x >= 1 && x <= 12) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  int front = stoi(s.substr(0, 2));
  int back = stoi(s.substr(2, 2));

  if (is_month(front) && is_month(back))
    cout << "AMBIGUOUS" << endl;
  else if (is_month(front))
    cout << "MMYY" << endl;
  else if (is_month(back))
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}


Measured memory_bytes: 256
n = gets.chop.to_i
R = []

n.times { R << gets.to_i }

maxv = -2000000000
minv = R[0]

def maxof(x, y)
    return (x > y) ? x : y
end

def minof(x, y)
    return (x < y) ? x : y
end

(1...n).each do |i|
  maxv = maxof(maxv, R[i] - minv)
  minv = minof(minv, R[i])
end

puts maxv



Measured memory_bytes: 8556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String input = br.readLine();
			String[] text = br.readLine().split(" ");
			int i;
			String ret = "";
			for (i = text.length - 1; i >= 0; i--) {
				if (i == text.length - 1) {
					ret = text[i];
				} else {
					ret = ret + " " + text[i];
				}
			}
			System.out.println(ret);

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17124
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q,r,g,b;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> n >> s;

	fo(i,0,n)
	{
		r += ( s[i] == 'R' );
		g += ( s[i] == 'G' );
		b += ( s[i] == 'B' );
	}

	int ans = r * g * b;

	fo(i,0,n)
	{
		fo(j,i+1,n)
		{
			int pos = 2*i - j;

			if( pos < n and pos >= 0 and s[pos] != s[i] and s[i] != s[j] and s[j] != s[pos] ) ans--;
		}
	}

	cout << ans << endl;
}

int32_t main()
{
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

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

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

  int a=0,b=0;
  for(int i=0; i<n; i++){
    if(s[i]=='(')a++;
    else{
      if(a>0)a--;
      else b++;
    }
  }

  for(int i=0; i<b; i++)cout<<'(';
  cout<<s;
  for(int i=0; i<a; i++)cout<<')';
  cout<<endl;
  
}

Measured memory_bytes: 256
k, x = map(int, input().split())
l =  [x-n for n in range(1,k)] + [x+n for n in range(k)]
l = [x for x in l if x <= 1000000]
l = [x for x in l if x >= 1000000 * -1]
l = sorted(l)
print(" ".join(map(str, l)))

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number_n, i, j, count = 0;
    number_n = Integer.parseInt(sc.next());
    int[] height = new int[number_n];
    for(i = 0; i < number_n; i++) {
      height[i] = Integer.parseInt(sc.next());
      for(j = 0; j < i; j++) {
        if(height[j] > height[i]) {
          break;
        }
      }
      if(j == i) count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 23764
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1
print(cnt)

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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for(auto& i : s) cin >> i;

    sort(s.begin(), s.end());
    int ans = 1;
    for(int i = 1; i < n; ++i)
    {
        if(s[i - 1] != s[i]) ++ans;
    }
    cout << ans << endl;
}

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

int main()
{
    int n, result = 0, counts = 0;

    cin >> n;

    if (n < 105)
    {
        cout << 0 << endl;
        return 0;
    }

    for (int j = 105; j <= n; j += 2)
    {

        for (int i = 1; i * i <= j; i++)
        {
            if ((j % i) == 0)
            {
                counts++;
                if ((j / i) != i)
                    counts++;
            }
        }
        if (counts == 8)
            result++;
        counts = 0;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3600
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,d;
  cin>>n>>d;
  ll ans=n/(2*d+1);
  if((n%(2*d+1))!=0)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 888
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include <array>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

typedef long long int LL;
//typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VP;
typedef vector<double> VD;
typedef vector<vector<int>> VVI;
typedef vector<string> VS;
typedef long double ld;

#define MAXN 1000006
//#define MAXN 1006

const LL MOD = 1000000007;
//const LL MOD = 998244353;
const LL INF = 2000000000000000001LL; //2e18 + 1

void solve(int ks) {
	char S[200005];
	scanf("%s", S);
	for (int i = 0; S[i]; i++) if (S[i] == '?') S[i] = 'D';
	printf("%s\n", S);
}

void gen() {
}

int main()
{
	double start_time = clock();
#ifdef LOCAL
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	// freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif

	gen();

	if (0) {
		int T;
		scanf("%d", &T);
		//AIN(T, 1, 5000);
		for (int ks = 1; ks <= T; ks++) {
			solve(ks);
			if (ks % 1 == 0) fprintf(stderr, "%d done\n", ks);
		}
	}
	else {
		solve(0);
	}

	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);

	return 0;
}


Measured memory_bytes: 3944
PROGRAM-ID.                      PROGRAM_ID.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 LN          PIC X(8).
    01 N           PIC 9(3).
    01 R           PIC 9(4).
    01 ans         PIC X(4).
    01 ZS          PIC Z(4)9.
    01 DUMMY       PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT LN.
    UNSTRING LN
    DELIMITED BY SPACE
    INTO N R.
    IF 10 <= N
        THEN
            MOVE R TO ZS;
        ELSE
            COMPUTE ZS = R + 100 * (10 - N);
    END-IF.
    PERFORM UNANS.
    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
    ZS DELIMITED BY ALL SPACE
    INTO DUMMY ans.


Measured memory_bytes: 504
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  int count = 0;
  
  for (int i=0;i<N;i++){
    cin >> p[i];
  }
  
  for (int i=1;i<N-1;i++){
    if((p[i]>p[i-1] && p[i]<p[i+1])) count++;
    if((p[i]<p[i-1] && p[i]>p[i+1])) count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n;
    if((n%10==2)||(n%10==4)||(n%10==5)||(n%10==7)||(n%10==9))
    {
        cout<<"hon"<<endl;
    }
    else if((n%10==0)||(n%10==1)||(n%10==6)||(n%10==8))
    {
        cout<<"pon"<<endl;
    }
    else if(n%10==3)
    {
        cout<<"bon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

int main(){
    int n,m; cin >> n >> m;
    string s; cin >> s;
    stack<int> q;
    int now=n;
    while(now>=0){
        int k=m;
        if(now-k<=0){
            q.push(now);
            break;
        }
        else if(s[now-k]=='0') q.push(k);
        else{
            while(k>0){
                if(s[now-k]=='0'){
                    q.push(k);
                    break;
                }
                k--;
                if(k==0){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
        now-=k;
    }
    while(!q.empty()){
        cout << q.top() << " ";
        q.pop();
    }
    
}


Measured memory_bytes: 868
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		double[] x = new double[n];
		double[] y = new double[n];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			y[i] = sc.nextInt();
		}

		double D1 = 0, D2 = 0,D3=0, D = 0;

		for (int i = 0; i < n; i++) {
			D1 += Math.abs(x[i] - y[i]);
            D2 += Math.pow(Math.abs(x[i] - y[i]), 2);
            D3 += Math.pow(Math.abs(x[i] - y[i]), 3);
            D=Math.max(D,Math.abs(x[i]-y[i]));
		}
		System.out.printf("%.6f\n",D1);
		System.out.printf("%.6f\n",Math.sqrt(D2));
		System.out.printf("%.6f\n",Math.cbrt(D3));
        System.out.printf("%.6f\n",D);
        
		sc.close();

	}

}



Measured memory_bytes: 26624
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
    A.append(int(input()))

P = []
for i in range(N):
    P.append(K - Q)

for i in range(Q):
    P[A[i]-1] += 1

for i in range(N):
    if(P[i] > 0): print('Yes')
    else: print('No')

Measured memory_bytes: 11776
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            var W = cin.ReadIntArray(N);
            int s1 = 0;
            int s2 = 0;
            int ans = int.MaxValue;
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < i; j++)
                {
                    s1 += W[j];
                }
                for(int j = i; j < N; j++)
                {
                    s2 += W[j];
                }
                if(ans > Abs(s1 - s2))
                {
                    ans = Abs(s1 - s2);
                }
                s1 = 0;
                s2 = 0;
            }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

namespace ndifix{

}

int main(){
    int n;cin>>n;
    vector<int> b(n);for(int i=0;i<n;i++)cin>>b[i];
    
    vector<int> ans;

    while(b.size()){
        //for(int i=0;i<b.size();i++)cout<<b[i]<<" ";cout<<endl;
        for(int i=b.size()-1;i>=0;i--){
            if(b[i]==i+1){
                ans.push_back(i+1);
                b.erase(b.begin()+i,b.begin()+i+1);
                break;
            }
            else if(b[i] > i+1){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    
    while(ans.size()){
        cout<<ans[ans.size()-1]<<endl;
        ans.pop_back();
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int a , b;
int x[N];
vector < pair < long long , int > > v;
int parent[N];
int find(int node){
    if(parent[node] == node){
        return node;
    }
    return parent[node] = find(parent[node]);
}
bool join(int a , int b){
    int x = find(a);
    int y = find(b);
    if(x == y){
        return 0;
    }
    parent[y] = x;
    return 1;
}
int main(){
    scanf("%d" , &n);
    scanf("%d %d" , &a , &b);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , x + i);
    }
    v.clear();
    for(int i = 1 ; i <= n ; ++i){
        parent[i] = i;
    }
    for(int i = 1 ; i < n ; ++i){
        v.push_back({1LL * a * (x[i + 1] - x[i]) , {i}});
    }
    sort(v.begin() , v.end());
    int tot = n - 1;
    long long ans = 0;
    for(auto it : v){
        if(it.first <= b){
            if(join(it.second , it.second + 1)){
                --tot;
                ans += it.first;
            }
        }
    }
    ans += 1LL * tot * b;
    printf("%lld\n" , ans);
}

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

using namespace std;

int main(){
    int N;
    double x;
    string u;
    cin >> N;
    int i;
    double total = 0;;
    for(i = 0;i<N;i++){
        cin >> x;
        cin >> u;
        if(u.compare("BTC") == 0){
            x = x*380000;
        }
        
        total += x;
    }
    cout << total << "\n";
    return 0;
}


Measured memory_bytes: 256