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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<998244353>;

void solve() {
  int n, s;
  cin >> n >> s;
  vi32 a(n);
  cin >> a;
  vector<vector<mint>> dp(n + 1, vector<mint>(s + 1));
  rep(i, n) {
    dp[i][0] += 1;
    repc(j, s) {
      dp[i + 1][j] += dp[i][j];
      if (j + a[i] <= s) dp[i + 1][j + a[i]] += dp[i][j];
    }
  }
  mint ans = 0;
  reps(i, n) ans += dp[i][s];
  cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
double dp[3010][3010];
signed main() {
    int n;
    cin >> n;
    rep(i,n) {
        double p;
        cin >> p;
        double np = 1-p;
        if(i==0) {
            dp[0][0] = np;
            dp[0][1] = p;
            continue;
        }
        rep(j,i+2) {
            if(i==0) dp[i][j] = dp[i-1][0]*np;
            else if(i==i+1) dp[i][j] = dp[i-1][j-1]*p;
            else dp[i][j] = dp[i-1][j-1]*p+dp[i-1][j]*np;
        } 
    }
    double ans = 0;
    FOR(i,n/2+1,n+1) {
        ans += dp[n-1][i];
        //cout << dp[n-1][i] << endl;
    }
    cout << setprecision(20)<<ans << endl;
  return 0;
}



Measured memory_bytes: 49856
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
ll a[1000000], sum;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, 3*n) cin >> a[i];
    sort(a, a+3*n);
    int cnt = 0, i = 3*n-2;
    while (cnt != n) {
        sum += a[i];
        i -= 2;
        cnt++;
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  while(s.size()) {
    s.pop_back();
    if(s.size() % 2) continue;
    bool ok = true;
    for(int i = 0; i < s.size() / 2; i++) {
      if(s[i] != s[s.size() / 2 + i]){
	ok = false;
	break;
      }
    }
    if(ok) {
      cout << s.size() << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;

  ll m = -1;
  for(ll i=1; i<=n; ++i) {
    if(i*(i+1)/2 == n) {
      m = i;
    }
  }
  
  // cout << m << endl;

  if(m == -1) {
    cout << "No" << endl;
    return 0;
  }

  vector<vector<ll>> ans(m+1);
  ll idx1 = 0, idx2 = 1, j = 1;
  for(ll i=m; i>=1; --i) {
    // cout << "i=" << i << endl;
    for(ll k=0; k<i; j++,k++) {
      // cout << idx1 << " " << idx2 << " " << j << endl;
      ans[idx1].push_back(j);
      ans[idx2].push_back(j);
      idx2++;
    }
    idx1++;
    idx2 = idx1+1;
  }

  cout << "Yes" << endl;
  cout << m+1 << endl;
  REP(i, m+1) {
    cout << ans[i].size();
    for(auto j: ans[i]) cout << " " << j;
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  string s; cin>>s; int k; cin>>k;
  int n=s.size();
  for(int i=0;i<n;i++) {
    if (s[i] == 'a') continue;
    int cs = 'z' - s[i] + 1;
    if (cs <= k) {
      s[i] = 'a'; k -= cs;
    }
  }
  if (k > 0) {
    k %= 26;
    for(int i=0;i<k;i++) {
      if (s[n-1] == 'z') s[n-1]='a';
      else s[n-1]++;
    }
  }
  cout<<s<<endl;
}

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

using namespace std;
typedef long long ll;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = min(x, y) * min(a + b, 2 * c);
    if (y > x) {
        int remain = y - x;
        ans += remain * min(b, 2 * c);
    } else {
        int remain = x - y;
        ans += remain * min(a, 2 * c);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n, x, a;
SAIKI:	
	cin >> n >> x;
	if( n == 0 && x == 0 ){ return 0; }
	for( int i = 1; i <= n ; i++ ){ for( int j = 1; j <= n; j++ ){ for( int k = 1; k <= n; k++ ){ if( i > j && j > k && i + j + k == x ){ ++a; } } } }
	cout << a << endl;
	a = 0;
goto SAIKI;

return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    
    int p[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}; //15
    int x[15] = {0};

    for(int i = 1 ; i <= n;i++){
        int t = i;
        rep(j,15){
            while(t%p[j] == 0){
                t /= p[j];
                x[j]++;
            }
        }
    }

    rep(i,15){
        rep(j,15){
            rep(k,15){
                if(x[i] >= 2 && x[j] >= 4 && x[k] >= 4 && i != j && j != k && k != i){
                    ans++;
                } 
            }
        }
    }
    ans /= 2;

    rep(i,15){
        rep(j,15){
            if(x[i] >= 14 && x[j] >= 4  && i != j){
                ans++;
            } 
        }
    }
    rep(i,15){
        rep(j,15){
            if(x[i] >= 24 && x[j] >= 2  && i != j){
                ans++;
            } 
        }
    }
    rep(i,15){
        
            if(x[i] >= 74){
                ans++;
            } 
        
    }




    cout << ans << endl;

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include<map>
#include<cstdio>

int main(){
    int n;
    scanf("%d", &n);

    long long ans = 1;
    const long long mod = 1e9 + 7;

    std::map<int, long long> factors;
    for(int i = 2; i <= n; i++){
        for(int j = 2, d = i; d > 1; j++){
            while(d % j == 0){
                factors[j]++;
                d /= j;
            }
        }
    }

    for(auto p : factors) ans = ans *(1 + p.second) % mod;
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    ls = [0] * (n + 1)
    ls[0] = 2
    ls[1] = 1
    for i in range(2, len(ls)):
        ls[i] = ls[i-1] + ls[i-2]
    print(ls[-1])


if __name__ == '__main__':
    solve()


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

public class Main{
    public static void main(String[] args)throws Exception{
        Queue<String> que=new ArrayDeque<>();
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        if(k<=12){
            System.out.println(k);
            System.exit(0);
        }
        int count=2;
        for(int i=2;i<=12;i++){
            que.add(Integer.toString(i));
        }
        while(true){
            if(count==k){
                break;
            }
            String str=que.remove();
            
            int l=str.length();
            int i=(str.charAt(l-1)=='0' ? 0 : -1);
            int j=(str.charAt(l-1)=='9' ? 0 : 1);
            for(;i<=j;i++){
                que.add(str + (char)(str.charAt(l-1)+i));
            }
            count++;
        }
        System.out.println(que.remove());
    }
}

Measured memory_bytes: 54744
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

clock_t start=clock();
const double tl = 1.9;
const double T0=2e3;
const double T1=6e2;
double T=T0;

const int n=26;
int d;
VI c(n);
VVI s(365,VI(n));

ll f(VI a){
	ll ret=0;
	VI last(n,-1);
	REP(i,d){
		last[a[i]]=i;
		ret+=s[i][a[i]];
		REP(j,26)
			ret-=c[j]*(i-last[j]);
	}
	return ret;
}

int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	VI ans(d,10);
	int cnt=0;
	while(1){
		cnt++;
		if(cnt%100==0){
			double t=(double)(clock()-start)/CLOCKS_PER_SEC/tl;
			if(t>=1.0)
				break;
			T=pow(T0,1.0-t)*pow(T1,t);
		}
		ll oldscore=f(ans);
		if(rand()%2){
			int cd=rand()%d;
			int old=ans[cd];
			ans[cd]=rand()%26;
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			ans[cd]=old;
		}
		else{
			int cd1=rand()%(d-1);
			int cd2=cd1+1+(rand()%(d-cd1-1));
			swap(ans[cd1],ans[cd2]);
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			swap(ans[cd1],ans[cd2]);
		}
	}
	REP(i,d)
		cout << ans[i]+1 << endl;
	//cout << f(ans) << endl;
	return 0;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S, T; cin >> S >> T;
    int sol = 0;

    for(int i=0; i<S.size(); i++){

        if(S.at(i) != T.at(i)){
            sol++;
        }


    }
    cout << sol << endl;

}

Measured memory_bytes: 3916
N,L = input().split()
N,L = int(N),int(L)


if(L>=0):
    print(int(0.5*N*(N+1)+N*L-N-(L)))
else:
    n = min([-L,N-1])
    print(int(0.5*N*(N+1)+N*L-N-(L+n)))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector <int> h(N);
  int m  = 2 * 1e9;
  int mi = 0;
  for (int i = 0; i < N; i++) {
	  cin >> h[i];
	  if (abs(1000 * T - 6 * h[i] - 1000 * A) < m) {
		  m  = abs(1000 * T - 6 * h[i] - 1000 * A);
		  mi = i + 1;
		}
	}
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------

int main(){
  int N;
  cin >> N;
  int x[N];
  int y[N];
  rep(i,N) cin >> x[i],y[i]=x[i];
  sort(y,y+N);
  int m = y[N/2-1],M = y[N/2];
  rep(i,N){
    if(M <= x[i]) cout << m << endl;
    else cout << M << endl;
  }
 
  return 0;
}







Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        else{
            for(int j = 0; j < H; j++){
                for(int i = 0; i < W; i++){
                    cout << "#";
                }
                cout << "\n";
            }
            cout << "\n";
            
        }
    }
    return 0;
    
}

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

int main(){
  int N,x;
  cin >> N;
  x=1;
    
  vector<string> vec(N);
   for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
 
  for (int i = 1; i < N; i++) {
    if( vec.at(i-1) != vec.at(i)){
    x++;
  }
  }
    cout << x <<endl;
}


Measured memory_bytes: 9596
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
      int N= int.Parse(Console.ReadLine());
      int AK=0;
      int sum=0;
      string[] input = Console.ReadLine().Split(' ');
      var A=new int[N];
      for(int i=0;i<N;i++){
        A[i]=int.Parse(input[i]);
      }
      for(int i=0;i<N;++i){
        AK=A[i];
        if(AK%2==0){
          if(AK%3!=0){
            if(AK%5!=0){
              sum++;
            }
          }
        }
      }
      if(sum>0){
        Console.WriteLine("DENIED");
      }
      else{
        Console.WriteLine("APPROVED");
      }
    }
}
      


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << endl;
}


Measured memory_bytes: 888
from functools import reduce

reduce(lambda a, b: a + b, [[1,2,3],[4,5,6],[7,8,9]])  #=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

abflatten = sum(ab, [])

# print(abflatten)

for i in range(N):
  print(abflatten.count(i+1))
  


Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] ans = new int[10000];
		int i = 0;
		while(true) {
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();
			if(op.equals("+")) {
				ans[i] = a + b;
			}
			else if(op.equals("-")) {
				ans[i] = a - b;
			}
			else if(op.equals("*")) {
				ans[i] = a * b;
			}
			else if(op.equals("/")) {
				ans[i] = a / b;
			}
			else if(op.equals("?")) {
				break;
			}
			i++;
		}
		for(int j = 0; j < i; j++) {
			System.out.println(ans[j]);
		}
	}
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

  for (int i = 1; i <= 5; ++i) {
    int a; cin >> a;
    if (!a) {
      cout << i << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>v;

int main(){
	ll m,n,tmp;

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n>>m;

	int sum = 0;

	for(int i=0;i<n;i++){
		cin>>tmp;
		v.push_back(tmp);
		sum += tmp;
	}
	sort(v.begin(),v.end());
	if(sum % (4*m)==0)
		sum = sum / (4 * m);
	else
		sum = (sum + 4*m) / (4 * m);
	//cout<<sum<<endl;
	bool flag = false;
	for(int i=v.size()-m;i<v.size();i++){

		if(v[i] < sum)
			flag = true;
	}
	if(flag){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  cin >> n;
  cout << n/3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n; i++)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> ans;
    if(n%2 == 1){
        rep1(i, n+1){
            for(int j=i+1; j<n+1; j++){
                if(i+j == n) continue;
                ans.push_back(make_pair(i, j));
            }
        }
    }else{
        rep1(i, n+1){
            for(int j=i+1; j<n+1; j++){
                if(i+j == n+1) continue;
                ans.push_back(make_pair(i, j));
            }
        }
    }
    cout << ans.size() << endl;
    for(auto &i: ans) cout << i.first << " " << i.second << endl;


}

Measured memory_bytes: 384
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月08日 星期一 01时37分00秒
File Name     :D.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;

bool prime[N];
int s[N];

void solve(){

	for(int i=2;i<N;i++) prime[i]=1;

	for(int i=2;i<N;i++){
		if(prime[i]){
			for(int j=2*i;j<N;j+=i){
				prime[j]=0;
			}
		}
	}

	for(int i=2;i<N;i++){
		s[i]=s[i-1];
		if((i&1) && prime[i] && prime[(i+1)/2]) s[i]++;
	}

	int Q;
	scanf("%d",&Q);
	while(Q--){
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",s[r]-s[l-1]);
	}

}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //?????????????????§??????????????????????????????????????????
            while(true){ 
                string[] s = Console.ReadLine().Split(' ');
                int a = int.Parse(s[0]);
                int b = int.Parse(s[2]);
                string op = s[1];


                //op?????????£?????´????????????????????????
                if (op == "?") break;


                //op????????????????????\???????¨???????????????????
                switch (op)
                {
                    case "+": Console.WriteLine(a + b);
                        break;

                    case "-": Console.WriteLine(a - b);
                        break;

                    case "*": Console.WriteLine(a * b);
                        break;

                    case "/": Console.WriteLine(a / b);
                        break;

                    default : break;
                }


            }

        }
    }
}

Measured memory_bytes: 5704
import Control.Monad
import Control.Monad.ST
import Data.List
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Unboxed.Mutable as MV

main=do
    [n,k]<-map read.words<$>getLine::IO[Int]
    as<-map read.words<$>getLine::IO[Int]
    putStrLn $ ["Second", "First"] !! min 1 (f k as)

f k as = runST $ do
    kv <- MV.new (k+1) :: ST s (MV.STVector s Int)
    forM_ [0..k] $ \i -> do
        g <- fmap (gr.((-1):).sort) $ forM as $ \a -> if i-a>=0 then MV.read kv (i-a) else pure (-1)
        MV.write kv i g
    MV.read kv k

gr [a] = a+1
gr (a:b:x) | a+1>=b = gr (b:x) |otherwise = a+1

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int A, B, C;

int main(){
	cin >> A >> B >> C;
	if (A == B&&B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;
const  LL M = 1e9 + 7;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	std::cin >> n;
	LL a[n + 1] = {1};
	for (int i = 3; i <= n; ++i) {
		for (int j = 3; j <= i; ++j) {	
			a[i] += a[i - j];
		}
		a[i] %= M;
	}
	print(a[n]);
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD NUM000007
#define EPS 0.0000001
#define NUM 1440
using namespace std;

struct Info{
	void init(){
		latest_in = 0;
		sum = 0;
		exist = false;
	}

	int latest_in,sum;
	bool exist;
};

Info info[1000];
char buf[20];
int pg_num,pg_id[1000];


int getDate(){
	return 1000*(buf[0]-'0')+100*(buf[1]-'0')+10*(buf[3]-'0')+(buf[4]-0);
}

int getTime(){
	return 60*(10*(buf[6]-'0')+(buf[7]-'0'))+10*(buf[9]-'0')+(buf[10]-'0');
}

int getID(){
	return 100*(buf[14]-'0')+10*(buf[15]-'0')+(buf[16]-'0');
}

bool isFirst(int id){

	for(int i = 0; i < pg_num; i++){
		if(pg_id[i] == id)return false;
	}
	return true;
}

int main(){

	int N,maximum,pre_date,tmp_date,tmp_time,id;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		info[0].init();
		for(int i = 0; i < pg_num; i++)info[pg_id[i]].init();
		pg_num = 0;

		getchar();
		fgets(buf,20,stdin);

		pre_date = getDate();
		tmp_time = getTime();
		id = getID();

		info[id].exist = true;
		info[id].latest_in = tmp_time;
		if(id != 0){
			pg_id[pg_num++] = id;
		}

		for(int loop = 1; loop <= N-1; loop++){
			fgets(buf,20,stdin);
			tmp_date = getDate();
			tmp_time = getTime();
			id = getID();

			if(tmp_date != pre_date){

				if(info[0].exist){

					for(int i = 0; i < pg_num; i++){
						if(info[pg_id[i]].exist){

							info[pg_id[i]].sum += NUM - max(info[pg_id[i]].latest_in,info[0].latest_in);
							info[pg_id[i]].exist = false;
						}
					}
					info[0].exist = false;
				}else{

					for(int i = 0; i < pg_num; i++){
						info[pg_id[i]].exist = false;
					}
				}

				info[id].exist = true;
				info[id].latest_in = tmp_time;
				if(id != 0){
					if(isFirst(id)){
						pg_id[pg_num++] = id;
					}
				}

			}else{

				if(buf[12] == 'I'){

					info[id].exist = true;
					info[id].latest_in = tmp_time;
					if(id != 0){
						if(isFirst(id)){
							pg_id[pg_num++] = id;
						}
					}

				}else{

					if(id == 0){
						info[0].exist = false;

						for(int i = 0; i < pg_num; i++){
							if(info[pg_id[i]].exist){
								info[pg_id[i]].sum += tmp_time - max(info[0].latest_in,info[pg_id[i]].latest_in);
							}
						}

					}else{
						info[id].exist = false;

						if(info[0].exist){
							info[id].sum += tmp_time - max(info[0].latest_in,info[id].latest_in);
						}else{
							//Do nothing
						}
					}
				}
			}
			pre_date = tmp_date;
		}

		maximum = 0;
		for(int i = 0; i < pg_num; i++){
			maximum = max(maximum,info[pg_id[i]].sum);
		}

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

	}

	return 0;
}

Measured memory_bytes: 2664
import math

N, K = map(int, input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

for i in range(1, K+1):
  if N - K + 1 < i:
    print(0)
  else:
    print((combinations_count(N-K+1, i) * combinations_count(K-1, i-1)) % (10**9 + 7))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int maxn=1e5+5;
typedef long long ll;
const int mod=1e9+7;
int a[2005];
int ksm(int x,int y){
    x%=mod;
    int res=1;
    while(y){
        if(y&1)res=(res*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
    return res;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    if(n==1){
        cout<<"0"<<endl;
        return 0;
    }
    if(n==2){
        cout<<"2"<<endl;
        return 0;
    }
    int ans=(ksm(10,n)-2*ksm(9,n)+ksm(8,n)+2*mod)%mod;
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 3656
N = int(input())
a = tuple(map(int, input().split()))
b = [-1] * N
for i in range(N//2, N):
    b[i] = 1 if a[i] == 1 else 0
for j in range(N//2-1, -1, -1):
    acc = sum([b[i] for i in range(2*j+1, N, j+1)])%2
    b[j] = acc ^ a[j]
ans = len([i for i in b if i == 1])
print(ans)
if ans == 0:
    exit()
print(*[j+1 for j, v in enumerate(b) if v == 1])

Measured memory_bytes: 137028
a,b,c,d = map(int,input().split())
takahashi = a
aoki = c
count_takahashi = 0
count_aoki = 0

while takahashi > 0:
    count_aoki += 1
    takahashi -= d

while aoki > 0:
    count_takahashi += 1
    aoki -= b

if count_takahashi <= count_aoki:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
       #define int long long
        #define mod  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------

ll frac[200010];
ll inv[200010];

ll saikif(ll a,int n){
  if(n==1) return a%mod;
  else if(n%2==0){
    ll q=saikif(a,n/2);
    return (q*q)%mod;
  }
  else return (a*saikif(a,n-1))%mod;
}

void gyakugen(){
  frac[0]=1;
  for(int i=1;i<=200000;i++) frac[i]=(frac[i-1]*i)%mod;
  for(int i=0;i<=200000;i++) inv[i]=saikif(frac[i],mod-2);
}


ll C(int n,int k){
	if(k<0|| k>n) return 0;
	ll ans=frac[n];
	ans*= inv[n-k];
	ans %=mod;
	ans *= inv[k];
	ans %=mod;
	return ans;
}


signed main(){
int w,h,a,b;
	cin>>h>>w>>a>>b;
	gyakugen();
	ll ans=1;
	ans= C(h-a+b-2,b-1);
	ans += C(h-a+b-2,b);
	ans%=mod;
	ans *= C(w-b+a-1,a);
	ans %=mod;
//	cout<<ans<<endl;
	for(int i=b+2;i<=w;i++){
		ll d=C(i+h-a-3,i-1);
		d *= C(w-i+a,a);
		d %=mod;
		
		ans += d;
		ans %=mod;
		
	}
	
	cout<<ans<<endl;
	
	return 0;
        }


Measured memory_bytes: 3328
use proconio::input;

fn main() {
    if let Some(ans) = solve() {
        println!("{}", ans)
    } else {
        println!("-1")
    }
}

fn solve() -> Option<u64> {
    input!(n: usize, a: [u64; n + 1]);
    if n == 0 {
        return if a[0] <= 1 { Some(a[0]) } else { None };
    }
    let mut s = a.clone();
    for i in (1..=n).rev() {
        s[i - 1] += s[i];
    }
    let mut b = vec![0; n];
    b[0] = 1u64.checked_sub(a[0])?;
    for i in 1..n {
        let bmax = (b[i - 1] * 2).checked_sub(a[i])?.min(s[i + 1]);
        let bmin = b[i - 1].saturating_sub(a[i]);
        if bmin > bmax {
            return None;
        }
        b[i] = bmax;
    }
    if n > 0 && a[n] <= b[n - 1] * 2 {
        Some(a.iter().sum::<u64>() + b.iter().sum::<u64>())
    } else {
        None
    }
}


Measured memory_bytes: 5096
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int A, B;
    cin >> A >> B;

    int count = 0;
    FOR(i, A, B+1){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]){
            count++;
        }   
    }    

    p(count);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

template<typename T>
struct Sum_2D{
  vector<vector<T>>cul;
  bool flag;
  Sum_2D(int h,int w):cul(h+1,vector<T>(w+1)){
    flag=false;
  }

  void add(int x,int y,T val){//0インデックス
    ++x;++y;
    if(x>=cul.size()||y>=cul[0].size())return;
    cul[x][y]+=val;
  }

  void build(){
    flag=true;
    for(int i=1;i<cul.size();++i){
      for(int j=1;j<cul[i].size();++j){
        cul[i][j]+=cul[i][j-1]+cul[i-1][j]-cul[i-1][j-1];
      }
    }
  }

  T query(int lb_x,int lb_y,int ub_x,int ub_y){
    //lb_x,lb_y:左下(含む),ub_x,ub_y:右上(含まない)
    //0インデックスに直す
    assert(flag==true);
    return cul[ub_x][ub_y]-cul[ub_x][lb_y]-cul[lb_x][ub_y]+cul[lb_x][lb_y];
  }
};


void solve()
{
	ll n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	sort(rall(a));
	ll ans=0;
	ans+=a[0];
	rep(i,n-2){
		ans+=a[i/2+1];
	}
	cout<<ans;
}

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


Measured memory_bytes: 4776
#include <stdio.h>
#include <ctype.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  char *it;

  for ( ; ; )
  {
    char s[ 128 ], *p;
    char m;

    scanf ( " %s %c", s, &m );
    if ( m == 'X' ) break ;

    p = s;
    for ( it = s; *it != '\0'; ++it )
    {
      if ( *it == '_' )
      {
        it[ 1 ] = toupper ( it[ 1 ] );
        continue ;
      }
      *( p++ ) = *it;
    }
    *p = '\0';

    s[ 0 ] = tolower ( s[ 0 ] );
    switch ( m )
    {
      case 'U':
        s[ 0 ] = toupper ( s[ 0 ] );
        puts ( s );
        break ;
      case 'L':
        puts ( s );
        break ;
      case 'D':
        for ( it = s; *it != '\0'; ++it )
        {
          if ( isupper ( *it ) )
          {
            printf ( "_%c", tolower ( *it ) );
          }
          else
          {
            putchar ( *it );
          }
        }
        puts ( "" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int y,m,d;

int main(){
	while(cin>>y>>m>>d){
		if(y>1989)cout<<"heisei "<<y-1988;
		else if(y==1989){
			if(m>1)cout<<"heisei 1";
			else if(d>7)cout<<"heisei 1";
			else cout<<"showa 64";
		}
		else if(y>1926)cout<<"showa "<<y-1925;
		else if(y==1926){
			if(m==12&&d>24)cout<<"showa 1";
			else cout<<"taisho 15";
		}
		else if(y>1912)cout<<"taisho "<<y-1911;
		else if(y==1912){
			if(m>7)cout<<"taisho 1";
			else if(m==7&&d>29)cout<<"taisho 1";
			else cout<<"meiji 45";
		}
		else if(y>1868)cout<<"meiji "<<y-1867;
		else if(y==1868){
			if(m>9)cout<<"meiji 1";
			else if(m==9&&d>7)cout<<"meiji 1";
			else {cout<<"pre-meiji"<<endl;continue;}
		}
		else {cout<<"pre-meiji"<<endl;continue;}
		cout<<" "<<m<<" "<<d<<endl;
	}
}

Measured memory_bytes: 0
program judge_status_summary
  implicit none
  integer :: n, i, k, c(4) = 0
  character(1) :: s
  read(*,*) n
  do i = 1, n
    read(*,*) s
    select case (s)
    case ('A')
      k = 1
    case ('W')
      k = 2
    case ('T')
      k = 3
    case ('R')
      k = 4
    end select
    c(k) = c(k) + 1
  end do
  write(*,'(a,x,a,x,i0)') 'AC', 'x', c(1)
  write(*,'(a,x,a,x,i0)') 'WA', 'x', c(2)
  write(*,'(a,x,a,x,i0)') 'TLE', 'x', c(3)
  write(*,'(a,x,a,x,i0)') 'RE', 'x', c(4)
end program judge_status_summary

Measured memory_bytes: 2932
#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()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    ll cnt = 0;
    ll ans = 0;
    rep(i, s.size()){
        if(s[i] == 'W'){
            ans += i - cnt;
            cnt++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

class Proc{
    string name;
    int time;
    public:
    Proc(string n, int t): name(n), time(t){}
    Proc(): name(""), time(0){}
    int exec(int q){return time -= q;};
    string get_name(){return name;};
    int get_time(){return time;};
};

int main(int argc, char* argv[]) {
    int n, q, time, cnt = 0;
    string name;
    cin >> n >> q;
    Proc queue[n];

    for (int i = 0; i < n; i++){
        cin >> name >> time;
        queue[i] = Proc(name, time);
    }

    int size = n, abstime = 0, last = 0, i = 0, tmp;
    while (size){
        abstime += q;
        tmp = queue[i].exec(q);
        if (tmp <= 0){
            abstime += tmp;
            cout << queue[i].get_name() << " " << abstime << "\n";
            size--;
        }else{
            queue[last] = queue[i];
            last = ++last % n;
        }
        i = ++i % n;
    }
    return 0;
}



Measured memory_bytes: 6280
str = gets.split
H,W,A,B = str[0].to_i, str[1].to_i, str[2].to_i, str[3].to_i

for i in 1..H do
    for j in 1..W do
        if (i <= B && j <= A) || (i > B && j > A)
            print 0
        else
            print 1
        end
    end
    puts
end

Measured memory_bytes: 2812
#include<stdio.h>
#include<string>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include <cmath>
#include <limits>
#include <numeric>
#include <cmath>
#include <limits>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n;
    ll ans;
    scanf("%lld",&n);
    int a = int(sqrt(n));
    //printf("%d\n",a);
    for(int i=a;i>=1;i--){
        if(n%i==0){
            ans = i+(n/i)-2;
            break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
S = rs()
x = 0
ans = 0
for s in S:
    if s == 'I':
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10
const int MAX_N =10000000;


bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll par[MAX_N],ranking[MAX_N];

void init(ll n){
    rep(i,n){
        par[i]=i;
        ranking[i]=0;
    }
}

ll find(ll x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(ranking[x]<ranking[y]) par[x]=y;
    else{
        par[y]=x;
        if(ranking[x]==ranking[y]) ranking[x]++;
    }
}

bool same(ll x,ll y){
    return find(x)==find(y);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll l,r,d;
    cin>>l>>r>>d;
    ll count=0;
    for(ll i=l;i<=r;i++){
        if(i%d==0) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3636