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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, l, ans = 0;
  ll n, k, d, a;

  cin >> n >> k;
  vector<ll> sunuke(n, 1);

  for (i = 0; i < k; i++)
  {
    cin >> d;
    for (j = 0; j < d; j++)
    {
      cin >> a;
      sunuke[a - 1] = 0;
    }
  }

  for (i = 0; i < n; i++)
  {
    ans += sunuke[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.*;

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

        String S = sc.next();

        if (S.equals("AAA") || S.equals("BBB")) {
            System.out.println("No");
            return;
        }

        System.out.println("Yes");

    }
}


Measured memory_bytes: 21972
#include<stdio.h>
#include <math.h>


int main(){
    double a,b,x,tmp,ans;
    scanf("%lf %lf %lf",&a,&b,&x);
    tmp=x*2.0/(a*a);
    if(tmp>=b){
        tmp=2.0*b-tmp;
        ans=atan2(tmp,a);
        printf("%.10lf",ans*180/M_PI);
        return 0;
    }else{
        tmp=x*2/(a*b);
        ans=atan2(b,tmp);
        printf("%.10lf",ans*180/M_PI);
        return 0;
    }
}

Measured memory_bytes: 128
const main = (stdin) => {
    const input = stdin.split("\n");
    const init = input[0].split(' ');
  	
    let c = 0;
  	for(let i=1;i<=parseInt(init[0]);i++) {
	  const xy = input[i].split(' ');
	  if((Math.sqrt((parseInt(xy[0])**2) + (parseInt(xy[1])**2))) <= parseInt(init[1])) c++;
    }
  console.log(c);
 
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 62776
s = input()
answer = "-1 -1"

if s[-2] == s[-1]:
    answer = "{} {}".format(len(s) - 1, len(s))

for i in range(len(s) - 2):
    if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
        answer = "{} {}".format(i + 1, i + 3)
        break

print(answer)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#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 ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// int n;
// cin >> n;
// vector<int> v(n);
// REP(i, n) {
//   cin >> v[i];
// }

int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
}

Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

const ll mod = 1e9 + 7;
int N, K, dp[2005][2005];
ll f[4000005], inf[4000005];

ll mul(ll a, ll b){
    return ((a%mod)*(b%mod))%mod;
}

ll add(ll a, ll b){
    return ((a%mod)+(b%mod))%mod;
}

ll pw(ll b, ll e){
    if(e==0) return 1ll;
    ll t = pw(b,e/2);
    if(e&1) return mul(b,mul(t,t));
    return mul(t,t);
}

ll modinv(ll x){
    return pw(x, mod-2);
}

void precompute(){
    f[0] = inf[0] = 1ll;
    FOR(i,4000000){
        f[i] = mul(f[i-1], i);
        inf[i] = modinv(f[i]);
    }
}

ll C(ll n, ll r){
    if(n < r) return 0;
    return mul(f[n], mul(inf[n-r], inf[r]));
}

int main(){

    ios :: sync_with_stdio(false);
    cin >> N >> K;
    precompute();

    if(K==1){
        cout << 1 << endl;
        return 0;
    }
    
    REP(i,N+1){
        FORU(j,i,N){
            if(i==0 && j==0) dp[i][j] = 1;
            if(i-1 >= 0) dp[i][j] = dp[i-1][j];
            if(j > i){
                dp[i][j] = add(dp[i][j], mul(dp[i][j-1], C(i + j*(K-1) -1, K-2)));
            }
        }
    }

    ll ans = mul(dp[N][N], f[N]);
    cout << ans << endl;
    return 0;
}

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

int main()
{
int N,K; cin >>N>>K;
int x[N];
for (int i = 0; i < N; i++)
{
    cin >>x[i];
}
int sum = 0;
for (int i = 0; i < N; i++)
{
    sum += min(x[i],K-x[i]);
}
cout << sum*2 <<endl;

}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
sum = 0

(n-1).times do |i|
  if a[i] > a[i+1]
    sum += a[i] - a[i+1] 
    a[i+1] = a[i] 
  end
end

puts sum

Measured memory_bytes: 30432
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int d,g;
	int ans=INF;
	cin >>d>>g;
	VP data(d);
	rep(i,d){
		cin>>data[i].F>>data[i].S;
	}
	int cnt=0;
	int at=0;
	int ter=0;
	rep(bit,1<<d){
		cnt=0;
		at=0;
		rep(i,d){if(bit & (1<<i)){
				at+=data[i].F*100*(i+1)+data[i].S;
				cnt+=data[i].F;
				}
		}
		if(at <g){
			ter=d-1;
			while(bit & (1<<ter)){
				ter--;
			}
			//cnt+=(g-at/*+ter*100 -1*/)/((ter+1)*100);
			if ((g - at + (ter + 1) * 100 - 1) / ((ter + 1) * 100) <=data[ter].F){
				cnt += (g - at + (ter + 1) * 100 - 1) / ((ter + 1) * 100);
				}else{
					continue;
				}
		}
		chmin(ans,cnt);
		//clog<<cnt<<" "<<bitset<10>(bit)<<endl;

			
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  int c500=(x-x%500)/500;
  x %= 500;
  int c5=(x-x%5)/5;
  x %=5;
  cout << 1000*c500+5*c5;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 123456;
int B[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    vector<int> lineA, lineC;
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        lineA.push_back(tmp);
    }
    for (int i = 0; i < N; i++) {
        scanf("%d", &B[i]);
    }
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        lineC.push_back(tmp);
    }
    sort(lineA.begin(), lineA.end());
    sort(lineC.begin(), lineC.end());
    LL ans = 0;
    for (int i = 0; i < N; i++) {
        LL sumC = lineC.end() - upper_bound(lineC.begin(), lineC.end(), B[i]);
        LL sumA = (lower_bound(lineA.begin(), lineA.end(), B[i]) - lineA.begin());
        ans += sumA * sumC;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1912
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/4/2018
 
 23:30-23:56 TLE on sample #4 locally
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=2e5+1;
int H,W,A,B;
const LL MOD=1e9+7;

LL fact[MAX_N],factinv[MAX_N],inv[MAX_N];
LL powmod(LL a, LL b) {
  assert(0<=a && a<MOD);
  assert(0<=b);
  
  LL res=1;
  for(LL mask=1; mask<=b; mask<<=1) {
    if(b&mask) res*=a, res%=MOD;
    a*=a; a%=MOD;
  }
  return res;
}
LL modinv(LL a, LL p=MOD) {
  return powmod(a, p-2);
}
// broken
LL choose(int n, int r) {
  if(n<r) return 0;
  r = min(n-r,r);
//  dump3(n,n-r,r);
//  dump3(fact[n],factinv[n-r],factinv[r]);
  LL a=(fact[n]*factinv[n-r])%MOD;
  LL res=(a*factinv[r])%MOD;
  return res;
}

LL f(int r1, int c1, int r2, int c2) {
  int dr=r2-r1,dc=c2-c1;
  return choose(dr+dc,dr);
  //return choose_factmod(dr+dc,dr);
}

void solve() {
  LL res=0;
  
  fact[0]=1,factinv[0]=1;
  FOR(i,1,MAX_N) fact[i]=fact[i-1]*i%MOD,factinv[i]=modinv(fact[i]);
  
  FOR(c,B,W) {
    int r=H-A-1;
    LL x=f(0,0,r,c),y=r<H-1?f(r+1,c,H-1,W-1):0LL;
    x*=y,x%=MOD;
    res+=x,res%=MOD;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>H>>W>>A>>B;
  solve();
  return 0;
}


Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define veci(x,n) vector<int> x((int) (n))
#define vecs(x,n) vector<string> x((int) (n))
#define vecbf(x,n) vector<bool> x((int) (n), false)

int d,g;
int mini = 100000;

void search(vector<int> &p,vector<int> &c,vector<bool> &full,int sum,int score,int j){
  if(j == d){
    if(score >= g){
      mini = min(mini,sum);
      return;
    }
    for(int i=d-1;i>=0;i--){
      if(full.at(i)) continue;
      int tmp = (g - score + 100*(i+1) - 1)/(100*(i+1));
      if(tmp > p.at(i)) return;
      else{
        mini = min(mini,sum+tmp);
        return;
      }
    }
    //return;
  }
  full.at(j) = false;
  search(p,c,full,sum,score,j+1);
  
  full.at(j) = true;
  sum += p.at(j);
  score += 100*(j+1)*p.at(j) + c.at(j);
  search(p,c,full,sum,score,j+1);
  return;
}

int main(){
  cin >> d >> g;
  veci(p,d);
  veci(c,d);
  veci(bonus,d);
  veci(ave,d);
  rep(i,d){
    cin >> p.at(i) >> c.at(i);
    bonus.at(i) = 100*(i+1)*p.at(i) + c.at(i);
    ave.at(i) = (100*(i+1)*p.at(i) + c.at(i))/p.at(i);
  }
  vector<bool> full(10,false);
  int sum = 0;
  int score = 0;
  search(p,c,full,sum,score,0);
  cout << mini << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n,i,y,i2,y2;
	int a,b,c,d,h=0,k=0;
	
	cin >> i >> y;
	cin >> i2 >> y2;
	cin >> a >> b >> c >> d ;
	h += (i/10)*c + (y/20)*d + i*a + y*b;
	k += (i2/10)*c + (y2/20)*d + i2*a + y2*b;
	if(h < k) cout << "kenjiro" << endl;
	else if(h == k) cout << "even" << endl;
	else  cout << "hiroshi" << endl;
	
	return 0 ;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  
  int answer = 0;
  if (n <= m) {
    for (int i = 0; i < m; i++) {
      answer += pow(10.0, i) * n;
    }
  } else {
    for (int i = 0; i < n; i++) {
      answer += pow(10.0, i) * m;
    }
  }
  
  cout << (int)answer << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    ll res = 1;
    rep(i, n){
      res *= (ll)(i + 1);
      res %= mod;
    }
    pri(res);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {

	int n;
	cin>>n;
	string a[n];
	set<string>s;

	for(int i=0; i<n; i++){
		cin>>a[i];
		s.insert(a[i]);
	}
	cout<<s.size();
}


Measured memory_bytes: 25476
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    vector<char> s(7*100000);
    int left=3*100000;
    int right=3*100000;
    string tmp;cin>>tmp;
    REP(i,SIZE(tmp)){
        s[right]=tmp[i];
        right++;
    }
    int q;cin>>q;

    int r = 0;

    REP(i,q){
        int t;cin>>t;
        if(t==1){
            r = (r+1)%2;

        }
        else{
            int f;cin>>f;
            char c;cin>>c;

            if((r+f)%2 == 1){
                left--;
                s[left]=c;
                //s = c+s;
            }
            else{
                s[right]=c;
                right++;
                //s = s+c;
            }

        }
    }

    if(r==1){
        //reverse(s.begin(),s.end());
        ROF(i,left,right){
            cout<<s[i];
        }
        cout<<endl;
    }
    else{
        FOR(i,left,right){
            cout<<s[i];
        }
        cout<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1488
#include <iostream>
#include<math.h>
#include<iomanip>
 int main()
{
    double A,B,H,M;
    double r;
    std::cin>>A>>B>>H>>M;
    H=(H*60+M)*.5;
    H > M*6 ? r = H - M*6 : r = M*6 - H;
    if(r>180)
    {
        r=360-r;
    }
    r = r  * M_PI / 180.0;
    std::cout  <<std:: fixed<<std::setprecision(10)<< sqrt(A*A+B*B-2*A*B*cos(r)) << std::endl;
    return 0;
}


Measured memory_bytes: 3568
from time import time
import random


def main():
    random.seed(145)

    now = time()

    MAX = 26

    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]
    t = []
    for row in s:
        mxi = 1
        mx = 0
        for i, e in enumerate(row, 1):
            if e > mx:
                mx = e
                mxi = i

        t.append(mxi)

    last = [0] * MAX

    score = 0
    for day, e in enumerate(t, 1):
        score += s[day-1][e-1]
        last[e-1] = day

        for ec, elast in zip(c, last):
            score -= ec * (day - elast)

    d_li = []
    for i in range(1, d + 1):
        ln = max(1, (-(i - d // 2) ** 2 + d ** 2 // 4) // 500)
        d_li += [i] * ln

    di_max = len(d_li) - 1

    c_sum = sum(c)
    c_li = []
    for i, e in enumerate(c, 1):
        c_li += [i] * e

    while time() - now <= 1.85:
        prev_score = score

        di = random.randint(0, di_max)
        ed = d_li[di]
        qi = random.randint(0, c_sum - 1)
        eq = c_li[qi]

        q_old = t[ed-1]
        d_prev = {q_old: 0, eq: 0}

        c_old = c[q_old-1]
        c_new = c[eq-1]

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score += c_old * (day - d_prev[q_old])
            score += c_new * (day - d_prev[eq])

        score -= s[ed-1][q_old-1]
        score += s[ed-1][eq-1]

        t[ed-1] = eq

        d_prev = {q_old: 0, eq: 0}

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score -= c_old * (day - d_prev[q_old])
            score -= c_new * (day - d_prev[eq])

        if prev_score > score:
            t[ed-1] = q_old
            score = prev_score

    print(*t, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 81864
#include <bits/stdc++.h>
using namespace std;
int main(){
    const long double pi = 3.14159265358979323846264338327950288419716939937510;
  	long double angle, hangle, mangle, a, b, h, m;
    cin >> a >> b >> h >> m;
    //times pi/180 for angle in radians
    mangle = 6*m;
    hangle = (h*60+m)/2;
    angle = abs(hangle - mangle);
  	cout << fixed << setprecision(14) << sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(angle*pi/180)) << endl;
}

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

N, X = map(int, input().split())
A = list(map(int, input().split()))

dp = [[None for _ in range(N)] for _ in range(N)]
for i in range(N):
    dp[0][i] = A[i]

ans = sum(dp[0])
for d in range(1, N):
    for i in range(N):
        dp[d][i] = min(dp[d-1][i], A[(i+d)%N])
    ans = min(ans, sum(dp[d])+X*d)

print(ans)

Measured memory_bytes: 136156
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	ll N;
	cin >> N;
	int F = 10;
	for (ll i = 1; i <= sqrt(N); i++){
		if (N%i == 0){
			ll j = N / i;
			int f = max(to_string(i).length(), to_string(j).length());
			F = min(F, f);
		}
	}
	cout << F << endl;
}




Measured memory_bytes: 256
<?php
while (true) {
    $line = trim(fgets(STDIN));
    list($H, $W) = explode(' ', $line);
    if ($W == 0 && $H == 0) {
        break;
    }
    $room = array();
    for ($i = 0; $i < $H; $i++) {
        $room[$i] = trim(fgets(STDIN));
    }
    $visited = array();
    for ($i = 0; $i < $H; $i++) {
        for ($j = 0; $j < $W; $j++) {
            $visited[$i][$j] = false;
        }
    }
    $x = 0; $y = 0;
    $isLoop = false;
    while (true) {
        $line = $room[$y];
        $dir = $line[$x];
        if ($dir == '.') {
            break;
        }
        $visited[$y][$x] = true;
        switch ($dir) {
            case '>':
                $x++;
                break;
            case '<':
                $x--;
                break;
            case 'v':
                $y++;
                break;
            case '^':
                $y--;
                break;
        }
        if ($visited[$y][$x]) {
            $isLoop = true;
            break;
        }
    }
    if ($isLoop) {
        echo "LOOP\n";
    } else {
        echo "$x $y\n"; 
    }
}

Measured memory_bytes: 16648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
int c[22],v[22];
int ans;
int sumv,sumc;
void dfs(int x)
{
    if(x>n)
    {
        ans=max(ans,sumv-sumc);
        return;
    }
    sumv+=v[x];
    sumc+=c[x];
    dfs(x+1);
    sumv-=v[x];
    sumc-=c[x];
    dfs(x+1);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)  scanf("%d",&v[i]);
    for(int i=1;i<=n;i++)  scanf("%d",&c[i]);
    dfs(1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
A = []
for i in range(2):
    A.append([int(i) for i in input().split()])

B =[[0 for i in range(n)] for j in range(2)]
B[0][0] = A[0][0]
for i in range(1,n):
    B[0][i] = B[0][i-1]+A[0][i]

B[1][0]=A[0][0]+A[1][0]
for i in range(1,n):
    B[1][i] = max(B[1][i-1],B[0][i])+A[1][i]

# print(B)

ans = B[-1][-1]

print(ans)


Measured memory_bytes: 13332
#!/usr/bin/env python3
n,time = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
for i in range(1,n):
	if t[i] - t[i-1] <= time: ans += t[i] - t[i-1]
	else: ans += time
print(ans+time)

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

int main()
{
	ll x;
	cin >> x;
	ll a = x / 500;
	x -= 500 * a;
	ll b = x / 5;
	cout << 1000 * a + 5 * b << endl;
}

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

using namespace std;

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

    long long int n,sum=0;
    cin>>n;

    for(long int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<"\n";

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    if(A==B)
    {
        cout<<A+B<<endl;
    }
    else if(A>B)
    {
        cout<<(A*2)-1<<endl;
    }
    else
    {
        cout<<(B*2)-1<<endl;
    }
    return 0;
}


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

int main()
{
	int ans,n,k;
	int i=1;

	cin >> n >> k;

	//最初の1つめ
	ans = k;
	for (i; i < n; i++) {
		ans = ans * (k - 1);
	}
		cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    n, d = map(int, input().split())
    if n == 0 and d == 0: break

    a = [n]
    cnt = 0
    while True:
        t = list(map(int, list(("{:0%d}"%d).format(n))))
        n = int("".join(map(str, sorted(t, reverse=True)))) - int("".join(map(str, sorted(t))))
        if n in a:
            break
        a.append(n)
        cnt += 1
    i = a.index(n)
    print(i, n, cnt - i + 1)

Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string word,order,rep_word,new_word;
	int times, start, end;
	
	cin >> word >> times;
	
	for(int i=0; i<times; ++i){
		cin >> order >> start >> end;
		if(order == "replace"){
			cin >> rep_word;
			word.replace(start, end-start+1, rep_word);
		}else if(order == "reverse"){
			reverse(word.begin()+start, word.begin()+end+1);
		}else{
			cout << word.substr(start, end-start+1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3180
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define repp(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
const int N = 305, inf = int(1e9);
int n;
int mp[N][N], key[N][N];
ll ans;
/*
int fa[N];
int find(int x) {return x==fa[x]?fa[x]:fa[x]=find(fa[x]);}
int egtot;
struct edge{int a,b,d;}eg[N*N];
bool cmpD(edge a, edge b){return a.d<b.d;}
*/
inline int re() {
	int x = 0; char ch = getchar(); bool f = 0;
	for(; ch>'9'||ch<'0'; ch = getchar()) if(ch=='-')f=1;
	for(; ch>='0'&&ch<='9'; ch = getchar()) x = (x<<1)+(x<<3)+ch-48;
	if(f) return -x;
	return x;
}
int main() {
	n = re();
	rep(i,1,n) {
		rep(j,1,n) {
			mp[i][j] = re();
			key[i][j] = mp[i][j];
		}
	}
	
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			for(int k = j+1; k <= n; ++k) {
				if(mp[j][i]+mp[i][k]<mp[j][k])
					{printf("-1\n"); return 0;}
				else if(j!=i&&i!=k&&mp[j][i]+mp[i][k]==mp[j][k]) key[j][k]=key[k][j]=0;
			}
/*	rep(i,1,n) {
		for(int j = i+1; j <= n; ++j) {
			eg[++egtot].a = i;
			eg[egtot].b = j;
			eg[egtot].d = mp[i][j];
		}
	}
	sort(eg+1,eg+1+egtot,cmpD);
	rep(i,1,n) fa[i]=i;
	rep(i,1,egtot) {
		if(find(eg[i].a)==find(eg[i].b)) continue;
		fa[find(eg[i].b)] = find(eg[i].a);
		ans += eg[i].d;
	}
*/
	rep(i,1,n)
		rep(j,i+1,n)
			ans += key[i][j];
	printf("%lld\n",ans);
	return 0;
}


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

dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])

for i in range(2, N):
    for j in range(1, K+1):
        if i >= j:
            dp[i] = min(dp[i], dp[i-j] + abs(H[i-j] - H[i]))

print(dp[N-1])



Measured memory_bytes: 55392
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;
static const cc MAX = 200000;

cc N, M, i, j, k, sub = 0, n = 0, A[MAX], B[MAX];
cc judge = 0, Ans = 0;
string S;
char vec[10];
char T;
/*
vector<cc> vec1(MAX), vec2(MAX);
vector<pair<cc, cc>> pairs(MAX);
*/



int main() {	
	cin >> S;
	for (i = 0; i < S.size(); i++) {
		if (judge == 0) {
			Ans ++;
			T = S[i];
			judge = 1;
		}
		else if (judge == 1) {
			if (T == S[i]) {
				i++;
				judge = 0;
				if (i == S.size())
					break;
			}
			else
				T = S[i];
			Ans++;
		}
	}
	

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <tuple>

int main(){
  int A,B;
  std::cin >> A >> B;

  std::vector<std::vector<int>> AB_arr(100, std::vector<int>(100));
  for(int i = 0; i < 50; i++){
    for(int j = 0; j < 100; j++){
      AB_arr[i][j] = 1;
    }
  }
  for(int i = 0; i < A-1; i++){
    AB_arr[2*(i/50)][2*(i%50)] = 0;
  }
  for(int i = 0; i < B-1; i++){
    AB_arr[99-2*(i/50)][2*(i%50)] = 1;
  }
  std::cout << "100 100\n";
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      std::cout << (AB_arr[i][j]==0?'.':'#');
    }
    std::cout << "\n";
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int k = cin.Int();
			if (k > (n - 1) * (n - 2) / 2) {
				Console.WriteLine(-1);
				return;
			}

			List<Pair<int, int>> anss = new List<Pair<int, int>>();
			for (int i = 1; i < n; i++) {
				anss.Add(new Pair<int, int>(i, n));
			}

			List<Pair<int, int>> kouho = new List<Pair<int, int>>();
			for (int i = 1; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					kouho.Add(new Pair<int, int>(i, j));
				}
			}

			for (int i = 0; i < (n - 1) * (n - 2) / 2 - k; i++) {
				anss.Add(kouho[i]);
			}

			Console.WriteLine(anss.Count());
			foreach (var ans in anss) {
				Console.WriteLine($"{ans.F} {ans.S}");
			}
		}
	}

	class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
	{
		public T F; public U S;
		public Pair(T f, U s) { this.F = f; this.S = s; }
		public int CompareTo(Pair<T, U> a) => F.CompareTo(a.F) != 0 ? F.CompareTo(a.F) : S.CompareTo(a.S);
		public override string ToString() => $"{F} {S}";
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13396
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a;
  cin>>a;
  cout<<a/3;

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

typedef pair< int, pair<int, int>> PIPII;

int main() {
	int N, M, A;
	while( cin >> N >> M >> A, N || M || A ) {
		vector<int>D( N );
		iota( D.begin(), D.end(), 1 );
		priority_queue<PIPII, vector<PIPII>>que;
		for( size_t i = 0; i < M; i++ ) {
			int H, P, Q;
			cin >> H >> P >> Q;
			P--; Q--;
			que.push( make_pair( H, make_pair( P, Q ) ) );
		}
		while( que.size() ) {
			PIPII now = que.top(); que.pop();
			swap( D[now.second.first], D[now.second.second] );
		}
		for( size_t i = 0; i < N; i++ ) {
			if( D[i] == A ) {
				cout << i + 1 << endl;
			}
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  int A[2][N];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int tmp = 0;
    int line = 0;
    for (int j = 0; j < N; j++) {
      tmp += A[line][j];

      if (i == j) {
        line++;
        tmp += A[line][j];
      }
    }
    ans = max(tmp, ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';
 
int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int h, n;
	cin >> h >> n;
	vector<int> dp(h + 1, MOD);
	dp[0] = 0;
	rep(i, n) {
		int a, b;
		scanf("%d%d", &a,&b);
		rep(j, h) {
			int nj = min(j + a, h);
			dp[nj] = min(dp[nj], dp[j] + b);
		}
	}
	cout << dp[h];
}
 

Measured memory_bytes: 888
N = gets.to_i
As = [nil ] + readlines.map(&:to_i)

m = [false] * (N + 1)
c, n = 0, 1
loop do
  n = As[n]
  c += 1
  if n == 2
    puts c
    exit
  end
  if m[n]
    puts -1
    exit
  end
  m[n] = true
end

Measured memory_bytes: 9852
S = list(input())

count = 1
index = 0
cur = 'R'
ans = [0] * len(S)
r_count = 1
for i in range(1, len(S)):
    if cur == 'R' and S[i] == 'L':
        cur = 'L'
        index = i
    elif cur == 'L' and S[i] == 'R':
        if count % 2 == 0:
            ans[index - 1] = count // 2
            ans[index] = count // 2
        else:
            if r_count % 2 != 0:
                ans[index - 1] = count // 2 + 1
                ans[index] = count // 2
            else:
                ans[index - 1] = count // 2
                ans[index] = count // 2 + 1
        cur = 'R'
        r_count = 0
        count = 0
    count += 1
    if S[i] == 'R':
        r_count += 1

    if i == len(S) - 1:
        if count % 2 == 0:
            ans[index - 1] = count // 2
            ans[index] = count // 2
        else:
            if r_count % 2 != 0:
                ans[index - 1] = count // 2 + 1
                ans[index] = count // 2
            else:
                ans[index - 1] = count // 2
                ans[index] = count // 2 + 1
print(" ".join(map(str, ans)))


Measured memory_bytes: 11180
def is_prime(N):
    i = 0
    if N <= 1:
        return False, i
    i = 2
    while i*i <= N:
        if N%i == 0:
            return True, i
        i += 1
    return True, N

N = int(input())
print(str(N)+': ', end='')
ans = []
while True:
    F, i = is_prime(N)
    if F:
        ans.append(i)
        N //= i
    else:
        print(' '.join(map(str, ans)))
        break


Measured memory_bytes: 5604
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-

import heapq

m = 2*10**5
mod = 998244353

fact = [0]*(m+5)
fact_inv = [0]*(m+5)
inv = [0]*(m+5)

fact[0] = fact[1] = 1
fact_inv[0] = fact_inv[1] = 1
inv[1] = 1

for i in range(2,m+5):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    fact_inv[i] = fact_inv[i-1] * inv[i] % mod

# nCkをmod（素数）で割った余りを求める．ただしn<10**7
# 前処理はm=n+5まで
def cmb(n,k,mod):
    return fact[n] * (fact_inv[k] * fact_inv[n-k] % mod) % mod

ans = 0

n,m,k = list(map(int, input().split()))
for i in range(k+1):
    ans = (ans + (m*cmb(n-1,i,mod) % mod)*(pow(m-1,n-1-i,mod)) % mod) % mod

print(ans)

Measured memory_bytes: 33112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			int ans = 0;

			if(op.equals("?"))
				break;
			if(op.equals("+")) {
				ans = a + b;
			} else if(op.equals("-")) {
				ans = a - b;
			} else if(op.equals("*")) {
				ans = a * b;
			} else if(op.equals("/")) {
				ans = a / b;
			}

			System.out.println(ans);

		}
		sc.close();
	}

}

Measured memory_bytes: 26212
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int G, R;
int main(){
  rd(R);
  rd(G);
  wt_L(2*G-R);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20171023-1 [beta]

// --- original code ---
// int R, G;
// {
//   rd(R,G);
//   wt(2G-R);
// }


Measured memory_bytes: 256
N = gets.to_i
S = gets
if N % 2 != 0
  puts "No"
  exit
end
n = N / 2
a = S.scan(/.{1,#{n}}/)
if a.length == 2
  if a[0] == a[1]
    puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

void insetrtionsort(int a[], int n)
{
    int j, v;
    for (int i = 1; i < n; i++)
    {
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        for (int i = 0; i < n; i++)
        {
            cout << a[i] << " ";
        }
        cout << endl;
    }
}

int gcd(int a, int b)
{
    if (a < b)
    {
        int t = a;
        a = b;
        b = t;
    }
    if (b == 0) return a;
    else return gcd(b, a%b);
}

int main()
{
    int a, b;
    cin >> a >> b;
  	cout << gcd(a, b) << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int par[100010] = { 0 };
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		par[a]++;
		par[b]++;
	}
	for (int j = 1; j <= n; j++) {
		if (par[j] % 2 != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    x[i]=a+b
    y[i]=a-b
xmax=max(x)
xmin=min(x)
ymax=max(y)
ymin=min(y)
print(max(xmax-xmin,ymax-ymin))


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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**

string s;

void solve(){
	cin >> s;
	int n = SZ(s);
	if(s[n-1]=='s')
		cout << s << "es\n";
	else
		cout << s << "s\n";
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


Measured memory_bytes: 3636
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))

int main(){
	int n,i;
	long a[100000],x;
	long long ans=0;
	scanf("%d%ld",&n,&x);
	for(i=0;i<n;i++)scanf("%ld",&a[i]);
	for(i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			if(x-a[i]>=0){
				ans+=(a[i+1]-(x-a[i]));
				a[i+1]=x-a[i];
			}
			else {
				ans+=(a[i+1]+a[i]-x);
				a[i+1]=0;
				a[i]=x;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#define rep(i,k,n)for(ll i=k;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int gcd(ll a, ll b) {

	if (b == 0) {

		return a;
	}
	else {
		a = a%b;
		gcd(b, a);
	}
}
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
mint func(ll n, ll a,mint q,ll p,mint ans) {
	mint N = n;
	
	if (p == a) {

		return ans;
	}else{
		ans *=(N - q) / (q + 1);
		q += 1;
		p++;
		func(n, a, q, p,ans);
	}
	
}

int main() {
	string S, T;
	cin >> S >> T;
	if (T.substr(0, S.size()) == S) {

		cout << "Yes";
	}
	else {
		cout << "No";
	}


}

Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
    int a,b,c;
    int d;
    scanf("%d %d %d",&a,&b,&c);

    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    printf("%d %d %d\n",a,b,c);


    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

ll GCD(ll a, ll b) {
    if (a <= 0 || b <= 0) {
        return -1;
    }
    if (a > b) {
        if (a % b == 0) {
            return b;
        } else {
            GCD(b, a % b);
        }
    } else if (a < b) {
        if (b % a == 0) {
            return a;
        } else {
            GCD(a, b % a);
        }
    } else {
        return a;
    }
}

ll LCM(ll a, ll b) {
    return a / GCD(a, b) * b;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    ll ans = 1;
    rep (i, N) {
        ll T;
        cin >> T;
        ans = LCM(ans, T);
    }

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

Measured memory_bytes: 256