akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    ll n;
    cin >> n;
    ll p = sqrt(n)+1;
    for(ll i=p; i>0; i--){
        if(n%i==0){
            ll ans = (n/i)+i-2;
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3732
#include <stdio.h>

int main (){
    int S, h, m, s;
    scanf("%d", &S);
    h = S/3600;
    m = (S%3600)/60;
    s = (S%3600)%60;
    printf("%d:%d:%d\n",h, m, s);
    
    return 0;
}


Measured memory_bytes: 2064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int r = Integer.parseInt(in.readLine());
    if(r<1200)
      System.out.println("ABC");
    else if(r<2800)
      System.out.println("ARC");
    else
      System.out.println("AGC");
  }
}

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

int main () {
    int N; cin >> N;
    vector<int> A(N); rep(i, N) cin >> A[i];

    int o = 0;
    int e = 0;
    rep (i, N) {
        if (A[i] % 2 == 0) e++;
        else o++; 
    }

    if (o % 2 != 0) cout << "NO" <<endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 640
n = int(input())

a = 0
b = 0
ans = 0
c = 0

for i in range(n):
    s = input()
    ans+=s.count('AB')
    if s[0]=='B':
        b+=1
    if s[-1]=='A':
        a+=1
    if s[0]=='B' and s[-1]=='A':
        c+=1

if a==b and a==c and a!=0:
    ans += a-1
else:
    ans += min(a,b)

print(ans)

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


// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3") 
// #pragma GCC optimization ("unroll-loops")
 
#define ll  long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define MD          1000000007
#define M           100011

long long  md=MD;


int solve(){
	int n,i,j,k,m;
	cin>>m;
	priority_queue<int> l;
	priority_queue<int,vector<int>,greater<int> > r;
	ll bs=0,lo=0,hi=0;
	while(m--){
		cin>>i;
		if(i==1){
			int a,b;
			cin>>a>>b;
			bs+=b;
			if(l.size()==0){
				lo+=a;
				l.push(a);
				continue;
			}
			int x=l.top();
			if(a>x){
					hi+=a;
					r.push(a);

			}
			else {
				lo-=l.top();
				l.pop();
				lo+=a;
				l.push(a);
				hi+=x;
				r.push(x);
			}
			if(r.size()>l.size()){
				lo+=r.top();
				l.push(r.top());
				hi-=r.top();
				r.pop();
			}


		}
		else{
			ll p=l.size()*l.top()-lo+(hi-r.size()*l.top());
			// cerr<<p<<" "<<bs<<"\n";
			cout<<l.top()<<" "<<p+bs<<"\n";



		}
	}
}


int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;

    t=1;
    // cin>>t;

    while(t--){
    	solve();
    }



    

}



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

using namespace std;

int main(){
    int n, k, m;
    while(cin >> n >> k >> m, n+k+m){
        vector<int> v;
        for(int i=1; i <= n; i++) v.push_back(i);
        vector<int> vv;
        for(int j=0; j < v.size(); j++) if(m-1!=j)vv.push_back(v[j]);
        v = vv; m--;
        while(v.size() != 1){
            int t = (m-1+k)%v.size();
            vv.clear();
            for(int j=0; j < v.size(); j++) if(t!=j)vv.push_back(v[j]);
            v = vv;
            m = t;
        }
        cout << v[0] << endl;
    }
}

Measured memory_bytes: 1356
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define fi freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

const int N = 150000 + 20;
const int inf = 1e9;
vector<int>g[N];
double ans[N], xia[N], sha[N];
int n;
int du[N], down[N];
void dfs1(int u, int fa)
{
    int sz = g[u].size();
    if(fa == -1) down[u] = sz;
    else down[u] = sz-1;
    FF(i, 0, sz-1)
    {
        int v = g[u][i]; if(v == fa) continue;
        dfs1(v, u);
        xia[u] += xia[v] + 1;
    }
    if(xia[u] != 0)
        xia[u] /= down[u];
}
void dfs2(int u, int fa)
{
    if(fa == -1) sha[u] = 0;
    else{
        if(du[fa] - 1 == 0)
            sha[u] = 0;
        else
            sha[u] = (xia[fa] * down[fa] - xia[u] - 1 + sha[fa]) / (du[fa] - 1);
        sha[u] += 1;
    }
    if(fa == -1) ans[u] = xia[u];
    else{
        ans[u] = xia[u] * down[u] / du[u] + sha[u] / du[u];
    }
    int sz = g[u].size();
    FF(i, 0, sz-1)
    {
        int v = g[u][i]; if(v == fa) continue;
        dfs2(v, u);
    }
}
int main()
{


    SC(n);
    FF(i, 1, n-1){
        int x, y; SCC(x, y);
        g[x].PB(y); g[y].PB(x);
        ++du[x]; ++du[y];
    }
    dfs1(1, -1);
    dfs2(1, -1);
    FF(i, 1, n)
        printf("%.8lf\n", ans[i]);
    return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i = 0; i< m; i++){
        cin>>b[i];
    }
    int counter = 0;
    for(int i = 0; i<n; i++){
        int sum = 0;
        for(int j = 0; j<m; j++){
            int a;
            cin>>a;
            sum+=a*b[j];
        }
        if(sum+c>0) counter++;
    }
    cout<<counter<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace CodeIQ
{
	public class Solver
	{
		public Solver() { }
		private static int IsPrime(int n)
		{
			int i;
			if (n < 2) return 0;
			else if (n == 2) return 1;
			if (n % 2 == 0) return 0;
			for (i = 3; i <= n / i; i += 2)
				if (n % i == 0) return 0;
			return 1;
		}

		public static int Main()
		{
			string sep = " ./";
			int[] D = Console.ReadLine().Trim().Split(sep.ToCharArray()).Select(x => int.Parse(x)).ToArray();
			for (int i = 0; i < D[0]; i++)
			{
				string[] s = Console.ReadLine().Trim().Split(sep.ToCharArray());
				for (int j = 0; j < D[1]; j++)
				{
					if (s[j] == "snuke")
					{
						Console.WriteLine("{0}{1}", Convert.ToChar('A'+j), i+1);
					}
				}
			}
			return 0;
		}
	}
}

Measured memory_bytes: 2904
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){
	
	string s[3];
	
	while(cin>>s[0],s[0]!="0"){
		cin>>s[1]>>s[2];
		int a[3]={0};
		int b[3]={0};
		
		for(int j=0;j<3;j++){
		for(int i=1;i<s[j].size();i++){
			if(s[j][i]=='A')
				a[j]++;
			else
				b[j]++;
		}
			if(a[j]>b[j])
				a[j]++;
			else
				b[j]++;
		}
		
		for(int i=0;i<3;i++)
			cout<<a[i]<<" "<<b[i]<<endl;
		
	}
}

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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int x = ceil(n / 1.08);
  if (floor(x * 1.08) == n) cout << x << endl;
  else cout << ":(" << endl;
}

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e-a > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main() {
    string s;
    int q;
    cin >> s >> q;
    string t;

    rep(i, q){
        int query;
        cin >> query;

        if(query == 1){
            swap(s, t);
        }else{
            int f; char c;
            cin >> f >> c;

            if(f == 1){
                t += c;
            }else{
                s += c;
            }
        }
    }

    reverse(all(t));
    t += s;
    println(t);
}


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

int main(){
    long long int h,w;

    cin >> h >> w;
    if( h == 1 || w == 1 )
        printf("1\n");
    else
        cout << (h*w+1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.stream.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.util.function.*;
import static java.lang.System.out;


public final class Main {
	public static void main(String[] args) throws IOException {
		try (var istr = new InputStreamReader(System.in);
			 var br = new BufferedReader(istr)) {
			int k = Integer.parseInt(br.readLine());
			var st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			for (int score = a; score <= b; score++) {
				if (score % k == 0) {
					out.printf("OK%n");
					return;
				}
			}
			out.printf("NG%n");
		}
	}
}


Measured memory_bytes: 33976
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

ll dp[110][100100];

int main()
{
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);

    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    // 配列の初期化
    for (int i = 0; i < 110; i++)
    {
        for (int j = 0; j < 100100; j++)
        {
            dp[i][j] = LINF;
        }
    }
    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < n; i++)
    {
        for (int sum_v = 0; sum_v < 100100; ++sum_v)
        {
            // i番目の品物を選ぶ場合
            if (sum_v - v[i] >= 0)
            {
                dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i]);
            }
            // i番目の品物を選ばない場合
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }
    // 最適値の出力
    ll res = 0;
    for (int sum_v = 0; sum_v < 100100; ++sum_v)
    {
        if (dp[n][sum_v] <= W)
        {
            res = sum_v;
        }
    }
    cout << res << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 89604
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(void)
{
    const double eps = 1e-9;
    string str;
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f){
        double delta = a * e - b * d;
        double x = 1.0 / delta * (c * e - b * f) + eps;
        double y = 1.0 / delta * (-d * c + a * f) + eps;
        printf("%.3f %.3f\n", x, y);
    }
    
    return 0;
}

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

bool compare(int a, int b){
	return (a > b);
}

int s[10000];

int main(){
	while(true){
		int a,b,c,d,e,f;
		cin >> a >> b >> c;
		if(a==0&&b==0&&c==0){
			break;
		}
		for(int n=0;n<a;n++){
			cin >> d;
			s[n]=d;
		}
		sort(s,s+a, compare);
		a=0;
		for(int m=b;m<=c;m++){
			e=s[m-1]-s[m];
			if(a<=e){
				a=e;
				f=m;
			}
		}
		printf("%d\n",f);
	}
}


Measured memory_bytes: 3212
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

int calc(int n, int k) {
	int c = 0;
	REP(i, n / k) REP(j, n / k)if (pow(n - i * k, 2) + pow(n - j * k, 2) <= pow(n, 2))c++;
	c *= 4;
	if (n * 2/ k % 2) c += ((n * 2/ k) - 2) * 2 - 1;
	return c;
}

/* main */
int main() {
	ll n, k, a, b, c[100000] = {};
	scanf("%lld%lld", &n, &k);
	REP(i, n){
		scanf("%lld%lld", &a, &b);
		c[a] += b;
	}
	for (int i = 1;; i++) {
		if (c[i] >= k) {
			printf("%lld", i);
			return 0;
		}
		else k -= c[i];
	}
}

Measured memory_bytes: 896
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())
n = readi()
t = readl()
s = defaultdict(int)
for i in t:
    s[i] += 1

t1 = 0
t2 = 0
for i in sorted(s.items(),reverse=True,key=lambda x:x[0]):
    if t1 == 0:
        if i[1] >= 4:
            t1 = i[0]
            t2 = i[0]
            break
        elif i[1] >= 2:
            t1 = i[0]
    elif t2 == 0:
        if i[1] >= 2:
            t2 = i[0]
            break
print(t1 * t2)

Measured memory_bytes: 24320
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll x;
	ll y;
	bool operator<(const edge& e)const{
		return x+y<e.x+e.y;
	}
	bool operator>(const edge& e)const{
		return x+y>e.x+e.y;
	}


};
struct road{ll cost;int to;};
int n,k;
ll b[100005]={};
vector<int> l,r;
vector<P> pa;
void bisetup(){

}
int a[4]={};
int c,d;
int main() {
	rep(i,0,3){
		cin>>c>>d;
		a[c-1]++;
		a[d-1]++;
	}
	if(a[0]<3&&a[1]<3&&a[2]<3&&a[3]<3)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
rsp = [r, s, p]
T = input()
S = ''
a = [True]*n

for t in T:
    if t == 'r':
        S += '2'
    elif t == 's':
        S += '0'
    else:
        S += '1'

ans = 0
for i in range(n):
    if not a[i]:
        continue
    if i < n-k:
        if S[i] == S[i+k]:
            a[i+k] = False
    ans += rsp[int(S[i])]

print(ans)

Measured memory_bytes: 4212
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_C() {}
#else

#endif


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

    string S, T; cin >> S >> T;    
    int SL = S.size();
    int TL = T.size();

    vi idxs;
    for (int i = 0; i <= SL - TL; i++) {
        bool match = true;
        for (int j=0; j<TL; j++) {
            if (S[i+j] != T[j] && S[i+j] != '?') {
                match = false;
                break;
            }
        }
        if (match) idxs.push_back(i);
    }

    int idx = idxs.size() > 0 ? idxs.back() : -1;
    string ans = "";
    if (idx < 0) ans = "UNRESTORABLE";
    else {
        int i = 0;
        while(i < SL) {
            if (i == idx) {
                ans += T;
                i += TL;
            } else {
                if (S[i] == '?') ans += 'a';
                else ans += S[i];
                i++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
 int q,p,c[1000001],b[1000001],o;
 string a;
 int main()
 {
     cin>>a;
     for (int i=0;i<a.size();i++)
     {
         if (a[i]=='C') 
         {
             p++;
             b[p]=i+1;
         }//判断是否发现C这个东西，并统计其位置
         else if (a[i]=='F')
         {
            q++;
             c[q]=i+1;
         }
     }//判断是否发现F，同理 统计位置情况
     if (q>=1 && p>=1)
     {
     for (int i=1;i<=p;i++)
     {
         for (int j=1;j<=q;j++)
         {
             if (b[i]<c[j])
             {
                 o=1;
             }
         }
     }//循环，找到C是否在F的前面
     if (o==1) cout<<"Yes"<<endl;//在前面则Yes
     else cout<<"No"<<endl;//否则No   
     }
     else cout<<"No"<<endl;//不存在两个数，直接No
     //以上为全部过程，希望能理解。
 }

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

int main(){
    int n, t;
    vector<int> v;
    cin >> n;
    rep(i, n){
        cin >> t;
        v.push_back(t);
    }
    rep(i, n){
        rep(j, i){
            if(v.at(i) <= v.at(j)){
                v.insert(v.begin()+j, v.at(i));
                v.erase(v.begin()+i+1);
            }
        }
        repc(j, v.begin(), v.end()){
            cout << (j == v.begin() ? "" : " ") << *j;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000
#define mod 1000000007
#define inf 1000000000000000000
#define mI2 500000004
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll modexp(ll x, ll n){
    if(n==0){
        return 1;
    }else if(n&1){
        return ((x%mod)*(modexp((x%mod*x%mod),n/2)%mod)%mod)%mod;
    }else{
        return modexp((x%mod*x%mod),n/2)%mod;
    }
}

ll modInv(ll x){
    return modexp(x,mod-2)%mod;
}

void Flash(){
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<ll>());
    ll ss[n+1];
    ss[0]=0;
    for(ll i=1;i<=n;i++){
        ss[i]=(ss[i-1]+a[i-1]);
    }
    ll fac[n+1];
    ll facInv[n+1];
    fac[0]=1;
    for(ll i=1;i<=n;i++){
        fac[i]=mul(fac[i-1],i);
    }
    for(ll i=0;i<=n;i++){
        facInv[i]=modInv(fac[i]);
    }
    ll ans=0;
    ll comb;
    for(ll size=k;size<=n;size++){
        comb=mul(fac[size-2],mul(facInv[k-2],facInv[size-k]));
        ans=add(ans,mul(sub(ss[n-size+1],sub(ss[n],ss[size-1])),comb));
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 3328
while True:
    try:
        h = 0
        a=["","","",""]
        for i in range(8):
            tmp = raw_input()
            if int(tmp) != 0:
                a[h] = tmp
                h += 1
    	if h == 1:
            print "C"
        elif h == 2:
            c = a[0].index("1") - a[1].index("1")
            if c == 0:
                print "A"
            elif c == -1:
                print "E"
            else:
                print "G"
        elif h == 3:
            c = a[0].index("1") - a[2].index("1")
            print "D" if c == 1 else "F"
        else:
            print "B"
    	raw_input()
    except:
	break

Measured memory_bytes: 4232
#include <iostream>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double e = exp(1);
const double eps = 1e-9;
const int MAX_N = 10000 + 5;

int h, w, n;
int a[MAX_N];
int mp[105][105];

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

    ios::sync_with_stdio(false);
    cin >> h >> w;
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];
    int j = 1;
    for(int i=0; i<h*w; i++) {
        if(a[j]==0) j++;
        mp[i/w][(i%(2*w)<w) ? (i%w) : (w-1-(i%w)) ] = j;
        a[j]--;
    }
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            printf("%d%c", mp[i][j], (j==w-1) ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//#define _USE_MATH_DEFINES
#include <math.h>  /* M_PI */



int main(){

    string s;
    cin >> s;

    bool f = true;
    int cnt = 0;

    for(int i=1;i < s.length();i++){
        if(s[0] == 'A'){
            //区間内にCがある場合
            if(i >= 2 && i <= s.length() - 2 && s[i] == 'C'){
                if(cnt == 0)cnt++;
                else{
                    f = false;
                    break;
                }
            }

            //区間外のCがある場合
            if(!(i >= 2 && i <= s.length() - 2) && s[i] == 'C'){
                f = false;
                break;
            }

            //小文字の場合
            if(!(s[i] >= 'a' && s[i] <= 'z') && s[i] != 'C') {
                f = false;
                break;
            }

        }else{
            f = false;
        }

    }

    if(cnt == 0) f = false;

    if(f) cout << "AC" << endl;
    else cout << "WA" << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    unordered_map<ll, ll> M;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        M[A[i]]++;
    }
    ll total = 0;
    for(auto it : M){
        ll freq = it.second;
        total += ((freq * (freq - 1))/2);
    }
    for(ll i = 0; i < N; i++){
        ll n = M[A[i]];
        cout << total - n + 1 << "\n";
    }
}

Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 998244353;

vector<pair<ll, ll>> vec;
vector<ll> pref;
ll dp[SIZE];

ll get_sum(int l, int r) {
	if (l < 0) l = 0;
	if (r < 0) r = -1;

	return pref[r + 1] - pref[l];
}

int main()
{
	fastInp;

	pref.push_back(0);
	ll n, k;
	vector<pair<ll, ll>> segs;
	cin >> n >> k;

	for (int i = 0; i < k; i++) {
		ll l, r;
		cin >> l >> r;
		segs.push_back({ l, r });
	}

	dp[0] = 1;

	pref.push_back(1);

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < k; j++) {
			ll mn = i - segs[j].first, mx = i - segs[j].second;
			dp[i] += get_sum(mx, mn);
			dp[i] %= MOD;
		}

		pref.push_back(dp[i] + pref.back());
	}

	cout << dp[n - 1];

	return 0;
}

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

int main()
{
	int a, b, C;
	cin >> a >> b >> C;
	cout << fixed << setprecision(6);
	cout << a * b * sin((double)C / 180 * acos(-1)) / 2.0 << endl;
	cout << a + b + sqrt(a * a + b * b - a * b * 2 * cos((double)C / 180 * acos(-1))) << endl;
	cout << b * sin((double)C / 180 * acos(-1)) << endl;
	return 0;
}

Measured memory_bytes: 3484
n=int(input())
data=[]
for i in range(n):
	a,b=(i for i in input().split())  
	data.append([a, int(b), i+1])

tmp = sorted(data, key=lambda x:x[1], reverse=True)
ans = sorted(tmp, key=lambda x:x[0])

for i in ans:
	print(i[2])

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int x, n, flag1, flag2, diff, i;
    cin>>x>>n;
    int p[n];
    for(i=0; i<n; i++){
        cin>>p[i];
    }
    diff=0;
    while(1){
        flag1 = 1;
        flag2 = 1;
        for(i=0;i<n;i++){
            if(x-diff == p[i]){
                flag1=0;
            }if(x+diff == p[i]){
                flag2=0;
            }
        }
        if(flag1){
            cout<<x-diff;
            break;
        }
        else if(flag2){
            cout<<x+diff;
            break;
        }
        diff++;
    }
    
    return 0;
}


Measured memory_bytes: 3636
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n, k;
	cin >> n >> k;
	
	int ans = 0;
	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define MAX_N 181
#define INF 100000000

int r[MAX_N];

int main() {
    r[0] = 0;
    r[1] = 1;
    int j = 3;
    FOR(i, 2, MAX_N) {
        r[i] = r[i-1] + j;
        j += i+1;
    }

    int n;
    while (cin >> n, n) {
        vvi dp(2, vi(n+1, INF));
        FOR(i, 1, MAX_N) {
            if (r[i] <= n) {
                dp[0][r[i]] = 1;
            } else {
                break;
            }
        }
        while (dp[0][n] == INF) {
            FOR(i, 1, n+1) {
                if (dp[0][i] != INF) {
                    REP(j, MAX_N) {
                        if (i + r[j] <= n) {
                            dp[1][i+r[j]] = min(dp[0][i+r[j]], dp[0][i] + 1);
                        }
                    }
                }
            }
            dp[0] = dp[1];
        }
        cout << dp[0][n] << " ";

        fill(ALL(dp[0]), INF);
        fill(ALL(dp[1]), INF);
        FOR(i, 1, MAX_N) {
            if (r[i] <= n) {
                if (r[i] % 2 == 1) dp[0][r[i]] = 1;
            } else {
                break;
            }
        }
        while (dp[0][n] == INF) {
            FOR(i, 1, n+1) {
                if (dp[0][i] != INF) {
                    REP(j, MAX_N) {
                        if (r[j] % 2 == 1 && i + r[j] <= n) {
                            dp[1][i+r[j]] = min(dp[0][i+r[j]], dp[0][i] + 1);
                        }
                    }
                }
            }
            dp[0] = dp[1];
        }
        cout << dp[0][n] << endl;
    }
}

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int N;
string S;
int64 po[11];
int64 dp[1001][1001];
int64 dp2[1001][1001][11];

int64 add(int64 x, int64 y) {
  x += y;
  x = min(x, (int64) INF);
  return x;
}

int64 rec2(int idx, int flip);

int64 make_num(int idx, int flip, int length) {
  if(length == -1) return rec2(idx, flip);
  if(flip < 0 || idx >= S.size()) return INF;
  if(~dp2[idx][flip][length]) return dp2[idx][flip][length];
  int64 ret = INF;
  ret = min(ret, make_num(idx + 1, flip - (S[idx] != '0'), length - 1));
  if(isdigit(S[idx])) ret = min(ret, add(make_num(idx + 1, flip, length - 1), (S[idx] - '0') * po[length]));
  return dp2[idx][flip][length] = ret;
}

int64 rec(int idx, int flip) {
  if(flip < 0) return INF;
  if(idx >= S.size()) return INF;
  if(~dp[idx][flip]) return dp[idx][flip];
  int64 ret = INF;

  ret = min(ret, make_num(idx + 1, flip - (S[idx] != '0'), -1));
  if(isdigit(S[idx])) ret = min(ret, add(make_num(idx + 1, flip, -1), S[idx] - '0'));

  for(int i = 1; i <= 10; i++) {
    ret = min(ret, add(make_num(idx + 1, flip - (S[idx] != '1'), i - 1), po[i]));
    if(isdigit(S[idx]) && S[idx] != '0') ret = min(ret, add(make_num(idx + 1, flip, i - 1), po[i] * (S[idx] - '0')));
  }

  return dp[idx][flip] = ret;
}

int64 rec2(int idx, int flip) {
  if(flip < 0) return INF;
  if(idx == S.size()) return 0;
  return rec(idx + 1, flip - (S[idx] != '+'));
}

int main() {
  po[0] = 1;
  for(int i = 1; i < 11; i++) po[i] = po[i - 1] * 10;

  memset(dp, -1, sizeof(dp));
  memset(dp2, -1, sizeof(dp2));

  cin >> N;
  cin >> S;
  for(int i = 0; i <= S.size(); i++) {
    if(rec(0, i) <= N) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}



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

int main()
{
    long long int N,A,B;
    scanf("%lld%lld%lld",&N,&A,&B);
    long long int sumab=A+B;
    long long int asum=0;
    long long int mul=N/sumab;
    long long int mod=N%sumab;
    if(mod>A)mod=A;
    asum=mul*A+mod;
    printf("%lld",asum);
    return 0;
}

Measured memory_bytes: 128
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,n=mp()
a=sum(lmp())
print("Yes" if a>=h else "No")

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

using namespace std;

#define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define FORD(i, m, n) for (int(i) = (m); (i) >= (n); (i)--)
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REP1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	REP(i, k)
	{
		if (a >= b)
			b *= 2;
		else if (b >= c)
			c *= 2;
		if(a<b&&b<c)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3636
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
import functools

n = input()
for i in range(len(n)):
    if n[i] == "9":
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 12500
#include<cstdio>
#define MAXN 100005
#define LL long long
int n;
LL a[MAXN],b[MAXN],sum,cnt;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	LL tmp=1LL*n*(n+1)/2;
	if(sum%tmp)
	{
		printf("NO\n");
		return 0;
	}
	LL cnt=sum/tmp;
	b[n]=b[1]-a[n];
	b[n]=cnt-b[n];
	for(int i=1;i<n;i++)
		b[i]=cnt-(a[i+1]-a[i]);
	for(int i=1;i<n;i++)
	{
		if(b[i]<0||(b[i]%n))
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1664
'use strict'

function main(input) {

  const nums = input.split('\n')[1].split(' ').map(n => Number(n));
  const arr = [0];

  for (let i = 0, sum = 0; i < nums.length; i++) {
    sum += nums[i];
    arr.push(sum);
  }

  let min = arr[arr.length - 1];
  for (let i = 1; i < arr.length - 1; i++) {
    const abs = Math.abs(arr[i] - (arr[arr.length - 1] - arr[i]));
    min = Math.min(min, abs);
  }

  console.log(min);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long H,W,answer=INT_MAX,a,b;
  cin >> H >> W;
  if (W > 2) {
    answer = min(answer,H*((W-1)/3+1-W/3));
  } 
  if (H > 2) {
    answer = min(answer,W*((H-1)/3+1-H/3));
  }
  for (int i = 1; i < H; i++) {\
    a = min(i*W,W/2*(H-i));
    b = max(i*W,(W-1)/2*(H-i)+H-i);
    answer = min(answer,b-a);
  }
  for (int i = 1; i < W; i++) {
    a = min(i*H,H/2*(W-i));
    b = max(i*H,(H-1)/2*(W-i)+W-i);
    answer = min(answer,b-a);
  }
  cout << answer;
}

Measured memory_bytes: 3636
#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,int_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,int_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define M1 100000000000000000ll
#define PRECISE cout.precision(18);
#define BS(v,n) binary_search(v.begin(),v.end(),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater <int>())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

    FAST
//	PRECISE


ll n;
cin>>n;
ll ma=0;
ll mi=0;
ve <ll> v(n,0);
FOR(i,0,n)
cin>>v[i];
srt(v);
ll a1=maxe(v);
ll a2=mine(v);
if(a1==a2){
	if(a1==n-1||n>=2*a1)
		cout<<"Yes";
	else
		cout<<"No";
}
else{
if(a1-a2>1)
	cout<<"No";
else{
FOR(i,0,n)
if(v[i]==a1)
	ma++;
else
	mi++;
ll ind=mi;
if(a2-(ind-1)>0&&ma>=2*(a2-(ind-1)))
cout<<"Yes";
else
cout<<"No";
}
}







//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
return 0;
 }

Measured memory_bytes: 3992
//https://atcoder.jp/contests/abc123/tasks/abc123_b?lang=ja
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

// 今の時間(current_time)から，次の(current_time"以降"の)10Nの時間を求める
int getNextOrderTime(int current_time){
    return current_time%10==0 ? current_time : ( current_time/10 + 1 ) * 10;
}
int computeLastTime(vector<int> times){
    int res{};
    REP(i, (int)times.size()){
        res = getNextOrderTime(res) + times[i];
    }
    return res;
}
struct cwwUnitTest{
    cwwUnitTest(){
        assert(getNextOrderTime(7)==10);
        assert(getNextOrderTime(20)==20);
        assert(getNextOrderTime(29)==30);

        assert(computeLastTime({29,7,20})==60);
        assert(computeLastTime({20,7,29})==59);
        assert(computeLastTime({20,29,7})==57);
    }
}unitTester;
int main()
{
    vector<int> v(5);
    for(auto &x : v){
        cin >> x;
    }
    sort(ALL(v));
    int res = INT_MAX;
    do{
        res = min(res, computeLastTime(v));
    }while(next_permutation(begin(v), end(v)));

    cout << res << endl;
    return 0;
}

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

int main() {
  string s;cin>>s;
  int k;cin>>k;
  rep(i,s.size()-1) {
    char c = s[i];
    int x = 'z' - c + 1;
    if (x==26 || x > k) cout<<c;
    else {
      cout<<'a';
      k -= x;
    }
  }
  char c = s[s.size()-1];
  c = (c - 'a' + k) % 26 + 'a';
  cout<<c<<endl;
}


Measured memory_bytes: 512
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;


//constant
const int MOD = 1e9+7;
const int INF = 1e18;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};
const double pi = acos(-1);


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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n
//memset(obj,value,sizeof(obj));

#define YET 0
#define NOW 1
#define END 2


void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> A;
    
    A.push_back(0);
    rep(i,n){
        int a; cin >> a;
        A.push_back(a);
    }
    A.push_back(0);
    
    int sum = 0;
    for (int i = 0; i < n+1; i++) sum += abs(A[i+1] - A[i]);
    
    
    for (int i = 1; i < n+1; i++) {
        cout << sum - (abs(A[i]-A[i-1])+abs(A[i]-A[i+1])) + abs(A[i-1]-A[i+1]) << endl;
    }
    
    
}





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




Measured memory_bytes: 2164
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int n,m,ans=0,ac=0;
  cin>>n>>m;
  vector<lli> p(m),a(n+1,0),b(n+1);
  vector<bool> ok(n+1,false),wa(n+1,false);
  vector<string> s(m);
  rep(i,0,m){
    cin>>p.at(i)>>s.at(i);
    if(s.at(i)=="WA"&& ! wa.at(p.at(i)))
      ++a.at(p.at(i));
    if(s.at(i)=="AC"){
      wa.at(p.at(i))=true;;
      if(ok.at(p.at(i))==false)
        ++ac;
      b.at(p.at(i))=a.at(p.at(i));
      ok.at(p.at(i))=true;
    }
  }
  rep(i,0,b.size()){
    ans+=b.at(i);
  }
  ou(ac<<' '<<ans);
}

Measured memory_bytes: 8064
n = int(input())
M = 0
A = 0
R = 0
C = 0
H = 0
for _ in range(n):
    x = input()[0]
    if x == "M":
        M += 1
    elif x == "A":
        A += 1
    elif x == "R":
        R += 1
    elif x == "C":
        C += 1
    elif x == "H":
        H += 1
    else:
        pass
print ((M*A*R)+(M*A*C)+(M*A*H)+(M*R*C)+(M*R*H)+(M*C*H)+(A*R*C)+(A*R*H)+(A*C*H)+(R*C*H))


Measured memory_bytes: 3064
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ld a,b;
    cin >> a >> b;

    f(i,1,10000)
    {
        // cout <<  i << " " << floor(i*0.08) << " " << floor(i*0.1) << endl;
        if(floor(i*0.08)==a && floor(i*0.1)==b)
        {
                cout << i ;
                return;
        }
    }
    cout << -1;
    return;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}


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

int main() {
    int K; cin >> K;
    string S; cin >> S;

    if(S.size() <= K){
        cout << S << endl;
    } else {
        for (int i = 0; i < K; i++){
            cout << S[i];
            if(i == K-1){
                cout << "..." << endl;
            }
        }
    }
}

Measured memory_bytes: 3632