akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/agc019/tasks/agc019_a
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll Q,H,S,D;
    ll N;
    cin>>Q>>H>>S>>D>>N;

    if(Q*2<H)H=Q*2;
    if(H*2<S)S=H*2;
    if(S*2<D)D=S*2;

    N*=4;
    ll ans=0;
    ans+=D*(N/8);N%=8;
    ans+=S*(N/4);N%=4;
    ans+=H*(N/2);N%=2;
    ans+=Q*(N);

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

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

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

    return gcd(b, a%b);
}

const ll L = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 
    ll N;
    cin >> N;

    vector <ll> a;
    vector <ll> ans(N, 0);

    ll sum = 0;

    for(ll i=0; i<N; i++)
    {
        ll t;
        cin >> t;

        a.pb(t);
        
        sum+=t;
    }

    ll cur = 0;

    for(ll i=1; i<N; i+=2)
    {
        cur+=a[i];
    }

    ans[0] = sum-2*cur;

    for(ll i=1; i<N; i++)
    {
        ans[i] = 2*a[i-1] - ans[i-1];
    }

    for(ll i=0; i<N; i++)
    {
        cout << ans[i] << " ";
    }
    cout << endl;



    return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,a[5],count=1;
  for(i=0;i<5;i++){
    cin>>a[i];

    


    if(a[i]==0)
      break;
    count=count + 1;
  }
    
  
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3572
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto H = readln.split.to!(int[])[0];
    foreach (A; readln.split.to!(int[])) H -= A;
    writeln(H <= 0 ? "Yes" : "No");
}

Measured memory_bytes: 4272
#include <iostream>
using namespace std;
int main() {
    int N; cin>>N;
    int A[N];
    for (int i=0; i<N; i++) cin >> A[i];
    bool f=true;
    for (int i=0; i<N && f==true; i++) {
        if (A[i]%2==0) {
            if ((A[i]%3==0) || (A[i]%5==0))
                ;
            else
                f=false;
        }
    }
    if (f) cout << "APPROVED" << endl;
    else   cout << "DENIED"   << endl;
}

Measured memory_bytes: 256
def solve():
  N = int(input())
  ans = [0]*N
  for x in range(1,101):
    for y in range(1,101):
      for z in range(1,101):
        cnt = x*x+y*y+z*z+x*y+y*z+z*x
        if cnt<=N:
          ans[cnt-1] += 1
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 9364
a,b=map(int,input().split())
if (b-a+1)%2==0:
  val=(b-a+1)//2
  if a%2==0:
    print(0) if val%2==0 else print(1)
  elif val>0:
    print(a^b) if (val-1)%2==0 else print(a^b^1)
  else:
    print(a^b) 
else:
  if a%2==0:
    val=(b-1-a+1)//2
    print(b) if val%2==0 else print(b^1)
  else:
    val=(b-(a+1)+1)//2
    print(a) if val%2==0 else print(a^1)



Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll X = 0;
	ll M = 0;
	ll Q = 0;
	//double a[100000] = {};
	//double b[100000] = {};
	//ll v[100] = {};
	ll *p, *c, *d;
	string S[100],T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;


	//char p;
	cin >>N;
	rep(i, 0, N) {
		cin >> S[i];
	}

	count = 1;

	while (count != N) {
		
		//cout << S[count - 1].substr(S[count - 1].size()-1, 1) << "," << S[count].substr(0, 1) << endl;

		if (S[count - 1].substr(S[count - 1].size()-1, 1) != S[count].substr(0, 1))
			flag = 1;

		rep(i,0,count){

			
			if (S[i] == S[count]) {
				flag = 1;
			}
		}

		

		if (flag == 1)
			break;


		count++;
	}


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



	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(is.begin(), is.end());
	//p = (ll *)malloc(D * sizeof(ll));
	//c = (ll *)malloc(D * sizeof(ll));
	//d = (ll *)malloc(D * sizeof(ll));

	


	
	//sort(l,l+N);


	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
bool v[100002];
char c[1002];
int num[100002];
signed main(){
int n,m,k,a,sum,ans1=0,ans2=0;
cin>>n>>m;
for(re int i=1;i<=m;++i){
	cin>>a>>c;
	if(v[a])continue;
	if(c[0]=='W')++num[a];
	else ++ans1,v[a]=1;
}
for(re int i=1;i<=n;++i)if(v[i])ans2+=num[i];
cout<<ans1<<" "<<ans2;
	}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define FOR(i,n) for(long long i=0;i<n;i++)
#define SFOR(i,a,b) for(long long i=a;i<b;i++)
#define RFOR(i,a,b) for(long long i=b;i>a;i--)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  ll ans;
  ans=0;
  SFOR(i,1,n){
    ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


/*
1 2 3 4 5 6 7 8  9 10 11 12 13
2 3 4 5 6 7 8 9 10 11 12 13  1
*/


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

int main() {
  string s;

  cin >> s;

  if(s.back() == 's') {
    s += "es";
  } else {
    s += "s";
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 3624
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    string s;
    cin>>s;
    map<char,int>cnt;
    for(auto ch:s)
    {
        cnt[ch]++;
    }
    int flag=0;
    for(auto x:cnt)
    {
        if(x.si%2!=0)flag=1;
    }
    if(flag)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;

}





































Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  rep(i,n){
    int j=i;
    while(j&&a[j-1]>a[j]){
      swap(a[j-1],a[j]);
      j--;
    }
    rep(j,n){
      if(j) cout<<' ';
      cout<<a[j];
    }
    cout<<endl;
  }


}


Measured memory_bytes: 3176
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    long long int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k % 2 == 0)cout << (a - b) << endl;
    else cout << (b - a) << endl;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
int A[3];
cin>>A[0]>>A[1]>>A[2];
sort(A,A+3);
cout<<A[2]-A[1]+(A[1]-A[0])/2+((A[1]-A[0])%2)*2<<endl;


return 0;
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int turn=0;
    while(A>0 && C>0){
        if(turn%2==0) C-=B;
        else A-=D;
        turn++;
    }

    if(A<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, t;
int a[10];
signed main() {
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> t;
		if (t < 3200) {
			a[t / 400]++;
		}
		else {
			sum++;
		}
	}
	int res = 0;
	for (int i = 0; i < 10; i++) {
		res += a[i] > 0;
	}
	if (res == 0) res++, sum--;
	cout << res << " " << res + sum << endl;
}

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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (0 <= x - r && 0 <= y - r && x + r <= W && y + r <= H){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String ans = in.replace(",", " ");
			System.out.println(ans);

		}
	}
}


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

int isalldigit(const string& str)
{
  for(int i = 0; i < str.size(); i++){
    if(!isdigit(str[i])) return false;
  }
  return true;
}

bool dahara(const string& str){
  int foo = 0;
  for(int i = 0; i < str.size(); i++){
    if(str[i] == '(') foo++;
    else if(str[i] == ')') foo--;
    else if(foo == 0) return false;
  }
  return true;
}

set< int > expr(string str)
{
  set< int > ret;

  int foo = 0 ;
  if(isalldigit(str)){
    ret.insert(atoi(str.c_str()));
  } else if (dahara(str)){
    return expr( str.substr( 1, str.size() - 2));
  } else {
    for(int i = 0; i < str.size(); i++){
      if(str[i] == '('){ //開き括弧だなぁ
        foo++;
        continue;
      } else if(str[i] == ')'){ //閉じ括弧だなぁ 
        foo--;
        continue;
      } else if(isdigit(str[i])){ //数字はどうでもいいなぁ
        continue;
      }
      if(foo == 0){
        set< int > hori = expr(str.substr( 0, i));
        set< int > tkc = expr(str.substr( i + 1));
        for(set< int >::iterator msy = hori.begin(); msy != hori.end(); msy++){
          for(set< int >::iterator mtur = tkc.begin(); mtur != tkc.end(); mtur++){
            if(str[i] == '+'){
              ret.insert( *msy + *mtur);
            } else if(str[i] == '-'){
              ret.insert( *msy - *mtur);
            } else if(str[i] == '*'){
              ret.insert( *msy * *mtur);
            } else {
              if(*mtur == 0) continue;
              ret.insert( *msy / *mtur);
            }
          }
        }
      }
    }
  }
  return ret;
}


int main()
{
  string s;
  while(cin >> s, s != "#"){
    cout << expr(s).size() << endl;
  }
}

Measured memory_bytes: 1276
import math
A,B,H,M= map(int, input().split())
T = 60 * H + M
d = T * 5.5 % 360
Long = H * 0.5
Short = M * 6
ans = A**2 + B**2 -2 * A * B * math.cos(math.radians(d))
print(math.sqrt(ans))


Measured memory_bytes: 9492
#include<math.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define SIZE 1000
#define INF 1000000
using namespace std;

int main(){

  int h,i,j,k;
  int p,q,r;
  int n,m;
  int a,b,c,d;
  int cost[SIZE][SIZE],time[SIZE][SIZE];

  while(cin>>n>>m,(n!=0 && m!=0)){

    for(i=1;i<=101;i++){
      for(j=1;j<=101;j++){
	cost[i][j]=INF;
	time[i][j]=INF;
      }
    }

    for(i=0;i<n;i++){
      cin>>a>>b>>c>>d;
      cost[a][b]=cost[b][a]=c;
      time[a][b]=time[b][a]=d;
    }

	for(i=1;i<m+1;i++){
	  for(j=1;j<m+1;j++){
	    for(k=1;k<m+1;k++){
	      cost[j][k]=min(cost[j][k],cost[j][i]+cost[i][k]);
	      time[j][k]=min(time[j][k],time[j][i]+time[i][k]);
	    }
	  }
	}

	cin>>k;
	for(i=0;i<k;i++){
	  cin>>p>>q>>r;
	  
	  if(r==0){
	    cout<<cost[p][q]<<endl;
	  }
	  else {
	    cout<<time[p][q]<<endl;
	  }
	}
	
  }
  
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  string s[n];
  int t[n];
  for (int i=0; i<n; i++) cin>>s[i]>>t[i];
  string x;
  cin>>x;
  int start;
  for (int i=0; i<n; i++) {
    if (s[i] == x) {
      start = i + 1;
      break;
    }
  }
  int ans = 0;
  for (int i=start; i<n; i++) {
    ans += t[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int N, M; cin>>N>>M;
  vector<int> H(N+1);
  vector<int> good(N+1);
  for(int i=1; i<=N; i++){
    int h; cin>>h;
    H.at(i)=h;
    good.at(i)=1;
  }
  for(int i=0; i<M; i++){
    int A, B; cin>>A>>B;
    if(H.at(A)<=H.at(B)) good.at(A)=0;
    if(H.at(A)>=H.at(B)) good.at(B)=0;
  }
  int sum=0;
  for(int i=1; i<=N; i++){
    sum+=good.at(i);
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 4052
#include <iostream>
using namespace std;
int main(void){

    int n,m,q;
    cin>>n>>m;
    int a[10020];
    for(int i=0;i<m;++i) cin>>a[i];
    for(int i=0;i<m;++i) n=n-a[i];
    q=n;
    if(q>=0){cout <<q  ;}
    else{cout <<-1;}
}


Measured memory_bytes: 3612
using System;

class Program
{
    static void Main()
    {
            int i;
            int[] x = new int[3000];
            int[] y = new int[3000];
            for (i = 0; i < 3000; i++)
            {
                string inp = Console.ReadLine();
                string[] data = inp.Split(' ');
                x[i] = int.Parse(data[0]);
                y[i] = int.Parse(data[1]);
                if (x[i] == 0 && y[i] == 0)
                {
                    break;
                }
            }
            for (i = 0; i < 3000; i++)
            {
                if (x[i] == 0 && y[i] == 0)
                {
                    break;
                }
                if (x[i] > y[i])
                {
                    Console.WriteLine("{0} {1}", y[i], x[i]);
                }else
                {
                    Console.WriteLine("{0} {1}", x[i], y[i]);
                }

            }
    }
}


Measured memory_bytes: 9300
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e5 + 5;

/***************************************************************************/

int W[N], V[N];
ll dp[105][N];

int main() {

	boost;
	int n, w; cin>>n>>w;
	for(int i=1; i<=n; i++) {
		cin>>W[i]>>V[i];
		for(int j=0; j<W[i]; j++) {
			dp[i][j] = dp[i-1][j];
		}
		for(int j=W[i]; j<N; j++) {
			dp[i][j] = max(dp[i-1][j], V[i]+dp[i-1][j-W[i]]);
		}
	}
	cout<<dp[n][w]<<"\n";
	return 0;
}

Measured memory_bytes: 79360
n = int(input())
ans = []


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


for a in make_divisors(n):
    b = int(n / a)
    if len(str(a)) <= len(str(b)):
        ans.append(len(str(b)))

print(min(ans))


Measured memory_bytes: 3060
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = ""; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def inp(): return int(sys.stdin.readline())
def st(): return input()
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

def main():
    n, m = wi()
    xy = mip(m)
    direct = [[] for _ in range(n)]
    for x, y in xy:
        direct[x].append(y)
    flag = [0 for _ in range(n)]
    """f(x)=(xを始点とする最長経路)とすると
    f(x)=
    {0 (xが葉のとき)
    max{f(y)+1|xからyへの辺があるようなy (そうでないとき)}
    として再帰で計算できるよ。答えはmax{f(x)}だね。
    再帰の深さがO(N)くらいになる
    """
    dp = [0 for _ in range(n)]
    def f(x):
        if flag[x]:
            return dp[x]
        flag[x] = 1
        fans = 0
        for y in direct[x]:
            fans = max(fans, f(y) + 1)
        dp[x] = fans
        return dp[x]

    ans = []
    for i in range(n):
        ans.append(f(i))
    print(max(ans))
    # 計算量はO(N+M)
if __name__ == '__main__':
    main()

Measured memory_bytes: 86340
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int k=sc.nextInt();
        int sum=0;
        if(k<=a){
            System.out.println(k);

        }else if(k<=a+b){
            System.out.println(a);


        }
        else {
            System.out.println(a-(k-a-b));
        }



    }
}


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

int main(){
    int n,k; cin >> n >> k;
    ll x[n];
    for(int i = 0; i < n; i++) cin >> x[i];
    ll mi = LONG_MAX;
    for(int i = 0; i <= n-k; i++){
        ll l = abs(x[i]) + abs(x[i]-x[i+k-1]);
        ll r = abs(x[i+k-1]) + abs(x[i]-x[i+k-1]);
        mi = min(mi, min(l,r));
    }
    cout << mi << endl;

    return 0;
}

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

int main()
{
	int N, tmp;
	cin >> N;
	int A[100000], B[100000];
	int MAX = 0;
	for(int i=0; i<N;i++)
	{
		cin >> A[i] >> B[i];
		MAX = max(MAX, A[i]);
		if (MAX == A[i]) tmp = B[i];
	}

	int ans = MAX + tmp;
	cout << ans << endl;

        return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int H, W, N; cin >> H >> W >> N;
    int a[10010]; rep(i, N) cin >> a[i];
    int c[110][110];
    int k = 0;
    rep(i, H) {
        if(i & 1) {
            rep(j, W) {
                if(a[k] != 0) {
                    c[i][j] = k + 1;
                    a[k] --;
                } else {
                    k ++;
                    c[i][j] = k + 1;
                    a[k] --;
                }
            }
        } else {
            per(j, W) {
                if(a[k] != 0) {
                    c[i][j] = k + 1;
                    a[k] --;
                } else {
                    k ++;
                    c[i][j] = k + 1;
                    a[k] --;
                }
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
	return 0;
}

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

def main():
  n = int(input())
  alist = list(map(int, input().split()))
  asum = sum(alist)
  rm = (1 + n) * n // 2
  if asum % rm != 0:
    print('NO')
  else:
    k = asum // rm
    d = [a-pa-k for pa, a in zip(alist, alist[1:])]
    d.append(alist[0] - alist[-1] - k)
    nk = 0
    for _d in d:
      if _d % n != 0:
        break
      else:
        nk += abs(_d) // n
    else:
      if nk == k:
        print('YES')
      else:
        print('NO')
      sys.exit(0)
    print('NO')


if __name__ == '__main__':
  main()

Measured memory_bytes: 60400
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	string s; cin>>s;
	for(int i=0; i<s.size(); ++i){
		if(s[i]==',') cout<<" ";
		else cout<<s[i];
	
	}
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ans=[0]*n
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if x*x+y*y+z*z+x*y+y*z+z*x>n:break
      ans[x*x+y*y+z*z+x*y+y*z+z*x-1]+=1
print(*ans)

Measured memory_bytes: 68896
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int x1,x2,x3,x4,x5;
    scanf("%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5);
    if(x1==0) printf("%d",1);
    else if(x2==0) printf("%d",2);
    else if(x3==0) printf("%d",3);
    else if(x4==0) printf("%d",4);
    else if(x5==0) printf("%d",5);
    return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<math.h>
using namespace std;
int a,b,c;
float d;
int main(){
    cin>>a>>b;
    if(b<10)c=10*a+b;
    else if(b<100) c=100*a+b;
    else c=1000*a+b;                                                

    d=sqrt(c);
    cout<<(c==(int)d*d?"Yes":"No")<<"\n";
    return 0;


}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
fn main(){
    input!{
        n: usize,
        k: usize
    }
    println!("{}",if n%k==0{0}else{1});
}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> ans(n);
  rep(i,n) ans[a[i]-1] = i+1;
  rep(i,n) cout << ans[i] << " ";
  return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=9;
const ll LINF=100000000000000000;

vector<int> edge[MAX_N];
int N,cnt;

void dfs(int passed,int now){
  if(passed==(1<<N)-1){
    cnt++; return;
  }
  rep(i,edge[now].size()){
    if((passed & (1<<edge[now][i]))==0) dfs(passed | (1<<edge[now][i]),edge[now][i]);
  }
}

int main(){
  int M;
  cin >> N >> M;
  rep(i,M){
    int a,b;
    cin >> a >> b ;
    a--; b--;
    edge[a].pb(b); edge[b].pb(a);
  }
  dfs(1,0);
  cout << cnt << endl;

  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int64 f(int64 a, int64 b, int64 x){
    return a * x / b - a * (x / b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 a,b,n;
    cin >> a >> b >> n;
    int64 ans = f(a,b,n);
    if(n >= b-1){
        ans = max(ans, f(a,b,b-1));
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 2e4, M = 3e4;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  if (n == 3) {
    cout << "2 5 63\n";
    return 0;
  }
  if (n == 4) {
    cout << "2 5 20 63\n";
    return 0;
  }

  VI ans {2, 4, 3, 9, 6};
  n -= 5;

  int i2 = 8;
  while (n >= 2) {
    if (i2 + 2 <= M) {
      ans.push_back(i2);
      ans.push_back(i2 + 2);
      i2 += 6;
      n -= 2;
    } else {
      break;
    }
  }

  int i3 = 9+6;
  while (n >= 2) {
    if (i3 + 6 <= M) {
      ans.push_back(i3);
      ans.push_back(i3 + 6);
      n -= 2;
      i3 += 12;
    } else {
      break;
    }
  }

  int i6 = 6+6;
  while (n >= 1) {
    n--;
    ans.push_back(i6);
    i6 += 6;
  }

  for (int x: ans) cout << x << ' ';
  cout << endl;

  return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    ll n;
    cin >> n;
    ll s = 0;
    ll ails = n;
    while (ails > 0)
    {
        s += ails % 10;
        ails /= 10;
    }
    //c(s);
    if (n % s == 0)
    {
        c("Yes");
    }
    else
    {
        c("No");
    }
    return 0;
}

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

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

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

  bool ans = true;
  for(int i=0; i<n; i++){
    if(a.at(i) % 2 == 0){
      if(a.at(i)%3 != 0 && a.at(i)%5 != 0) ans = false;
    }
  }

  if(ans) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	_, M := ReadInt(), ReadInt()
	m := make(map[int]bool)
	wa := make(map[int]int)
	for i := 0; i < M; i++ {
		p, s := ReadInt(), ReadString()
		if s == "AC" {
			m[p] = true
		} else {
			if !m[p] {
				wa[p]++
			}
		}
	}

	waSum := 0
	for p, cnt := range wa {
		if m[p] {
			waSum += cnt
		}
	}
	fmt.Printf("%d %d\n", len(m), waSum)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 8892
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,I;cin>>N>>I;
    cout<<N-I+1<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, D: "List[List[int]]"):
    ans = False
    c = 0
    for i in range(N):
        if D[i][0]==D[i][1]:
            c += 1
            if c == 3:
                ans = True
        else:
            c = 0

    if ans:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27128
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[0])
bought = 0
budget = 0
i = 0
while bought < m:
    buy = min(ab[i][1], m-bought)
    budget += ab[i][0] * buy
    bought += buy
    i += 1

print(budget)


Measured memory_bytes: 29028
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> ac(n),pena(n);
    REP(i,m){
        int x;
        string y;
        cin >> x >> y;
        x--;
        if(ac[x]) continue;
        if(y=="AC"){
            ac[x]=1;
        }else{
            pena[x]++;
        }
    }
    int wa=0;
    REP(i,n){
        if(ac[i]) wa+=pena[i];
    }
    printf("%d %d",accumulate(ALL(ac),0),wa);
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	string n;
	cin >> n;

	for( auto& ch: n ) {
		ch = (ch == '1' ? '9' : '1');
	}
	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
S = input()
list = ["A","C","T","G"]
n = len(S)
box = []

for i in range(n):
    if S[i] in list:
        box.append(1)
    else:
        box.append(0)
        
box.append(0)

cnt = 0
ans = [0]

for i in range(n):
    if box[i] == 1:
        cnt += 1
        if box[i+1] == 0:
            max = cnt
            ans.append(max)
            cnt = 0
X = sorted(ans)
print(X[-1])

Measured memory_bytes: 3064
#include<stdio.h>
main()
{
	int a,b,c,cbaki,baki,tbaki;
	scanf("%d%d%d",&a,&b,&c);
	baki=a-b;
	cbaki=baki/c;
	tbaki=baki-(cbaki*c);
	printf("%d\n",tbaki);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<int,int>
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,k,l,m,o,p,t,sum,sum1,flag;
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;

}



Measured memory_bytes: 3648
S = input()
Q = int(input())
Query = [list(map(str, input().split())) for i in range(Q)]

reverse = 0
b = []
a = []

for i in range(Q):
  if len(Query[i]) == 1:
    reverse += 1
  else:
    if Query[i][1] == '1':
      if reverse % 2 == 0:
        b.append(Query[i][2])
      else:
        a.append(Query[i][2])
    else:
      if reverse % 2 == 0:
        a.append(Query[i][2])
      else:
        b.append(Query[i][2])
        
ans = ''
s = (''.join(b))[::-1] + S + ''.join(a)
if reverse % 2 == 0:
  ans = s
else:
  ans = s[::-1]
  
print(ans)

Measured memory_bytes: 41816
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-8;
const int N=2e5+10;
const ll mod=1e9+7;
inline ll read()
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar()) x=x*10+ch-'0';
   return x*f;
}
int n;
int main()
{  cin>>n;
   if(n>=30)printf("Yes\n");
   else printf("No\n"); 

}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

int N;
double K,S[SIZE],ruiseki[SIZE],table[SIZE];

int main(){

	scanf("%d %lf",&N,&K);

	ruiseki[0] = 0.0;

	for(int i = 1; i <= N; i++){

		scanf("%lf",&S[i]);
		if(S[i] == 0.0){
			printf("%d\n",N);
			return 0;
		}
		S[i] = log(S[i]);
		ruiseki[i] = S[i];
		ruiseki[i] += ruiseki[i-1];
	}
	if(K == 0){

		printf("0\n");
		return 0;
	}

	K = log(K);

	table[N] = ruiseki[N];

	for(int i = N-1; i >= 1; i--){

		table[i] = min(ruiseki[i],table[i+1]);
	}

	int ans = 0;
	int left,right,mid,R;

	for(int i = 1; i <= N; i++){

		left = i,right = N,mid = (left+right)/2;
		R = -1;

		while(left <= right){

			if(table[mid]-ruiseki[i-1] <= K){

				R = mid;
				left = mid+1;
			}else{

				right = mid-1;
			}
			mid = (left+right)/2;
		}

		if(R == -1)continue;
		ans = max(ans,R-i+1);
	}

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

	return 0;
}



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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

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

	map<ll, ll> mp;
	rep( i, n ) {
		ll a;
		cin >> a;

		/* 初回 */
		if ( mp.find(a) == mp.end() ) {
			mp.insert(make_pair(a, 1));
		}
		else {
			mp[a]++;
		}
	}

	ll rem = 0;
	for ( const auto& tmp : mp ) {
		if ( tmp.second < tmp.first ) rem += tmp.second;
		if ( tmp.second > tmp.first ) rem += (tmp.second - tmp.first);
	}

	cout << rem << endl;

	return 0;
}


Measured memory_bytes: 6272
state = [0 for x in range(0, 10)]

def next(state):
    new_state = [x for x in state]
    new_state[9] += 1
    for i in range(0, 9):
        if new_state[9 - i] >= 2:
            new_state[9 - i] = 0
            new_state[9 - i - 1] += 1
        else:
            break

    return new_state


n = int(input())

f = list()
for i in range(0, n):
    tmp = list(map(int, input().split(" ")))
    f.append(tmp)

p = list()
for i in range(0, n):
    tmp = list(map(int, input().split(" ")))
    p.append(tmp)

ans = -1000000000
for i in range(0, 2 ** 10 - 1):
    state = next(state)
    v = 0
    for j in range(0, n):
        opens = 0
        for k in range(0, len(state)):
            opens += f[j][k] * state[k]
        v += p[j][opens]
    ans = max(ans, v)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };


vector<P>delX, delY;

char maze[101][101];

signed main() {
	int A, B; cin >> A >> B;
	REP(i, 100) {
		REP(j, 100) {
			if (j < 50) {
				maze[i][j] = '#';
			}
			else maze[i][j] = '.';
		}
	}
	A--, B--;
	REP(i, 100) {
		REP(j, 48) {
			if (A == 0)break;
			if (i % 2 == 1 && j % 2 == 1) {
				maze[i][j] = '.';
				A--;
			}
		}
	}
	REP(i, 100) {
		FOR(j, 51, 100) {
			if (B == 0)break;
			if (i % 2 == 1 && j % 2 == 1) {
				maze[i][j] = '#';
				B--;
			}
		}
	}
	pe(100); print(100);
	REP(i, 100) {
		REP(j, 100) {
			cout << maze[i][j];
		}
		cout << endl;
	}
}	


Measured memory_bytes: 256
using System;
using System.Linq;
public class Hello{
    public static void Main()
    {
        // Your code here!
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int N = a[0];
        int A = a[1];
        int B = a[2];
        int total = 0;
        for(int i = 1; i <= N; i++)
        {
            int sum = findSumOfDigits(i);
            if(A <= sum && sum <= B)
            {
                total += i;
            }
        }
        
        Console.WriteLine(total);
    }
    
    public static int findSumOfDigits(int n)//各桁の和を返す関数
    {
        int sum = 0;
        while(n > 0)
        {
            sum += n % 10;
            n /= 10;
        }
        
        return sum;
    }
    
    
    
    
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define first F
#define second S
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	cout<<n*n*n<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1000000007;
int dp[2005][2005];
int a[2005],b[2005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&b[i]);
    }
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            dp[i][j]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            dp[i][j]=((dp[i-1][j]+dp[i][j-1])%mod-dp[i-1][j-1])%mod;
            if(a[i]==b[j])
                dp[i][j]+=dp[i-1][j-1]+1;
            if(dp[i][j]<0)
                dp[i][j]+=mod;
            dp[i][j]%=mod;
        }
    }
    printf("%d\n",(dp[n][m]+1)%mod);
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
typedef long long ll;
int n, m, seen[100010], sign[100010];
vector<int> adj[100010];
vector<pair<int, int> > dfsadj[100010];
vector<pair<int, int> > other;
void dfs(int a)
{
	seen[a] = 1;
	for (auto b : adj[a])
	{
		if (seen[b] == 1) continue;
		else if (seen[b]) sign[a] = !sign[a], other.emplace_back(a, b);
		else dfs(b), sign[a] = !sign[a], dfsadj[a].emplace_back(b, 0);
	}
	seen[a] = 2;
}	
int dfs2(int a)
{
	for (auto &b : dfsadj[a])
	{
		if (dfs2(b.first))
		{
			b.second = 1;
			sign[a] = !sign[a];
		}
	}
	return sign[a];
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1);
	if (dfs2(1)) printf("-1\n");
	else 
	{
		for (int i = 1; i <= n; i++)
		{
			for (auto a : dfsadj[i])
			{
				if (a.second) printf("%d %d\n", a.first, i);
				else printf("%d %d\n", i, a.first);
			}
		}
		for (auto a : other) printf("%d %d\n", a.first, a.second);
	}
}

Measured memory_bytes: 19328