akhauriyash/Code-Regression huggingface dataset:
# N, Mの入力
N, M = map(int, input().split())

# 得票数の入力
A = list(map(int,input().split()))

# 総得票数
total = sum(A)

# 得票数が1/4M以上の商品数のカウント
cnt = 0
for n in A:
    if (n >= total/(4*M)):
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int n, m;
  cin>>n>>m;
  std::cout << (n-1)*(m-1) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
using namespace std;

//fixed << setprecision(10)
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

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

map<int, int> prime;
void Prime(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) {
		cout << a * b << endl;
	}
	else
		cout << -1 << endl;
}

Measured memory_bytes: 256
x,y = map(int, input().split())

A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

if x in A and y in A :
  print("Yes")
elif x in B and y in B :
  print("Yes")
elif x in C and y in C :
  print("Yes")
else :
  print("No")

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

using namespace std;



int main(int argc, char* argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, K;
  cin >> N >> K;

  auto candidates = [N,K](int mod)
  {
    if (mod == 0) mod = K;
    return (N/K) + (((N%K) >= mod) ? 1 : 0);
  };

  uint64_t res = 0LL;
  for (int aMod = 0; aMod < K; ++aMod)
  {
    const int bcMod = (K - aMod) % K;
    if ((bcMod+bcMod) % K) continue;
    const uint64_t aCandidates = candidates(aMod);
    const uint64_t bcCandidates = candidates(bcMod);
    res += aCandidates * bcCandidates * bcCandidates;
  }

  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
double PI=acos(-1);
ll n,w,weight[105],value[105];
ll dp[105][100005];
// dp[i][j]=min(dp[i-1][j-value[i]]+weight[i],dp[i-1][j])
ll solve(int idx,ll w){
    if(idx==0) return dp[idx][w];
    if(dp[idx][w]!=-1)
        return dp[idx][w];
    if(w>=value[idx]) return dp[idx][w]=min(solve(idx-1,w-value[idx])+weight[idx],solve(idx-1,w));
    else return dp[idx][w]=min(solve(idx-1,w),weight[idx]);
}

int main(){
    IO
    cin>>n>>w;
    ll ans=0;
    int maxv=0;
    for(int i=1;i<n+1;i++){
        cin>>weight[i]>>value[i];
        maxv+=value[i];
    }
    memset(dp,-1,sizeof dp);
    for(int i=0;i<100005;i++) dp[0][i]=1e18;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=maxv;j++) solve(i,j);
    }
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<=20;j++) cout<<dp[i][j]<<" ";
        cout<<'\n';
    }*/
    for(int i=1;i<=maxv;i++){
        if(dp[n][i]<=w) ans=i;
    }
    cout<<ans+1<<'\n';



    return 0;
}


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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

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

  vector<uint64_t> a(N);
  N_TIMES(n, N) { cin >> a[n]; }

  uint64_t x = 1, c = 0;
  N_TIMES(n, N) {
    if (a[n] == x) {
      ++x;
    } else {
      ++c;
    }
  }

  if (c == N) {
    cout << -1 << endl;
  } else {
    cout << c << endl;
  }

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int Q=505;
int ans[Q][Q],vis[Q][Q];
int tx[]={0,0,-1,1},ty[]={-1,1,0,0};
int qx[Q*Q],qy[Q*Q];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            ans[i][j]=min(min(i,n-i+1),min(j,n-j+1));
    int qaq=n*n;
    int tot=0;
    while(qaq--){
        int x,y,p;
        scanf("%d",&p);
        x=(p-1)/n+1,y=p-(x-1)*n;
        --ans[x][y],tot+=ans[x][y],vis[x][y]=1;
        int hd=1,tl=0;
        qx[++tl]=x,qy[tl]=y;
        while(hd<=tl){
            int xx=qx[hd],yy=qy[hd++];
            for(int t=0;t<4;t++){
                int x0=xx+tx[t],y0=yy+ty[t],nw=ans[xx][yy]+1-vis[x0][y0];
                if(x0>=1&&x0<=n&&y0>=1&&y0<=n&&nw<ans[x0][y0])
                    ans[x0][y0]=nw,qx[++tl]=x0,qy[tl]=y0;
            }
        }
    }
    printf("%d\n",tot);
    return 0;
}

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


int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    vector<int> X;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        X.push_back(tmp);
    }
    
    sort(X.begin(), X.end());
    int _min = X[0];
    int _max = X[X.size() - 1];
    int v;
    int ans = INT_MAX;
    for (int i = _min; i <= _max; i++) {
        v = 0;
        for (int x : X) {
            int t = (x - i);
            v += t * t;
        }
        if (v < ans) {
            ans = v;
        }else if (v > ans) {
            break;
        }
    }
    
    
    std::cout << ans;
    return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

struct Info {
    int id, year, prefecture, x;
    Info(int id, int year, int prefecture) : id(id), year(year), prefecture(prefecture) {}
    Info() = default;

    bool operator < (const Info& i) {
        return year < i.year;
    }
};

void solve(long long N, long long M, std::vector<long long> P, std::vector<long long> Y){
    vector<Info> info(M), answer(M+1);
    rep(i,0,M) info[i] = Info(i+1, Y[i], P[i]);
    sort(all(info));
    vector<int> cnt(N+1);
    rep(i,0,M) {
        cnt[info[i].prefecture]++;
        info[i].x = cnt[info[i].prefecture];
        answer[info[i].id] = info[i];
    }
    rep(i,1,M+1) {
        cout << setfill('0') << right << setw(6) << answer[i].prefecture;
        cout << setfill('0') << right << setw(6) << answer[i].x << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> P(M);
    std::vector<long long> Y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&P[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, M, std::move(P), std::move(Y));
    return 0;
}


Measured memory_bytes: 8264
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Double> list = new ArrayList<Double>();
		for (int i = 0; i < N; i++) {
			list.add(sc.nextDouble());
		}

		double ans = list.stream().mapToDouble(s -> 1.0 / s).sum();

		ans = 1.0 / ans;
		
		PrintWriter out = new PrintWriter(System.out);
		out.println(ans);
		out.flush();
	}

}


Measured memory_bytes: 26708
N = int(input())

L = []
for i in range(N):
    x, y, h = map(int, input().split())
    L.append([x, y, h])
    if h != 0:
        idx = i


for i in range(101):
    for j in range(101):
        H = L[idx][2] + abs(L[idx][0]-i) + abs(L[idx][1]-j)
        for k in range(N):
            if L[k][2] == max(H - abs(L[k][0]-i) - abs(L[k][1]-j), 0):
                pass
            else:
                break
            if k == N-1:
                ansx = i
                ansy = j
                ansh = H

print(ansx, ansy, ansh)

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

N = INT()
A = LIST()

ans = INF

sum_A = sum(A)
tmp = 0
for a in A:
	tmp += a
	ans = min(ans, abs(tmp-(sum_A-tmp)))
print(ans)


Measured memory_bytes: 27284
#include<stdio.h>
int f(int a)
{
	int s=0;
	while(a!=0)
	{
		s+=a%10;
		a/=10;	
	}
	return s;
}
int main()
{
	int n,min=100001,i;
	scanf("%d",&n);
	for(i=1;i<=n/2;i++)
	{
		if(f(i)+f(n-i)<min)
			min=f(i)+f(n-i);	
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[0] + a[1]);
    }
}

Measured memory_bytes: 35680
import collections

n,m = map(int,input().split())
friend = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    friend[a].append(b)
    friend[b].append(a)

q = collections.deque()
visited = [0 for i in range(n)]

ans = 0
for i in range(n):
    tmp = 0
    if visited[i] == 0:
        visited[i] = 1
        tmp += 1
        for j in friend[i]:
            if visited[j] == 0:
                visited[j] = 1
                tmp += 1
                q.append(j)
        while q:
            s = q.pop()
            for k in friend[s]:
                if visited[k] == 0:
                    visited[k] = 1
                    tmp += 1
                    q.append(k)
    ans = max(ans,tmp)

print(max(ans,1))

Measured memory_bytes: 123828
#include<bits/stdc++.h>
using namespace std;
int v[55],c[55];
int main() {
	int zd;
	int n;
	cin>>n;
	for(int i=0; i<n; i++) cin>>v[i];
	for(int j=0; j<n; j++) cin>>c[j];
	for(int x=0; x<n; x++) {
		if(v[x]-c[x]>0) {
			zd+=v[x]-c[x];
		}
	}
	cout<<zd;

	return 0;
}


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

int main(){
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k;
        return 0;
    }
    if(k<=(a+b)){
        cout<<a;
        return 0;
    }
    cout<<((2*a)+b-k);
    return 0;
}


Measured memory_bytes: 3636
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

const int MAX_M = 1e5;
int N, M;
bool used[MAX_M];
int c[MAX_M];

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

  cin >> N >> M;
  used[0]= true;
  REP(i, N) c[i] = 1;

  REP(i, M) {
    int x, y;

    cin >> x >> y;
    x--; y--;
    if (used[x]) {
      if (c[x] == 1) {
        used[x] = false;
      }
      used[y] = true;
    }
    c[x]--;
    c[y]++;
  }
  int ans = 0;
  REP(i, N) {
    if (used[i] && c[i] > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
import * as fs from "fs"

const process = (k: number, x: number): string => {
  const shita = x - k + 1
  const ue = x + k - 1 > 1000000 ? 1000000 : k + x - 1

  let res = ""
  for (let i = shita; i <= ue; i++) {
    res = res + " " + i
  }
  return res.trim()
}

const Main = (input: string): string => {
  const a: string[] = input.split(" ")
  const na: number[] = a.map((e) => parseInt(e))

  const res = process(na[0], na[1]) + ""
  console.log(res)
  return res
}

Main(fs.readFileSync("/dev/stdin", "utf8"))


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

struct path{
		int cst,x;char wh;
		path(){};
		path(int cst_,int x_,char wh_){
			cst=cst_,x=x_,wh=wh_;
		};
	bool operator<(const path& o)const{return cst>o.cst;}
};

struct unionFind{
	int n,cn;vector<int>pr;
	unionFind(){};
	unionFind(int n_){
		n=n_;
		cn=n;
		pr.resize(n,-1);
	};
	int root(int a){
		if(pr[a]==-1)return a;
		else return pr[a]=root(pr[a]);
	}
	void unify(int a,int b){
		a=root(a),b=root(b);
		if(a==b)return;
		pr[a]=b;
		cn--;
	}
	bool same(int a,int b){return root(a)==root(b);}

};


signed main(){
	int w,h;cin>>w>>h;
	priority_queue<path> pq;	
	unionFind uw(w+1),uh(h+1);
	int y;
	rep(i,w){
		cin>>y;pq.push(path(y,i,'w'));
	}
	rep(i,h){
		cin>>y;pq.push(path(y,i,'h'));
	}

	int cst=0,num=0;
	
	while(!pq.empty()){
		auto u=pq.top();pq.pop();
		if(u.wh=='w'){
//			if(uw.same(u.x,u.x+1))continue;
			uw.unify(u.x,u.x+1);
			cst+=u.cst*uh.cn;
			num+=uh.cn;

			
		}else if(u.wh=='h'){
//			if(uh.same(u.x,u.x+1))continue;
			uh.unify(u.x,u.x+1);
			cst+=u.cst*uw.cn;
			num+=uw.cn;

		}
//		cerr<<u.wh<<u.x<<" "<<cst<<" "<<num<<endl;
		if(num>=(h+1)*(w+1)-1)break;
	}
	cout<<cst<<endl;
}


Measured memory_bytes: 10096
#include"bits/stdc++.h"
using namespace std;

bool include3(int x) {
	return x % 10 == 3;
}

void Main() {
	int x, n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		x = i;
		if (x % 3 == 0) {
			cout << " " << i;
			continue;
		}
		if (include3(x)) {
			cout << " " << i;
			continue;
		}
		x /= 10;
		while (x) {
			if (include3(x)) {
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
}
int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int Q;
  cin >> Q;
  deque<int> as;

  // asの要素数でみて中央にある値をmとする。
  // ただし要素数が偶数のとき、手前よりのものをmとする。
  auto mi = [&]() {
    return (as.size() - 1) / 2;
  };

  // mより手前の値の合計と、奥の値の合計
  i64 ls = 0, hs = 0;
  
  i64 bs = 0;
  F0R(i, Q) {
    int q;
    cin >> q;
    i64 x = as.size() ? as[mi()] : 0;
    if (q == 1) {
      int a, b;
      cin >> a >> b;
      auto where = lower_bound(rng(as), a);
      if (as.size()) {
        bool insLeft, odd = as.size() & 1;
        insLeft = where - as.begin() <= mi();
        as.insert(where, a);
        if (insLeft) {
          ls += a;
          if (odd) {
            hs += x;
            ls -= as[mi()];
          }
          else {
            // 中央値は引き続き中央値
          }
        }
        else {
          hs += a;
          if (odd) {
            // 中央値は引き続き中央値
          }
          else {
            ls += x;
            hs -= as[mi()];
          }
        }
        //debug(hs);
        //debug(ls);
      }
      else {
        as.insert(where, a);
      }
      bs += b;
    }
    else {
      i64 f = bs;
      //*
      f += x * mi() - ls;
      f += hs - x * (as.size() - mi() - 1);
      //*/
      /*
      F0R(j, as.size()) {
        f += abs(x - as[j]);
      }
      //*/
      cout << x << ' ' << f << newl;
    }
  }
}
#endif


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

using namespace std;

using int64 = long long;

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

  int64 n, k;
  cin >> n >> k;
  if (k % 2 == 1) {
    cout << (n / k) * (n / k) * (n / k) << endl;
  } else {
    int64 answer = (n / k) * (n / k) * (n / k);
    int64 base_2 = (n + k / 2) / k;
    answer += base_2 * base_2 * base_2;
    cout << answer << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  ll a,b,c=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
  {
    string s=to_string(i);
    ll n=s.length(),f=0;
    for(int j=0;j<s.length()/2;j++)
    {
      if(s[j]!=s[n-1-j])
        {
          f=1;
          break;
        }

    }
    if(f==0)
      c++;


  }
  cout<<c<<endl;
    
}
return 0;
}

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

int main()
{

  int a, b, c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c << endl;
  }else if(a == c){
    cout << b << endl;
  }else{
    cout << a << endl;
  }
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 2e9
#define ALL(v) v.begin(), v.end()
 
using namespace std;
typedef long long ll;

int main(){
    string W;
    cin >> W;
    int result=0;
    if(W[0]=='R'){
        result=1;
        if(W[1]=='R'){
            result=2;
            if(W[2]=='R'){
                result=3;
            }
        }
    }
    if(W[1]=='R'){
        if(result<1) result=1;
        if(W[2]=='R'){
            if(result<2) result=2;
        }
    }
    if(W[2]=='R'){
        if(result<1) result=1;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
      long A =sc.nextLong(),ans=0;
      String B = sc.next();
      ans += 100*A*Character.getNumericValue(B.charAt(0));
      ans += 10*A*Character.getNumericValue(B.charAt(2));
      ans += A*Character.getNumericValue(B.charAt(3));
      System.out.println(ans/100);
	}
}

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005

int main(){
sp;
int n;
cin>>n;
ll h[n+1];
for(int i=1; i<=n; ++i)cin>>h[i];
ll dp[n+1];
memset(dp,0,sizeof dp);
ll ans=0;
dp[2]=abs(h[1]-h[2]);
for(int i=3; i<=n; ++i)
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
cout<<dp[n];
return 0;}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        int[][] max = new int[n][3];
        for (int i = 0 ; i < n ; i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
            c[i] = in.nextInt();
        }
        max[0][0] = a[0];
        max[0][1] = b[0];
        max[0][2] = c[0];
        for (int i = 1 ; i < n ; i++) {
            max[i][0] = Math.max(max[i-1][1], max[i-1][2]) + a[i];
            max[i][1] = Math.max(max[i-1][0], max[i-1][2]) + b[i];
            max[i][2] = Math.max(max[i-1][0], max[i-1][1]) + c[i];
        }
        System.out.println(Math.max(max[n-1][0], Math.max(max[n-1][1], max[n-1][2])));
    }
}


Measured memory_bytes: 96884
n = int(input())
a_list = list(map(int, input().split()))

full_cost = 0

a_list = [0] + a_list + [0]

for i in range(n+1):
    full_cost += abs(a_list[i] - a_list[i+1])

for i in range(1, n+1):
    cost_diff = abs(a_list[i-1] - a_list[i+1]) - \
        abs(a_list[i] - a_list[i+1]) - abs(a_list[i-1] - a_list[i])
    print(full_cost + cost_diff)


Measured memory_bytes: 20560
using System;
public class Hello{
    public static void Main(){
        string input = Console.ReadLine();
        bool flag = true;
        
        for(int x = 0;x < input.Length - 1;x++){
            for(int y = x + 1;y < input.Length;y++){
                if(input.Substring(x,1) == input.Substring(y,1)){
                    flag = false;
                    break;
                }
            }
        }
        
        if(flag == true){
            Console.WriteLine("yes");
        }else{
            Console.WriteLine("no");
        }
    }
}


Measured memory_bytes: 13140
def cardnum(c):
    cc = list(c)
    return int(cc[1])

def cardlabel(c):
    cc = list(c)
    return cc[0]

def bubleSort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if cardnum(c[j]) < cardnum(c[j-1]):
                (c[j], c[j-1]) = (c[j-1], c[j])
    return c

def selectionSort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if cardnum(c[j]) < cardnum(c[minj]):
                minj = j
        if minj != i:
            (c[i], c[minj]) = (c[minj], c[i])
    return c

def isStable(c1, c0):
    l0 = []
    l1 = []
    for i in range(1, 10):
        for j in range(len(c0)):
            if (cardnum(c0[j])==i):
                l0.append(cardlabel(c0[j]))
            if (cardnum(c1[j])==i):
                l1.append(cardlabel(c1[j]))
#    print(l0)
#    print(l1)
#    print(l0==l1)
    return l0 == l1
     

n = int(input())
cards = input().split()
c1 = cards.copy()
c1ret = bubleSort(c1, n)
print(' '.join(c1ret))
if (isStable(c1ret, cards)):
    print('Stable')
else:
    print('Not stable')

#print(c1, c1ret, cards)

c2 = cards.copy()
c2ret = selectionSort(c2, n)
print(' '.join(c2ret))
if (isStable(c2ret, cards)):
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5612
/*
 * C言語のサンプルプログラム - Webkaru
 * - 入力した数値の桁数を表示 -
 */
#include <stdio.h>
 
int main(void)
{
  /* 変数の宣言 */
  int number,souko;
  int digit = 0;
 
  /* 数値の入力 */
  scanf("%d", &number);
  souko=number;
  /* 桁数を計算 */
  while(souko!=0){
    souko = souko / 10;
    ++digit;
  }
  if(digit==1){
    printf("%d",number);
  }else if(digit==2){
    printf("9");
  }else if(digit==3){
    printf("%d",9+number-99);
  }else if(digit==4){
    printf("%d",9+900);
  }else if (digit==5)
  {
    printf("%d",9+900+number-9999);
  }else if(digit==6) {
    printf("90909");
  }
  
 
  /* 数値の桁数を表示 */
 
}


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

use std::collections::BTreeMap;

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let d = 1000000007;
    let mut map: BTreeMap<usize, Vec<usize>> = BTreeMap::new();
    for i in 0..n {
        map.entry(v[i]).or_insert_with(Vec::new).push(i);
    }
    let css: Vec<Vec<usize>> = map.values().map(|x| x.clone()).collect();
    let mut line: Vec<usize> = (0..n).collect();
    for cs in css {
        for i in 1..cs.len() {
            line[cs[i]] = cs[i - 1];
        }
    }
    let mut dp: Vec<usize> = vec![0; n];
    dp[0] = 1;
    for i in 1..n {
        dp[i] = dp[i - 1];
        if line[i] < i - 1 {
            dp[i] = (dp[i] + dp[line[i]]) % d;
        }
    }
    println!("{}", dp[n - 1]);
}


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

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

    int tmp;
    int a = s/1000;
    tmp = s%1000;
    int b = tmp/100;
    tmp = tmp%100;
    int c = tmp/10;
    int d = tmp%10;

    bool ab,cd;
    ab = false;
    cd = false;
    if ((a == 0 && b <= 9 && b >= 1) || (a == 1&& b <=2 && b>=0 )){
        ab = true;
    } 
    if ((c == 0 && d <= 9 && d >= 1) || (c == 1&& d <=2 && d>=0 )){
        cd = true;
    } 
    if (ab && cd) {
        cout << "AMBIGUOUS" << endl;
    } else if (ab) {
        cout << "MMYY" << endl;
    } else if (cd) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }

}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
bool flag=true;
sort(v.begin(),v.end());
for(ll i=1;i<n;i++)
{
    if(v[i]==v[i-1])
    {
        flag=false;
        break;
    }
}
if(flag)
{
    cout<<"YES"<<endl;
}else
{
    cout<<"NO"<<endl;
}
return 0;
}


Measured memory_bytes: 2420
s = list(input())
t = s[::-1]
for i in range(len(t)):
  if t[i] == "p":
    t[i] = "q"
  elif t[i] == "q":
    t[i] = "p"
  if t[i] == "b":
    t[i] = "d"
  elif t[i] == "d":
    t[i] = "b" 
if s == t:
  ans = "Yes"
else:
  ans = "No"
print(ans)
    

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

#define inf  1e18
#define int  long long
#define float double
#define endl  "\n"
#define w(t)  int t;cin>>t;while(t--)
#define str  to_string
#define vci  vector<int>
#define vcs  vector<string> 
#define mp   make_pair
#define pb   push_back
#define pii   pair<int,int>
#define pis   pair<int,string>
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define mod   1000000007
random_device rd;
mt19937 rand_gen(rd());
#define setbits(x)     __builtin_popcountll(x)
#define trailzero(x)   __builtin_ctzll(x)
#define shuffle(vc) shuffle(vc.begin(), vc.end(), rand_gen);
#define decimal(x,value)  cout<<fixed<<setprecision(x)<<value
void io()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("/home/kashif/cp/input.txt","r",stdin);
		
		freopen("/home/kashif/cp/output.txt","w",stdout);
	#endif

}
int n;
int dp[100005];
int h[100005]={0};
int ans(int h[],int k)
{
	
	if(k>=n)
		return dp[k]=0;
	if(k==n-1)
		return dp[k]=abs(h[k]-h[k+1]);
	int &a=dp[k];
	if(a!=-1)
		return a;
	else
	{
		int f=abs(h[k]-h[k+1])+ans(h,k+1);
		int g=abs(h[k]-h[k+2])+ans(h,k+2);
		a=min(f,g);
	}
	return a;

}
//


int32_t main()
{
	
	fastio();
	// io();
	memset(dp,-1,sizeof(dp));
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	cout<<ans(h,1)<<endl;


	
	
}


Measured memory_bytes: 12960
N, M = map(int, input().split())

ans = 1

import math

l = []
for i in range(1, int(math.sqrt(M)) + 1):
    if M % i == 0 and i * N <= M:
        l.append(i)
        if M // i * N <= M:
            l.append(M // i)

print(max(l))


Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    char ch;
    int x,c[26]= {0};

    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            x=ch-'A';
            c[x]+=1;
        }
        else if(ch>='a' && ch<='z')
        {
            x=ch-'a';
            c[x]+=1;
        }
    }

    for(x=0,ch='a'; x<26; x++,ch++)
    {
        printf("%c : %d\n",ch,c[x]);
    }
    return 0;
}



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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    //各マスまでの到達コストの初期値を定義
    const int INF = pow(10, 9);
    //各マスからの移動方法を定義
    const vector<int> di = {-1, 0, 1, 0};
    const vector<int> dj = {0, -1, 0, 1};
    //入力
    int H, W;
    cin >> H >> W;
    int si, sj;
    int gi, gj;
    cin >> si >> sj;
    cin >> gi >> gj;
    //配列で扱うため、0-indexに直す
    si--; sj--; gi--; gj--;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    vector<vector<int>> dist(H, vector<int>(W, INF));
    //dequeのデータ構造を用意
    deque<pair<int, int>> q;
    //始点の情報を更新、dequeに格納
    dist[si][sj] = 0;
    q.emplace_back(si, sj);

    //01-BFS開始
    while(!q.empty()){
        //dequeから、探索開始点の情報を取得し、dequeから消去
        int i = q.front().first;
        int j = q.front().second;
        //探索開始点の距離情報を取得
        int d = dist[i][j];
        q.pop_front();
        //壁に邪魔されずに移動できる時の方法（縦横に1マスだけ動く場合の動き方）
        rep(v, 4){
            int ni = i + di[v];
            int nj = j + dj[v];
            if(ni >= H || nj >= W || ni < 0 || nj < 0) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            //dequeの先頭から入れる
            q.emplace_front(ni, nj);
        }
        //ワープを用いての移動の方法（周囲5x5マスに移動可能）
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int ni = i + ei;
                int nj = j + ej;
                if(ni >= H || nj >= W || ni < 0 || nj < 0) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                //dequeの末尾から入れる
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[gi][gj];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 9552
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)
    val n ="${a}" + "${b}"
    val n1 = n.toInt()
    var flug = false
    for(i in 1..n1) {
        if(i * i == n1) {
            flug = true
        }
    }
    if(flug) {
        print("Yes")
    } else {
        print("No")
    }
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;
struct segtree{
    static const int SEG=1<<19;
    vector<int>dat,put;
    segtree():dat(SEG*2),put(SEG*2){}

    inline void push(int k){
        dat[k]+=put[k];
        if(k<SEG-1){
            put[k*2+1]+=put[k];
            put[k*2+2]+=put[k];
        }
        put[k]=0;
    }
    void add(int a,int b,int x,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]=x;
            push(k);
            return;
        }
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
    int query(int a,int b,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return -INF;
        if(a<=l&&r<=b)return dat[k];
        return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
    }
};

int W,H,N;
int X[333333],Y[333333];

int ans;

void solve(){
    vector<pint>ps;
    rep(i,N)ps.pb({X[i],Y[i]});
    sort(all(ps));

    vector<int>xs={0};
    rep(i,N)if(ps[i].fi)xs.pb(ps[i].fi);

    stack<pint>up,dw;
    up.push({0,H/2});
    dw.push({0,H/2});
    rep(i,N)ps[i].fi=lower_bound(all(xs),ps[i].fi)-xs.begin();

    segtree seg;
    for(int i=0;i<xs.size();i++)seg.add(i,i+1,-xs[i]);
    rep(i,N){
        seg.add(up.top().fi,ps[i].fi,H/2);
        seg.add(dw.top().fi,ps[i].fi,H/2);
        chmax(ans,xs[ps[i].fi]+seg.query(0,ps[i].fi));
        seg.add(up.top().fi,ps[i].fi,-H/2);
        seg.add(dw.top().fi,ps[i].fi,-H/2);
        if(ps[i].se<=H/2){
            while(up.top().se<ps[i].se){
                pint p=up.top();
                up.pop();
                seg.add(up.top().fi,p.fi,-(H/2-p.se));
            }
            seg.add(up.top().fi,ps[i].fi,H/2-ps[i].se);
            up.push(ps[i]);
        }
        else{
            while(dw.top().se>ps[i].se){
                pint p=dw.top();
                dw.pop();
                seg.add(dw.top().fi,p.fi,-(p.se-H/2));
            }
            seg.add(dw.top().fi,ps[i].fi,ps[i].se-H/2);
            dw.push(ps[i]);
        }
    }

    seg.add(up.top().fi,xs.size(),H/2);
    seg.add(dw.top().fi,xs.size(),H/2);
    chmax(ans,W+seg.query(0,xs.size()));
}

signed main(){
    cin>>W>>H>>N;
    rep(i,N)cin>>X[i]>>Y[i],X[i]*=2,Y[i]*=2;
    W*=2;H*=2;

    rep(t,2){
        solve();
        swap(H,W);
        rep(i,N)swap(X[i],Y[i]);
    }

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


Measured memory_bytes: 36624
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    elif s == 'RE':
        re += 1
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

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

int dist_recursive(int node, vector<int64_t> &dist, vector<vector<pair<int,int>>> &links_by_node);

int main()
{
	int n;
	cin >> n;
	vector<tuple<int,int,int>> link(n);

	for (int i=0;i<n-1;++i)
	{
		int u,v,w;
		cin >> u >> v >> w;
		link[i]=make_tuple(u,v,w);
	}

	vector<vector<pair<int,int>>> links_by_node(n+1);
	for (int i=0;i<n-1;++i)
	{
		int u,v,w;
		tie(u,v,w)=link[i];
		links_by_node[u].push_back(make_pair(v,w));
		links_by_node[v].push_back(make_pair(u,w));
	}

	vector<int64_t> dist(n+1);
	dist[1]=0;
	for (int i=2;i<=n;++i)
	{
		dist[i]=-1;
	}

	dist_recursive(1,dist,links_by_node);

	for (int i=1;i<=n;++i)
	{
		//fprintf(stderr,"%d %lld\n",i,dist[i]);
		if ((dist[i]&1)==0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << 1 << endl;
		}
	}


}

int dist_recursive(int node, vector<int64_t> &dist, vector<vector<pair<int,int>>> &links_by_node)
{
	for (int i=0;i<links_by_node[node].size();++i)
	{
		pair<int,int> p=links_by_node[node][i];
		if (dist[p.first]<0)
		{
			dist[p.first]=dist[node]+p.second;
			dist_recursive(p.first,dist,links_by_node);
		}
	}
	return 0;
}





Measured memory_bytes: 9600
X = int(input())

# if A > B > 0 then
#  X >= 5A^4 - 10A^3 + 10A^2 -5A + 1


def fn(a):
    return 5 * a**4 - 10 * a**3 + 10 * a**2 - 5 * a + 1


A_max = 0
for a in range(3, 1000):
    if fn(a) > X and a**5 > X:
        A_max = a
        break

s = dict()
for a in range(0, A_max):
    s[a**5] = a

for a5 in s:
    if a5 - X in s:
        print(s[a5], s[a5 - X])
        exit()
    if X - a5 in s:
        print(s[a5], -s[X - a5])
        exit()


Measured memory_bytes: 61848
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    for(int i=0;i<10;i++){
        string card;
        cin >> card;
        if(card=="-"){
            break;
        }
        int m;
        cin >> m;
        for(int j=0;j<m;j++){
            int h;
            cin >> h;
            card+=card.substr(0,h);
            card.erase(0,h);
        }
        cout << card << endl;
    }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    multiset<int> a;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int now;
        cin >> now;
        now *= -1;
        if (a.empty() || *--a.end() <= now) a.insert(now);
        else {
            auto it = a.upper_bound(now);
            a.erase(it);
            a.insert(now);
        }
    }
    cout << a.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
int main (){
  int n,call[100],count=0,i;
  char moji[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&moji[i]);
  }
  /*AUAAUAUU okey*/
  for(i=0;i<n;i++){
    
    if(moji[i]=='A')count=count+1;
    else count=count-1;

    if(count<0)break;
  }
  if(count==0)printf("YES\n");
  else printf("NO\n");

  return 0;
}

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

int n, k, p;

int main() {
  int ans = 0;
  std::cin >> n >> k;
  for (int i = 0; i < n; i++) {
    std::cin >> p;
    ans += (std::min(k-p, p) * 2);
  }
  std::cout << ans << std::endl;
  
}

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

using ll = long long;

const int mod = 1e9+7;



int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> v(n);
    rep(i,n) cin >> v[i];
    int64_t ans=0;
    int64_t tot=0;
    rep(i,n){
        tot+=v[i];
        tot%=mod;
    }
    rep(i,n-1){
        ll x=v[i];
        tot=(tot+mod-x)%mod;
        ll sum=(x*tot)%mod;
        ans+=sum;
        ans%=mod;
    }
    ans%=mod;
    cout << ans << endl;
}

Measured memory_bytes: 4816
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
struct duilie {
    char name[10];
    int time;
} Q[MAX];

int head;
int tail;
int max;

void initialize(){
    head = tail = 0;
}

int isEmpty(){
    return head == tail;
}

int isFull(){
    return (head == tail+1) || (tail+1 == MAX && head == 0);
    //return head == (tail+1)%MAX
}

void enqueue(struct duilie x){
    if (isFull()){
        printf("Full, error\n");
        exit(-1);
    }
    Q[tail] = x;
    if (tail+1 == MAX)
        tail = 0;
    else
        tail++;
}

struct duilie dequeue(){
    if (isEmpty()){
        printf("Empty, error\n");
        exit(-1);
    }
    struct duilie tmp = Q[head];
    if (head+1 == MAX)
        head = 0;
    else
        head++;    

    return tmp;
}

int main (){
    initialize();
    int n, split;
    scanf("%d", &max);
    scanf("%d", &split);
    for (int i = 0; i < max; i++){
        scanf("%s", &Q[i].name);
        scanf("%d", &Q[i].time);
		tail++;
    }
    int totalTime = 0;
	while (!isEmpty()){
		if (Q[head].time <= split){
			totalTime += Q[head].time;
			printf("%s %d\n", Q[head].name, totalTime);
			dequeue();
		}
		else {
			totalTime += split;
            Q[head].time -= split;
			enqueue(dequeue());
		}
	}
    return 0;
}


Measured memory_bytes: 3356
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  long N, A, B;

  cin.scan(N, A, B);

  writeln(N / (A + B) * A + (N % (A + B) < A ? N % (A + B) : A));
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		
		int r1 = A+B;
		int r2 = B+C;
		int r3 = C+A;
		
		int ans = Math.min(Math.min(r1, r2), r3);
	
		System.out.println(ans);
		
		in.close();
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<cstring> 
#include<algorithm>
using namespace std;

int n,m,a[100000];

long long ans;

int main()
{
    cin>>n>>m;
    int t = n-1;
    for(int i=0;i<n;++i) cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n/2;++i)
		swap(a[i],a[t--]);
	for(int i=0;i<m;++i)
		ans+=a[i];
	cout<<ans; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  ll maxt=a[0];
  ll sum=0;
  for(ll i=1;i<n;i++){
    if(maxt>a[i]){
      sum+=maxt-a[i];
    }
    if(maxt<a[i]){
      maxt=a[i];
    }
  }
  cout<<sum<<endl;

  return 0;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N,M;
  cin>>N>>M;
  string S;
  cin>>S;
  reverse(S.begin(),S.end());
  vector<int> ans;
  int p = 0;
  bool can = true;
  while(p!=N&&can){
    for(int i = min(N-p,M); i>=1;i--){
      if(S[p+i]=='0') {
        ans.push_back(i);
        p+=i;
        break;
      }
      if(i==1) {
        can = false;
        break;
      }
    }
  }
  reverse(ans.begin(),ans.end());
  if(can){
    for(auto x:ans) cout<<x<<" ";
    cout<<endl;
  }
  else cout<<-1<<endl;
}

Measured memory_bytes: 1144
import sys
import numpy as np
#import math
#import itertools
#import re
#from functools import lru_cache

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    n = input()

    if n[-1] == '3':
        print('bon')
    elif n[-1] in ['0','1','6','8']:
        print('pon')
    else:
        print('hon')


if __name__ == '__main__':
    main()


Measured memory_bytes: 27088
import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)
for m in range(M):
    a = heapq.heappop(A)
    a = int(a/2)
    heapq.heappush(A, a)
print(-sum(A))



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

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "0") {
        cout << "0" << endl;
        return 0;
    }
    int size = s.length();
    int z = 0, o = 0;
    for (int i = 0; i < size; ++i) {
        if (s[i] == '0') ++z;
        else ++o;
    }
    cout << min(z, o) * 2 << endl;
}

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

int main(){
    long long A;
    cin >> A;
    string B;
    cin >> B;
    long long BB;
    BB = (B[0]-'0')*100 + (B[2]-'0')*10 + (B[3]-'0');
    cout << (A*BB)/100 << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3636