akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N ;
    cin >> N ;
    vector<ll> A;
    vector<ll> B;
    
    ll mx = 0;
    rep(i, N-1){
        ll inp; cin >> inp;
        B.pb(inp);
        mx = max(mx, inp);
    }
    rep(i, N){
        A.pb(mx);
    }
    
    
    rep(i, N-1){
        if(A[i] > B[i]) A[i] = B[i];
        if(A[i+1] > B[i]) A[i+1] = B[i];
    }
    
    ll ans = 0 ;
    rep(i, N){
        ans += A[i] ;
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int dp[330][330];
int n;
int w[330];

int rec(int l, int r) {
    if(dp[l][r] != -1) return dp[l][r];
    if(abs(r - l) <= 1) return 0;

    int res = 0;
    if(abs(w[l] - w[r - 1]) <= 1 && rec(l + 1, r - 1) == r - l - 2) {
        res = r - l;
    }
    for(int mid = l + 1; mid <= r - 1; mid++) {
        res = max(res, rec(l, mid) + rec(mid, r));
    }
    return dp[l][r] = res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    for(;;) {
        cin >> n;
        if(n == 0) break;
        rep(i, n) cin >> w[i];
        rep(i, n + 1) rep(j, n + 1) dp[i][j] = -1;
        cout << rec(0, n) << endl;
    }
	return 0;
}


Measured memory_bytes: 3540
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: f64,
    }
    println!(
        "{}",
        if n as u32 % 2 == 0 {
            0.5
        } else {
            (n + 1.0) / 2.0 / n
        }
    );
}


Measured memory_bytes: 2156
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

const ll M = pow(10, 9) + 7;
vector<ll> fac(2000001);   // n!(mod M)
vector<ll> ifac(2000001);  // k!^{M-2} (mod M)

ll mpow(ll x, ll n) {  // x^n(mod M)
  ll ans = 1;
  while (n != 0) {
    if (n & 1) ans = ans * x % M;
    x = x * x % M;
    n = n >> 1;
  }
  return ans;
}

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

void fact_ifact_mod(ll max_range) {
  fac[0] = 1;
  ifac[0] = 1;
  for (ll i = 0; i < max_range; i++) {
    fac[i + 1] = fac[i] * (i + 1) % M;               // n!(mod M)
    ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M;  // k!^{M-2} (mod M)
  }
}

int main() {
  ll X, Y;
  cin >> X >> Y;
  if ((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll n = (2 * Y - X) / 3;
  ll m = (2 * X - Y) / 3;
  if (n < 0 || m < 0) {
    cout << 0 << endl;
    return 0;
  }
  fact_ifact_mod(n + m);
  ll ans = comb(n + m, n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 31488
#include <iostream>

using namespace std;

int main() {
	long long n; cin >> n;
	long long a, b; cin >> a >> b;
	long long ans = n / (a + b) * a;
	long long tmp = n % (a + b);
	ans += (tmp > a ? a : tmp);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,b) for(int i=0;i<b;i++)
typedef pair<int,int>P;
vector<P>v[100009];
int n,d[100009];
bool used[100009];
void dfs(int x,int dis){
  used[x]=1;
  d[x]=dis;
  r(i,v[x].size()){
    if(!used[v[x][i].first]){
      dfs(v[x][i].first,dis+v[x][i].second);
    }
  }
}
main(){
  cin>>n;
  r(i,n-1){
    int s,t,e;
    cin>>s>>t>>e;
    s--,t--;
    v[s].push_back(P(t,e));
    v[t].push_back(P(s,e));
  }
  int q,k;
  cin>>q>>k;
  dfs(k-1,0);
  //r(i,n+1)cout<<d[i]<<endl;
  while(q--){
    int s,t;
    cin>>s>>t;
    s--,t--;
    cout<<d[s]+d[t]<<endl;
  }
}

Measured memory_bytes: 14336
N = int(input())
namelist = []
num2alpha = lambda c: chr(c+64)
for i in range(20):
    if N <= 26:
        namelist.append(num2alpha(N))
        break
    
    if  N % 26 == 0:
        namelist.append('z')
        N = (N//26)-1
    else:
        mod = N%26
        namelist.append(num2alpha(mod))
        N = (N//26)
    
while '' in namelist:
    namelist.remove('')
namelist.reverse()
ans = ''.join(namelist)

print(ans.lower())

Measured memory_bytes: 9204
N, X = map(int, input().split())

layer_size = [1]
P_cnt = [1]

for _ in range(50):
  #[-1]は末尾の要素を取得。layer_sizeで、合計
  layer_size.append(layer_size[-1]*2+3)

  #[-1]は末尾の要素を取得。P_cntはパティの枚数
  P_cnt.append(P_cnt[-1]*2+1)


def solve(level, x):
  if x == 1:
    return 0 if level > 0 else 1
  l = layer_size[level-1]
  p = P_cnt[level-1]
  if x <= 1+l:
    return solve(level-1, x-1)
  elif x == l+2:
    return p+1
  elif x <= 2*l+2:
    return p+1+solve(level-1, x-l-2)
  else:
    return 2*p+1
  
ans = solve(N, X)
print(ans)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
ans = 10000
for i in range(0, len(s) - len(t) + 1):
    tmp = 0
    s_tmp = s[i: i + len(t)]
    for j in range(len(t)):
        if s_tmp[j] != t[j]:
            tmp += 1
    ans = min(ans, tmp)
print(ans)    

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;


main(){
    int x;
    cin>>x;
    if(x>=400 && x<600) cout<<'8';
    else if(x>=600 && x<800) cout<<'7';
    else if(x>=800 && x<1000) cout<<'6';
    else if(x>=1000 && x<1200) cout<<'5';
    else if(x>=1200 && x<1400) cout<<'4';
    else if(x>=1400 && x<1600) cout<<'3';
    else if(x>=1600 && x<1800) cout<<'2';
    else cout<<'1';
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  int a;
  if (x1 == 0) a = 1;
  else if (x2 == 0) a = 2;
  else if (x3 == 0) a = 3;
  else if (x4 == 0) a = 4;
  else if (x5 == 0) a = 5;

  cout << a << endl;
}


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

int main(void){
    set<string> st;
    string s;
    cin >> s;
    int k;
    cin >> k;
    for(int i=1; i<=min(5,(int)s.size()); i++){
        for(int j=0; j<=s.size()-i; j++){
            st.insert(s.substr(j,i));
        }
    }
    auto itr = st.begin();
    for(int i=1; i<k; i++){
        itr++;
    }

    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
from collections import deque
N, u, v = map(int, input().split())

G = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)


def bfs(s):
    dist = [-1] * (N + 1)
    dist[s] = 0
    d = deque([s])
    while len(d) > 0:
        v = d.popleft()
        for w in G[v]:
            if dist[w] < 0:
                dist[w] = dist[v] + 1
                d.append(w)
    return dist


tkhs = bfs(u)
aok = bfs(v)
ans = 0
for i in range(1, N + 1):
    if tkhs[i] < aok[i]:
        ans = max(ans, aok[i] - 1)
print(ans)


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

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> hs(n);
  cin >> hs[0];
  hs[0]--;
  bool ok = true;
  for (int i = 1; i < n; i++) {
    cin >> hs[i];
    ll d = hs[i] - hs[i - 1];
    if (1 <= d) {
      hs[i]--;
    } else if (d == 0) {
    } else {
      ok = false;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	ll ans = 0;
	ll mn = LLONG_MAX;
	for (ll i = 0; i < n; i++) {
		ll t; cin >> t;
		if (t <= mn) ans++;
		mn = min(mn, t);
	}


	cout << ans << endl;

	return 0;	
}

/*
3
0 1
3 0
1 0
*/

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

int main() {
    long long L, R; cin >> L >> R;
    if (R - L > 2019) cout << 0 << endl;
    else {
        long long res = 2018;
        for (long long i = L; i < R; ++i)
            for (long long j = i+1; j <= R; ++j)
                res = min(res, (i * j) % 2019);
        cout << res << endl;
    }
}
//けんちょんさん

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int N = 100;
int main() {
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
 
    for (int i = 1; i <= n; i++)cin >> p[i - 1] >> p[i];
 
    for (int i = 1; i <= n; i++)m[i][i] = 0;
 
    for (int l = 2; l <= n; l++) {
        for (int i = 1; i <= n - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k < j; k++) {
                m[i][j] = min(m[i][j], m[i][k] +  m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int main (void) {
int n, k;
cin >> n >> k;
int c = 1;
n -= k;
if(n %( k - 1))
c += (n + k - (n % (k - 1))) / ( k - 1 );
else if(n > 0)
c += n / (k - 1);
cout << c << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

const ll SIZE = 1e5+10;
ll n, k;
ll h[SIZE];

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    ll cou = 0;

    for(int i = 0; i < n; i++){
        if(h[i] >= k){
            ++cou;
        }
    }
    cout << cou << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char c[10][10];
int main()
{
	int n,m,k,ans=0,cnt,i,j,x,y;
    cin>>n>>m>>k;
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    cin>>c[i][j];
    for(i=0;i<1<<n;i++)
    for(j=0;j<1<<m;j++)
    {
    	cnt=0;
    	for(x=0;x<n;x++)
    	for(y=0;y<m;y++)
    	if(((i>>x)&1)&&((j>>y)&1)&c[x][y]=='#')cnt++;
		if(cnt==k)ans++; 
	}
    cout<<ans;
   
} 

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

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

vector<bool> seen; 
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto e : G[v]) {
        if (!seen[e.to]) {  
            dfs(G, e.to);
        }
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N,M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }
    seen.assign(N, false); 
    int cnt = 0; 
    for (int i = 0; i < N; i++) {
        if (!seen[i]) {
            dfs(G, i);
            cnt++;
        }
    }
    cout << cnt-1 << endl;
    return 0;
}

Measured memory_bytes: 9484
import sys
input = sys.stdin.readline
n=int(input())
c=[]
tmp=0
num=0
for i in range(n):
    m=int(input())
    if m!=tmp:
        c.append(m)
        tmp=m
        num+=1
n=num
from collections import Counter
dp=Counter()
ans=1
mod=10**9+7
for i in range(n):
    dp[c[i]]=(dp[c[i]]+ans)%mod
    ans=dp[c[i]]
print(ans)

Measured memory_bytes: 29824
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

int H, W;
char s[52][52];

int input(){
  cin >> H >> W;
  for( int i = 0; i < 52; i++ ){
    for( int j = 0; j < 52; j++ ){
      s[i][j] = '.';
    }
  }
  for( int i = 1; i <= H; i++ ){
    for( int j = 1; j <= W; j++ ){
      cin >> s[i][j];
    }
  }
  return 0;
}

int check(int i, int j){
  int ret = 0;
  int dx[4] = {0,1,0,-1};
  int dy[4] = {-1,0,1,0};
  char target = '#';
  if( s[i][j] != target ){ return -1; }
  for( int k = 0; k < 4; k++ ){
    ret += (s[i+dy[k]][j+dx[k]]==target ? 1 : 0);
  }
  return ret;
}

int run(){
  for( int i = 1; i <= H; i++ ){
    for( int j = 1; j <= W; j++ ){
      if( check(i,j) == 0 ){
        // cout << i << "," << j << endl;
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        char[] c = new char[s.Length];
        c = s.ToCharArray();
        if (s.Length < 1200)
        {
            for(int i = 0;i < c.Length; i++)
            {
                if (char.IsUpper(c[i])) 
                {
                    c[i] = char.ToLower(c[i]);
                }else if(char.IsLower(c[i]))
                {
                    c[i] = char.ToUpper(c[i]);
                }
            }
        }
        string s2 = new string(c);

        Console.WriteLine(s2);
    }
}

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    int n;
    cin >> n;
    long double ans=0;
    vector<long long> x(n),y(n);
    rep(i,n){
        cin >> x.at(i) >> y.at(i);
    }
    rep(i,n){
        long long a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
        long long aa=0,bb=0,cc=0,dd=0,ee=0,ff=0,gg=0,hh=0;
        long long u=-x.at(i),o=y.at(i);
        rep(j,n){
            if (o*x.at(j)+u*y.at(j)>=0) {
                c+=x.at(j);d+=y.at(j);
                if (o*x.at(j)+u*y.at(j)==0){
                if (x.at(i)*x.at(j)>0 || y.at(i)*y.at(j)>0) {g+=x.at(j);h+=y.at(j);}
                else {e+=x.at(j);f+=y.at(j);}
                }
                else {g+=x.at(j);h+=y.at(j);e+=x.at(j);f+=y.at(j);}
                }
            if (o*x.at(j)+u*y.at(j)>0) {
                a+=x.at(j);b+=y.at(j);
            }
            if (o*x.at(j)+u*y.at(j)<=0) {
                cc+=x.at(j);dd+=y.at(j);
                if (o*x.at(j)+u*y.at(j)==0){
                if (x.at(i)*x.at(j)>0 || y.at(i)*y.at(j)>0) {gg+=x.at(j);hh+=y.at(j);}
                else {ee+=x.at(j);ff+=y.at(j);}
                }
                else {gg+=x.at(j);hh+=y.at(j);ee+=x.at(j);ff+=y.at(j);}
                }
            if (o*x.at(j)+u*y.at(j)<0) {
                aa+=x.at(j);bb+=y.at(j);
                
            }
        }
        
        long double t=sqrt(a*a+b*b),tt=sqrt(c*c+d*d),r=sqrt(e*e+f*f),rr=sqrt(g*g+h*h);
        long double t1=sqrt(aa*aa+bb*bb),tt1=sqrt(cc*cc+dd*dd),r1=sqrt(ee*ee+ff*ff),rr1=sqrt(gg*gg+hh*hh);
        ans=max(ans,t);ans=max(ans,tt);ans=max(ans,r);ans=max(ans,rr);
        ans=max(ans,t1);ans=max(ans,tt1);ans=max(ans,r1);ans=max(ans,rr1);
    }
    cout << fixed << setprecision(13) << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int calc(int x, char mark, int y);

int main(void){
  int a, b;
  char op, sp1, sp2;
  int ans;
  scanf("%d", &a);
  scanf("%c", &sp1);
  scanf("%c", &op);
  scanf("%c", &sp2);
  scanf("%d", &b);
  while(op != '?'){
    ans = calc(a, op, b);
    printf("%d\n", ans);
    scanf("%d", &a);
    scanf("%c", &sp1);
    scanf("%c", &op);
    scanf("%c", &sp2);
    scanf("%d", &b);
  }
  
  return 0;
}

int calc(int x, char mark, int y){
  int c;
  if(mark == '+'){
    c = x+y;
  }
  else if(mark == '-'){
    c = x-y;
  }
  else if(mark == '*'){
    c = x*y;
  }
  else if(mark == '/'){
    c = x/y;
  }
  return c;
}

Measured memory_bytes: 600
from collections import defaultdict


if __name__=="__main__":
    brave_n = int(input())
    monster_dic = defaultdict(int)
    brave_dic = defaultdict(int)
    monster_n = list(map(int, input().split()))
    brave_can = list(map(int, input().split()))
    kill_count = 0

    for i, m in enumerate(monster_n):
        monster_dic[i] = m

    for i, b in enumerate(brave_can):
        brave_dic[i] = b

    for i in range(len(brave_dic)):

        if brave_dic[i] >= monster_dic[i]:
            kill = monster_dic[i]
            monster_dic[i] -= kill
            brave_dic[i] -= kill
            kill_count += kill
            if brave_dic[i] >= monster_dic[i+1]:
                kill = monster_dic[i+1]
                monster_dic[i+1] -= kill
                brave_dic[i] -= kill
                kill_count += kill
            else:
                kill = brave_dic[i]
                monster_dic[i+1] -= kill
                brave_dic[i] -= kill
                kill_count += kill
        else :
            kill = brave_dic[i]
            monster_dic[i] -= kill
            brave_dic[i] -= kill
            kill_count += kill

    print(kill_count)


Measured memory_bytes: 36680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string n;
    cin >> n;
    if (n[0] == n[2]) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <climits>
using namespace std;
long long max (long long a, long long b) {if (a > b) return a; return b;}
 
int main()
{
    int N;
    int a[200005] = {0};
    long long dp4[200005][3] = {0};
    long long sum = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    long long ans = LLONG_MIN;
        dp4[0][0] = a[0]; dp4[0][1] = INT_MIN;  dp4[0][2] = INT_MIN;
        dp4[1][1] = a[1]; 
        dp4[1][2] = INT_MIN; 
        dp4[1][0] = INT_MIN; 
        dp4[2][2] = a[2]; 
        for (int i = 2; i < N; i++) {
            if (i >= 2) dp4[i][0] = dp4[i-2][0]==INT_MIN?INT_MIN:dp4[i-2][0] + a[i];
            if (i >= 3) dp4[i][1] = dp4[i-2][1]==INT_MIN?INT_MIN:dp4[i-2][1] + a[i];
            if (i - 3 >= 0) dp4[i][1] = max(dp4[i][1], dp4[i-3][0]==INT_MIN?INT_MIN:dp4[i-3][0] + a[i]); 
            // else dp4[i][1] = max(dp4[i][1], a[i]);
            if (i >= 4) dp4[i][2] = dp4[i-2][2]==INT_MIN?INT_MIN: dp4[i-2][2]+a[i];
            if (i - 4 >= 0) dp4[i][2] = max(dp4[i][2], dp4[i-3][1]==INT_MIN?INT_MIN:dp4[i-3][1] + a[i]); 
            if (i - 4 >= 0) dp4[i][2] = max(dp4[i][2], dp4[i-4][0]==INT_MIN?INT_MIN:dp4[i-4][0] + a[i]); 
            // else dp4[i][2] = max(dp4[i][2], a[i]);
        }
        // for (int i = 0; i < N; ++i) {
        //     cout << dp4[i][0] << ' ';
        // } cout << endl;
        // for (int i = 0; i < N; ++i) {
        //     cout << dp4[i][1] << ' ';
        // } cout << endl;
        // for (int i = 0; i < N; ++i) {
        //     cout << dp4[i][2] << ' ';
        // } cout << endl;

        if (N % 2 == 0){
            if (N - 1 >= 0)ans = max(ans, dp4[N-1][1]);
            if (N - 2 >= 0)ans = max(ans, dp4[N-2][0]);
        }else {
            if (N - 1 >= 0)ans = max(ans, dp4[N-1][2]);
            if (N - 2 >= 0)ans = max(ans, dp4[N-2][1]);
            if (N - 3 >= 0)ans = max(ans, dp4[N-3][0]);
        }
        cout << ans << endl;
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[111];

int main() {
    li n;
    cin >> n;
    rin{cin >> a[i];}

    li all = 1;
    li odd = 1;
    rin{
        all *= 3;
        if (a[i] % 2 == 0) {
            odd *= 2;
        } else{
            odd *= 1;
        }
    }
    cout << all - odd << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL n, k;
    cin >> n >> k;
    LL ans = 1;
    for( int i = 0; i < n - 1; ++i ) {
        ans *= ( k - 1 );

    }

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



Measured memory_bytes: 256
n = gets.to_i

line = []
n.times do |i|
  line[i] = gets.split.map(&:to_i)
end

old = [0, 0, 0]
line.each do |l|
  check = l[0] - old[0] - (old[1] - l[1]).abs - (old[2] - l[2]).abs

  if check < 0 || check.odd?
    puts 'No'
    exit
  end

  old = l
end

puts 'Yes'

Measured memory_bytes: 9596
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define int ll
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }

template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class F>
constexpr decltype(auto) funcs(F &&f) {
    return FixPoint<F>{std::forward<F>(f)};
}

template <class T>
std::vector<T> vecs(int n, T &&val) {
    return std::vector<T>(std::forward<int>(n), std::forward<T>(val));
}

template <class... Args>
decltype(auto) vecs(int n, Args &&... args) {
    return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...));
}

template <class V, class T>
void fill(V &x, const T &val) {
    x = val;
}

template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n, k;
    cin >> n >> k;
    auto log_v = log2(k) + 2;
    auto val = vecs(n, 63, int());
    rep(i, n) {
        int a;
        cin >> a;
        --a;
        val[i][0] = a;
    }

    rep(j, log_v - 1) rep(i, n) val[i][j + 1] = val[val[i][j]][j];
    int pos = 0;
    repd(i, log_v) {
        if ((k >> i) & 1) pos = val[pos][i];
    }

    cout << pos + 1 << '\n';
}

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


Measured memory_bytes: 108192
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  int B, C, D ,E ,F;
  int A[3];
  string S,Sa,Sb,Sc;
  cin >> A[0] >> A[1] >> A[2];
  int ans = 0;
sort(A,A + 3);
ans = A[1] + A[0];
cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    int n;
    int input;
    vector<int> v;
    vector<int> c;

    // input
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> input;
        v.push_back(input);
    }
    for (int i = 0; i < n; i++) {
        cin >> input;
        c.push_back(input);
    }

    // output
    int maxValue = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            maxValue += v[i] - c[i];
        }
    }

    // answer
    cout << maxValue << endl;
    return (0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int M;
    int D;
    int count=0;
    scanf("%d %d", &M, &D);
    int i,j;
    for(i=1; i <= M; i++){
        for(j=22; j<=D; j++){
            int s = j%10;
            if(s==1)continue;
            int m = j/10;
            int t = m%10;
            if(s*t==i)count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100005
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)            //counts no of ones in binary representation
#define w(t)     int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n];
	forn(i,n)	cin>>a[i];
	ll ans=0;
	for(int i=0;i<n;i+=2){
		if(a[i]%2)	ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

vvi g(15, vi(15, -1));

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

    rep(i, n)
    {
        int a;
        cin >> a;
        rep(j, a)
        {
            int x, y;
            cin >> x >> y;
            x--;
            g[i][x] = y;
        }
    }

    int ans = 0;

    /*
    rep(x, 3)
    {
        rep(y, 3)
        {
            printf("%d ", g[x][y]);
        }
        printf("\n");
    }
    */

    rep(i, 1 << n)
    {
        vi d(n);
        rep(j, n)
        {
            d[j] = ((i >> j) & 1);
        }

        bool ok = true;

        rep(j, n)
        {
            if (d[j] == 0)
                continue;
            rep(k, 15)
            {
                if (g[j][k] == -1)
                    continue;
                if (g[j][k] != d[k])
                    ok = false;
            }
        }

        /*
        printf("bool:%d\n", ok);
        printf("count:%d\n", __builtin_popcount(i));
        */
        if (ok)
        {
            ans = max(ans, __builtin_popcount(i));
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int counter = 700;
    if (s[0] == 'o') counter = counter + 100;
    if (s[1] == 'o') counter = counter + 100;
    if (s[2] == 'o') counter = counter + 100;
    cout << counter << endl;
}

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


signed main(){

  int n,q; cin >> n >> q;
  queue< pair<string,int> > que;
  for(int i = 0; i < n; i++){
    string s;
    int t;
    cin >> s >> t;
    que.push({s,t});
  }

  int t = 0;
  for(;!que.empty();){
    pair<string,int> p = que.front(); que.pop();
    if(p.second-q <= 0){
      t += p.second;
      cout << p.first << " " << t << endl;
    }
    else{
      t += q;
      que.push({p.first,p.second-q});
    }
  }

  return 0;
}



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

int main()
{
	ll n, k, q; cin >> n >> k >> q;
	
	vector<ll> point(n, 0);
	for (ll i = 0; i < q; i++) {
		ll tmp; cin >> tmp;
		point[tmp - 1]++;
	
	}

	for (ll i = 0; i < n; i++) {
		if (0 < point[i] + k- q) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for(long long i = (long long)(n - 1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	int a, b;
	cin >> a >> b;
	a--; b--;
	int ans[3] = {};
	ans[a] = 1;
	ans[b] = 1;

	rep(i, 3)
	{
		if (ans[i] == 0)
		{
			cout << i + 1 << endl;
		}
	}


	return 0;
}

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

int main() {
  int n,k; cin>>n>>k;
  int p[n]; for (int i=0; i<n; i++) cin >> p[i];
  sort(p, p+n);
  int ans = 0;
  for (int i=0; i<k; i++) ans += p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << " " << (a + b) * 2 << endl;
	return 0;
}



Measured memory_bytes: 3080
// Date: 2020-03-13

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 3000 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n;
LL dp[N][N], a[N];

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) rep(j, 1, n) dp[i][j] = -INF;
    rep(i, 1, n) cin >> a[i], dp[i][i] = a[i];
    rep(len, 1, n) {
        rep(i, 1, n-len) {
            int j = i+len;
            chkmax(dp[i][j], a[i] - dp[i+1][j]);
            chkmax(dp[i][j], a[j] - dp[i][j-1]);
        }
    }
    cout << dp[1][n];

    return 0;
}

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

int main(){
  long X, A, B;
  cin >> X;
  for(A=-118; A<=119; A++){
    for(B=-119; B<=118; B++){
      if(A*A*A*A*A==B*B*B*B*B+X){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

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

        while (true) {
            int a = scanner.nextInt();
            String op = scanner.next();
            int b = scanner.nextInt();
            int res = 0;

            switch (op) {
            	case "?":
            		return;

            	case "+":
            		res = a + b;
            		break;

            	case "-":
            		res = a - b;
            		break;

            	case "*":
            		res = a * b;
            		break;

            	case "/":
            		res = a / b;
            		break;
            }
            String s = String.format("%d", res);
            System.out.println(s);
        }

    }
}


Measured memory_bytes: 26440
A, B, C, X, Y = map(int, input().split())

if A+B < 2*C:
    print(A*X + B*Y)
else:
    ans = 0
    num = 0
    if X < Y:
        ans += 2 * C * X
        num = Y - X
        if B > 2*C:
            ans += 2 * C * num
        else:
            ans += B * num
    else:
        ans += 2 * C * Y
        num = X - Y
        if A > 2*C:
            ans += 2 * C * num
        else:
            ans += A * num
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n,m;
int a[100010];
int cnt[100010];
int mod[100010];

void input() {
    cin >> n >> m;
    REP(i,n) {
        cin >> a[i];
        cnt[a[i]]++;
        mod[a[i] % m]++;
    }
}

void solve() {
    int ans = 0;
    ans += mod[0] / 2;
    mod[0] -= ans * 2;
    for (int i = 1; i < m; i++) {
        int add = min(mod[i], mod[m - i]);
        if (i == m - i) {
            mod[i] -= add / 2 * 2;
            ans += add / 2;
            continue;
        }
        mod[i] -= add;
        mod[m - i] -= add;
        ans += add;
        // cout << i << " " << m - i << " " << add << endl;
    }
    for (int i = 0; i < m; i++) {
        if (mod[i] >= 2) {
            for (int j = i; j <= 100000; j += m) {
                if (cnt[j] >= 2) {
                    int add = min(mod[i] / 2, cnt[j] / 2);
                    mod[i] -= add * 2;
                    ans += add;
                    // cout << j << " " << add << endl;
                }
                if (mod[i] < 2) break;
            }
        }
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


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

int main() {
    int n,a;

    cin >> n;
    int ai[n];
    int cnt[100000];

    for(int i=0; i<100000; i++){
        cnt[i] = 0;
    }

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

    int x;

    for(int i=0;i<n;i++){
        x = ai[i];
        cnt[x]++;
        cnt[x-1]++;
        cnt[x+1]++;
    }

    int r;
    int rmax = 0;

    for(int i=0;i<100000;i++){
        r = cnt[i];
        if(rmax < cnt[i]){
            rmax = cnt[i];
        }
    }

    cout << rmax << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    stack<ll> st;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    while (n != 1) {
        if (n % 2 != 0) {
            st.push(1);
            n = (n - 1) / -2;
        } else {
            st.push(0);
            n /= -2;
        }
    }
    cout << 1;
    while (!st.empty()) {
        cout << st.top();
        st.pop();
    }
    cout << endl;
    return 0;
}

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

const int MOD = 1e9+7;

// 繰り返し二乗法(繰り返し自乗法, 二分累乗法)
long modpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}

// これはなに
long comb(long a, long b) {
  long x = 1, y = 1;
  for (int i = 1; i <= b; i++) {
    x = x * (a - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * modpow(y, MOD - 2) % MOD;
}

int main() {
  long N, A, B;
  cin >> N >> A >> B;
  long ans = modpow(2, N);
  ans--;
  ans -= comb(N, A);
  ans -= comb(N, B);
  while (ans < 0) ans += MOD;
  cout << ans << "\n";
}

Measured memory_bytes: 256
def count_list(lst):
    count_lst = [0] * (max(lst) + 2) #0からmax(lst)+1までの個数のリスト

    for i in lst:
        count_lst[i] += 1

    return count_lst


def main():
    n, k = map(int, input().split())
    a_lst = list(map(int, input().split()))
    new_lst = list(set(a_lst))
    types = len(new_lst)

    if types <= k:
        print(0)
    else:
        erase = types - k
        count_lst = count_list(a_lst)
        count_lst.sort()
        count = 0

        tmp = 0
        for i in count_lst:
            if i != 0:
                count += i
                tmp += 1

            if tmp == erase:
                break

        print(count)


if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define YESNO(ans) cout << (ans?"YES":"NO") << endl;
#define pqueue priority_queue
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

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

    int n, m;cin>>n>>m;
    char arr[23][23];
    _fi(n)_fj(m) cin>>arr[i][j];

    int ans = 0;
    for(int a = 0;a < n;a++){
        for(int b = 0;b < m;b++){
            for(int c = 0;c < n;c++){
                for(int d = 0;d < m;d++){
                    if (arr[a][b] == '#' || arr[c][d] == '#') continue;
                    bool processed[23][23] = {};

                    queue<tuple<int, int, int>>q;
                    q.push(mt(a, b, 0));
                    while(!q.empty()){
                        int e = get<0>(q.front());
                        int f = get<1>(q.front());
                        int dis = get<2>(q.front());
                        q.pop();
                        if (processed[e][f]) continue;
                        processed[e][f] = true;

                        if (e == c && f == d){
                            ans = max(ans, dis);
                            break;
                        }

                        if (e+1 < n && arr[e+1][f] == '.') q.push(mt(e+1, f, dis+1));
                        if (e-1 >= 0 && arr[e-1][f] == '.') q.push(mt(e-1, f, dis+1));
                        if (f+1 < m && arr[e][f+1] == '.') q.push(mt(e, f+1, dis+1));
                        if (f-1 >= 0 && arr[e][f-1] == '.') q.push(mt(e, f-1, dis+1));
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}

#pragma endregion



int main(void) {
	int N,A,B;
	int i, b=0,cnt=0;
	char s[100001];

	i_cin3(N,A,B);
	s_cin(s);

	for (i = 0; i < N; i++) {
		if (s[i] == 'c') {
			s_cout("No"); continue;
		}
		
		if (s[i] == 'a') { 
			if (cnt < A + B) {
				s_cout("Yes"); cnt++;
			}
			else           s_cout("No");
			continue;
		}
		
		if ((cnt<A+B)&&(b < B)) {
			s_cout("Yes"); cnt++; b++;
		}
		else s_cout("No");
	}
	return 0;
}




Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;
void enquenue(P x){
  Q[tail]=x;
  tail = (tail + 1)% LEN;
}
P dequeue(){
  P x =Q[head];
  head = (head + 1)% LEN;
  return x;
}

int min(int a,int b){return a<b ? a:b;}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;tail = n+1;
  while (head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0)enquenue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11884