akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #define ll long long
    #define sz(a) int((a).size())
    #define fr(i,n) for(int i=0;i<n;i++) 
    #define rf(i,n) for(int i=1;i<=n;i++)
    #define jdb(i,v) for(__typeof(v.begin())i=v.begin(); i!=v.end();i++)
    #define present(c,a) (find(all(c),a) != c.end())
    #define spresent(c,a) (c.find(a)!=c.end())
    #define no(s,c) s.count(c)  
    #define pb push_back 
    #define eb emplace_back
    #define mp make_pair
    #define all(c) (c).begin(),(c).end()
    #define MAX INT_MAX 
    using namespace std;
    #define f first
    #define s second
    int backtrack(int,int);
    int M = 1000000007;
    int v[100001];
    int dp[100001];
    int n;
    int main() 
    { 
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin>>n;
        fr(i,n)
        cin>>v[i];
        cout<<backtrack(2,0)<<endl;
        return 0; 
    }

    int backtrack(int j,int sum)
    {
        dp[0]=0;
        dp[1]=abs(v[1]-v[0]);
        while(j<n)
        {
            dp[j] = min(dp[j-1]+sum+abs(v[j]-v[j-1]),dp[j-2]+sum+abs(v[j-2]-v[j]));
            j++;
        }
        return dp[n-1];
    }

Measured memory_bytes: 1024
def conv(c): return '+' if c==1 else '-'
def main():
	num = [int(c) for c in input()]
	choices = [-1,1]
	for a in choices:
		for b in choices:
			for c in choices:
				if num[0]+num[1]*a+num[2]*b+num[3]*c==7:
					print("{}{}{}{}{}{}{}=7".format(num[0],conv(a),num[1],conv(b),num[2],conv(c),num[3]))
					return
main()


Measured memory_bytes: 3060
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50f\n", a)//少数出力
#define printdbd(a) printf("%.16f\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/

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

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

d = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(d)]
# T = [int(input()) for i in range(d)]
c = 26
# m = int(input())
# Q = [list(map(int,input().split())) for i in range(m)]

ans = 0
L = [[-1] * c for i in range(d)]
T = [-1] * d  # この中には0-25を入れる

for i in range(d):
    ANS = [0] * c
    L[i] = L[i-1][:]
    for k in range(c):
        ANS[k] = S[i][k] + C[k] * (i - L[i][k])
    ind = ANS.index(max(ANS))
    ans += S[i][ind]
    L[i][ind] = i
    for j in range(c):
        ans -= C[j] * (i - L[i][j])
    # print(ans)
    # print(ind + 1)
    T[i] = ind


# print("fans",ans)
# print(L)
# print(T)

K = [[] for i in range(d)]

cp = 3
dp = 3

CC = [[C[i], i] for i in range(c)]
CC.sort(reverse=True)
for i in range(d):
    for k in range(cp):
        K[i].append(CC[k][1])

for i in range(d):
    DD = [[S[i][j], j] for j in range(c)]
    DD.sort(reverse=True)
    for k in range(dp):
        K[i].append(DD[k][1])

# print("K",K)
    
from random import randint

m = 5*10**5

Q = [[0] * 2 for i in range(m)]
for i in range(m):
    dd = randint(0, d-1)
    # print("dd",dd)
    # print(dd-1,randint(0, len(K[dd-1])-1))
    q = K[dd][randint(0, len(K[dd])-1)]
    Q[i][0] = dd
    Q[i][1] = q

# print(Q)

for i in range(m):
    # print(*T)
    # print(Q)
    dd = Q[i][0]
    q = Q[i][1]
    nans = ans
    # print("dd",dd)
    nans -= S[dd][T[dd]]
    nans += S[dd][q]
    for j in range(dd, d):
        # print("j",j)
        if T[j] == q:
            # print("break")
            break
        nans += C[q] * (j - L[j][q])
        nans -= C[q] * (j - dd)
        L[j][q] = dd
    
    old = T[dd]
    T[dd] = q

    for j in range(dd, d):
        # print("j",j)
        if T[j] == old:
            # print("break")
            break
        oldl = L[j-1][old] if j > 0 else -1
        nans += C[old] * (j - dd)
        nans -= C[old] * (j - oldl)
        L[j][old] = oldl

    # print(nans, ans)

    if nans < ans:
        if i != m-1:
            Q[i+1] = [dd, old]
        else:
            T[dd] = old
    
    ans = nans

# print(max(ans,nans))
for i in T:
    print(i+1)


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  vector<int> kosuu(N,0);
  for(int i=0;i<N;i++){
    kosuu.at(A.at(i)-1)++;
  }
  sort(kosuu.begin(),kosuu.end());
  reverse(kosuu.begin(),kosuu.end());
  int goukei=0;
  for(int i=0;i<K;i++){
    goukei+=kosuu.at(i);
  }
  cout << N-goukei << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << endl
using namespace std;
int input() {
	int r;
	cin >> r;
	//scanf("%lld", &r);
	return r;
}
signed main() {
	int a, b, c; cin >> c >> a >> b;
	for0(i, 10000) {
		if (a <= i * c&&i*c <= b) {
			puts("OK"); return 0;
		}
	}
	puts("NG");
}

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

int n;
map<int,int> mp;
int query(int x)
{
	if(mp.find(x)!=mp.end()) return mp[x];
	cout<<x<<'\n';
	fflush(stdout);
	string s;
	cin>>s;
	if(s=="Vacant") exit(0);
	return mp[x]=(s=="Male");
}

int main()
{
	
	cin>>n;
	int l=0,r=n-1;
	while(r-l>=2)
	{
		int mid=(l+r)/2;
		if(query(l)^(l%2)!=query(mid)^(mid%2)) r=mid;
		else l=mid;
	}
	for(int i=l;i<=r;i++)
		query(i);
	
	return 0;
}

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

int main() {
int N;
cin >> N ;
int cnt=0;
for (int i = 1; i <=N; i++)
{
  
  string x = to_string(i);
  if(x.size()%2!=0) cnt++;
}
cout << cnt << endl;
  return 0;
}

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

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    range(h, 1, 3501) range(n, 1, 3501) {
        lint numerator = N * h * n;
        lint denominator = 4 * h * n - N * (h + n);
        if (denominator <= 0) continue;
        else if (numerator % denominator) continue;
        lint w = numerator / denominator;
        cout << h << " " << n << " " << w << "\n";
        assert(4 * h * n * w == N * (n * w + w * h + h * n));
        return 0;
    }
}

Measured memory_bytes: 764
A,B,C;a,b,c;p;main(X){scanf("%d%d%d%d",&A,&B,&C,&X);for(;a<=A;a++)for(b=0;b<=B;b++)for(c=0;c<=C;c++)p+=!((10*a+2*b+c)*50-X);printf("%d",p);}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  for (int a = 1; a < 10; a++)
  {
    for (int b = 0; b < 10; b++)
    {
      for (int c = 0; c < 10; c++)
      {
        int x=10001*a+1010*b+100*c;
        if(x>=A && x<=B)
        {
          ans++;
        }
      }
      
    }
    
  }
  
cout<<ans <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long LL;
const int N = 1e5 + 5;
LL a[N];
int n;
LL sum, c, cc;
bool solve(){
	c = 1ll*n*(n+1)>>1;
	if(sum % c) return false;
	c = sum / c;
	for(int i = 1; i < n; i ++){
		if(c < a[i] - a[i-1]) return false;
		if((c - a[i] + a[i-1]) % n) return false;
		cc += (c - a[i] + a[i-1]) / n;
	}
	if((c - a[0] + a[n-1]) % n) return false;
	cc += (c - a[0] + a[n-1]) / n;
	if(c == cc) return true;
	return false;
}
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i ++){
		scanf("%lld", &a[i]);
		sum += a[i];
	}
	puts(solve()?"YES":"NO");
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define l long 
#define ll long long 
#define ld long double 
#define MOD 1000000007
#define MAX_N 1000006
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    vector<ld> pr;
    ld p;
    for(int i=0;i<n;i++)
    {
        cin>>p;
        pr.push_back(p);
    }
    ld dp[n][n+1];
    for(int i=0;i<=n;i++)
    {
        if(i==0)
        dp[0][i]=(1-pr[0]);
        else if(i==1)
        dp[0][i]=pr[0];
        else
        dp[0][i]=0;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j>i+1)
                dp[i][j]=0;
            else if(j==0)
                dp[i][j]=(1-pr[i])*dp[i-1][j];
            else 
                dp[i][j]=pr[i]*dp[i-1][j-1]+(1-pr[i])*dp[i-1][j];
        }
    }
    ld ans=0;
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[n-1][i];
    }
    cout<<fixed<<setprecision(14)<<ans<<endl;
}

Measured memory_bytes: 144360
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 100000
#define MOD 1000000007
#define ll long long
#define rint register int
#define gc() getchar()
inline ll read(ll ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int N, pA[MAXN+5], pB[MAXN+5], fx[MAXN+5], fy[MAXN+5]; ll S[MAXN+5], A, B, px, py, xi, yi; 
int main()
{
	N = read(), A = read(), B = read(), A<=B?:A^=B^=A^=B;
	for(rint i = 1; i <= N; S[i++] = read()); fx[0] = fy[0] = 1;
	for(rint i = 1, pa = 1, pb = 1; i <= N; pA[i] = pa-1, pB[i] = pb-1, i++)
		{for(; S[pa]+A <= S[i]; pa++); for(; S[pb]+B <= S[i]; pb++);}
	for(rint i = 2; i <= N; i++)
	{
		xi = fy[min(i-2,pA[i])], yi = fx[min(i-2,pB[i])];
		if(pA[i] < i-1){memset(fx+px,0,i-px-1<<2); px = i-1;}
		if(pB[i] < i-1){memset(fy+py,0,i-py-1<<2); py = i-1;}
		fx[i-1] += fx[i-2], fx[i-1]<MOD?:fx[i-1]-=MOD, fx[i-1] += xi, fx[i-1]<MOD?:fx[i-1]-=MOD;
		fy[i-1] += fy[i-2], fy[i-1]<MOD?:fy[i-1]-=MOD, fy[i-1] += yi, fy[i-1]<MOD?:fy[i-1]-=MOD;
	}	printf("%d\n",(fx[N-1]+fy[N-1])%MOD); return 0;
}

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

using namespace std;

#define MAX 110
#define MOD 100000

int dp[MAX][MAX][4];

void make_table()
{
    for (int i = 0; i < MAX; i++) {
        dp[i][0][0] = dp[0][i][1] = 1;
    }

    for (int i = 1; i < MAX; i++) {
        for (int j = 1; j < MAX; j++) {
            dp[i][j][0] += dp[i-1][j][0] + dp[i-1][j][2];
            dp[i][j][1] += dp[i][j-1][1] + dp[i][j-1][3];
            dp[i][j][2] += dp[i-1][j][1];
            dp[i][j][3] += dp[i][j-1][0];
            
            for (int k = 0; k < 4; k++) {
                dp[i][j][k] %= MOD;
            }
        }
    }
}

int main()
{
    make_table();
    
    int W, H;
    while (cin >> W >> H, W) {
        int res = 0;
        for (int i = 0; i < 4; i++) {
            res = (res + dp[H-1][W-1][i]) % MOD;
        }        
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3264
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <algorithm>

int main(int argc, char* argv[])
{
  std::string s;
  std::cin >> s;
  int ans;

  int all_size = s.size();
  for (int i = all_size-2; i>=0; i--) {
    if (i % 2 != 0) { continue; }
    std::string a1 = s.substr(0, i / 2);
    std::string a2 = s.substr(i / 2, i / 2);

    if (a1 == a2) {
      ans = i;
      break;
    }
    //std::cout << i << " " << a1 << "/" << a2 << std::endl;
  }

  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
t = [int(input()) for i in range(5)] 
a = np.zeros(5)

for i in range(5):
  a[i] = ( t[i] + 9 ) // 10 * 10 - t[i]
  
b = 0  
for j in range(1,5):
  if a[0] < a[j]:
    b = j
    a[0] = a[b]

c = np.zeros(5)
for i in range(5):
  c[i] = ( t[i] + 9 ) // 10 * 10
    
ans = 0     
ans = np.sum(c) + t[b] - c[b]
print(int(ans))

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

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;
static long rec(long x, Map<Long,Long> map,long[][] op,long d){
    if(x<=0l){
        map.put(0l,0l); return 0l;
    }
    if(map.get(x)!=null) return map.get(x);
    long n=x;
    map.put(x,(long)4e18);
    if((map.get(x)+d-1)/d>n) map.put(x,d*n);
    for(int i=0;i<3;i++){
        if(x%op[i][0]==0){
            map.put(x,Math.min(map.get(x),rec(x/op[i][0],map,op,d)+op[i][1]));
        }
        else{
            map.put(x,Math.min(map.get(x),d*(x%op[i][0])+rec(x/op[i][0],map,op,d)+op[i][1]));
            map.put(x,Math.min(map.get(x),d*(op[i][0]-x%op[i][0])+rec(x/op[i][0]+1,map,op,d)+op[i][1]));
        }
    }
    
     return map.get(n);
}
public static void main(String[] args) throws  IOException{
                assign();
                int t=int_v(read());
               while(t--!=0){
                     long[] x=long_arr();
                     long n=x[0],a=x[1],b=x[2],c=x[3],d=x[4];
                     Map<Long,Long> map=new HashMap<>();
                     long[][] op=new long[][]{{2l,a},{3l,b},{5l,c}};
                     out.write(rec(n,map,op,d)+"\n");
               }

                out.flush();

    }
}


Measured memory_bytes: 56972
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
c = [0]*n
cash = 1000
stock = 0
#1:底 2:頂点 0:どちらでもない

for i in range(1,n):
    if a[i-1]<a[i]:
        b[i]='+'
    elif a[i-1]>a[i]:
        b[i]='-'
    elif a[i-1]==a[i]:
        b[i]=b[i-1]

if b[1]=='+':
    c[0]=1
elif b[1]=='-':
    c[0]=2

for i in range(1,n-1):
    if b[i]=='+' and b[i+1]=='-':
        c[i]=2
    elif b[i]=='-' and b[i+1]=='+':
        c[i]=1

if b[n-1]=='+':
    c[n-1]=2
elif b[n-1]=='-':
    c[n-1]=1
last = n
ch = 0
for i in range(n):
    if c[n-1-i]==1:
        ch = 1
    elif c[n-1-i]==2 and ch==0:
        break
    elif c[n-1-i]==2 and ch==1:
        last = n-i
        break
    elif ch == 1 and i==n-1:
        last=0
        break

if c[0]==0:
    for i in range(1,n):
        if c[i]==2:
            c[0]=1
            break

for i in range(last):
    if c[i]==1:
        stock += cash//a[i]
        cash -= cash//a[i]*a[i]
    if c[i]==2:
        cash += stock*a[i]
        stock =0
print(cash)


Measured memory_bytes: 9252
#include <stdio.h>

int main(void){
   int N, i, j, k, x, m, f;

   scanf("%d", &N);

   int A[N];

   for(i = 0; i < N; i++) {
      scanf("%d", &A[i]);
   }

   m = 0;

   f = 1;

   if (N > 1){

   while(f == 1) {
     f = 0;
     for(j = N - 1; j > 0; j--){
        if (A[j] < A[j - 1]){
          x = A[j];
          A[j] = A[j - 1];
          A[j - 1] = x;
          m++;
          f = 1;
        }
     }
   }

   for(k = 0; k < N - 1; k++) {
      printf("%d ", A[k]);
   }
   printf("%d\n", A[N - 1]);

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

   } else {

   printf("%d\n", A[0]);

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

   }


   return 0;
}


Measured memory_bytes: 2068
n,k=map(int,input().split())
p=list(map(int,input().split()))
new_p=[]
s=[]
ans=-(10**9)
for i in range(n):
    new_p.append((1+p[i])/2)
s.append(new_p[0])
for i in range(n-1):
    s.append(s[i]+new_p[i+1])
s.insert(0,0)
for i in range((len(s)-k)):
    val=s[k+i]-s[i]
    ans=max(ans,val)
print(ans)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 1000000007
using namespace std;

typedef pair<ll, ll> P;

ll A, B, m;
ll a[maxn], b[maxn];

int main()
{
    cin >> A >> B >> m;
    ll ans = LLONG_MAX;
    ll am = LLONG_MAX, bm = LLONG_MAX;
    for (int i = 1; i <= A; i++)
    {
        scanf("%lld\n", &a[i]);
        am = min(am, a[i]);
    }
    for (int i = 1; i <= B; i++)
    {
        scanf("%lld\n", &b[i]);
        bm = min(bm, b[i]);
    }
    ans = am + bm;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        ll c;
        scanf("%d%d%lld", &x, &y, &c);
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
using System;
class Program
{
	static void Main(string[] args)
	{
			string[] input = Console.ReadLine().Split(' ');
			long a = long.Parse(input[0]);
			long b = long.Parse(input[1]);

			long towerHeight = 0;
			long difference = b - a;

			for (long i = 1; i < difference; i++) { towerHeight += i; }

			Console.WriteLine(towerHeight - a);

	}
}


Measured memory_bytes: 11092
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
)

var(
	inf = 10000000071000000
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
)

func init()  {
	rand.Seed(time.Now().UnixNano())
}


func main() {
	n := goint();m := goint()
	graph := make([][][]int,n)
	for i:=0;i<m;i++{
		l,r,d := goint(),goint(),goint()
		graph[l-1] = append(graph[l-1],[]int{r-1,d})
		graph[r-1] = append(graph[r-1],[]int{l-1,-d})
	}
	ls := intList(n,inf)
	var stack []int
	for i:=0;i<n;i++{
		if ls[i] != inf{
			continue
		} else {
			stack = []int{i}
			ls[i] = 0
		}
		for ;len(stack) != 0;  {
			p := stack[len(stack)-1]
			stack = stack[:len(stack)-1]
			for _,v := range graph[p]{
				if ls[v[0]] != inf{
					continue
				}
				ls[v[0]] = ls[p] + v[1]
				stack = append(stack,v[0])
			}
		}
	}
	check := true
	for i,val:=range graph{
		for _,v := range val{
			if ls[v[0]] - ls[i] != v[1]{
				check = false
				goto label
			}
		}
	}
	label:
	if check {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//数字一行
func intLine(n ,a int) []int {
	ls := make([]int,n)
	for i,_ := range ls{
		ls[i] = goint() + a
	}
	return ls
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

func intList(n,k int) []int {
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = k
	}
	return ls
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> ab(n);
  ll bmax=0;
  for(int i=0;i<n;++i){
    ll a,b;
    cin >> a >> b;
    ab[i]=a+b;
    bmax+=b;
  }
  sort(ab.rbegin(),ab.rend());
  ll ans=0;
  for(int i=0;i<n;++i){
    if(i%2==0) ans+=ab[i];
  }
  ans-=bmax;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

ll  lcm(ll x, ll y){
	ll mindata, maxdata;
	mindata = min(x, y);
	maxdata = max(x, y);
	while (maxdata%mindata != 0){
		ll temp;
		temp = maxdata%mindata;
		maxdata = mindata;
		mindata = temp;
	}
	return x*y / mindata;
}



int main(){
	ll a, b, c, d, ansL, ansS;
	cin >> a >> b >> c >> d;
	ansL = b / c + b / d - b / lcm(c, d);
	ansS = (a - 1) / c + (a - 1) / d - (a - 1) / lcm(c, d);
	cout << (b - a + 1) - ansL + ansS << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    int x = stoi(s);
    int head = x/100;
    int bottom = x%100;
    bool isMonthHead = head >= 1 && head <= 12;
    bool isMonthBottom = bottom >= 1 && bottom <= 12;
    if(isMonthHead && isMonthBottom){
        cout << "AMBIGUOUS" << endl;
    }else if(isMonthHead){
        cout << "MMYY" << endl;
    }else if(isMonthBottom){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s, p;
	getline(cin, s);
	getline(cin, p);
	
	int chk = 0;

	for (int i = 0; i <= s.length(); i++) {
		rotate(s.begin(), s.begin() + 1, s.end());
		chk = s.find(p);
		if (chk != -1) {
			cout << "Yes" << endl;
			break;
		}	
		if (i == s.length()) {
			cout << "No" << endl;
			break;
		}
	}

}



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

int main() {
  int N,a=0,n=0,Br=0;
  cin >> N;
  vector <int> button(N);
  for(int i=0;i<N;i++){
    cin >> button.at(i);
  }
  while(a!=1 && Br==0){
  a=button.at(a)-1;
    n++;
    if (n>N)
      Br=1;
  }
  if (Br==0)
  cout <<n;
  else if (Br==1)
    cout <<-1;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int c = Integer.valueOf(a+b);
		System.out.println(Math.sqrt(c) == Math.ceil(Math.sqrt(c)) ? "Yes" : "No");
	}
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
const ll MOD = 1000000007LL;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	map<P, int> cnt;
	for (int bit = 0; bit < (1 << N); bit++) {
		string a = "", b = "";
		for (int i = 0; i < N; i++) {
			if (bit&(1 << i)) a.push_back(S[i]);
			else b.push_back(S[i]);
		}
		cnt[P(a, b)]++;
	}
	ll ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		string a = "", b = "";
		for (int i = 0; i < N; i++) {
			if (bit&(1 << i)) b.push_back(S[i + N]);
			else a.push_back(S[i + N]);
		}
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		ans += cnt[P(a, b)];
	}
	cout << ans << endl;
}

Measured memory_bytes: 87040
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,a+r+r*(1+3**.5*1j)/2,b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5920
import bisect

def cumsum(a):
   r = [0]
   for v in a:
      r.append(r[-1] + v)
   return r

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

# 累積和をとる
a_cumsum = cumsum(a)
b_cumsum = cumsum(b)

ans = 0

# a_numはindex、vの部分aの値（中味）
for a_num, v in enumerate(a_cumsum):
    tmp = 0
    if k >= v:
        b_num = bisect.bisect_right(b_cumsum, k-v) -1
        # -1は「0」先頭に入れてるからね
        tmp = a_num + b_num
    ans = max(ans,tmp)

print(ans)

Measured memory_bytes: 47336
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N,A;
    int ans=0;
    cin>>N>>A;
    ans=(N+(2*A))/(2*A+1);
    

    Out(ans);
    return 0;
}

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));
    vector<ll> Bs;
    Bs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Bs));

    vector<ll> ABdiffs;
    ABdiffs.reserve(N);
    transform(begin(As), end(As), begin(Bs), back_inserter(ABdiffs),
        [](int a, int b) { return a - b; });

    // 準備度が足りない試験の数
    auto ans = count_if(begin(ABdiffs), end(ABdiffs), [](auto n) { return n < 0; });

    // 足りない準備度の合計
    auto short_point_total = accumulate(begin(ABdiffs), end(ABdiffs), 0LL,
        [](auto acc, auto n) {
            return (n >= 0) ? acc : acc - n;
        });
    if (short_point_total <= 0) {
        cout << 0 << endl;
        return;
    }

    sort(begin(ABdiffs), end(ABdiffs), greater<ll>());

    // 準備度に余裕のある試験から順に余剰準備度の累積和を計算
    vector<ll> enough_sums;
    partial_sum(begin(ABdiffs), end(ABdiffs), back_inserter(enough_sums));

    auto it = lower_bound(begin(enough_sums), end(enough_sums), short_point_total);
    if (it == end(enough_sums)) {
        cout << -1 << endl;
        return;
    }

    ans += distance(begin(enough_sums), it) + 1;
    cout << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int Exchange(int tarousum, int hanakosum, set<int> tarouset, set<int> hanakoset){
  int sa;
  set<int>::iterator tarouit;
  set<int>::iterator hanakoit;

  if(tarousum > hanakosum){
    sa = tarousum - hanakosum;
  }else{
    sa = hanakosum - tarousum;
  }
  if(sa % 2 == 1) return 1;
  sa /= 2;

  for(tarouit = tarouset.begin(); tarouit != tarouset.end(); tarouit++){
    for(hanakoit = hanakoset.begin(); hanakoit != hanakoset.end(); hanakoit++){
      //もし太郎-花子(花子-太郎)がsaと等しかったら表示して終わる
      if(tarousum > hanakosum){
	if(*tarouit - *hanakoit == sa){
	  cout << *tarouit << " " << *hanakoit << endl;
	  return 0;
	}
      }else{
	if(*hanakoit - *tarouit == sa){
	  cout << *tarouit << " " << *hanakoit << endl;
	  return 0;
	}
      }
    }
  }

  return 1;
}
int main(){
  int n, m, tarousum, hanakosum;
  set<int> tarouset;
  set<int> hanakoset;

  while(1){
    cin >> n >> m;
    if(n ==0 || m == 0) break;

    //太郎の値をもらう
    tarousum = 0;
    tarouset.clear();
    for(int i = 0, s; i < n; i++){
      cin >> s;
      tarousum += s;
      tarouset.insert(s);
    }
    //花子の値をもらう
    hanakosum = 0;
    hanakoset.clear();
    for(int i = 0, s; i < m; i++){
      cin >> s;
      hanakosum += s;
      hanakoset.insert(s);
    }

    //差を求めて差/2の数を交換する
    if(Exchange(tarousum, hanakosum, tarouset, hanakoset)){
      cout << "-1" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1196
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		HashMap<Integer, Integer> data = new HashMap<Integer, Integer>();
		
		String line = sc.nextLine();
		while (line.equals("0,0") == false) {
			String[] nico = line.split(",");
			
			Integer[] tmp = new Integer[nico.length];
			for (int i = 0; i < nico.length; i++) {
				tmp[i] = Integer.parseInt(nico[i]);
			}

			data.put(tmp[0], tmp[1]);
			
			line = sc.nextLine();
		}
		
		int[] scores = new int[data.size()];
		
		int index = 0;
		for (int key : data.keySet()) {
			scores[index] = data.get(key);
			index++;
		}
		Arrays.sort(scores);


		HashMap<Integer, Integer> number = new HashMap<Integer, Integer>();
		
		int pre = 0;
		int num = 0;
		for (int i = 0; i < scores.length; i++) {
			int tmp = scores[scores.length - i - 1];
			
			if ((pre == 0) || (tmp < pre)) {
				num++;
				number.put(tmp, num);
			}
			
			pre = tmp;
		}
		
		while (sc.hasNextLine() == true) {
			int q = Integer.parseInt(sc.nextLine());
			System.out.println(number.get(data.get(q)));
		}
	}
}

Measured memory_bytes: 26108
//g++ main.cpp -I /usr/local/include/ac-library
//#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
//using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define sz(x) (int)(x).size()
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)

ll dp[51][51][2501];

int main(){
    int n,a;
    cin >> n>> a;
    vector<int> x(n+1);
    x[0]=0;
    rep2(i,n){
        cin >> x[i];
    }
    rep(j,n+1){
        rep(k,n+1){
            rep(s,n*50+1){
                if(j==0&&k==0&&s==0){
                    dp[j][k][s]=1;
                }else if(j>=1&&s<x[j]){
                    dp[j][k][s]=dp[j-1][k][s];
                }else if(j>=1&&k>=1&&s>=x[j]){
                    dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
                }else{
                    dp[j][k][s]=0;
                }
            }
        }
    }
    ll ans=0;
    rep2(k,n){
        ans+=dp[n][k][k*a];
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 54328
#include <stdio.h>

int main(void)
{
	int a,b,c,T;
	scanf("%d %d %d" ,&a,&b,&c);
	if(a>b){
	T=a;
	a=b;
	b=T;
	};
	if(a>c){
	T=a;
	a=c;
	c=T;
	};
	if(b>c){
	T=b;
	b=c;
	c=T;
	};
	printf("%d %d %d\n" ,a,b,c);
	return 0;
}

Measured memory_bytes: 596
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int A=0,B=0,C=0,D=0;
  cin >> A >> B >> C >> D;
  cout << (A+B<C+D?"Right":A+B>C+D?"Left":"Balanced") << endl;

  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int N,M,i,a,b;
vector<bool> path1;
vector<bool> path2;
inline void solve(){
  IN2(N,M);
  path1.resize(N+1);
  path2.resize(N+1);
  REP(i,M){
    IN2(a,b);
    if(a==1)path1[b]=true;
    if(b==N)path2[a]=true;
  }
  UP(i,2,N-1){
    if(path1[i]&&path2[i]){
      OUT("POSSIBLE");
      return;
    }
  }
  OUT("IMPOSSIBLE");
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;
long long n,a[200005],v[200005],s,s1;
int main()
{
    //ifstream fin("fis.in");
    //ofstream fout("fis.out");
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        v[a[i]]++;
    }
    for(int i=1;i<=200000;i++)
    {
        s+=v[i]*(v[i]-1)/2;
    }
    for(int i=1;i<=n;i++)
    {
        long long c=v[a[i]]-1;
        s1=s;
        s1=s1-v[a[i]]*(v[a[i]]-1)/2;
        s1=s1+c*(c-1)/2;
        cout<<s1<<endl;
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(5);
    rep(i, 0, 5) cin >> a[i];
    int ans = (int)INF;
    rep(i, 0, 5)
    {
        int tmp = 0;
        rep(j, 0, 5)
        {
            if (i == j)
                tmp += a[j];
            else
                tmp += (a[j] + 9) / 10 * 10;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (a, b) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let a: usize = split.next().unwrap().parse().unwrap();
        let b: usize = split.next().unwrap().parse().unwrap();
        (a, b)
    };

    let s = get_input();

    let s1 = &s[0..a];
    let s2 = &s[a..s.len()-b];
    let s3 = &s[s.len()-b..];

    if s1.parse::<u64>().is_ok() && s2 == "-" && s3.parse::<u64>().is_ok() {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    int ans = 0;
    bool f = 1;
    while (f){
        f = 0;
        FORR(j,n-1,1){
            if (a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                ans++;
                f=1;
            }
        }
    }
    REP(i,n){
        cout << a[i];
        if (i<n-1)
            cout << " ";
        else
            cout << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
bool vis[100001];
int32_t main()
{
    fast;
    int n, m;
    cin >> n >> m;
    vector<int > v[n + 1];
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int dis[n + 1];
    for (int i = 0; i < n + 1; i++) {
        dis[i] = 1e18;
    }
    dis[1] = 0;
    queue<int > q;
    q.push(1);
    vis[1] = 1;
    while (q.size()) {
        int parent = q.front();
        q.pop();
        for (auto ch : v[parent]) {
            if (vis[ch] == 0) {
                dis[ch] = dis[parent] + 1;
                q.push(ch);
                vis[ch] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if (dis[i] == 1e18) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    int par[n + 1];
    for (int i = 2; i <= n; i++) {
        int pa = -1;
        int d = 1e18;
        for (auto ch : v[i]) {
            if (dis[ch] < d) {
                pa = ch;
                d = dis[ch];
            }
        }
        par[i] = pa;
    }
    for (int i = 2; i <= n; i++) {
        cout << par[i] << "\n";
    }



}

Measured memory_bytes: 13848
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////


int main()
{	
	int k,x;
	cin>>k>>x;
	if(500*k>=x) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(void){
  //dp[i+1][s][j] = (i桁目までで条件を満たす数の総数)　s 未満フラグ01、j3フラグ01
  int n; cin >> n;
  int r; cin >> r;
  if(n >= 10) cout << r<< "\n";
  else cout << r+100*(10-n) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define eps 1e-3
inline int lowbit(int x){ return x & -x; }
const int N = 1e5 + 10;
const int mod = (int) 998244353;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
using namespace std;

//char buf[100000],*p1=buf,*p2=buf;
//inline char nc(){
//  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline bool read(int & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//inline bool readL(LL & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//LL q_pow(LL base, LL b){LL res=1;for(base%=mod;b;b>>=1,base=base*base%mod)if(b&1){res=res*base%mod;}return res;}

char s[N];

int main(){
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
  scanf("%s", s + 1);
  int len = strlen(s + 1);
  if(s[1] == '0' || s[len] == '1') {
    printf("-1\n");
    return 0;
  }
  for(int i = 2; i <= len / 2; i++) if(s[i] != s[len - i]) {
    printf("-1\n");
    return 0;
  }
  int v = 1;
  for(int i = 2; i <= len; i++) {
    printf("%d %d\n", v, i);
    if(s[i - 1] == '1') v = i;
  }
  return 0;
}



Measured memory_bytes: 1536
from collections import deque
n,m=map(int,input().split())
G=[[] for i in range(3*n)]
for i in range(m):
  u,v=map(int,input().split())
  for j in range(3):
    G[u+n*j-1].append(v+n*((j+1)%3)-1)
s,g=map(int,input().split())
s=s-1
g=g-1
D=deque([s])
V=[0]*3*n
V[s]=1
DD=[0]*3*n
while len(D)>0:
  x=D[0]
  D.popleft()
  for y in G[x]:
    if V[y]==0:
      V[y]=1
      D.append(y)
      DD[y]=DD[x]+1
if DD[g]==0:
  print(-1)
else:
  print(DD[g]//3)

Measured memory_bytes: 62536
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <string>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

int main(){

    ll n , m, k;
    cin >> n >> m >> k;
    ll tmp;
//    vint a(n);
    vector<ll> sum_a(n+1,0);
    REP(i, 1, n+1){
        cin >> tmp;
        sum_a[i] = sum_a[i - 1] + tmp;
    }
//    vint b(m);
    vector<ll> sum_b(m+1,0);
    REP(i, 1, m+1){
        cin >> tmp;
        sum_b[i] = sum_b[i - 1] + tmp;
    }

    int ans = 0;
    int j = m;
    for(int i = 0; i < n+ 1; i++){
        if(sum_a[i] > k){break;}
        while(sum_b[j] > k - sum_a[i]){
            j -= 1;
        }
        ans = max(ans, i+j);
    }

    p(ans);

    return 0;
}


Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n; cin >> n;
        unordered_map<int, int> mp, an;
        int cnt= 0, mx= 0;
        vector<int> v;
        lp(i, n) {
                int x; cin >> x;
                mx = max(mx, x);
                mp[x]++;
                v.push_back(x);
        }
        for (int i = 0; i < v.size(); i++) {
                for (int j= v[i]; j<= mx; j+= v[i]) {
                        if (mp.count(j)&& ((v[i]!= j) || (v[i]== j&& mp[j]> 1))) {
                                an[j]++;
                        }
                }
        }
        for (int i = 0; i< n; i++) {
                if (an.count(v[i])) continue;
                cnt++;
        }
        cout << cnt<< "\n";

}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        lp(i, t) {
                solve();
        }
return 0;
}


Measured memory_bytes: 21208