akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_AtCoder
{

    
    class Program
    {
       
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            int alpha_num = 26;

            for(int i = 0; i < S.Length; i++)
            {
                int s_num = S[i] - 'A';
                int next_num = (s_num + N) % alpha_num;
                char next_c = (char)('A' + next_num);
                Console.Write(next_c);
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13140
object Main {
  def main(args: Array[String]): Unit = {
    val length = readLine().toInt
    val source = readLine().split(" ").toList.map(_.toInt)

    val four = source.count(_ % 4 == 0)
    val two = source.filter(_ % 4 != 0).count(_ % 2 == 0)

    if (length / 2 <= four + two / 2) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

Measured memory_bytes: 49192
n = gets.to_i
a = gets.split.map &:to_i

hist = Array.new(n+1,0)
hist[0] = 3

MOD = 10**9+7
ans = 1

a.each do |i|
  ans = ans * hist[i] % MOD
  hist[i] -= 1
  hist[i+1] += 1
end

puts ans


Measured memory_bytes: 8836
#include <stdio.h>

int main(){


	int a, b;
	char op;


	while(1){
	
		scanf( "%d %c %d", &a, &op, &b);

		switch(op){
		case '+': printf( "%d\n", a+b ); break;
		case '-': printf( "%d\n", a-b ); break;
		case '*': printf( "%d\n", a*b ); break;
		case '/': printf( "%d\n", a/b ); break;

		}

		if( op == '?' ) break;

	}


	return 0;

}

Measured memory_bytes: 600
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

const int N = 310;

int n, k, d[N][N][N];
char s[N];

int main() {
    int i, j, l;
    //freopen("tttt", "r", stdin);

    cin >> (s + 1);
    cin >> k;

    n = strlen(s + 1);

    for(i = 1; i <= n; ++i) {
        for(j = n; j; --j) {

            for(l = 0; l <= k; ++l) {
                d[i][j][l] = max(d[i - 1][j][l], d[i][j + 1][l]);

                if(s[i] == s[j]) {
                    d[i][j][l] = max(d[i][j][l], d[i - 1][j + 1][l] + 1);
                }
                else if(l) {
                    d[i][j][l] = max(d[i][j][l], d[i - 1][j + 1][l - 1] + 1);
                }
            }

        }
    }

    int r = 0;

    for(i = 1; i <= n; ++i) {
        r = max(r, d[i - 1][i + 1][k] * 2 + 1);
        r = max(r, d[i - 1][i][k] * 2);
    }

    cout << r;

    return 0;
}


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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<int> hyouka(10, 0);
    for (int i = 0; i < n; ++i) {
      int k;
      cin >> k;
      ++hyouka[k];
    }

    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < hyouka[i]; ++j)
	cout << "*";
      if (hyouka[i] == 0)
	cout << "-";
      cout << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	ll n, a, b, x;
	ll ans = 0;
	cin >> n >> a >> b >> x;
	for (int i = 1; i < n; i++) {
		ll f;
		cin >> f;
		ans += min((f - x)*a, b);
		x = f;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//看劳资手打一遍过
    #include<bits/stdc++.h>
    using namespace std;
     
    int Solve(int x, int y)
    {
    if (!(x % y)) return x / y;
    int v=x/y+1;
    return Solve(x-max(x%y/v,1)*v,y);
    }
     
    int main()
    {
    int Ans = 0, n, x, y;
    scanf("%d", &n);
    while (n --) {
    scanf("%d%d", &x, &y);
    Ans ^= Solve(x, y);
    }
    if (Ans) puts("Takahashi");else puts("Aoki");
    return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll MAX = 510000;
const ll MOD = 1000000007;
// MAXの値に注意 !!!!!
long long fac[MAX], finv[MAX], inv[MAX];

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
    ll N , A , B , C; cin >> N >> A >> B >> C;
    ll ans = 0;
    rep(i,N){
      // Aが N - 1 回勝利、Bがi回勝利の　後　Aが勝利して確定
      ll tmp = COM(N + i - 1 , i) * modpow(A, N, MOD)
      % MOD * modpow(B, i, MOD) % MOD * modpow(inv[A + B] , N + i , MOD)
      % MOD * (N + i) % MOD * 100 % MOD * inv[100 - C] % MOD;
      ans += tmp;
      ans %= MOD;
    }
    rep(i,N){
      // Aが i 回勝利、Bが N - i 回勝利の　後　Bが勝利して確定
      ll tmp = COM(N + i - 1 , i) * modpow(B, N, MOD)
      % MOD * modpow(A, i, MOD) % MOD * modpow(inv[A + B], N + i , MOD)
      % MOD * (N + i) % MOD * 100 % MOD * inv[100 - C] % MOD;
      ans += tmp;
      ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12160
#include<cstdio>
int n,ans,x[210],y[210],f[210];
const int MD=998244353;
int main()
{
    scanf("%d",&n);
    f[0]=1;
    for(int i=1; i<=n; i++)
    {
        scanf("%d%d",&x[i],&y[i]);
        f[i]=1ll*f[i-1]*2%MD;
    }
    ans=f[n]-n-1;
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            int d=0;
            for(int k=j+1; k<=n; k++)
            d+=(y[i]-y[j])*(x[i]-x[k])==(y[i]-y[k])*(x[i]-x[j]);
            ans=(ans+MD-f[d])%MD;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
import math
import sys

sys.setrecursionlimit(10 ** 7)

# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

A, B, H, M = map(int, input().split())


short = H * 360 / 12 + M / 2
long = M * 360 / 60

angle = abs(short - long)
angle = min(angle, 360-angle)

radian = math.pi*angle/180
ans = math.sqrt((A**2+B**2-2*A*B*math.cos(radian)))

print(ans)



Measured memory_bytes: 9448
def f(d, n):
    add = pow(100, d)
    total = 0
    c = 0
    while True:
        total += add
        if total % pow(100, (d + 1)) == 0:
            pass
        else:
            c += 1
        if c == n:
            print(total)
            exit()


d, n = map(int, input().split())
f(d, n)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N_MAX = 2e5+10;
char str[N_MAX];

int main() {
	scanf("%s", str);
	int n=strlen(str);
	int ans=n, tmp=0;
	for(int i=0; i<n; i++)
		if(str[i]=='S')
			tmp++;
		else if(tmp)
			tmp--, ans-=2;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    vector<ll> v(2*n);
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        if(i&1) v[i] = i*w-x, v[i+n] = (i+1)*w-x+MOD;
        else v[i] = i*w+x, v[i+n] = (i+1)*w+x+MOD;
    }
    sort(v.begin(),v.end(), [&](ll x, ll y){ return x%MOD < y%MOD;});
    ll ans = 0;
    ll cnt = 0;
    for (int i = 0; i < 2*n; ++i) {
        if(v[i] >= MOD) v[i] %= MOD, cnt--;
        else cnt++;
        if(cnt > 0){
            ans += (v[i+1]-v[i]+MOD*2)%MOD;
        }
    }
    cout << (w*n-ans)*h << "\n";
    return 0;
}


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

int main(void){
  int i;
  int n;
  int *w;
  int sum=0;//すべての重さ
  int s1=0;//s1の和
  int sa;//求める差の絶対値|s1-s2|=|sum-2*s1|
  int mae, ato;
  int ans;//答え

  scanf("%d", &n);
  w=(int *)malloc((n+1)*sizeof(int));
  //おもりの番号とインデックスを合わせる
  if(w == (int *)NULL){
    //エラーメッセージ
    printf("メモリ領域の確保に失敗しました。\n");
    exit(1);
  }

  w[0]=0;
  for(i=1; i<=n; i++){
    scanf("%d", &w[i]);
  }
  for(i=1; i<=n; i++){
    sum+=w[i];
  }

  for(i=0; i<=n; i++){
    s1+=w[i];
    sa=sum-2*s1;
    if(sa==0){
      ans=0;
      break;
    }
    if(i==1){
      if(sa<=0){
        ans=abs(sa);
        break;
      }
    }else{
      //sum-2*s1の符号が入れ替わったとき
      //入れ替わったときか、入れ替わる一個前が最小
      //1 3 1 1の時 sum=6
      //sは 6-2=4, 6-8=-2, ...となり2が最小
      if(sa<0){
        ato=sa;
        //一個前は
        //mae=ato+2*w[i]
        mae=ato+2*w[i];
        //前と後の絶対値が小さい方がans
        //mae>0 ato<0
        // printf("mae=%d, ato=%d\n", mae, ato);
        if(mae>-ato){
          ans=-ato;
        }else{
          ans=mae;
        }
        break;
      }
    }
  }

  // printf("sum=%d\n", sum);
  printf("%d\n", ans);
  free(w);
  return 0;
}


Measured memory_bytes: 128
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

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

int main(void) {
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    { 
        static void Main(string[] args)
        {
            string[] s =Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            if (a < b)
            {
                if (b < c)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }

            
            //int n =int.Parse(s);
        }
    }
}

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

using namespace std;

const int INF = 1e9 + 5;
const int N = 2e5 + 5;
const int MOD = 998244353;
const double EPS = 1e-9;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    long long x;
    cin >> x;
    long long cur = 100;
    int cnt = 0;
    while (cur < x) {
        cur += cur / 100;
        cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

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

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,K,ans=0;
  cin>>N>>K;
  if(N<=K){
    print(0);
    return 0;
  }
  vec v(N,0);
  rep(i,N)cin>>v[i];
  vrsort(v);
  rep(i,K)v[i]=0;
  rep(i,N)ans+=v[i];
  print(ans);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;


int main() {

    int N[4];
    int check[4] = {1, 9, 7, 4};

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

    for(int i=0; i<4; ++i)
    {
        bool flag = false;
        for(int j=0; j<4; ++j)
        {
            if(N[j]==check[i])
            {
                flag = true;
                break;
            }
        }
        if(!flag)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input_text = String::new();
    io::stdin() .read_line(&mut input_text)
        .expect("failed to read from stdin");

    let trimmed = input_text.trim();
    match trimmed.parse::<u32>() {
        Ok(i) => println!("{}", i.pow(3)),
        Err(..) => println!("this was not an integer: {}", trimmed),
    };
}


Measured memory_bytes: 5032
import math

def prime(x):
  p = {}
  last = math.floor(x ** 0.5)
  if x % 2 == 0:
    cnt = 1
    x //= 2
    while x & 1 == 0:
      x //= 2
      cnt += 1
    p[2] = cnt
  for i in range(3, last + 1, 2):
    if x % i == 0:
      x //= i
      cnt = 1
      while x % i == 0:
        cnt += 1
        x //= i
      p[i] = cnt
  if x != 1:
    p[x] = 1
  return p

N = int(input())

P = prime(N - 1)

if N == 2:
  print(1)
  exit()

ans = 1
for i in P.keys():
  ans *= P[i] + 1
ans -= 1

P = prime(N)
D = [1]
for i in P.keys():
  L = len(D)
  n = i
  for j in range(P[i]):
    for k in range(L):
      D.append(D[k] * n)
    n *= i


for i in D:
  if i == 1: continue
  t = N
  while (t / i == t // i):
    t //= i

  t -= 1
  if t / i == t // i:
    ans += 1

print(ans)


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

int main() {
  
  int N;
  cin >> N;
  
  //cout << (N / 100) * 100 + ((N - (N / 100) * 100) / 10) * 10 << endl;
  
  if(N / 100 == N - ((N / 100) * 100 + ((N - (N / 100) * 100) / 10) * 10)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

long long v[310][310];
char vaz[310][310];

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    long long sol=0,sol1=0;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            scanf("%lld",&v[i][j]);
            sol+=v[i][j];
        }
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
            {
                if(i!=j && v[i][k]!=0 && v[k][j]!=0 && v[i][j]==v[i][k]+v[k][j] && vaz[i][j]==0) {sol1+=v[i][j];vaz[i][j]=1;}
                if(v[i][k]!=0 && v[k][j]!=0 && (v[i][j]>v[i][k]+v[k][j])) {printf("-1");return 0;}
            }
    printf("%lld",(sol-sol1)/2);
    return 0;
}


Measured memory_bytes: 1024
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int n,m,a[13]={2,3,4,5,6,7,8,9,10,11,12,13,1},sol1,sol2;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=13;i++){
		if(a[i]==n)
		sol1=i;
		if(a[i]==m)
		sol2=i;
	}
	if(sol1<sol2)
	cout<<"Bob"<<endl;
	else if(sol1==sol2)
	cout<<"Draw"<<endl;
	else
	cout<<"Alice"<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




// 問題文誤読してた

string s;
string t;

void Plus() { cout << "+" << endl; }
void Minus() { cout << "-" << endl; }

vector<string> make(string x) {
    string tmp; tmp += x[0];
    vector<string> ret;
    int flg = 0; // 文字
    if (isdigit(x[0])) flg = 1;
    rep3(i, 1, sz(x)) {
        if ((flg ^ isdigit(x[i])) == 1) {
            flg ^= 1;
            ret.eb(tmp);
            tmp = x[i];
        } else {
            tmp += x[i];
        }
    }
    ret.eb(tmp);
    return ret;
}

void solve() {
    if (s == t) return Plus();
    auto v = make(s);
    // rep(i, sz(v)) cout << v[i] << " "; cout << endl;
    auto v2 = make(t);
    // rep(i, sz(v2)) cout << v2[i] << " "; cout << endl;
    
    rep(i, min(sz(v), sz(v2))) {
        if (v[i] == v2[i]) continue;
        if (isdigit(v[i][0]) && isdigit(v2[i][0])) {
            return (stoi(v[i]) < stoi(v2[i]) ? Plus() : Minus());
        }
        return (v[i] < v2[i] ? Plus() : Minus());
    }
    return (sz(v2) >= sz(v) ? Plus() : Minus());
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    cin >> s;
    
    rep(i, n) {
        cin >> t;
        solve();
    }
}





Measured memory_bytes: 3232
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String[] temp   = scanner.nextLine().split(" ");
		int h = Integer.parseInt(temp[0]);
		int n = Integer.parseInt(temp[1]);
		String[] temp2  = scanner.nextLine().split(" ");
		int sum = 0;

		for(int i = 0; i < n; i++) {

			sum += Integer.parseInt(temp2[i]);

			if(h <= sum ) {

				System.out.println("Yes");
				return;

			}

		}

		System.out.println("No");


	}

}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    string s,t;
    cin2(s,t);
    lli slen, tlen;
    slen = s.length();
    tlen = t.length();

    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    REPE_R(i,tlen,1) {
        // i 個分見る。
        REP(j,0,slen-tlen+1) {
            // s の j 個目からi個分比べる
            bool is_ok = true;
            REP(k,0,i) {
                if (s[j+k] != '?' && s[j+k] != t[k])
                    is_ok = false;
            }
            if (!is_ok)
                continue;

            // s のj個目からi個分は一致しているので、tlen-i個分が一致しているかをチェック
            is_ok = true;
            //cout << "oge" << endl;
            REPE(k,1,tlen-i) {
                //cout2(s[j+i+k], t[i+k]);
                if (s[j+i+k-1] != '?' && s[j+i+k-1] != t[i+k-1])
                    is_ok = false;
            }
            if (!is_ok)
                continue;

            //cout2(i,j);
            REP(k,0,tlen) {
                s[j+k] = t[k];
            }
            REP(k,0,slen) {
                if (s[k] == '?')
                    s[k] = 'a';
            }
            goto END;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;

END:
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int m = in.nextInt();
        String []a = new String[n];
        String []b = new String[m];
        for (int i = 0;i<n;i++){
            a[i] = in.next();
        }
        for (int i = 0;i<m;i++){
            b[i] = in.next();
        }
        Boolean pass=true;
        for(int i=0;i<n-m+1;i++){
            for(int j=0;j<n-m+1;j++){
                pass=true;
                for(int k =0;k<m;k++){
                    if(!pass)
                        break;
                    for(int l=0;l<m;l++){
                        if(a[i+k].charAt(j+l)!=b[k].charAt(l)){
                            pass=false;
                            break;
                        }
                    }

                }
                if(pass){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");

    }
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

      cin >> a >> b >> c;
      rrep(i,1,100000){
          if((a*i)%b==c){
              Cout("YES");
              return 0;
          }
      }
       Cout("NO");
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}



int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i <= r; i++){
	  if(i%d == 0){
		  ans++;
	  }
  }
  cout << ans << endl;;
  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String result = "Yes";

    for ( int i = 0; i < 2; i++) {
      int N = scanner.nextInt();
      if ( N % 2 == 0) {
        result = "No";
        break;
      }
    }
    System.out.println(result);
    scanner.close();
  }
}


Measured memory_bytes: 23380
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int lisA[200000],lisB[200000];
int main(){
    long long int N,M,K;
    cin>>N>>M>>K;
    long long int nowjikan=0;
    for(int i=0;i<N;i++)cin>>lisA[i];
    for(int i=0;i<M;i++)cin>>lisB[i];
    long long int nowA=0,nowB=0;
    while(1){
        if(nowA==N)break;
        if(nowjikan+lisA[nowA]<=K){
            nowjikan+=lisA[nowA];
            nowA++;
        }
        else break;
    }
    long long int ans=nowA+nowB;
    for(int i=0;i<M;i++){
        //printf("[%lld][%lld][%lld]\n",nowA,nowB,nowjikan);
        nowjikan+=lisB[i];
        nowB++;
        while(K<nowjikan){
            if(nowA==0){
                cout<<ans<<endl;
                return 0;
            }
            nowA--;
            nowjikan-=lisA[nowA];
        }
        ans=max(nowA+nowB,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6744
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int x;
    cin >> x;
    int ans = -1;
    if(x >= 400 && x <= 599){
        ans = 8;
    }
    else if(x >= 600 && x <= 799){
        ans = 7;
    }
    else if(x >= 800 && x <= 999){
        ans = 6;
    }
    else if(x >= 1000 && x <= 1199){
        ans = 5;
    }
    else if(x >= 1200 && x <= 1399){
        ans = 4;
    }
    else if(x >= 1400 && x <= 1599){
        ans = 3;
    }
    else if(x >= 1600 && x <= 1799){
        ans = 2;
    }
    else {
        ans = 1;
    }
    assert(ans!=-1);
    cout << ans << endl;
}

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

    solve();
}


Measured memory_bytes: 3660
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int n, m;
	scanf("%d %d", &n, &m);

	int M[m];
	for (int i = 0; i < m; ++i) {
		scanf("%d", &M[i]);
	}

	int V[n + 1];
	for (int i = 1; i <= n; ++i) {
		V[i] = 50000;
	}
	V[0] = 0;
	for (int i = 0; i < m; ++i) {
		for (int j = M[i]; j <= n; ++j) {
			V[j] = min(V[j], V[j - M[i]] + 1);
		}
	}
	cout << V[n] << endl;

	return 0;
}

Measured memory_bytes: 3336
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
A = 0
for j in range(a[1]):
    A = A + b[j]
c = A
d = 0
ans = 0
if a[0] == a[1]:
    for l in range(a[0]):
        ans=ans +((b[l] + 1)/2)
else:
    for i in range(a[1],a[0]):
        B = A - b[(i-a[1])] + b[i]
        if B > c:
            d = i - a[1] + 1
            c = B
        A = B

    for k in range(a[1]):
        ans =ans + ((b[d+k] + 1)/2)

print(ans)

Measured memory_bytes: 25604
#include<stdio.h>
int main(){
  int flag,j,n,a[100],temp,sum=0;
  flag=1;
  scanf("%d",&n);
  for(j=0;j<n;j++){
    scanf("%d",&a[j]);
  }
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
	sum++;
	flag=1;
      }
    }
  }
    for(j=0;j<n;j++){
      if(j==n-1)printf("%d\n",a[j]);
      else printf("%d ",a[j]);
    }
    printf("%d\n",sum);
    return 0;
}
  
      
    



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

const int INFTY =2147483647;
int L[200000],R[200000];

void merge(int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1] =R[n2]=INFTY;
    int i=0,j=0;
    for(int p=left;p<right;p++){
        if(L[i]<=R[j]) A[p]=L[i++];
        else A[p]=R[j++];
    }
}

void sort(int A[],int left,int right){
    if(left+1<right){
        int mid=(left + right)/2;
        sort(A,left,mid);
        sort(A,mid,right);
        merge(A,left,mid,right);
    }
}

//sort(A,0,n)で使用
int main(){
    int n,ans=0;
    int d[2005];
    cin>>n;
    for(int i=0;i<n;i++)cin>>d[i];
    sort(d,0,n);
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(d[k]<d[i]+d[j]) ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
while 1:
	N,K = map(int,raw_input().split())
	if N == 0: break
	S = map(int,raw_input().split())
	B = [map(int,raw_input().split()) for i in range(N)]
	for breed in B:
		for i in range(K):
			S[i] -= breed[i]
	print "Yes" if min(S) >= 0 else "No"

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

class Card {
    int hit, miss, diff;
    public:
    void set(int o, int x);
    int use_diff();
};

void Card::set(int o, int x) {
    hit = o;
    miss = x;
    diff = o - x;
}

int Card::use_diff() { return diff; }

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

    int diff_worst = 0;
    int diff_bad_better = INT_MIN;
    int diff_sum = 0;
    Card cards[m];
    for (int i=0; i<m; i++) {
        Card card = cards[i];
        int a, b; cin >> a >> b;
        card.set(a, b);
        diff_worst = min(card.use_diff(), diff_worst);
        if (card.use_diff() < 0) {
            diff_bad_better = max(card.use_diff(), diff_bad_better);
            diff_sum += card.use_diff();
        }
    }

    cout << - ( diff_sum - diff_worst ) / 2 << endl;
}


Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
import math

def mod_factorial(n):
    mod = 10**9+7

    if n < 1:
        return 1

    r = n
    for i in range(n-1):
        r = r*(i+1) % mod
    
    return r

def mod_pow(n,m):

    mod = 10**9+7
    r = 1

    while m > 0:
        if m & 1:
            r = r*n % mod
        n = n * n % mod
        m = m>>1

    return(r)



def mod_comb(n, k):
    mod = 10**9+7

    if n+k < 1:
        return 1
    
    a = mod_factorial(n)
    b = mod_pow(mod_factorial(k), mod-2)
    c = mod_pow(mod_factorial(n-k), mod-2)


    return (a * ((b * c) % mod)) % mod


a, b= map(int, input().split())

t = [a,b]

r = 0
mod = 10**9+7

x = (2*a-b)
y = (2*b-a)

if x%3 == 0 and y%3 == 0 and x*y >=0:
    m = int(x/3)
    n = int(y/3)

    r += mod_comb(n+m,m)

print(r)

Measured memory_bytes: 3064
#include<iostream>
#include<string.h>
#include<cstdio>
using namespace std;
int main()
{char str1[100];
 char str2[100];
char str3[1000];

scanf("%s",str1);
scanf("%s",str2);


 strcpy(str3,str2);
 strcat(str3,str1);
 printf("%s",str3);
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
//	int len=s.length();
	for(int i=0;i<s.size()-1&&s.size()>0;i++)
	//for(int i=0;i<len-1&&len>0;i++)
	{
		if(s[i]=='S'&&s[i+1]=='T')
		{
			s.erase(i,2);
			if(i==0)
			{
				i--;
			}
			else
			{
				i=i-2;
			}
		}
	}
	cout<<s.size()<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<P> a(n);
    for(int i=0; i<n; i++){
        int p; cin>>p;
        a[i]=P(p, i);
    }

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

    set<int> s;
    s.insert(-1), s.insert(n);

    ll ans=0;
    for(int i=0; i<n; i++){
        int p=a[i].second;
        s.insert(p);
        set<int>::iterator itr=s.find(p);
        auto ub=itr; ub++;
        auto lb=itr; lb--;
        ans+=(ll)(*ub-*itr)*(*itr-*lb)*a[i].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
    ll n,i,ans=0,d;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        ll k=n/i;
        ans=ans+i*k*(k+1)/2;
    }
    cout<<ans<<endl;
}


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

int main () {
  int n;
  cin >> n;
  vector<int> a(n);

  bool even = true;
  ll ans = 0;
  int m = 1e9 + 1;
  rep(i,n) {
    cin >> a[i];
    int ab = abs(a[i]);
    ans += ab;
    if(a[i] < 0) even = !even;
    m = min(m, ab);
  }

  cout << (even ? ans : ans - 2*m) << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    if (ans <= 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3612
from collections import deque

h,w=list(map(int,input().split()))
a=[[c for c in input()] for _ in range(h)]
visit=[[0]*w for _ in range(h)]
q=deque()

for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            deque.appendleft(q,(i,j,0))
            visit[i][j]=1
ans=0
while len(q)>0:
    i,j,cnt=deque.pop(q)

    ans=max(ans,cnt)

    for di,dj in [(-1,0),(1,0),(0,-1),(0,1)]:
        ni=i+di
        nj=j+dj
        if 0<=ni<h and 0<=nj<w and visit[ni][nj]==0:
            visit[ni][nj]=1
            deque.appendleft(q,(ni,nj,cnt+1))

print(ans)

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

static const int INF=1e9;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=5){
        cout << 0 << endl;
    }else if(a<=12){
        cout << b/2 << endl;
    }else{
        cout << b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  long int N, Ln, Ln1, Ln2, tmp;

  cin >> N;

  for(int i = 0; i <= N; i++){
    if(i == 0) Ln2 = 2;
    else if(i == 1){
        Ln = 1;
        Ln1 = 1;
    }else{
      Ln = Ln2 + Ln1;
      tmp = Ln1;
      Ln1 = Ln;
      Ln2 = tmp;
    }
  }

  cout << Ln << endl;

	return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N, M;
	LL K;
	cin >> N >> M >> K;
	vector<LL> A(N), B(M), A_sum(N+1), B_sum(M+1);
	rep(i,N) cin >> A[i];
	rep(i,M) cin >> B[i];
	rep(i,N) A_sum[i+1]=A_sum[i]+A[i];
	rep(i,M) B_sum[i+1]=B_sum[i]+B[i];
	int ans=0;
	rep(i,N+1){
		LL sum=A_sum[i];
		int res=i;
		if(sum>K) break;
		int b=upper_bound(B_sum.begin(),B_sum.end(),K-sum)-B_sum.begin();
		res+=b-1;
		ans=max(ans,res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvl a;

int main(){
	cin>>n>>m;
	a=vvl(n,vl(3));
	for(int i=0;i<n;i++) for(int j=0;j<3;j++) cin>>a[i][j];
	ll res=0;
	for(int i=0;i<1<<3;i++){
		vvl b(n,vl(4));
		for(int j=0;j<n;j++){
			for(int k=0;k<3;k++){
				b[j][k+1]=a[j][k];
				if(i&1<<k) b[j][0]+=a[j][k];
				else b[j][0]-=a[j][k];
			}
		}
		sort(b.rbegin(),b.rend());
		vl c(3);
		for(int j=0;j<m;j++) for(int k=0;k<3;k++) c[k]+=b[j][k+1];
		ll tmp=0;
		for(int j=0;j<3;j++) tmp+=abs(c[j]);
		res=max(res,tmp);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


const char* roma = "ixcm";
int dec(const string& s)
{
	int res = 0;
	for (int i = 0, t = 1; i < 4; ++i, t *= 10)
	{
		int k = s.find(roma[i]);
		if (k != -1)
		{
			if (k == 0 || !isdigit(s[k - 1]))
				res += t;
			else if (k > 0)
				res += t * (s[k - 1] - '0');
		}
	}
	return res;
}
string enc(int n)
{
	string res;
	for (int i = 0; i < 4; ++i, n /= 10)
	{
		int r = n % 10;
		if (r == 1)
			res = roma[i] + res;
		else if (r > 1)
			res = (char)('0' + r) + string() + roma[i] + res;
	}
	return res;
}
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		string a, b;
		cin >> a >> b;
		cout << enc(dec(a) + dec(b)) << endl;
	}
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    vector<int> T(n);
    for (int i = 0; i < n; i++)
        cin >> S[i] >> T[i];
    string X;
    cin >> X;
    int ans = 0;
    bool flag = false;
    for (int i = 0; i < n; i++){
        if (flag)
            ans += T[i];
        flag |= S[i] == X;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>


int main(void){

  char roman[101];
  int num[101];
  int sum;
  int i;  

  while(scanf("%s", roman)!=EOF){
    sum=0;

    for(i=0; i<strlen(roman); i++){
      if(roman[i]=='I'){
	num[i]=1;
      }
      else if(roman[i]=='V'){
	num[i]=5;
      }
      else if(roman[i]=='X'){
	num[i]=10;
      }
      else if(roman[i]=='L'){
	num[i]=50;
      }
      else if(roman[i]=='C'){
	num[i]=100;
      }
      else if(roman[i]=='D'){
	num[i]=500;
      }
      else if(roman[i]=='M'){
	num[i]=1000;
      }
    }

    sum+=num[0];
    for(i=1; i<strlen(roman); i++){
      if(num[i-1]<num[i]){
	sum-=(num[i-1]*2);
      }
      sum+=num[i];
    }

    printf("%d\n", sum);
  }
  

  return(0);
}



Measured memory_bytes: 2024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int i = 0;
  for(;;) {
    if (i >= k || i >= s.size()) {
      i--;
      break;
    }
    if (s[i] - '0' != 1) {
      break;
    }
    i++;
  }
  cout << s[i] - '0' << endl;
}

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

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

using namespace std;
#define ll long long int


int main()
{
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    swap(v[0],v[1]);
    swap(v[0],v[2]);
    for(int i=0;i<3;i++) cout << v[i] << " ";
}


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

public class Main {

    static class Question {
        int N, K;
        int[] arr;
        
        public int solve() {
            Arrays.sort(arr);
            int total = 0;
            for (int i = N-1; i >= N-K; i--) {
                total += arr[i];
            }
            return total;
        }
        
        public void main(FastScanner in, PrintWriter out) {
            N = in.nextInt();
            K = in.nextInt();
            arr = new int[N];
            for (int i = 0; i < N; i++) arr[i] = in.nextInt();
            out.println( solve() );
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) p( o[i][j] + " " );
                pl("");
            }
        }
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Question q = new Question();
        q.main(in, out);
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public void close() throws IOException { br.close(); }
    }
}


Measured memory_bytes: 21588