akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  ll N, K, ans;
  string S;
  cin >> N >> K;
  vector<vector<ll>> seg;
  cin >> S;
  bool flag = true;
  ll l = 0, r = 0;
  for (int i=0; i<S.size(); i++){
    if (flag && S[i] == '0'){
      l = i;
      flag = false;
    }
    else if (!flag && S[i] == '1'){
      r = i - 1;
      seg.emplace_back(vector<ll>({l, r}));
      l = r = 0;
      flag = true;
    }
  }
  if (!flag){
    r = S.size() - 1;
    seg.emplace_back(vector<ll>({l, r}));
  }
  //cout << seg.size() << endl;
  if (seg.size() <= K){
    cout << S.size() << endl;
  }
  else{
    seg.insert(seg.begin(), vector<ll>({-1, -1}));
    seg.emplace_back(vector<ll>({S.size(), S.size()}));
    ll max = 0, tmp = 0;
    for (int i=1; i<seg.size() - K; i++){
      //cout << seg[i + K][0] << " " << seg[i - 1][1] << endl;
      tmp = seg[i + K][0] - (seg[i - 1][1] + 1);
      max = (max < tmp ? tmp : max);
      //cout << max << endl;
    }
    cout << max;
  }
  
  return 0;
}

Measured memory_bytes: 3124
/// meowa 

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef hitorie
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    int n;
    cin >> n;
    long double res = 1ll;
    const long double N = 1e18;
    vector<long double> a(n);
    for (auto& x : a) {
        cin >> x;
        if (x == 0) {
            cout << 0, exit(0);
        }
    }
    for (auto x : a) {
        cin >> x;
        if (x == 0) {
            cout << 0, exit(0);
        }
        if (res*x > N) 
            cout << -1, exit(0);
        res *= x;
    }
    cout << setprecision(0) << fixed << res;        
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        maincode(); 
    }
    return 0;
}

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

const int mod=1000000007;

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  vector<long>dp(n, 0);
  vector<int>k(n, 0);
  if(a[0]!=0){
    cout << 0;
    return 0;
  }
  dp[0]=3;
  k[1]=1;
  k[0]=2;
  for(int i=1; i<n; i++){
    dp[i]=(dp[i-1]*k[a[i]])%mod;
    k[a[i]]--;
    k[a[i]+1]++;
  }
  cout << dp[n-1];
  return 0;
}
  

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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);

        map<int, int> mp;
        for (int x : a) mp[x]++;

        vector<pair<int, int>> b;
        for  (auto it : mp) b.push_back(it);

        bool ok = b.size() == 3 && b[0].second == b[1].second && b[0].second == b[2].second && (b[0].first ^ b[1].first ^ b[2].first) == 0;
        ok |= b.size() == 1 && b[0].first == 0;

        if (b.size() == 2) {
            for (int i = 0; i < 2; i++) {
                ok |= b[i ^ 1].second == 2 * b[i].second && b[i].first == 0;
            }
        }

        cout << (ok ? "Yes" : "No") << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 5372
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
char str[405][405];
bool vis[405][405];
const int ne[4][2]={{-1,0},{1,0},{0,1},{0,-1}};
long long a,b,ans=0,h,w;
void dfs(int i,int j){
	vis[i][j]=true;
	if(str[i][j]=='#')++a;else ++b;
	for(int k=0;k<4;k++){
		int xx=i+ne[k][0],yy=j+ne[k][1];
		if(xx>0&&yy>0&&xx<=h&&yy<=w&&!vis[xx][yy]&&str[i][j]!=str[xx][yy])
			dfs(xx,yy);
	}
}
int main(){
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		scanf("%s",str[i]+1);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(!vis[i][j])b=a=0,dfs(i,j),ans+=a*b;
			printf("%lld",ans);
}

Measured memory_bytes: 8064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint sum[N+1]={};
    rep(i,N) sum[i+1]=sum[i]^A[i];
    rep(i,N){
        lint ans=sum[i]^sum[N]^sum[i+1];
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6768
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def main():
    K = int(stdin.readline().rstrip())
    L = 0
    amari = 10
    if K % 2 == 0 or K % 5 == 0:
        print("-1")
    else:
        if K % 7 == 0:
            L = 9*K//7
        else:
            L = 9*K
        for i in range(1,1000000):
            if amari % L == 1:
                print(i)
                break
            else:
                amari = (amari % L) * 10
main()

Measured memory_bytes: 27252
t0 = 0
x0=0
y0=0
N = int(input())

ans='Yes'

for _ in range(N):
    t, x, y = [int(x) for x in input().split()]
    dist = abs(x-x0)+abs(y-y0)
    tt = t-t0
    if dist <= tt and (tt - dist)%2==0:
        pass
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<random>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,h[200005]={},ans=0;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> h[i];
  }
  sort(h,h+n,greater<ll>());
  for(int i=k; i<n; i++) {
    ans+=h[i];
  }
  cout << ans << endl;
 }

Measured memory_bytes: 1792
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
string s;
cin>>s;
if(n&1)
cout<<"No";
else
{
string s1=s.substr(0,n/2);
string s2=s.substr(n/2,n/2);
if(s1==s2)
cout<<"Yes";
else
cout<<"No";	
}
//abacabac
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



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

int main() {
	int x,r;

	rep(i,5) {
		cin >> x;
		if(!x)
			r = i+1;
	}

	cout << r << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <typename T>
class SegmentTree {
    const T unit;
    const function<T(const T&, const T&)> op;
    vector<T> container;

public:
    template <typename Op>
    SegmentTree(int size, const T& identity, const Op& operation)
        : unit(identity)
        , op(operation)
        , container(msb(size * 2 - 1))
    {
        fill(container.begin(), container.end(), unit);
    }
    void update(size_t index, T value)
    {
        int n = container.size() / 2;
        container[index + n] = value;

        int node = (index + n) >> 1;
        while (node > 0) {
            container[node] = op(container[node << 1], container[(node << 1) + 1]);
            node >>= 1;
        }
    }
    T find(size_t s, size_t t)
    {
        if (s >= t) {
            return unit;
        }
        return find_inner(s, t, 0, container.size() / 2);
    }

private:
    T find_inner(size_t s, size_t t, size_t lb, size_t ub)
    {
        if (s == lb && t == ub) {
            int n = container.size() / 2;
            return container[lca(n + s, n + t - 1)];
        }

        T result = unit;
        size_t mid = (lb + ub) / 2;
        if (mid > s) {
            result = op(result, find_inner(s, min(mid, t), lb, mid));
        }
        if (mid < t) {
            result = op(result, find_inner(max(s, mid), t, mid, ub));
        }

        return result;
    }
    int lca(int n0, int n1)
    {
        int a = n0 ^ n1;
        return n0 / msb(a);
    }
    int msb(int x)
    {
        x |= x >> 1;
        x |= x >> 2;
        x |= x >> 4;
        x |= x >> 8;
        x |= x >> 16;

        return x + 1;
    }
};

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

    int MAX = n + 1;
    SegmentTree<int64_t> dp(n + 1, MAX, [](const int64_t& l, const int64_t& r) {
        return min(l, r);
    });
    dp.update(n, 0);
    rrep(i, n)
    {
        if (s[i] == '1') {
            dp.update(i, MAX);
        } else {
            dp.update(i, dp.find(i + 1, min(i + m + 1, (int64_t)n + 1)) + 1);
        }
    }

    if (dp.find(0, 1) == MAX) {
        cout << -1 << endl;
    } else {
        int j = 0;
        vector<int> result;
        rep(i, n)
        {
            if (dp.find(i + 1, i + 2) + 1 == dp.find(j, j + 1)) {
                result.push_back(i + 1 - j);
                j = i + 1;
            }
        }

        rep(i, result.size())
        {
            cout << result[i] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;


/// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef double dd;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER false
#define TIME false
#define DEBUG true
#define SET_GEN false
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second
#define RANGE(a, b) (rand() % (b-a+1) + a)


const double pi = acos(-1.);
const double eps = 1e-7;
const int inf = 2147483647;
const int _inf = -2147483648;
const long long int INF = 1e18+1;
const int mod = 1e9+7;


void delay(int sec); // DEBUG


void solution(void)
{
    int n, w;

    cin >> n >> w;

    vector <int> weight(n), val(n);

    for(int i = 0; i < n; ++i) cin >> weight[i] >> val[i];

    int sum_val = 0;
    for(int x : val) sum_val += x;

    vector <ulli> dp(sum_val+1, INF);
    dp[0] = 0;

    for(int i = 0; i < n; ++i) {
        for(int val_already = sum_val-val[i]; val_already >= 0; --val_already) {
            dp[val_already+val[i]] = min(dp[val_already+val[i]], dp[val_already] + weight[i]);
        }
    }

    int ans = 0;
    for(int i = 0; i <= sum_val; ++i) {
        if (dp[i] <= (ulli)w) {
            ans = i;
        }
    }

    cout << ans << "\n";


    weight.clear();
    val.clear();
    dp.clear();




    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif

    #if SET_GEN
    srand((unsigned int) time(0));
    #endif


    unsigned short int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  vector<int> t(3);
  rep(i, 3) cin >> t[i];
  sort(t.begin(), t.end());
  cout << t[0] + t[1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <bitset>
#include <cmath>
#define ff first
#define ss second
#define MAXN 300005
#define INF 1000000001000000001LL
#define int long long

using namespace std;

const int mod = 998244353; //1000000007;
int n, a;
string s;

main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base :: sync_with_stdio(false);
    cin.tie();
    cin >> a >> s;

    if(a < 3200)
        cout << "red";
    else
        cout << s;

    return 0;
}







Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
const int n = 17;
int dp[n][n][n];

void experiment(void) {
  REP(i, 1, n) {
    cerr << "dp[" << i << "]:" << endl;
    REP(j, 1, n) {
      cerr << "dp[" << i << "," << j << "]:";
      REP(k, 1, n) {
	ll res = 1;
	if (i + j + k == 3) {
	  dp[i][j][k] = 0;
	  continue;
	}
	int g = __gcd(i, j);
	g = __gcd(g, k);
	if (g != 1) {
	  res = 1 - dp[i / g][j / g][k / g];
	} else {
	  if (i >= 2) {
	    res &= dp[i - 1][j][k];
	  }
	  if (j >= 2) {
	    res &= dp[i][j - 1][k];
	  }
	  if (k >= 2) {
	    res &= dp[i][j][k - 1];
	  }
	}
	dp[i][j][k] = 1 - res;
	cerr << " " << dp[i][j][k];
      }
      cerr << endl;
    }
    cerr << endl;
  }
  exit(0);
}


bool winning(const VL &a) {
  int n = a.size();
  ll evenodd = 0;
  int numodd = 0;
  REP(i, 0, n) {
    evenodd += a[i] - 1;
    numodd += a[i] % 2 == 1 ? 1 : 0;
  }
  if (evenodd % 2 == 1) {
    return true;
  }
  assert (numodd >= 1);
  if (n <= 2 || numodd >= 2) {
    return false;
  }
  int p = -1;
  REP(i, 0, n) {
    if (a[i] % 2 == 1) {
      p = i;
      break;
    }
  }
  if (a[p] == 1) {
    return false;
  }
  VL b(n);
  REP(i, 0, n) {
    b[i] = a[i] - (i == p ? 1 : 0);
  }
  ll g = b[0];
  REP(i, 1, n) {
    g = __gcd(g, b[i]);
  }
  REP(i, 0, n) {
    b[i] /= g;
  }
  return not winning(b);
}

int main(void){
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  cout << (winning(a) ? "First" : "Second") << endl;
}


Measured memory_bytes: 19072
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    std::vector<int> A(N);
    for(int i(0); i < N; ++i) std::cin >> A[i];
    long long ans(1000), cur(1000), st(0);
    bool decre(true);
    for(int k(0); k < N; ++k){
        cur = 1000;
        for(int i(k); i < N; ++i){
            std::vector<std::pair<int, int>> add;
            if(decre && (i < N-1 && A[i] < A[i+1])){
                decre = false;
                st += cur / A[i];
                cur %= A[i];
            }else if(i == N-1 || (!decre && A[i] > A[i+1])){
                decre = true;
                cur += st * A[i];
                st = 0;
                chmax(ans, cur);
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */
#define min min<ll>
ll N, A, B, C, D;
unordered_map<ll, ll>memo;


ll solve(ll n) { //nを0にするための最小コスト
    if(n == 0) return 0;
    if(n == 1) return D;
    if(memo[n] != 0) return memo[n];
    ll ret = 1e18;
    if(n < ret / D) ret = D * n;
    if(n % 2 == 0) {
        ret = min(ret, A + solve(n / 2));
    } else {
        ret = min(ret, A + D + solve(n / 2));
        ret = min(ret, A + D + solve((n + 1) / 2));
    }
    if(n % 3 == 0) {
        ret = min(ret, B + solve(n / 3));
    } else {
        ret = min(ret, B + (n % 3) * D + solve(n / 3));
        ret = min(ret, B + (3 - (n % 3)) * D + solve((n + 2) / 3));
    }
    if(n % 5 == 0) {
        ret = min(ret, C + solve(n / 5));
    }else {
        ret = min(ret, C + (n % 5) * D + solve(n / 5));
        ret = min(ret, C + (5 - (n % 5)) * D + solve((n + 4) / 5));
    }
    return memo[n] = ret;
}

int main() {
    int T; cin >> T;
    vector<ll>ans;
    rep(t, T) {
        cin >> N >> A >> B >> C >> D;
        memo.clear();
        ans.pb(solve(N));
    }
    rep(i, T)
        cout << ans[i] << endl;
}


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

const int maxn = 310, P = 998244353;
char s[maxn];
int K, f[maxn][maxn][maxn][2], sum[maxn][maxn];

int main() {
    scanf("%s %d", s + 1, &K);
    int n = strlen(s + 1), ans = 0;
    K = min(K, n);
    f[0][0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        memset(sum, 0, sizeof(s));
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= K; k++) {
                sum[j][k] = f[i - 1][j][k][0];
                if (j) (sum[j][k] += sum[j - 1][k]) %= P;
            }
        }
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= K; k++) {
                if (s[i] == '0') {
                    f[i][j][k][0] = (f[i - 1][j][k][0] + f[i - 1][j][k][1]) % P;
                    if (j) (f[i][j][k][0] += sum[j - 1][k]) %= P;
                } else {
                    f[i][j][k][0] = f[i - 1][j][k][0];
                    if (k) f[i][j][k][1] = (f[i - 1][j + 1][k - 1][0] + f[i - 1][j + 1][k - 1][1]) % P;
                }
            }
        }
    }
    for (int i = 0; i <= K; i++) {
        (ans += f[n][0][i][0]) %= P;
        (ans += f[n][0][i][1]) %= P;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 223636
# 参考: White_Pie_46
# https://atcoder.jp/contests/abc176/submissions/16168825
from collections import deque


def main():
    height, width = [int(x) for x in input().split()]
    init_h, init_w = [int(x) - 1 for x in input().split()]
    dest_h, dest_w = [int(x) - 1 for x in input().split()]
    grid = [list(input()) for _ in range(height)]

    adjacents = (
        (1, 0),
        (0, 1),
        (-1, 0),
        (0, -1)
    )

    def gen_warp_can_reach():
        for h in range(-2, 3):
            for w in range(-2, 3):
                if h == 0 == w:
                    continue
                if (h, w) in adjacents:
                    continue
                yield (h, w)
    warp_can_reach = tuple(gen_warp_can_reach())
    qu = deque()
    qu.append((init_h, init_w, 0))  # 座標とワープ回数を保持

    while qu:
        h, w, warps = qu.popleft()
        if h == dest_h and w == dest_w:
            return warps
        if grid[h][w] == 'R':
            # 同じマスを複数回キューに追加しているかもしれない。
            # 短距離で調査済みなら再調査は不要。
            continue
        grid[h][w] = 'R'  # reached

        for h_delta, w_delta in adjacents:
            new_h, new_w = h + h_delta, w + w_delta
            if 0 <= new_h < height and 0 <= new_w < width:
                if grid[new_h][new_w] == '.':
                    qu.appendleft((new_h, new_w, warps))

        for h_delta, w_delta in warp_can_reach:
            new_h, new_w = h + h_delta, w + w_delta
            if 0 <= new_h < height and 0 <= new_w < width:
                if grid[new_h][new_w] == '.':
                    qu.append((new_h, new_w, warps + 1))
    return -1


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 234172
#include <bits/stdc++.h>
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
using namespace std;
typedef   long long int ll;

int main()
{
string s;
cin>>s;
deque<char> st;
for(int i=0;i<s.length();i++)
st.pb(s[i]);
int rev=0;
int q;
cin>>q;
while(q--)
{
	int k;
	cin>>k;
	if(k==1)
	rev=abs(rev-k);
	else
	{
		int p;
		cin>>p;
char a;
		cin>>a;if(rev==1)
		{
			if(p==1)
			st.pb(a);
			else
			st.pf(a);
		}
		else
		{
			if(p==1)
			st.pf(a);
			else
			st.pb(a);
		}
	}
//cout<<rev<<" "<<st<<endl;
}
if(rev==1)
{
	for(auto iter = st.rbegin(); iter != st.rend(); ++iter) {
    cout<<*iter;// do stuff
}
}
else{
	  deque <char> :: iterator it; 
    for (it = st.begin(); it != st.end(); ++it) 
        cout <<  *it; 

}
}


Measured memory_bytes: 896
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


ll a[100009];


int main() {
	ll N, M,an=1,mod=1e9+7;
	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;

	}
	else if (abs(N - M) == 0)an++;

	rep(i, N) {
		an *= (1 + i);
		an %= mod;
	}
	rep(i, M) {
		an *= (1 + i);
		an %= mod;
	}
	cout << an << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
int main()
{
	llt n , a, b;
	cin >> n >> a >> b;
	llt r = a + b;
	if(a==0)
	{
		cout << "0";
	}
	else
	{
		llt z = n/r;
		llt o = n%r;
		if(o <=a)
		{
			cout << z*a+o; 
		}
		else
		{
			cout << a*(z +1);
		}
	}
}

Measured memory_bytes: 256
N, R1, R2 = map(int, input().split())
n = R2 - R1 - 1
count={}
for m in range(N-1):
    count[m+1] = 0 
for i in range(N):
    for j in range(i+1, N):
        k = min(j-i, abs((R1-1)-i) + 1 +abs((R2-1)-j))
        count[k]+=1
for k in count.values():
    print(k)

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];

set <pii> st;

int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin1(n);
    for1(i, n) cin1(a[i]);

    ans = 1;
    st.insert({a[1], ++c});

    fora(i, 2, n) {
        auto it = st.lower_bound({a[i], 0});
        if(it == st.begin()) {
            ans++;
        }
        else {
            it--;
            st.erase(it);
        }
        st.insert({a[i], ++c});
    }

    cot1(ans);

    return 0;
}



Measured memory_bytes: 10460
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

vector<LL> memo;

LL solve(int n) {
	if (n < 0) return 0;
	if (memo[n] != -1) return memo[n];
	if (n == 0) return memo[n] = 1;

	return memo[n] = solve(n - 1) + solve(n - 2) + solve(n - 3);
}

int main(void) {
	memo.resize(31, -1);
	int N;
	
	while (cin >> N, N) {
		cout << ((solve(N) + 9) / 10 + 364) / 365 << endl;
	}

	return 0;
}

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

void iSortAscend( char *, int );
void iSortDescend( char *, int );

int main( void ) {
	char aStr[ 20 ][ 7 ], min[ 7 ], max[ 7 ];
	int i, j, a[ 20 ], L;

	while ( scanf( "%d %d", a, &L ), L ) {
		sprintf( aStr[ 0 ], "%0*d", L, a[ 0 ] );

		for ( i = 1; ; i++ ) {
			strcpy( min, aStr[ i - 1 ] );
			iSortAscend( min, L );

			strcpy( max, aStr[ i - 1 ] );
			iSortDescend( max, L );

			sprintf( aStr[ i ], "%0*d", L, atoi( max ) - atoi( min ) );
			a[ i ] = atoi( aStr[ i ] );

			for ( j = 0; j < i; j++ )
				if ( a[ j ] == a[ i ] )
					break;
			if ( j != i )
				break;
		}

		printf( "%d %d %d\n", j, a[ i ], i - j );
	}

	return 0;
}


void iSortAscend( char *data, int n ) {
	char tmp;
	int i, j;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		if ( data[ i - 1 ] > tmp ) {
			j = i;
			do {
				data[ j ] = data[ j - 1 ];
				j--;
			} while ( j > 0 && data[ j - 1 ] > tmp );
			data[ j ] = tmp;
		}
	}
}

void iSortDescend( char *data, int n ) {
	char tmp;
	int i, j;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		if ( data[ i - 1 ] < tmp ) {
			j = i;
			do {
				data[ j ] = data[ j - 1 ];
				j--;
			} while ( j > 0 && data[ j - 1 ] < tmp );
			data[ j ] = tmp;
		}
	}
}

Measured memory_bytes: 632
N=int(input())
A=list(map(int,input().split()))
while len(A)>=2:
    A=sorted(A,reverse=True)
    while 1:
        if not A[-1]:
            A.pop()
        else:
            for i in range(len(A)-1):
                A[i]%=A[-1]
            break
print(A[0])


Measured memory_bytes: 62704
#include <stdio.h>

int main(void){
  
  int a, b, c, d, e, f;
  double x, y;
  double EPS = 0.0005;
  
  while( scanf("%d", &a) != EOF ){
    scanf(" %d %d %d %d %d", &b, &c, &d, &e, &f);
    
    x = (double)((c*e)-(b*f)) / (double)((a*e)-(b*d));
    y = (double)((a*f)-(c*d)) / (double)((a*e)-(b*d));
    
    if( -EPS < x && EPS > x ) x = 0.0;
    if( -EPS < y && EPS > y ) y = 0.0;
    
    printf("%.3f %.3f\n", x, y);
  }
  
    
  return 0;
}

Measured memory_bytes: 636
# include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 1e5 + 21;
int n, m, cnt;
int a[MAXN], b[MAXN];
 
int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
        if(a[i] & 1) 
        	cnt++;
    }
  
    if(m == 1) {
    	if(a[1] == 1)
        	cout << 1 << '\n' << 1 << '\n' << 1 << '\n';
		else 
          cout << a[1] << '\n' << 2 << '\n' << a[1] - 1 << ' ' << 1 << '\n';
		return 0;
	}
    if(cnt > 2) 
      cout << "Impossible";
    else {
        int p = 1;
		for (int i = 1; i <= m; i++) {
			if((a[i] % 2) && p == 1) {
             	swap(a[i], a[1]);
              	p++;
            }
			else if((a[i] % 2) && p == 2) 
            	swap(a[i], a[m]);
		}
        for (int i = 1; i <= m; i++)
        	cout << a[i] << ' ';
        cout << '\n';
       	cout << m - (a[m] == 1) << '\n';
        cout << a[1] + 1 << ' ';
        for (int i = 2; i < m; i++)
        	cout << a[i] << ' ';
        if(a[m] > 1) 
          cout << a[m] - 1 << ' ';
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
Fa = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
F = np.array(Fa)
ans = - 10**10
for i in range(1,2**10):
    tmp = 0
    joi = np.array(list(map(int,format(i,"010b"))))
    for j in range(N):
        tmp += P[j][np.dot(joi,F[j])]
    ans = max(tmp, ans)
print(ans)

Measured memory_bytes: 12448
#include <iostream>

using namespace std;



int main(){
	string S;
	int quant = 0;
	cin >> S;
	for(int i = 0, j = S.length() - 1; i <= j; i++, j--)
		if(S[i] != S[j]) quant++;
		
	cout << quant << endl;	 
	return 0;	
}

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

int main() {
  
  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  
  cout << x2 - (y2 - y1);
  
  cout << " ";
  
  cout << y2 + (x2 - x1);
  
  cout << " ";
  
  cout << x1 - (y2 - y1);
  
  cout << " ";
  
  cout << y1 + (x2 - x1);
  
  cout << endl;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long N,sum=100000000000000;
    int i;
    cin>>N;
    for(i=1; i<=N/i; i++)
        if(N%i==0)
        {
            if(i+(N/i)-2<sum)
                sum=i+(N/i)-2;
        }
    cout<<sum<<endl;
    return 0;
}

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

int main(){
	string s;
    cin >> s;
    int len = s.size();
    int cnt1 = 0;
    int cnt2 = 0;
    rep(i,len){
        if(i % 2 == 1){
            if(s[i] != '1') cnt1++;
        }else{
            if(s[i] != '0') cnt1++;
        }
    }

    rep(i,len){
        if(i % 2 == 1){
            if(s[i] == '1') cnt2++;
        }else{
            if(s[i] == '0') cnt2++;
        }
    }

    int ans = min(cnt1,cnt2);
    cout << ans << endl;
}

Measured memory_bytes: 3720
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    vector<int> d(N);
    rep(i, N) cin >> d[i];
    sort(d.begin(), d.end());

    int topABC = d[N/2-1];
    int bottomARC = d[N/2];

    LL ans = bottomARC-topABC;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
int N;
int s[110];
int sum;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> s[i];
    sum+=s[i];
  }
  sort(s,s+N);
    for(int i=0;i<N;i++){
      if(sum%10==0){
	if(s[i]%10!=0)
	  sum-=s[i];
	
      }
      else{
	cout << sum << endl;
	return 0;
      }
    }
    
    cout << '0' << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int h, w, k; cin >> h >> w >> k, --k;
  if (w == 1) return cout << 1 << '\n', 0;
  VV<lint> dp; assign(dp, h + 1, w);
  dp[0][0] = 1;
  for (int i = 0; i < h; ++i) {
    for (int bit = 0; bit < 1 << w - 1; ++bit) {
      bool ok = true;
      for (int x = 0; x < w - 2; ++x) if (bit & 1 << x and bit & 1 << x + 1) ok = false;
      if (!ok) continue;
      auto v = dp[i];
      for (int x = 0; x < w - 1; ++x) if (bit & 1 << x) swap(v[x], v[x + 1]);
      for (int j = 0; j < w; ++j) (dp[i + 1][j] += v[j]) %= mod;
    }
  }
  cout << emod(dp[h][k]) << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
  ll a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op=='?'){break;}
    switch(op){
      case '+':
        cout << a+b << endl;
        break;
      case '-':
        cout << a-b << endl;
        break;
      case '*':
        cout << a*b << endl;
        break;
      case '/':
        cout << (ll)(a/b) << endl;
        break;
      case '?':
        break;
    }
  }
  return 0;
}


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

int main()
{
	int i,j,num[3],tmp;
	
	cin >> num[0] >> num[1] >> num[2];
	
	for (i=0;i<3;i++)
	{
		for (j=i;j<3;j++)
		{
			if(num[i] > num[j])
			{
				tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}
		}
	}
	cout << num[0] << " "<< num[1] << " " << num[2] << endl;

	return 0;
}

Measured memory_bytes: 1164
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null, null);
    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null, null);
      while (x !== null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      newNode.parent = y;
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.map((line) => line.split(' ')).forEach(function(cmd) {
    switch(cmd[0].charAt(0)) {
    case 'i': tree.insert(Number(cmd[1])); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 270400
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
    // Your code here!
    
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A,B;
    cin >> A >> B;
    if(B%A == 0) cout << A+B << endl;
    else cout << B - A << endl; 
}

Measured memory_bytes: 256
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]


for cx in range(101):
  for cy in range(101):
    H = A[2] + abs(A[0] - cx) + abs(A[1] - cy)
    flag = True
    for i in range(N):
      if max(H - abs(X[i][0]-cx) - abs(X[i][1] - cy), 0) != X[i][2]:
        flag = False
        break
    if flag:
      print(cx,cy,H)
      break
  if flag:
    break

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-2){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(abs(s)>abs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1)continue;
            if(abs(t)>abs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


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


int main()
{
	int N;
	cin>>N;
	vector<ll> A(N);
	rep(i,N) cin>>A[i];
	sort(A.begin(),A.end(),greater<ll>());
	ll ans=A[0];
	int k=1;
	for(int i=0;i<N-2;i++)
	{
		ans+=A[k];
		if(i%2==1) k++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const long MOD = 1000000007;
const int  N_MAX = 200001;
const int INF = 2e+9;

using namespace std;

long inv[N_MAX];
long fac[N_MAX];
long finv[N_MAX];

typedef pair<int, int> P;

void init(){
    inv[0] = 1;
    fac[0] = 1;
    finv[0] = 1;
    inv[1] = 1;
    fac[1] = 1;
    finv[1] = 1;
    for(int i = 2; i < N_MAX; i++){
        fac[i] = (fac[i-1]*i)%MOD;
        inv[i] = ((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
        finv[i] = (finv[i-1]*inv[i])%MOD;
    }
}


long comb(int n, int m){
    long ans;
    ans = fac[n]*finv[m];
    ans %= MOD;
    ans *= finv[n-m];
    ans %= MOD;
    return ans;
}


int main(){
    init();
    int N, X, Y;
    vector<int> v[200001];
    cin >> N >> X >> Y;
    int c_max = 0;
    for(int i = 0; i < N; i++){
        int c, w;
        cin >> c >> w;
        v[c].push_back(w);
        c_max = max(c, c_max);
    }
    long ans = 1;
    vector<int> buf;
    
    
    vector<P> p;
    for(int i = 1;i <= c_max; i++){
        sort(v[i].begin(), v[i].end());
        if(v[i].size() == 0) continue;
        p.push_back(P(v[i][0], i));
    }
    sort(p.begin(), p.end());
    int v_min = p[0].second;
    int v_min_2nd = -1;
    if(p.size() >= 2) v_min_2nd = p[1].second;
    for(int i = 1;i <= c_max; i++){
        if(v[i].size() == 0) continue;
        if(i == v_min){
            int cnt = 1;
            for(int j = 1; j < v[i].size(); j++){
                if(v[i][0]+v[i][j] <= X || (v_min_2nd != -1 && v[v_min_2nd][0] + v[i][j] <= Y)) cnt++;
                else break;
            }
            buf.push_back(cnt);
        }else if(v[v_min][0] + v[i][0] <= Y){
            int cnt = 1;
            for(int j = 1; j < v[i].size(); j++){
                if(v[i][0]+v[i][j] <= X || v[v_min][0] + v[i][j] <= Y) cnt++;
                else break;
            }
            buf.push_back(cnt);
        }
    }
    int sum = 0;
    for(int i = 0; i < buf.size(); i++){
        sum += buf[i];
    }
    //cout << v_min << endl;
    for(int i = 0; i < buf.size(); i++){
        ans *= comb(sum, buf[i]);
        ans %= MOD;
        sum -= buf[i];
        //cout << buf[i] << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17140