akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include<bits/stdc++.h>
#define maxn 10010
#define maxl 5010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define IL inline
#define ss system
using namespace std;

int F[maxn][maxl],n,m;
const int c[]={0,2,5,5,4,5,6,3,7,6};
bool vis[maxn];
vector<int> v;
template <class T> void read(T &x){
	char ch=x=0;
	bool fl=false;
	while(!isdigit(ch))
		fl|=ch=='-',ch=getchar();
	while(isdigit(ch))
		x=x*10+ch-'0',ch=getchar();
	x=fl?-x:x;
}
int f(int x,int y){
	if(!y)
		return !x;
	if(~F[x][y])
		return F[x][y];
	for(int i=v.size()-1;~i;i--){
		if(x>=c[v[i]]&&f(x-c[v[i]],y-1))
			return F[x][y]=true;
	}
	return F[x][y]=false;
}
void g(int x,int y){
	if(!y)
		return;
	for(int i=v.size()-1;~i;i--){
		if(x>=c[v[i]]&&f(x-c[v[i]],y-1)){
			printf("%d",v[i]),g(x-c[v[i]],y-1);
			return;
		}
	}
}
int main(){
	read(n),read(m);
	for(int i=1,x;i<=m;i++)
		read(x),v.pb(x),vis[x]=1;
	sort(v.begin(),v.end());
	memset(F,-1,sizeof(F));
	for(int i=n/2;i;i--){
		if(f(n,i)){
			g(n,i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 196352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

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

  int ans = 10 - X/200;

  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    if (d * d >= x * x + y * y) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll a;
string b;

ll solve() {
    ll c = (b[0]-'0') * 100 + (b[2]-'0') * 10 + (b[3]-'0');
    return a * c / 100;
}

void input() {
    cin >> a >> b;
}

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

    input();
    cout << solve() << endl;
}


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

int main(){
	string s,t;
	int n,a=0,b=0;

	cin >>n;
	for(int i=0;i<n;++i){
		cin >>s >>t;
		if(s>t) a+=3;
		else if(s<t) b+=3;
		else{
			a++;
			b++;
		}
	}
	cout <<a <<" " <<b <<endl;
	return 0;
}

Measured memory_bytes: 3172
N = int(input())
d = input().split()
 
for i in range(len(d)):
    d[i] = int(d[i])
    
Total = 0
for i in range(len(d)-1):
    for j in range(1, len(d)-i):
        #print(d[i],d[i+j])
        Total += d[i]*d[i+j]
    
print(Total)


Measured memory_bytes: 2940
/**
 * There is a start and there is no end in the space. ---Infinity.
 * It ruins and goes though there is also a start in stars. ---Finite.
 * Only the man who has wisdom can read the most foolish one from the history.
 * Fishes living in the sea doesn't know the life in the land.
 * It also ruins and goes if they have wisdom.
 * It funnier that man exceeds the speed of light than fish start living in the land.
 * It can be said that this is an final ultimatum from the god to the people who can fight.
 *
 * Steins;Gate
 */

#include <bits/stdc++.h>

typedef long long LL;
const int N = 5010;

LL f[N][N];
int a[N], p[N];

int main() {

    int n;
    LL A, B;
    scanf("%d%lld%lld", &n, &A, &B);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        p[a[i]] = i;
    }
    memset(f, 0x3f, sizeof(f));
    /// DP
    f[0][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < i; j++) {
            /// f[i][j]
            /*for(int k = 0; k < i; k++) {
                /// f[i][j] <- f[i - 1][k]
                if(p[i] < p[k]) {
                    f[i][j] = std::min(f[i][j], f[i - 1][k] + A);
                }
                else {
                    f[i][j] = std::min(f[i][j], f[i - 1][k] + B);
                }
            }*/
            if(p[i] < p[j]) {
                f[i][j] = f[i - 1][j] + A;
            }
            else {
                f[i][j] = f[i - 1][j] + B;
                f[i][i] = std::min(f[i][i], f[i - 1][j]);
            }
        }
        /*for(int j = 0; j <= i; j++) {
            printf("%3lld ", f[i][j]);
        }
        puts("");*/
    }


    LL ans = 4e18;
    for(int i = 0; i <= n; i++) {
        ans = std::min(ans, f[n][i]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 196352
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	string S, T; cin >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3036
function Main(input) {
    input = input.trim().split(" ");
    var P = parseInt(input[0],10);
    var Q = parseInt(input[1],10);
    var R = parseInt(input[2],10);

    console.log(Math.min(P+Q,Q+R,R+P));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll w,h;
  while(cin >> w >> h && w && h){
    vector<vector<ll>> v(w * 2+1,vector<ll>(h*2+1,0));
    rep(j,h-1){
      rep(i,w-1){
        cin >> v[i*2+1][2*j];
      }
      rep(i,w){
        cin >> v[i*2][2*j+1];
      }
    }
    rep(i,w-1){
      cin >> v[i*2+1][(h-1)*2];
    }
    queue<pll> q;
    q.push({0,0});
    v[0][0] = 1;
    ll depth = 1;
    while(q.size()){
      ll s = q.size();
      rep(i,s){
        if(q.size()){
          auto p = q.front();q.pop();
          rep(i,4){
            int nx = p.fi + dx[i]*2,ny = p.se + dy[i]*2;
            if(value(nx,ny,w*2,h*2) && v[nx][ny] == 0){
              if(value(nx-dx[i],ny-dy[i],w*2+1,h*2-1) && v[nx-dx[i]][ny-dy[i]] == 0){
                q.push({nx,ny});
                v[nx][ny] = depth+1;
                if(nx == (w-1)*2 && ny == (h-1)*2){
                  q = queue<pll>();
                  i = s;
                  break;
                }
              }
            }
          }
        }
      }
      ++depth;
      if(depth > 900) break;
    }
//     rep(i,h*2){
//       rep(j,w*2+1){
//         cout << v[j][i]<< " ";
//       }
//       cout << endl;
//     }
    cout << v[(w-1)*2][(h-1)*2]<<endl;
  }
  return 0;
}

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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;

const int VMAX = 4000000;

int N, K;
int fct[VMAX + 5], ifct[VMAX + 5];

int dp[2005][2005];

int power(int x, int y)
{
    int p = x, r = 1;
    while(y)
    {
        if(y & 1)   r = (1LL * r * p) % mod;
        p = (1LL * p * p) % mod;
        y >>= 1;
    }
    return r;
}

int C(int N, int K)
{
    int ans = fct[N];
    ans = (1LL * ans * ifct[K]) % mod;
    ans = (1LL * ans * ifct[N - K]) % mod;
    return ans;
}

void precalc()
{
    fct[0] = 1;
    for(int i = 1; i <= VMAX; i++)
        fct[i] = (1LL * fct[i - 1] * i) % mod;
    ifct[VMAX] = power(fct[VMAX], mod - 2);
    for(int i = VMAX - 1; i >= 1; i--)
        ifct[i] = (1LL * ifct[i + 1] * (i + 1)) % mod;
    ifct[0] = 1;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    precalc();

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

    if(N == 1 || K == 1)
    {
        printf("1\n");
        return 0;
    }

    /*dp[N][N] =

    dp[i][j] = dp[i + 1][j];
    dp[i][j] += dp[i][j + 1] * C( (N - i + 1) + (N - j) * (K - 1) - 1 , K - 1 );*/

    /// DP[i][j] - i-th white ball, j-th colors


    dp[N + 1][N + 1] = 1;
    for(int i = N + 1; i >= 1; i--)
        for(int j = i == N + 1 ? N : i; j >= 1; j--)
        {
            int white = dp[i + 1][j];
            int color = ( 1LL * dp[i][j + 1] * C( (N - i + 1) + (N - j + 1) * (K - 1) - 1 , K - 2 ) ) % mod;
            dp[i][j] = (white + color) % mod;
        }

    int ans = (1LL * dp[1][1] * fct[N]) % mod;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 46464
import string
str_map = {num+1: item for num, item in enumerate(string.ascii_lowercase)}
def main():
	n = int(input())
	ans = []
	while n > 26:
		tmp = 26 if n%26 == 0 else n%26
		ans.append(str_map[tmp])
		n = (n-1) // 26
	ans.append(str_map[n])
	ans_str = ''.join(ans)
	print(ans_str[::-1])
	return

if __name__ == "__main__":
	main()

Measured memory_bytes: 9984
ans = []
add = ans.append
for line in open(0).readlines():
    H, W = map(int, line.split())
    if not H:
        break
    r = "#"*W+"\n"
    add(r)
    add(("#"+"."*(W-2)+"#\n")*(H-2))
    add(r)
    add("\n")
open(1, 'w').writelines(ans)


Measured memory_bytes: 5648
s = input()

aa = int(s[0]+s[1])
bb = int(s[2]+s[3])

if bb <= 12 and bb >=1:
    if aa <= 12 and aa >=1:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if aa <=12 and aa >=1:
        print("MMYY")
    else:
        print("NA")




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



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long H,W;

  cin >> H >> W;

  vector<string> as(H);
  vector<bool> vartical(W, true);
  vector<bool> horizontal(H, true);

  for(long long i = 0; i < H; i++){
    cin >> as.at(i);

    bool isall = true;

    for(long long j = 0; j < W; j++){
      if(as[i][j] == '#'){
        isall = false;
        vartical[j] = false;
      }
    }

    if(!isall) horizontal[i] = false;
  }

  for(long long i = 0; i < H; i++) {
    if(horizontal[i]) continue;
    for(long long j = 0; j < W; j++) {
      if(!vartical[j]) cout << as[i][j];
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    
    int N = 0;
    cin >> N;
    int half = N/2;
    vector<vector<double> > probability(N + 1,vector<double>(N + 2,0));
    vector<double> coin(N,0);
    for(int i = 0; i < N; i++) {
        cin >> coin.at(i);
    }
    int temp;
    probability.at(0).at(1) = 1;

    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N + 1; j++) {
            probability.at(i).at(j) = probability.at(i-1).at(j - 1)*coin.at(i - 1) + probability.at(i-1).at(j)*(1 - coin.at(i - 1));
        }
    }


    /*
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N + 1; j++) {
            cout << probability.at(i + 1).at(j + 1) << ' ';
        }
        cout << endl;
    }
    */

    double ans;

    for(int i = 0; i <= half; i++) {
        //cout << ans << endl;
        ans += probability.at(N).at(N + 1 - i);
        //cout << probability.at(N).at(N + 1 - i) << endl;
        //cout << ans << endl;
    }

    cout << fixed << setprecision(10) << ans << endl;




    return 0;
}

Measured memory_bytes: 74140
#include <iostream>
#include <string>
#include <vector>

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

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

    for (auto ch : s) {
        if ((int)ch + n > 90) {
            cout << (char)(ch + n - 26);
        } else {
            cout << (char)(ch + n);
        }
    }
    cout << endl;
}



Measured memory_bytes: 3660
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   vector<int> a(5);
   for(int i = 0;i < 5;i++){
         cin >> a[i];
   }
   for(int i = 0;i < 5;i++){
         if(a[i] == 0){
               cout << i + 1 << endl;
               return 0;
         }
   }
}


Measured memory_bytes: 3628
from math import ceil


def energy_drink_collector(N: int, M: int, AB: list)->int:
    total_price = 0
    total_num = 0
    for price, stock in sorted(AB, key=lambda x: x[0]):
        if total_num + stock >= M:
            total_price += price * (M - total_num)
            break
        else:
            total_price += price * stock
            total_num += stock
    return total_price


if __name__ == "__main__":
    N = 0
    N, M = map(int, input().split())
    AB = [tuple(int(s) for s in input().split()) for _ in range(N)]
    ans = energy_drink_collector(N, M, AB)
    print(ans)


Measured memory_bytes: 18892
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_small_and_large_integers(void) {
	int a, b, k;
	cin >> a >> b >> k;
	int a_start = a;
	int a_end = a + k - 1;

	int b_start = b - k + 1;
	int b_end = b;

	if (a_end < b_start) {
		for (int i = a; i < a + k; i++) cout << i << endl;
		for (int i = b - k + 1; i <= b; i++) cout << i << endl;
	}
	else {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
	}
}

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

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(){
  	int n;
  	cin>>n;
  	int a[n+1];
  	for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        a[x]=i;
  	}
  	for(int i=1;i<=n;i++){
        cout<<a[i]<<" ";
  	}
  	cout<<endl;
    return 0;
}


Measured memory_bytes: 1152
x,y = map(int,input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

x2 = Base_10_to_n(x, y)
print(len(str(x2)))


Measured memory_bytes: 2940
import java.util.*;
public class Main{

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        char z,x;
        z=input.next().charAt(0);
        x=input.next().charAt(0);
        if(z==x)
            System.out.println("=");
        else if(z>x)
            System.out.println(">");
        else System.out.println("<");
    }
    
}


Measured memory_bytes: 26980
#include <stdio.h>

int main(void)
{
    int a, b, i, n, c;
    c = 0;
    while (1) {
        c++;
        n = 0;
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0)
            break;
        if (c != 1)
            printf("\n");
        for (i = a; i <= b; i++) {
            if (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) {
                n++;
                printf("%d\n", i);
            }
        }
        if (n == 0)
                printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n)  for(int i=0;i<(n);++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> H(N);
  REP(i, N) {
    cin >> H.at(i);
  }
  
  int num = 1;
  float min = abs((T - H.at(0) * 0.006) - A);
  REP(i, N) {
    float deg = T - H.at(i) * 0.006;
    if (min > abs(deg - A)) {
      num = i + 1;
      min = abs(deg - A);
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 384
N = int(input())
P = [i for i in range(N)]
weight = []

def root(x):
    path_to_root = []
    while P[x] != x:
        path_to_root.append(x)
        x = P[x]
    for node in path_to_root:
        P[node] = x
    return x

def is_same_set(x,y):
    return root(x) == root(y)

def unite(x,y):
    P[root(x)] = root(y)
    
# まずは辺の重さをソートするために辺の重さの配列を作りましょう→マイナス1は除外
for i in range(N):
    lis = list(map(int,input().split()))
    for j in range(N):
        if lis[j] == -1:
            continue
        else:
            weight.append([lis[j],i,j])
# ソートされた順に小さい順から次々とuniteして行こう
weight.sort()
length = len(weight)
k = 0
total_weight = 0

for k in range(length):
    if is_same_set(weight[k][1],weight[k][2]):
        continue
    else:
        unite(weight[k][1],weight[k][2])
        total_weight += weight[k][0]

print(total_weight)
    
# その際にもし付け加えてis_same_set(x,y)がtrueだったらやめよう



Measured memory_bytes: 6552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[][] abs = new int[m][];
		for (int i = 0; i < abs.length; i++)
			abs[i] = new int[] { cin.nextInt(), cin.nextInt() };

		long millis = System.currentTimeMillis();

		boolean ans = solve(n, m, abs);
		if (ans)
			cout.println("POSSIBLE");
		else
			cout.println("IMPOSSIBLE");

		assert null != cout.format("%d elapsed", System.currentTimeMillis() - millis);
	}

	private static boolean solve(int n, int m, int[][] abs) {
		int[] ships = new int[n + 1];
		for (int[] ab : abs) {
			if (ab[0] == 1)
				ships[ab[1]] += 1;
			if (ab[1] == n)
				ships[ab[0]] += 1;
			if (ships[ab[0]] == 2 || ships[ab[1]] == 2)
				return true;
		}
		return false;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

}


Measured memory_bytes: 50200
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int a, b;
	cin >> a >> b;

	vector<Int> s(1000);
	s[1] = 1;
	for (Int i = 2; i < 1000; i++) {
		s[i] = s[i - 1] + i;
	}

	Int ans = s[b - a] - b;
	cout << ans << "\n";



}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define maxn 1000+15
using namespace std;

int main(){
	int n;
	cin>>n;
		if(n<1200){
			cout<<"ABC"<<endl;
		}else if(n<2800){
			cout<<"ARC"<<endl;
		}else{
			cout<<"AGC"<<endl;
		}
	
	return 0;
}

Measured memory_bytes: 256
# encoding: utf-8

import sys
from collections import deque


class Solution:
    @staticmethod
    def doubly_linked_list():
        # write your code here
        array_length = int(input())
        task_deque = deque()
        _input = sys.stdin.readlines()

        for i in range(array_length):
            l_arg = _input[i].split()
            action = l_arg[0]
            if len(l_arg) > 1:
                value = l_arg[-1]
            # print(action, 'v', value)

            if action == 'insert':
                task_deque.appendleft(value)
            elif action == 'deleteFirst':
                task_deque.popleft()
            elif action == 'deleteLast':
                task_deque.pop()
            else:
                try:
                    task_deque.remove(value)
                except Exception as e:
                    pass
        print(" ".join(task_deque))


if __name__ == '__main__':
    solution = Solution()
    solution.doubly_linked_list()

Measured memory_bytes: 214268
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#if defined(_MSC_VER)
#pragma warning(disable : 4996)  // VSでscanfを使う．
#endif

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

  int xor_all = 0;
  map<int, int> m;
  int nums = 0;

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (m[a] == 0) {
      nums++;
    }
    m[a]++;
    xor_all ^= a;
  }

  if (m[0] == n || (n % 3 == 0 && xor_all == 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char S1,S2,S3,T1,T2,T3;
    cin >> S1 >> S2 >> S3;
    cin >> T1 >> T2 >> T3;
    int ans = 0;
    
    if (S1 == T1){
        ans++;
    }
    
    if (S2 == T2){
        ans++;
    }
    
    if (S3 == T3){
        ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,time= map(int,input().split())
c = []
t = []
for i in range(n):
    a,b = map(int,input().split())
    c.append(a)
    t.append(b)
ans = 1001
for i in range(n):
    if time >= t[i]:
        if ans >= c[i]: ans = c[i]
if ans == 1001: print("TLE")
else: print(ans)


Measured memory_bytes: 3064
def sumdigit(m):
    s=str(m)
    array=list(map(int,s))
    return sum(array)
ans=9999
N=int(input())
for i in range(1,N):
    r=N-i
    if sumdigit(i)+sumdigit(r)<ans:
        ans=sumdigit(i)+sumdigit(r)
print(ans)

Measured memory_bytes: 3060
//============================================================================
// Name        : ProjG.cpp
// Author      : Yong Kiat
// Version     :
// Copyright   : By Algotae.
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

const int mxN=3000;
int n, a[mxN];
long long dp[mxN+1][mxN+1];

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

    cin >> n;
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    }

    for (int i = 1; i <= n; i++) {
    	for (int j = i - 1; j >= 0; j--) {
    		dp[i][j] = max(a[i-1] - dp[i-1][j], a[j] - dp[i][j+1]);
    	}
    }

    cout << dp[n][0];
}


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

typedef long long int int64;

void run(void){
  int n,q;
  scanf("%d%d",&n,&q);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  if(n==2){
    while(q--) printf("%d\n",a[1]);
    return;
  }
  int *y=(int *)calloc(n,sizeof(int));
  int64 *ans=(int64 *)calloc(n,sizeof(int64));
  int64 sum=0;
  for(i=n-1;i>=0;i-=2) sum+=a[i];
  y[0]=(a[n-2]+a[n-3])/2+1;
  ans[0]=sum;
  for(i=1;n-1-2*(i+1)>=0;i++){
    y[i]=(a[n-1-(i+1)]+a[n-1-2*(i+1)])/2+1;
    sum+=a[n-1-i]-a[n-1-2*i];
    ans[i]=sum;
  }
  int len=i+1;
  sum=0;
  for(i=0;n-1-i>=i;i++) sum+=a[n-1-i];
  y[len-1]=-1;
  ans[len-1]=sum;
  while(q--){
    int x;
    scanf("%d",&x);
    int l=-1;
    int r=len-1;
    while(r-l>1){
      int m=(l+r)/2;
      if(x>=y[m]){
	r=m;
      } else {
	l=m;
      }
    }
    printf("%lld\n",ans[r]);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
#define Would
#define you


int main() {
	int a, b, k[105], sum = 0;
	bool pl = false;
	cin >> a >> b;
	for (int i = 0; i < b; ++i) {
		cin >> k[i];
		sum += k[i];
	}
	int ans = sum / (a + 1);
	if (sum % (a + 1) != 0) { ++ans; }
	cout << ans << endl;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    vector<int> pos(n);
    REP(i,n) cin >> pos[i];
    int mn = INF;
    int cost = 0;
    FOR(i,1,101){
        REP(j,n){
            cost += (pos[j] - i) * (pos[j] - i);
        }
        CMIN(mn,cost);
        cost = 0;
    }
    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    char s[H][W];
    int dx[]={1,0,0,-1},dy[]={0,-1,1,0};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>s[i][j];
        }
    }
    bool ans=true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j]=='#'){
                bool found=false;
                for(int k=0;k<4;k++){
                    int x=i+dx[k];
                    int y=j+dy[k];
                    if(x>=0&&x<H&&y>=0&&y<W&&s[x][y]=='#')found=true;
                }
                if(!found) ans=false;
            }
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    int n;
    cin>>n;
    int ans=0;
    for (int i = 1; i <= n; ++i) {
        int a;
        cin>>a;
        ans+=(a%2 && i%2);
    }
    cout<<ans<<endl;

}

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

int main(){
    string n;
    cin >> n;
    int l;
    l = n.length();
    for(int i=0;i<l;i++){
        if(n[i]=='1')
            cout << '9';
        else
            cout << '1';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  long N,K;
  in(N,K);
  vector<cpp_int>a(N);
  rep(i,N)in(a[i]);
  cpp_int ans=10000000000000000;
  for(int i=0;i<1<<N;i++){
    if(__builtin_popcount(i)<(int)K)continue;
    cpp_int now=0,cost=0;
    rep(j,N){
      if(i>>j&1&&now>=a[j]){
        cost+=now-a[j]+1;
        now++;
      }
      chmax(now,a[j]);
    }
    chmin(ans,cost);
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
queue <char> a,b,c;
int main(){
	char x;
	while(scanf("%c",&x)&&x!='\n')
		a.push(x);
	while(scanf("%c",&x)&&x!='\n')
		b.push(x);
	while(scanf("%c",&x)&&x!='\n')
		c.push(x);
	char now=a.front();a.pop();
	while(1){
		if(now=='a')
			if(a.empty()){
				printf("A");
				return 0;
			} else now=a.front(),a.pop();
		if(now=='b')
			if(b.empty()){
				printf("B");
				return 0;
			} else now=b.front(),b.pop();
		if(now=='c')
			if(c.empty()){
				printf("C");
				return 0;
			} else now=c.front(),c.pop();
	}
	return 0;
}

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


void solve() {
  int A,B;
  cin >> A >> B;
  if (B%2 == 0) {
    if (A*2 <= B && A*4 >= B) {
      cout << "Yes" << "\n";
    } else {
      std::cout << "No" << '\n';
    }
  } else {
    std::cout << "No" << '\n';
  }

}

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


Measured memory_bytes: 3660
#include<iostream>
#include<stdlib.h>
using namespace std;


int w[105];
int N;
int sa(int i);
int main() {


	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> w[i];
	}
	int min = 10000;
	for (int j = 0; j < N; j++) {
		int tmp = sa(j);
		if (tmp < min) {
			min = tmp;
		}
		else
		{
			break;
		}


	}

	cout << min << endl;

	return 0;


}

int sa(int i) {
	int s1=0, s2=0;
	for (int j = 0; j < i; j++) {
		s1 += w[j];
	}

	for (int j = i; j < N; j++) {
		s2 += w[j];
	}

	return abs(s1 - s2);
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int,input().split()))
ans = 0
for x in range(n-1):
    #print(x, d[x], "d[x]" )
    for y in range(1,n - x):
        #print(y + x,"d[y+x]", d[y+x])
        ans += d[x] * (d[y+x])
print(ans)

Measured memory_bytes: 2940
fun main(args: Array<String>) {
  var tmp = readLine()!!.split(" ").map(String::toLong)
  val n = tmp[0]
  val allSum = n * (n + 1L) / 2L
  val count3 = n / 3L
  val count5 = n / 5L
  val count15 = n / 15L
  val sum3 = (3L + (n - (n % 3L))) * count3 / 2L
  val sum5 = (5L + (n - (n % 5L))) * count5 / 2L
  val sum15 = (15L + (n - (n % 15L))) * count15 / 2L
  println(allSum - (sum3 + sum5 - sum15));
}


Measured memory_bytes: 36328
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];

  vector<int> odd, even;
  for(int i = 0; i < n; i++){
    if(i%2 == 0){
      even.push_back(a[i]);
    }else {
      odd.push_back(a[i]);
    }
  }
  sort(even.begin(),even.end());
  sort(odd.begin(),odd.end());

  sort(a.begin(),a.end());
  int ans = 0;
  map<int,int> add;
  for(int i = 0; i < even.size(); i++){
    int p = even[i];
    int pos = lower_bound(a.begin(),a.end(),p) - a.begin() + add[p];
    if(pos%2 != 0) ans++;
    add[p]++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4980
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    l = len(S)

    def judge():
        if S[0] != "A":
            return False
        T = S[2:l - 1]

        cnt = 0
        for char in T:
            if char == "C":
                cnt += 1
        if cnt != 1:
            return False

        for char in S[1:]:
            if char == "C":
                continue
            elif char.isupper():
                return False
        return True

    if judge():
        print("AC")
    else:
        print("WA")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61932
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    //ll n,m,q;cin>>n>>m>>q;
    ll a,b,n;cin>>a>>b>>n;
    if(n>=b-1){
        cout<<(a*(b-1)/b)<<endl;
    }
    else{
        ll x=n;
        cout<<(a*x/b)-a*(x/b)<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
#include <complex>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

typedef complex<int> term;

bool overflow;

bool isnumber(const string& str){
    int i;
    for(i=0; i<str.length(); i++) if( !('0' <= str[i] && str[i] <= '9') ) return false;
    return true;
}

term parse(string str){
    int i,j, n = str.length();
    int x = 0;

    //cout << str << endl;
    if( str.length() == 0 ) return term(0,0);

    for(i=n-1; i>=0; i--){
        if( str[i] == '(' ) x++;
        if( str[i] == ')' ) x--;
        if( x == 0 && (str[i] == '+' || str[i] == '-') ){
            break;
        }
    }

    if( i == -1 ){
        x = 0;
        for(i=n-1; i>=0; i--){
            if( str[i] == '(' ) x++;
            if( str[i] == ')' ) x--;
            if( x == 0 && str[i] == '*' ){
                break;
            }
        }

        if( i == -1 ){
            if( isnumber(str) ){
                int res = 0;
                for(j=0; j<n; j++){
                    res = 10*res + (str[j] - '0');
                    if( res > 10000 ){
                        overflow = true;
                        break;
                    }
                }
                //printf("res = %d\n",res);
                return term(res,0);
            }
            if( str.length() == 1 && str[0] == 'i' ){
                return term(0,1);
            }
            return parse(str.substr(1,str.length()-2));
        }
    }

    term c;
    term a = parse(str.substr(0,i)), b = parse(str.substr(i+1));
    if( str[i] == '-' ) c = a - b;
    if( str[i] == '+' ) c = a + b;
    if( str[i] == '*' ) c = a * b;

    if( abs(c.real()) > 10000 || abs(c.imag()) > 10000 ) overflow = true;
    return c;
}


int main(){
    string in;

    while( cin >> in ){
        overflow = false;
        term res = parse(in);

        if( overflow ){
            puts("overflow");
        }
        else{
            if( res.imag() == 0 ){
                printf("%d\n",res.real());
            }
            else if( res.real() == 0 ){
                printf("%di\n",res.imag());
            }
            else{
                printf("%d%+di\n",res.real(),res.imag());
            }
        }
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int X = 100*N / 108, flag = 0;
    while(true){
        if(108*X/100 == N){
            cout << X << endl;
            break;
        }
        else if(108*X/100 > N){
            cout << ":(" << endl;
            break;
        }
        else ++X;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
ll n,d,m=1;
ll a[200005],pre[200005];

struct edge {
    ll u, v;
    ll w;
    edge() {}
    edge(ll u, ll v, ll w) : u(u), v(v), w(w) {}
    bool operator<(const edge &other) const { return w < other.w; }
};
edge edges[200005*30];

void add(ll l, ll r) {
    if (l == r) return;
    ll mid = (l + r) >> 1;
    ll min = LLONG_MAX;
    ll pos = -1;
    for (ll i = l; i <= mid; i++) {
        ll f = a[i] - i * d;
        if (f < min) {
            min = f;
            pos = i;
        }
    }
    for (ll i = mid + 1; i <= r; i++) {
        edges[m++] = edge(pos, i, (i - pos) * d + a[i] + a[pos]);
    }
    min = LLONG_MAX;
    pos = -1;
    for (ll i = mid + 1; i <= r; i++) {
        ll f = a[i] + i * d;
        if (f < min) {
            min = f;
            pos = i;
        }
    }
    for (ll i = l; i <= mid; i++) {
        edges[m++] = edge(pos, i, a[pos] + a[i] + d * (pos - i));
    }
    add(l, mid);
    add(mid + 1, r);
}

ll find(ll x) {
    if (0 == pre[x])
        return x;
    return pre[x] = find(pre[x]);
}


ll kruskal() {
    memset(pre, 0, sizeof(pre));
    sort(edges + 1, edges + m + 1);
    ll cnt = 1;
    ll res = 0;
    for (ll i = 1; i <= m; i++) {
        ll u = edges[i].u;
        ll v = edges[i].v;
        ll w = edges[i].w;
        ll fu = find(u);
        ll fv = find(v);
        if (fu == fv) continue;
        pre[fu] = fv;
        res += w;
        ++cnt;
        if (cnt == n) return res;
    }
    return res;
}

ll run() {
    cin >> n >> d;
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    add(1, n);
    cout << kruskal();
}








































Measured memory_bytes: 89216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 1e18;
    chmin(ans, (a & 1) * b * c);
    chmin(ans, a * (b & 1) * c);
    chmin(ans, a * b * (c & 1));
    cout << ans << '\n';
}

Measured memory_bytes: 3664