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

using namespace std;

void Main()
{
    string S;
    cin >> S;

    int i = 0;
    int k = S.size() - 1;
    int ans = 0;
    while (i < k) {
        if (S[i] != S[k]) {
            ans++;
        }
        i++;
        k--;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
n = int(input())
dicts = {}
for i in range(n):
    tempstr = input()
    if tempstr not in dicts:
        dicts[tempstr] = 1 
    else:
        dicts[tempstr] += 1 
if "AC" not in dicts:
    dicts["AC"] = 0 
if "WA" not in dicts:
    dicts["WA"] = 0 
if "TLE" not in dicts:
    dicts["TLE"] = 0 
if "RE" not in dicts:
    dicts["RE"] = 0 
print("AC x " + str(dicts["AC"]))
print("WA x " + str(dicts["WA"]))
print("TLE x " + str(dicts["TLE"]))
print("RE x " + str(dicts["RE"]))



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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

map<int, int> x[2];
vector<pair<int, int>> y[2];
int main() {
	int n;
	cin >> n;
	for (int i : range(n)) {
		int a;
		cin >> a;
		x[i % 2][a]++;
	}
	for (int i : range(2))for (auto p : x[i]) {
		y[i].push_back({ p.second,p.first });
	}
	sort(ALL(y[0]));
	sort(ALL(y[1]));
	reverse(ALL(y[0]));
	reverse(ALL(y[1]));
	int ret = n;
	for (int i : range(2)) {
		if (i < y[0].size()) {
			for (int j : range(2)) {
				if (j < y[1].size()) {
					if (y[0][i].second == y[1][j].second) {
						chmin(ret, n - y[0][i].first);
						chmin(ret, n - y[1][j].first);
					}
					else {
						chmin(ret, n - y[0][i].first - y[1][j].first);
					}
				}
			}
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 6140
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
	int N, M;
	cin >> N >> M;
	cout << N*(N-1) / 2+ M*(M- 1) / 2 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)
#define M 1000000007


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    cout<<(n?0:1)<<endl;
}



Measured memory_bytes: 3648
import itertools
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    X = int(input())

    x = 100
    for r in range(1,1000000):
        x = math.floor(x * 1.01)
        if x >= X:
            print(r)
            exit()



if __name__ == "__main__":
  main()


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

int main(void){
    int a, b, result;
    char op;

    while(1){
        cin >> a >> op >> b;
        if(op == '?') break;
        switch (op)
        {
        case '+':
            result = a + b;
            break;
        
        case '-':
            result = a - b;
            break;

        case '*':
            result = a * b;
            break;

        case '/':
            result = a / b;
            break;
        }
        cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>

using namespace std;

int main(){

	string str;
	char alph[7] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
	int num[7] = {1, 5, 10, 50, 100, 500, 1000};
	int x, s[100];
	
	while(cin >> str){
		for(int i=0; i<str.length(); i++){
			for(int j=0; j<7; j++){
				if(str[i] == alph[j]){
					s[i] = num[j];
				}
			}
		}
		
		x = s[str.length()-1];
		for(int i=str.length()-2; i>=0; i--){
			if(s[i+1] > s[i]){
				x -= s[i];
			}
			else{
				x += s[i];
			}
		}
		
		cout << x << endl;
		
	}
	
	return 0;
	
}

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

ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}
//aのｂ乗をｃで割った余り

int main(){
  int n;
  cin>>n;
  ll mod=1e9+7;
  ll ans=mpower(10,n,mod);
  ans+=mpower(8,n,mod);
  ans-=2*mpower(9,n,mod);
  ans%=mod;
  ans+=mod*100;
  ans%=mod;
  cout<<ans<<endl;
}

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

int main() {
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char c1=s1.at(0), c2=s2.at(0), c3=s3.at(0);
  
  cout << c1 << c2 << c3 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n, m; //nはグラフの頂点数,mは辺数
  cin >> n >> m;
  vector<vector<int>> v(n); //頂点同士の連結を保存
  vector<int> vv(n, 0); //親を保存
  vv[0] = 0;
  rep(i, 0, m) {
    int a, b; //頂点a,bは連結である
    cin >> a >> b;
    a--; b--;  
    v[a].push_back(b);
    v[b].push_back(a);
    }
    vector<int> c(n, -1); //その頂点に行くためのコストを保存、未探索は-1
    queue<int> q;
    c[0] = 0; //スタート地点を発見済みに
    q.push(0); //訪問queueに追加
    //ここからBFS
    while(!q.empty()) { //queueが空になるまで探索
        int f = q.front(); //queueの先頭を取り出す
        q.pop();
        for(int i : v[f]) { //範囲for文
          if(c[i] != -1) continue; //すでに発見済みなので探索しない
          c[i] = c[f] + 1; //c[i]:探索中の頂点 c[f]:親の階層 f:親
          vv[i] = f; //親を保存
          q.push(i);
        }
    }
  //for(int i = 0; i < n; i++) cout << c[i] << "\n";
  cout << "Yes" << "\n";
  for(int i = 1; i < n; i++) cout << vv[i]+1 << "\n";
}

Measured memory_bytes: 10564
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

struct Node;
using NodeP = shared_ptr<Node>;
struct Node {
  int key;
  NodeP right, left, parent;
};

NodeP root, NIL;

void insert(int k) {
  auto y = NIL;
  auto x = root;
  auto z = make_shared<Node>();
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    x = (z->key < x->key) ? x->left : x->right;
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

NodeP find(NodeP u, int k) {
  while (u != NIL && k != u->key) {
    u = (k < u->key) ? u->left : u->right;
  }
  return u;
}

NodeP tree_minimum(NodeP x) {
  while (x->left != NIL) x = x->left;
  return x;
}

NodeP tree_successor(NodeP x) {
  if (x->right != NIL) return tree_minimum(x->right);
  auto y = x->parent;
  while (y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void tree_delete(NodeP z) {
  NodeP x;
  auto y = (z->left == NIL || z->right == NIL) ? z : tree_successor(z);
  x = (y->left != NIL) ? y->left : y->right;
  if (x != NIL) x->parent = y->parent;
  if (y->parent == NIL) {
    root = x;
  } else {
    if (y == y->parent->left) {
      y->parent->left = x;

    } else {
      y->parent->right = x;
    }
  }
  if (y != z) z->key = y->key;
}

void inorder(const NodeP &u) {
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(const NodeP &u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;
  cin >> n;
  REP(i, n) {
    cin >> com;
    if (com == "insert") {
      cin >> x;
      insert(x);
    } else if (com == "find") {
      cin >> x;
      cout << ((find(root, x) != NIL) ? "yes" : "no") << endl;
    } else if (com == "delete") {
      cin >> x;
      tree_delete(find(root, x));
    } else if (com == "print") {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
}



Measured memory_bytes: 34404
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
   ll a;cin>>a;
   if(a==22)cout<<"Christmas Eve Eve Eve"<<endl;
   else if(a==23)cout<<"Christmas Eve Eve"<<endl;
   else if(a==24)cout<<"Christmas Eve"<<endl;
   else cout<<"Christmas"<<endl;




return 0;
}


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

int count(ll n) {
    int res = 0;
    while (n > 0) {
        n /= 10;
        res++;
    }
    return res;
}

int main() {
    ll N; 
    cin >> N;
    int ans = count(N);
    for (auto i=1LL; i*i<=N; i++) {
        if (N % i != 0) continue;
        const ll j = N / i;
        const int cur = max(count(i), count(j));
        if (ans > cur) ans = cur;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, x;
  cin >> N >> A;
 
  x = N % 500;	//Nを500円で割ったあまり 
  
  if (x <= A) {	//あまりより１円が多かったら
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 1003

int n, m;
int cnt[N];
int main() {
  cin >> n >> m;
  rep(i, m) {
    int c, d;
    cin >> c >> d;
    cnt[c-1] += 1;
    cnt[d-1] -= 1;
  }
  int ans = n + 1;
  int cur = 0, fst = 0;
  rep(i, n) {
    if(cur == 0 && cnt[i] > 0) {
      fst = i;
    }
    cur += cnt[i];
    if(cnt[i] < 0 && cur == 0) {
      ans += (i - fst) * 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long


int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(-1);
}

int n,k;
vector<int> v;
int a[300001];
vector<int> leng;

int main() {
    cin>>n>>k;
    REP(i,n)cin>>a[i];
    REP(i,300001)leng.push_back(0);

    auto seg = atcoder::segtree<int,op,e>(leng);
    REP(i,n){
        auto a_ = a[i];
        auto m = seg.prod(max(a_-k,0),min(a_+k+1,300001));
        //cerr<<a[i]<<" "<<m<<endl;
        seg.set(a_,m+1);
    }
    cout<<seg.prod(0,300001)<<endl;
}

Measured memory_bytes: 9992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy";
    else if(s == "Cloudy") cout << "Rainy";
    else cout << "Sunny";
    return 0;
}

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

int main(){
  ll a,ans,c;long double b;cin>>a>>b;
  c=b*100+0.5;
  ans=(a*c)/100;
  cout<<ans;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll n;
  cin >> n;
  vll v(n);
  for (ll i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  long double x = v[0];
  for (ll i = 1; i < n; i++) {
    x += v[i];
    x /= 2.0;
  }
  
  cout << fixed << setprecision(6);
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 bool sortbysec(pair<long long int,long long int> a,pair<long long int,long long int> b)
 {
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
 }     
 int main()
{
   // #define long long int long long long long int
    long long int n,w,i,j,a,b,max1;
    cin >> n >> w;
    vector <pair<long long int,long long int>> g;
    for(i=0;i<n;i++)
    {
        cin >> a >> b;
        g.push_back(make_pair(a,b));
    }
   // sort(g.begin(),g.end(),sortbysec);
    long long int mat[n][w+1];
    for(i=0;i<n;i++)
        mat[i][0]=0;
    for(j=1;j<=w;j++)
    {
        mat[0][j]=0;
    }
    mat[0][g[0].first]=g[0].second;
    for(i=1;i<n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if((j-g[i].first)<0)
                mat[i][j]=mat[i-1][j];
            else
                mat[i][j]=max(g[i].second+mat[i-1][j-g[i].first],mat[i-1][j]);
        }
    }
    max1=INT_MIN;
    for(j=0;j<=w;j++)
        max1=max(mat[n-1][j],max1);
    cout << max1;

    
}

Measured memory_bytes: 78336
a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            Y=500*i+100*j+50*k
            if Y==x:
                ans+=1

print(ans)

Measured memory_bytes: 3064
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  vector<int> a(123, 100);
  vector<int> aa(123, 0);

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.length(); j++) {
      aa[(int)s[j]]++;
    }
    for (int j = 97; j < 123; j++) {
      if (a[j] > aa[j]) a[j] = aa[j];
      aa[j] = 0;
    }
  }
  string s = "";
  for (int i = 97; i < 123; i++) {
    if (a[i] == 100) continue;
    for (int j = 0; j < a[i]; j++) {
      s = s + (char)i;
    }
  }
  cout << s << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;
  
  ll a[2][n];
  for(i=0;i<n;i++){
    cin >> a[0][i];
  }
  for(i=0;i<n;i++){
    cin >> a[1][i];
  }
  
  ll b[2][n];
  b[0][0]=a[0][0];
  b[1][n-1]=a[1][n-1];
  for(i=1;i<n;i++)b[0][i]=b[0][i-1]+a[0][i];
  for(i=n-2;i>=0;i--)b[1][i]=b[1][i+1]+a[1][i];
  
  for(i=0;i<n;i++){
    chmax(result,b[0][i]+b[1][i]);
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1728
// Problem : A - Serval vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int H, A; cin >> H >> A;
	cout << (H+A-1)/A << endl;
}



Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
  string s;
   cin >> s;
  bool ans=true;
  for(int i=0;i<s.size()-1;i++){
    for(int j=i+1;j<s.size();j++){
      if(s.at(i)==s.at(j)){
        ans=false;
        break;
      }
    }
    if(!ans){
      break;
    }
  }
  if(ans){
    cout << "yes" << endl;
  }
  else{
    cout << "no" << endl;
  }
}
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
	int k;
	cin >> k;
	if (k == 4 || k == 6 || k == 9 || k == 10 || k == 14 || k == 21 || k == 22 || k == 25 || k == 26) {
		cout << "2" << endl;
	}
	else if (k == 8 | k == 12 || k == 18 || k == 20 || k == 27) {
		cout << "5" << endl;
	}
	else if (k == 28 || k == 30) {
		cout << "4" << endl;
	}
	else if (k == 16) {
		cout << "14" << endl;
	}
	else if (k == 24) {
		cout << "15" << endl;
	}
	else if (k == 32) {
		cout << "51" << endl;
	}
	else {
		cout << "1" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
ll const INF = 1LL << 60;

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

    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B;
        cin >> A >> B;
        cout << A+B << endl;
    }
   return 0;
}

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

#define mo 1000000007
using namespace std;

int n, a[200005], pre[200005], ans;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        pre[i] = (pre[i - 1] + a[i]) % mo;
        ans = (ans + (long long) pre[i - 1] * a[i]) % mo;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  int cnt=0;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      for(int k=j+1;k<n;k++)
      {int x=a[i], y=a[j],z=a[k];
       if(x+y>z && (x!=y && y!=z && z!=x))
            cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}    


Measured memory_bytes: 3628
from sys import stdin

N, K, Q = map(int, stdin.readline().split())

A = []
for i in range(Q):
    A.append(int(stdin.readline()))

#print(A)

k = [0 for i in range(N)]
#print(k)

for i in range(Q):
    k[A[i]-1] += 1

for i in range(N):
    if 0 < K - (Q - k[i]):
        print("Yes")
    else:
        print("No")

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

int main() {
    int a[3];
    int ans = 0;
    
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    
    sort(a, a + 3);
    
    for (int i = 0; i < 2; i++) {
        ans += a[i + 1] - a[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();

        if(c-(a-b) <= 0) {
            System.out.println(0);
        }else {
        System.out.println(c-(a-b));
        }
    }

}

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

ll n;
ll sum = 0;
ll s[11];

void dfs(ll dp, bool *flag){
    if(dp == n - 1){
        ll p[11];
        rep(i, n){
            p[i] = s[i];
        }
        rep(i, n - 1){
            if(flag[i] == false){
                sum += p[i];
            }else{
                p[i+1] += 10 * p[i];
            }
        }
        sum += p[n-1];
        return;
    }

    flag[dp] = false;
    dfs(dp + 1, flag);
    flag[dp] = true;
    dfs(dp + 1, flag);
}

int main(void){
    ll tmp;
    cin >> tmp;

    ll i = 0;
    ll p[11];
    while(tmp != 0){
        p[i] = tmp % 10;
        tmp /= 10;
        i++;
    }
    n = i;

    i = 0;
    for(int j = n - 1; j >= 0; j--){
        s[j] = p[i];
        i++;
    }

    bool flag[n];
    dfs(0, flag);

    cout << sum << endl;
    return 0;
}


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

public class Main {
    static final long DIV = 1000000007;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] s = new boolean[n+1];
        for(int i=0; i<m; i++){
            int a = sc.nextInt();
            s[a] = true;
        }

        long[] dp = new long[n+1];
        dp[0] = 1;
        if(s[1]){
            dp[1] = 0;
        }else{
            dp[1] = 1;
        }
        for(int i=2; i<=n; i++){
            if(s[i]){
                dp[i] = 0;
            }else{
                dp[i] = dp[i-1] + dp[i-2];
                dp[i] %= DIV;
            }
        }

        System.out.println(dp[n]);


    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 22356
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int> h(N),dp(N);
  for(int i=0;i<N;i++)cin>>h[i];
  dp[1]=abs(h[1]-h[0]);
  for(int i=1;i<N-1;i++){
    dp[i+1]=min(dp[i]+abs(h[i+1]-h[i]), dp[i-1]+abs(h[i+1]-h[i-1]));
  }
  cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1024
S = input()
ans = len(S)

stack = []
for s in S:

    if s == 'S':
        stack.append(s)
    elif s == 'T' and len(stack) == 0 or stack[-1] == 'T':
        stack.append(s)
    elif s == 'T' and stack[-1] == 'S':
        stack.pop()

print(len(stack))

# #部分点
# while 'ST' in S:
#     num = S.count('ST')
#     S = S.replace('ST','',num)

#print(len(S))


Measured memory_bytes: 5092
#include <stdio.h>
#include <math.h>

int isPrime(int x);

main(){

  int N;
  int i,j,a;
  int count = 0;

  scanf("%d",&N);

  for (i=0;i<N;i++){
    scanf("%d",&a);
    count += isPrime(a);
  }

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

}

int isPrime(int x){

  int i;
  int limit = sqrt(x) + 1;
  int s;

  if(x>2 && x%2==0){
    return 0;
  }

  for (i=3;i<limit;i+=2){
    if(x%i==0){
      return 0;
    }
  }
  return 1;

}

Measured memory_bytes: 0
def gcd(a, b):
    bigger = max(a, b)
    smaller = min(a, b)
    while smaller:
        bigger, smaller = smaller, bigger % smaller
    return bigger


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
bool isPrime[1000000];
void calcPrime(){
  fill(isPrime, isPrime+1000000, true);
  isPrime[0] = isPrime[1] = false;

  for(int i = 4; i < 1000000; i+=2){
    isPrime[i] = false;
  }
  
  for(int i = 3; i*i < 1000000; i+=2){
    if(isPrime[i] == false)continue;
    for(int j = i+i; j < 1000000; j+=i){
      isPrime[j] = false;
    }
  }
}
int main(){
  calcPrime();
  int n;
  while(cin >> n){
    int cnt = 0;
    for(int i = 2; i <= n; i++){
      if(isPrime[i])cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

bool is_prime(int n){
	for(int i = 2; i <= n / 2; i++){
		if(n % i == 0){
			return false;
		}
	}
	return true;
}

int near_prime(int n){
	while(true){
		if(is_prime(n) == true){
			return n;
			break;
		}else{
			n++;
		}
	}
}

int main() {
	int n, a = 10, b, c = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		while(c != 1){
			b = near_prime(a);
			if(b % 5 == 1){
				cout << b << " ";
				c = 1;
				
			}else{
				a++;
			}
		}
		c = 0;
		a += 50;
		b = 0;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		List<Integer> productList = new ArrayList<>();
		int temp;
		int answer = 0;

		int N = scanner.nextInt();

		for(int i = 0; i < N; i++) {
			temp = scanner.nextInt();
			productList.add(Integer.valueOf(temp));
			answer += temp;
		}

		Optional<Integer> max = productList.stream().max(Comparator.naturalOrder());

		System.out.println(answer - (max.get()/2));

	}

}


Measured memory_bytes: 27732
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string str;
	while(1){
		cin >> str;
		if(str=="-") break;
		int n;
		cin >> n;
		REP(i,n){
			int tmp;
			cin >> tmp;
			str = str.substr(tmp,str.size()-tmp) + str.substr(0,tmp);
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 1216
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = {}
    ans = 0
    for i in range(n):
        if i+a[i] in d.keys():
            d[i+a[i]] += 1
        else:
            d[i+a[i]] = 1
    for i in range(n):
        if i - a[i] in d.keys():
            ans += d[i-a[i]]
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 116620
//use proconio::input;
use std::cmp::max;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: [(i32, i32, i32); n],
    }
    let mut dp = vec![(0, 0, 0); n];
    dp[0].0 = d[0].0;
    dp[0].1 = d[0].1;
    dp[0].2 = d[0].2;
    for i in 1..n {
        dp[i].0 = d[i].0 + max(dp[i - 1].1, dp[i - 1].2);
        dp[i].1 = d[i].1 + max(dp[i - 1].0, dp[i - 1].2);
        dp[i].2 = d[i].2 + max(dp[i - 1].0, dp[i - 1].1);
    }

    println!("{}", max(max(dp[n - 1].0, dp[n - 1].1), dp[n - 1]. 2));
}


Measured memory_bytes: 10492
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
typedef long long ll;
typedef long l;
int return_max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

int return_min(int a,int b){
  if(a<b){
    return a;
  }else{
    return b;
  }
}


int main(void)
{

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

  int ans[10010]={0};


  for(int x=1;x<=100;x++){
    for(int y=1;y<=100;y++){
      for(int z=1;z<=100;z++){
        int tmp=x*x+y*y+z*z+x*y+y*z+z*x;
        if(tmp<=n){
          ans[tmp]++;
        }
      }
    }
  }

  for(int i=1;i<=n;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 1768
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K, C = MAP()

S = input()

L = [0]*K

cnt = 0
idx = 0
while idx <= N-1 and cnt <= K-1:
	if S[idx] != "x":
		L[cnt] = idx+1
		idx += C+1
		cnt += 1
	else:
		idx += 1

R = [0]*K
S = S[::-1]

cnt = 0
idx = 0
while idx <= N-1 and cnt <= K-1:
	if S[idx] != "x":
		R[cnt] = N-idx
		idx += C+1
		cnt += 1
	else:
		idx += 1
R = R[::-1]
for x, y in zip(L, R):
	if x == y:
		print(x)


Measured memory_bytes: 22736
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
int a,b,a1,b1;

/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> a >> b ;
  a1 = 0 ;
  b1 = 0 ;
  for(int i = 1 ; i <= (b-a);i++){
    a1 += (i-1);
    b1 += i ;
    if(i == (b-a)){
      cout << a1 - a << endl ;
      return 0 ;
    }
  }
  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


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

double get_radian(double x1, double y1, double x2, double y2) {
	if(fabs(x1-x2) < 0.00000001) {
		if(y1 >= y2) {
			return 3 * M_PI / 2;
		}
		return M_PI / 2;
	} else if(fabs(y1-y2) < 0.00000001) {
		if(x1 >= x2) {
			return M_PI;
		}
		return 0.0;
	}
	
	if(x2 >= x1) {
		if(y2 >= y1) {
			return atan((y2-y1)/(x2-x1));
		}
		return 2 * M_PI + atan((y2-y1)/(x2-x1));
	} else {
		if(y2 >= y1) {
			return M_PI - atan((y2-y1)/(x1-x2));
		}
		return M_PI + atan((y2-y1)/(x2-x1));
	}
}

int main(void) {
	double base_x, base_y, x, y;
	double base_rad, target_rad;
	double rad;
	double r;
	int i, n;
	
	scanf("%lf %lf %lf %lf\n", &base_x, &base_y, &x, &y);
	scanf("%d\n", &n);
	base_rad = get_radian(base_x, base_y, x, y);
	
	for(i=0;i<n;i++) {
		scanf("%lf %lf\n", &x, &y);
		target_rad = get_radian(base_x, base_y, x, y);
		r = sqrt((x-base_x)*(x-base_x)+(y-base_y)*(y-base_y));
		
		// 後はどっち側に振れるか
		rad = fmod(2*M_PI+target_rad-base_rad, 2*M_PI);
		
		if(rad > M_PI) {
			rad = 2*M_PI - rad;
		}
		
		x = base_x + (r*cos(rad)) * cos(base_rad);
		y = base_y + (r*cos(rad)) * sin(base_rad);
		
		printf("%.10lf %.10lf\n", x, y);
	}
	
	return 0;
}

Measured memory_bytes: 780
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;


int main()
{
    string s;
    long long k;
    cin >> s;
    cin >> k;
    
    long long ans = 0;
    
    int check = 1;
    
    for (long long  i = 0;i < s.size()-1;i++){
        if (s[i] != s[i+1]) {
            check = 0;
            break;
        }
    }
    
    if (check){
        ans = (s.size()*k)/2;
    }
    else {
        long long t = 1;
        for (long long i = 0;i < s.size()-1;i++){
            if (s[i] == s[i+1]){
                t++;
            }
            else {
                ans += t/2;
                t = 1;
            }
        }
        ans += t/2;
        
        if (s[0] == s[s.size()-1]){
            long long sta = 1;
            long long end = 1;
            for (long long i = 0;i < s.size()-1;i++){
                if (s[i] != s[i+1]) break;
                sta++;
            }
            for (long long i = s.size()-1;i >= 1;i--){
                if (s[i] != s[i-1]) break;
                end++;
            }
            ans = ans*k-(sta/2+end/2-(sta+end)/2)*(k-1);
        }
        else {
            ans *= k;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
asum=sum(a)
a1=a
ans=0
for i in range(n):
  if b[i]>=a1[i]+a1[i+1]:
    a1[i],a1[i+1]=0,0
    ans+=a1[i]+a1[i+1]
  elif b[i]>=a1[i]:
    a1[i+1]-=b[i]-a1[i]
    a1[i]=0
    ans+=b[i]
  else:
    a1[i]-=b[i]
    ans+=b[i]
print(asum-sum(a1))


Measured memory_bytes: 19648
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;

struct sa
{
    int score,num;
    char name[20];
}a[105];

int cmp (const sa &a,const sa &b)
{
    if (strcmp(a.name,b.name))
        return strcmp(a.name,b.name)<0;
    else
        return a.score>b.score;

}
int main()
{
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        scanf("%s %d",a[i].name,&a[i].score);
        a[i].num=i;
    }
    sort(a+1,a+1+n,cmp);
    for (int i=1;i<=n;i++)
        printf("%d\n",a[i].num);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def dfs(u, v, pu=-1):
        if u == v: return True
        for cu in to[u]:
            if cu == pu: continue
            if dfs(cu, v, u):
                path.append(uvtoi[u, cu])
                return True
        return False

    to = defaultdict(list)
    n = II()
    uvtoi = {}
    for i in range(n - 1):
        a, b = MI1()
        to[a].append(b)
        to[b].append(a)
        uvtoi[a, b] = i
        uvtoi[b, a] = i
    m = II()
    itoj = defaultdict(list)
    for j in range(m):
        u, v = MI1()
        path = []
        dfs(u, v)
        #print(path)
        for i in path: itoj[i].append(j)
    #print(itoj)
    en = len(itoj)
    dp = [[0] * (1 << m) for _ in range(en + 1)]
    dp[0][0] = 1
    for i, jj in enumerate(itoj.values()):
        mask = sum(1 << j for j in jj)
        for bit in range(1 << m):
            pre = dp[i][bit]
            if pre == 0: continue
            dp[i + 1][bit | mask] += pre
            dp[i + 1][bit] += pre
    #print(dp)
    ans=dp[-1][-1]*pow(2,n-1-en)
    print(ans)

main()


Measured memory_bytes: 442780
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ans=0;
    int n = s.size();
    for(int i=1;i<n;i++){
        if((n-i)%2!=0) continue;
        //cout<<n-i<<":"<<s.substr(0,n-i)<<":"<<s.substr(0,(n-i)/2)<<":"<<s.substr((n-i)/2,(n-i)/2)<<endl;
        if(s.substr(0,(n-i)/2)==s.substr((n-i)/2,(n-i)/2)){
            ans = max(ans,n-i);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    for x in a:
        if x==0:
            print(0)
            return

    ans = 1
    for x in a:
        ans *= x
        if ans > 10**18:
            print(-1)
            return

    print(ans)

solve()


Measured memory_bytes: 21596
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <deque>
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
const ll inf = 1e18;

int getk(int n)
{
    int cnt=1;
    cnt = ((int)sqrt(1+8*n)-1)/2;
    return cnt;
}
void solve()
{
    ll n;
    cin >> n;
    vector<int> v;
    for(int i=2; i<=sqrt(n); i++)
        if(n%i==0)
        {
            int cnt = 0;
            while(n%i==0)
                n/=i, cnt++;
            v.push_back(cnt);
        }
    int ans=0;
    for(auto c : v)
        ans+=getk(c);
    if(n!=1)
        ans++;
    cout << ans << '\n';
}

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

Measured memory_bytes: 3676
// Ivan Zanov
// Template
#include <iostream>
#include <utility>
#include <bitset>
#include <vector>
#include <set>
#include <unordered_map>
#include <map>
#include <assert.h>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <memory>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <sstream>
#include <exception>
#include <functional>
#include <cstring>
#include <cstdlib>
using namespace std;
#define lowbit(x) ((x)&((x)^((x)-1)))
#define max(a,b) (a<b?b:a)
#define IOS ios_base::sync_with_stdio(0);
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define INF (int)1e9
#define EPS (int)1e-9
#define bit_count __builtin_popcount
#define gcd __gcd
#define size(r) r.size()
#define max3(a, b, c) max(a, max(b,c))
#define min3(a, b, c) min(a, min(b,c))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
inline void set_bit(int & n, int b) { n |= (1 << (int) b); }
inline void unset_bit(int & n, int b) { n &= ~(1 << (int) b); }
inline bool check_bit(int n, int pos) { return ( n & (1 << (pos))); }
inline ll lcm(ll a, ll b){ return (a * b / gcd(a,b));}
int main() {
    int n;
    cin>>n;
    int at = 0;
    int ith = 1;
    for(int i =0;i<n;i++)
    {
        int a;
        cin>>a;
        if(ith == a)
        {
            ith++;
            at++;
        }
    }
    if(n - at == n && n > 1)
        puts("-1");
    else
        cout<<n - at<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

int main() {
    int A,P;
    cin >> A >> P;
    P += 3*A;
    cout << P/2 << endl;
}

Measured memory_bytes: 256