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


int head, tail;

struct process { int time; string name;};

struct process Q[MAX];

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

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

int isFull(){
	return head == (tail + 1) % MAX;
}

void enqeueu(struct process x){
	Q[tail] = x;
	
	if(tail + 1 == MAX) 
		tail = 0;
	else
		tail++;
}

struct process deqeueu(){
	struct process x;	
	
	x = Q[head];
	if(head + 1 == MAX)
		head = 0;
	else
		head++;
	return x;
	
}

int main(){	
	int n, q, temp, tempQ, time = 0;
	struct process U;
	
	initialize();
	
	cin>>n>>q;

	for(int i = 1; i <= n; i++){
		cin>>Q[i].name>>Q[i].time;
	}

	head = 1; tail = n + 1;
	
	while(head != tail){
		temp = head;
		U = deqeueu();
		if(U.time <= q){
			time += U.time;
			cout<<Q[temp].name<<" "<<time<<endl;
			
		} else {
			U.time -= q; 
			enqeueu(U);
			time += q;
		}
	}
	
	
	
	return 0;
}


Measured memory_bytes: 6968
///Code by: Luis Alejandro
///Handle: Sekai
///Country: Cuba

#include <bits/stdc++.h>
#define endl '\n'
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")

using namespace std;

typedef unsigned long long ull;
typedef long long lld;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN=1e5+5;
const int MOD=1e9+7;
const int INF=1e9;
const ld PI=acos(-1);
const ld EPS=1e-9;

#define lg2(x) 31-__builtin_clz(x)
#define logx(a,b) (log(a)/log(b))
#define pow2(a) a*a
#define pow3(a) a*a*a
#define lcm(a,b) (a*b)/__gcd(a,b)

pii mkp(int a, int b){
    if(a>b)swap(a,b);
    return make_pair(a,b);
}

int mod_pow(int a, int b){
    if(!b)return 1;
    if(b&1)return mod_pow(a,b-1)*a%MOD;
    int power=mod_pow(a,b>>1);
    return power*power%MOD;
}

int modular_inverse(int a){
    return mod_pow(a,MOD-2);
}

vector<int> movy={0,0,1,-1};
vector<int> movx={1,-1,0,0};

void solve(){
    int n, x, t, ans=0, cnt=0;
    cin>>n>>x>>t;
    while(cnt<n){
        cnt+=x;
        ans+=t;
    }
    cout<<ans<<endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("IN.txt","r",stdin);
        //freopen("OUT.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,j,k,d[8],t,r=1,n1,ans=inf,n,a,c,b;
	cin>>n>>a>>b>>c;
	for (i=0;i<n;i++){
		cin>>d[i];
	}
	r=1<<(2*n);
	vector<int> g;
	for (i=1;i<r;i++){
		t=i;
		n1=n;
		while (n1>0){
			g.push_back(t%4);
			t/=4;
			n1--;
		}
		int sa=0,sb=0,sc=0,sa1=-1,sb1=-1,sc1=-1;
		reverse(g.begin(),g.end());
		for (j=0;j<g.size();j++){
			if (g[j]==0){
				sa+=d[j];
				sa1++;
			}
			else if (g[j]==1){
				sb+=d[j];
				sb1++;
			}
			else if (g[j]==2){
				sc+=d[j];
				sc1++;
			}
		}
		g.clear();
		if (sa1>=0&&sb1>=0&&sc1>=0){
			ans=min(ans,(sa1+sb1+sc1)*10+abs(sa-a)+abs(sb-b)+abs(sc-c));
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  vector<int>dp(N,INF);
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
    if(i<N-j){chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));}
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;  
}

Measured memory_bytes: 4052
#include <iostream>
#include <stdio.h>
#include<string.h>
using namespace std;

int main()
{
	char  a[99];
	int n, m, o, i;//nは文字数,
	
	scanf("%s", a);

	n = strlen(a);

	m = (n - 1) / 2;
	o = (n + 3) / 2;
	
	for (i = 0; i < n; i++) {
		if (a[i] == a[n - 1 - i]) {//回分である
		
		}
		else {
			cout << "No";
			return 0;
		}

	}

	for (i = 0; i < m; i++) { //２つ目の条件
		if (a[i] == a[m - 1 - i]) {
		
		}
		else {
			cout << "No";
			return 0;
		}
		
	}

	for (i = 0; i < n-o; i++) { //3つ目の条件
		if (a[o + i - 1] == a[n - 1 - i]) {
		}
		else {
			cout << "No";
			return 0;
		}

	}
	cout << "Yes";

}

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

int main(){
  int n,l;
  cin>>n>>l;
  vector<string> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());
  for(auto s:v) cout<<s;
  cout<<endl;
}


Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define cout (c_?cerr:cout)
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_;\
__VA_ARGS__;--c_;if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define dprt(...) dbg(prt(__VA_ARGS__))
#define drprt(...) dbg(rprt(__VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__, '=',  __VA_ARGS__)
#define rdmp(...) dbg(cerr<<#__VA_ARGS__<<": ";drprt(__VA_ARGS__);)
using namespace std; using ll = long long;
template< typename t > using V = vector< t >;
template< typename t > void prt(const t& a){cout<<a<<'\n';}
template< typename t, typename... v > void prt(const t& a, v&&... b){cout<<a<<' ';prt(b...);}
template< typename t > void rprt(t a, const t& b){while(a!=b)cout<<(*a++)<<' ';cout << '\n';}
/*}}}*/

int n, k;
bool tb[10];

inline bool spr(int v)
{
    while (v > 0)
        if (tb[v % 10])
            return false;
        else v /= 10;
    return true;
}

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

    cin >> n >> k;

    while (k--)
    {
        int v; cin >> v;
        tb[v] = true;
    }

    while (not spr(n))
        ++n;

    prt(n);
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  //  int flag=0;
  for(int i=s.size()-1; i>0; i--){
    if(i%2==1) continue;
    rep(j,i/2){
      if(s[j]!=s[j+i/2]) break;
      if(j==i/2-1){
	cout << i << endl;
	return 0;	
      }
    }
  }
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n; cin >> n;
  int h[n];
  REP(i, n) cin >> h[i];

  int cnt = 0; bool f = true;
  while(f){
    bool w = false, s = false;
    REP(i, n){
      if(w){
        if(h[i] <= 0) w = false;
        else h[i]--;
      } else {
        if(h[i] > 0){
          w = true; s = true;
          cnt++;
          h[i]--;
        }
      }
    }

    if(!s) break;
  }

  cout << cnt << endl;

  return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

//nの約数を追加する
vl divisor_count(ll n){
    vl a;
    for(ll i=1LL;i*i<=n;i++){
        if(n%i == 0){
            a.push_back(i);
            if(n/i != i)a.push_back(n/i);
        }
    }
    sort(all(a));
    return a;
}
signed main()
{   
    gearup;
    ll n,m; cin >> n >> m;
    auto a = divisor_count(m);
    ll res = 1;
    for(auto b:a) if(b*n<=m)chmax(res,b);
    out(res);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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

int main(){
  int a[1000010];
  rep(i,1000010) a[i]=1;
  
  rep(i,1000000){
    if(i<2){
      a[i]=0;
      continue;
    }
    if(i==2){
      a[i]=1;
      continue;
    }
    else if(i%2==0){
      a[i]=0;
      continue;
    }
    
    for(int j=3;j*j<=i;j+=2){
      if(i%j==0){
        a[i]=0;
        continue;
      }
    }
  }
  
  int dp[1000010];
  dp[0]=0;
  for(int i=1;i<1000009;i++){
    if(a[i]) dp[i]=dp[i-1]+1;
    else dp[i]=dp[i-1];
  }
  
  int n;
  while(cin>>n){
    cout<<dp[n]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 10908
#include<iostream>
using namespace std;
int main()
{
	long long a,b,x,temp;
	cin>>x;
	a=-64,b=-64;
	temp=a*a*a*a*a-b*b*b*b*b;
	while(temp!=x)
	{
		if(temp>x) b++;
		else a++;
		temp=a*a*a*a*a-b*b*b*b*b;
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            String tmp = Integer.toString(i);
            if (tmp.length() % 2 != 0) cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 28372
#t = Time.now
#N, K, Q = 2000, 10, 10
#as = (0...N).to_a.shuffle
N, K, Q = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

ia = N.times.map{|i|[i, as[i]]}.sort_by{|arr|arr[1]}

ans = Float::INFINITY
used = Array.new(N) + [true]
(N-Q+1).times do |i|
    #if ia[i+Q-1][1] - ia[i][1] >= ans
    #    used[ia[i][0]] = true
    #    next
    #end
    avail = []
    tmp = []
    d = 0
    (N+1).times do |j|
        if used[j]
            if d >= K
                tmp.sort!
                avail.concat(tmp[0, d-K+1])
            end
            tmp = []
            d = 0
        else
            d += 1
            tmp.push(as[j])
        end
    end
    avail.sort!
    if avail.length >= Q
        cand = avail[Q-1] - ia[i][1]
        ans = cand if ans > cand
    end
    used[ia[i][0]] = true
end

puts ans
#p Time.now - t

Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int n;
  int i,j;
  int alice,bob;
  int temp;
  
  cin>>n;
  vector<int> a(n,0);
  for(i=0;i<n;i++)cin>>a.at(i);
  
  for(i=0;i<n;i++){
    for(j=0;j<n-i-1;j++){
      if(a.at(j)<a.at(j+1)){
      	temp = a.at(j);
        a.at(j) = a.at(j+1);  
        a.at(j+1) = temp;}
    }
  }
  
  alice+=a.at(0);
  for(i=1;i<n;i++){
    if(i%2==0)alice+=a.at(i);
    else bob+=a.at(i);
  }
  cout<<(alice-bob);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import functools
import itertools
import math
INF = float('inf')
# MOD = 10**9+7
MOD = 998244353

class SegmentTree:

    def __init__(self, N):
        self.N = 1<<(N-1).bit_length()
        self.data = [None] * (2*self.N)

    # 時刻 t に [l, r) を v に変更する
    def update(self, l, r, t, v):
        L, R, val = l+self.N, r+self.N, (t, v)
        while L < R:
            if R & 1:
                R -= 1
                self.data[R-1] = val
            if L & 1:
                self.data[L-1] = val
                L += 1
            L >>= 1
            R >>= 1

    # 現在の x の値を得る
    def getValue(self, x):
        x += self.N-1
        ret = (-1, INF)
        while x >= 0:
            if self.data[x]:
                ret = max(ret, self.data[x])
            x = (x-1)//2
        return ret[1]

N, M = map(int, input().split())
es = defaultdict(list)
for i in range(M):
    l, r, c = map(int, input().split())
    es[l-1].append((c, r))
if 0 not in es:
    print(-1)
    exit()
for l in es:
    es[l].sort()
seg = SegmentTree(N)
seg.update(0, 1, 0, 0)
seg.update(1, N, 1, INF)
Time = 2
for l in range(N):
    esl = es[l]
    d = seg.getValue(l)
    for c, r in esl:
        s, t = l, r
        while s+1 < t:
            m = (s+t)//2
            if seg.getValue(m) <= d+c:
                s = m
            else:
                t = m
        seg.update(t, r, Time, d+c)
        Time += 1
ans = seg.getValue(N-1)
if ans == INF:
    print(-1)
else:
    print(ans)



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

const double eps = 1e-9;

bool same(double a, double b) { return abs(a - b) < eps; }

struct P {
    double x, y;
    P() : x(0), y(0) {}
    P(double x, double y) : x(x), y(y) {}
    P operator + (P b) { return P(x + b.x, y + b.y); }
    P operator - (P b) { return P(x - b.x, y - b.y); }
    P operator * (double b) { return P(x * b, y * b); }
    P operator / (double b) { return P(x / b, y / b); }
    double operator * (P b) { return x * b.x + y * b.y; }
    double operator ^ (P b) { return x * b.y - y * b.x; }
    double abs() { return hypot(x, y); }
    P unit() { return *this / abs(); }
};

struct L{
    // ax + by + c = 0
    double a, b ,c, o;
    P pa, pb;
    L() : a(0), b(0), c(0), o(0), pa(), pb() {}
    L(P pa, P pb) : a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), o(atan2(-a, b)), pa(pa), pb(pb) {}
    P project(P p) {
        return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs());
    }
    P reflect(P p) {
        return p + (project(p) - p) * 2;
    }
};

P intersect(L x, L y) {
    if (same(x.a * y.b, x.b * y.a)) throw;
    double z = -x.a * y.b + x.b * y.a;
    return P(-x.b * y.c + x.c * y.b, x.a * y.c - x.c * y.a) / z;
}

int main() {
    P p1; cin >> p1.x >> p1.y;
    P p2; cin >> p2.x >> p2.y;
    L l(p1, p2);
    int q; cin >> q; while (q--) {
        P p; cin >> p.x >> p.y;
        p = l.reflect(p);
        cout << fixed << setprecision(10) << p.x << " " << p.y << '\n';
    }
}



Measured memory_bytes: 3500
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=b[a[0]-1]
for i in range(1,n):
  s+=b[a[i]-1]
  if a[i-1]==a[i]-1:
    s+=c[a[i-1]-1]
    
print(s)

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

signed main() {
    while (true) {
        int n;
        cin >> n;
        
        if (n==0) {
            break;
        }
        
        map<int, int> mp{{0,0}, {1,1}, {2,2}, {3,3}, {4,5}, {5,7}, {6,8}, {7,9}};
        
        int ans = 0;
        int c = 1;
        
        while (!(n<8)) {
            ans += mp[n%8]*c;
            n /= 8;
            c *= 10;
        }
        
        ans += mp[n]*c;
        
        cout << ans << endl;
    }
}


Measured memory_bytes: 3004
n, k = map(int, input().split())
s, p, r = map(int, input().split())
t = input()

l = [['none'] for _ in range(k)]
for i in range(n):
    l[i % k].append(t[i])

ans = []
for i in l:
    num = 0
    li = len(i)
    mark = [0 for _ in range(li)]
    for j in range(1, li):
        if i[j-1] != i[j]:
            if i[j] == 'r':
                num += r
            elif i[j] == 's':
                num += s
            else:
                num += p
        else:
            if mark[j-1] == 1:
                if i[j] == 'r':
                    num += r
                elif i[j] == 's':
                    num += s
                else:
                    num += p
            else:
                mark[j] = 1
    ans.append(num)

print(sum(ans))

Measured memory_bytes: 17160
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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 FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
void solve(){
	int N,A,B,C,D;
	cin>>N>>A>>B>>C>>D;
	unordered_map<int,int>mp;
	auto dfs = [&](auto&&f,int n) -> unsigned long long{
		if(n == 1)return D;
		if(n == 0)return 0;
		if(mp.count(n))return mp[n];
		unsigned long long ret = D * n;
		FOR(i,-1,1 + 1){
			int cost = abs(i) * D + A;
			int nn = n + i;
			if(nn % 2 == 0){
				if(nn <= 0 || nn / 2 >= n)continue;
				CHMIN(ret,f(f,nn / 2) + cost);
			}
		}
		FOR(i,-2,2 + 1){
			int cost = abs(i) * D + B;
			int nn = n + i;
			if(nn % 3 == 0){
				if(nn <= 0 || nn / 3 >= n)continue;
				CHMIN(ret,f(f,nn / 3) + cost);
			}
		}
		FOR(i,-4,4 + 1){
			int cost = abs(i) * D + C;
			int nn = n + i;
			if(nn % 5 == 0){
				if(nn <= 0 || nn / 5 >= n)continue;
				CHMIN(ret,f(f,nn / 5) + cost);
			}
		}
		return mp[n] = ret;
	};
	out(dfs(dfs,N));
}
 
signed main(){
	IOS();
	int Q = 1;
	cin >> Q;
	while(Q--)solve();
}

Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

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

	multiset<int> st;
	for(auto& a : A) st.insert(-a);
	for(auto& a : A){
		auto itr = st.find(-a);
		st.erase(itr);
		cout << -(*st.begin()) << endl;
		st.insert(-a);
	}
}


Measured memory_bytes: 11776
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
    string str;
	cin>>str;
	if((str[0]=='A' && str[1]=='A' && str[2]=='A') || (str[0]=='B' && str[1]=='B' && str[2]=='B'))
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

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

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

  string Ans = "NA";

  int BunkatsuA = (S[0]-'0')*10 + (S[1]-'0');
  int BunkatsuB = (S[2]-'0')*10 + (S[3]-'0');

  if ( 1 <= BunkatsuA && BunkatsuA <= 12 ) {
    if ( 1 <= BunkatsuB && BunkatsuB <= 12 ) Ans = "AMBIGUOUS";
    else Ans = "MMYY";
  } else if ( 1 <= BunkatsuB && BunkatsuB <= 12 ) Ans = "YYMM";

  cout << Ans << endl;
}


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

using namespace std;

int func(string s1, string s2)
{
	int m = 0, t;
	
	for(int i = 0; i < s1.size(); i++){
		for(int j = 0; j < s2.size() && j+i < s1.size(); j++){
			if(s1[i+j] == s2[j]){
				t = 1;
				j++;
				while(i+j < s1.size() && j < s2.size() && s1[i+j] == s2[j]){
					j++;
					t++;
				}
				m = max(m, t);
			}
		}
	}
	
	return m;
}

int main()
{
	string s1, s2;
	
	while(cin>>s1>>s2){
		cout << max(func(s1, s2), func(s2, s1))	<< endl;
	}
	
	return 0;
}

Measured memory_bytes: 952
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	string A, B;
	cin >> A >> B;
	A = A + B;
	int N = stoi(A);
	int i = (int)sqrt(N);
	string S = (i * i == N) ? "Yes" : "No";
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  int M;
  int sum = 0;
  cin>>N;
  cin>>M;
  if(N > 1){
    for(int i = (N - 1);i > 0;i--){
      sum += i;
    }
  }
  if(M > 1){
    for(int i = (M - 1);i > 0;i--){
      sum += i;
    }
  }
  cout<<sum<<'\n';
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int n = in();
	vi a;
	rep(i, n) a.pb(in());

	sort(all(a));

	cout << a.rbegin()[0] - a[0] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
		
	public static void main(String[] args){	
		Scanner sc  =new Scanner(System.in);
		
		while(sc.hasNextInt()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			
			double d = (double)(a)/b;
			String str = "" + d;
			
			int sum = 0;
			int i = 0;
			boolean upper = true;
			for(char c:str.toCharArray()){
				if(upper){
					if(c == '.'){
						upper = false;
					}
				}else{
					i++;
					sum += c - '0';
					
					if(i >= n){
						break;
					}
				}
			}
			
			 System.out.println("" + sum);
			
		}
	}
}

Measured memory_bytes: 11000
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        char[][] matrix = new char[h][w];
        Deque<Point> points = new ArrayDeque<Point>();
        for(int i=0;i<h;i++){
            matrix[i] = sc.next().toCharArray();
            for(int j=0;j<w;j++){
                if(matrix[i][j] == '#'){
                    points.addLast(new Point(i,j));
                }
            }
        }
        sc.close();
        int count = search(matrix, points, h, w, 0);
        System.out.println(count);
        return;
    }
    public static int search(char[][] matrix, Deque<Point> points, int h, int w, int count){
        Point p;
        Deque<Point> new_points = new ArrayDeque<Point>();
        while(true){
            try{
                p = points.removeFirst();
            }catch(NoSuchElementException e){
                break;
            }
            int x = p.x; int y = p.y;
            matrix[y][x] = '%';
            int[] dx = {-1,0,1,0}; int[] dy = {0,-1,0,1};
            for(int i=0;i<4;i++){
                int nx = x + dx[i]; int ny = y + dy[i];
                if(ny<0 || ny>=h || nx<0 || nx>=w || matrix[ny][nx] != '.'){
                    continue;
                }
                matrix[ny][nx] = '#';
                new_points.addLast(new Point(ny,nx));
            }
        }
        try{
            p = new_points.getFirst();
            count++;
            return search(matrix, new_points, h, w, count);
        }catch(NoSuchElementException e){
            return count;
        }
    }
}
class Point{
    int x; int y;
    public Point(int y, int x){
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 98356
#include <math.h>

#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N;
  cin >> N;
  vector<int> H(N);

  rep(i, N) { cin >> H.at(i); }
  int count_ = 0;
  rep(i, N) {
    int a = H.at(N - i - 1);
    bool b = true;
    rep(j, N - i) {
      if (a < H.at(j)) {
        b = false;
        break;
      }
    }
    if (b == true) count_++;
  }
  cout << count_ << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;

int main(){
	ll x,y;
	cin >> x >> y;
	ll c=0;
	while(y>=x){
      	c++;
		x*=2;
	}
  cout << c;
}


Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::VecDeque;

fn main() {
    let n: usize = read();
    let s: String = read();
    let mut stack: VecDeque<char> = VecDeque::new();
    let sc: Vec<char> = s.chars().collect();
    let mut err_cnt = 0;

    for i in 0..sc.len() {
        let si = sc[i];
        if si == '(' {
            stack.push_front(si);
        }
        if si == ')' {
            if stack.len() > 0 {
                let top = stack.pop_front();
            } else {
                err_cnt += 1;
            }
        }
    }
    let mut ans = "".to_string();
    for _ in 0..err_cnt {
        ans += &"(";
    }
    ans += &s;
    for _ in 0..stack.len() {
        ans += &")";
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>
#include <set>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    string N;
    ll K;
    cin >> N >> K;

    string base = "";
    for(int i = 0;i< N.length();i++){
        base.push_back('0');
    }
    ll ans = 0;
    if (K == 1){
        for(int i = 0;i< N.length();i++){
            for(int i_num = 1;i_num < 10;i_num++){
                base[i] = (char) ('0' + i_num);
                if (base <= N){
                    ans++;
                }
                base[i] = '0';
            }
        }
    }else if (K == 2){
        for(int i = 0;i< N.length();i++){
            for(int i_num = 1;i_num < 10;i_num++){
                base[i] = (char) ('0' + i_num);
                for(int j = i+1;j< N.length();j++){
                    for(int j_num = 1;j_num < 10;j_num++){
                        base[j] = (char) ('0' + j_num);
                        if (base <= N){
                            ans++;
                        }
                        base[j] = '0';
                    }
                }

                base[i] = '0';
            }
        }
    }else{
        for(int i = 0;i< N.length();i++){
            for(int i_num = 1;i_num < 10;i_num++){
                base[i] = (char) ('0' + i_num);
                for(int j = i+1;j< N.length();j++){
                    for(int j_num = 1;j_num < 10;j_num++){
                        base[j] = (char) ('0' + j_num);

                        for(int k = j+1;k< N.length();k++){
                            for(int k_num = 1;k_num < 10;k_num++){
                                base[k] = (char) ('0' + k_num);
                                if (base <= N){
                                    ans++;
                                }
                                base[k] = '0';
                            }
                        }

                        base[j] = '0';
                    }
                }

                base[i] = '0';
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI acos(-1)
typedef long long ll;
ll gcd(ll x, ll y)
{
   if (y == 0)
      return x;
   else
      return gcd(y, x % y);
}
ll lcm(ll x, ll y)
{
   return x / gcd(x, y) * y;
}
using namespace std;
int main()
{
   string s;
   cin >> s;
   int n = s.size();
   ll ans = 0;

   for (int bit = 0; bit < (1 << n); ++bit)
   {
      ll sum = 0;
      ll kari=0;
      for (int i = 0; i < n; i++)
      {
         if(bit&(1<<i)){ //この時それまでの和を足す
         sum+=kari;
         kari=0;
         }
         else{ //kariが増える
         kari*=10;
         kari+=s[i]-'0';
         }
      }
      sum+=kari;
      ans+=sum;
   }
      cout << ans << endl;
      return 0;
   }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io

    ll x, k, d;
    cin>>x>>k>>d;
    //cnt回移動すれば0に近くなる
    ll cnt = abs(x)/d;
    ll now;
    ll ans;
    if(x == 0){
      if(k%2==0){
        cout<<0<<endl;
        return 0;
      }else{
        cout<<d<<endl;
        return 0;
      }
    }
    if(x > 0){
      if(k<=cnt){
        cout<<abs(x-k*d)<<endl;
        return 0;
      }
      now = x - d * cnt;
      k-=cnt;
      if(k%2==0){
        ans = now;
      }else{
        ans = min(abs(now-d), abs(now+d));
      }
      cout<<abs(ans)<<endl;
      return 0;
    }
    if(x < 0){
      if(k<=cnt){
        cout<<abs(x+k*d)<<endl;
        return 0;
      }
      now = x + d * cnt;
      k-=cnt;
      if(k%2==0){
        ans = now;
      }else{
        ans= now+d;
      }
      cout<<abs(ans)<<endl;
      return 0;
    }
    return 0;
}


Measured memory_bytes: 3584
#!/usr/bin/env python
# coding: utf-8

# In[25]:


N = int(input())
d = list(map(int, input().split()))


# In[27]:


ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += d[i]*d[j]
print(ans)


# In[ ]:






Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E = sc.nextInt();
		int F = sc.nextInt();
		int G = sc.nextInt();
		int H = sc.nextInt();
		int I = sc.nextInt();
		int sum = A+E+I;
		Main main = new Main();
		if (main.checkSum(sum,A,H,F)==false) {
			System.out.println("No");
			return ;
		}
		if (main.checkSum(sum,D,B,I)==false) {
			System.out.println("No");
			return ;
		}
		if (main.checkSum(sum,D,H,C)==false) {
			System.out.println("No");
			return ;
		}
		if (main.checkSum(sum,G,E,C)==false) {
			System.out.println("No");
			return ;
		}
		if (main.checkSum(sum,G,B,F)==false) {
			System.out.println("No");
			return ;
		}
			System.out.println("Yes");
	}

	public boolean checkSum(int sum ,int A,int B,int C) {
		if (A+B+C==sum)
			return true;
		return false;
	}
}

Measured memory_bytes: 23892
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;
long long int N,M;

int main(){

    cout << fixed << setprecision(18);
    cin>>N;
    if(N>=30){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    
    
}



Measured memory_bytes: 3632
N,W = map(int,input().split())
value = [0]
weight = [0]
for i in range(N):
    v,w = map(int,input().split())
    value.append(v)
    weight.append(w)

dp = [[0]*(W+3) for _ in range(N+3)]
for w in range(1,W+1):
    for k in range(1,N+1):
        if weight[k] > w:
            dp[k][w] = dp[k-1][w]
        else:
            #print(dp[k-1][w])
            dp[k][w] = max(dp[k-1][w], value[k] + dp[k-1][w-weight[k]])
print(dp[N][W])



Measured memory_bytes: 25660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int n,i,o;
	char line[101],ans[500],ch[2],ch1[2];
	while(scanf("%s",line) != EOF){
		i=0;o=0;
		while(line[i]){
			if(line[i] == '@'){
				ch[0]=line[i+1];ch[1]=0;
				memset(ans+o,line[i+2],atoi(ch));
				o+=atoi(ch);i+=2;
			}
			else{
				ans[o]=line[i];
				o++;
			}
			i++;
		}
		ans[o]=0;
		printf("%s\n",ans);
	}
	return 0;
}

Measured memory_bytes: 536
from fractions import gcd

A, B = map(int, input().split())

d = gcd(A, B)
d_ori = d
ans = 1
k = 2
while d > 2:
    plus = 0
    while d % k == 0:
        d //= k
        plus = 1
    ans += plus
    k += 1
    if k > d_ori**(1/2):
        ans += 1
        break
print(ans)


Measured memory_bytes: 66492
while True:
    h,w = map(int, input().split())
    if (h==0)&(w==0): break
    if w%2==0:
        for i in range(h):
            if i%2==0:
                print('#.'*(w//2))
            else:
                print('.#'*(w//2))
    else:
        for i in range(h):
            if i%2==0:
                print('#.'*(w//2)+'#')
            else:
                print('.#'*(w//2)+'.')
    print('')


Measured memory_bytes: 5608
import itertools

for dn in itertools.count(1):
    W = int(input())
    if W == 0: break
    N = int(input())
    d = [tuple(map(int, input().split(','))) for _ in range(N)]

    v = [0 for _ in range(W + 1)]
    for i in range(N):
        for j in range(W, d[i][1] - 1, -1):
            v[j] = max(v[j], v[j - d[i][1]] + d[i][0])
    print("Case %d:\n%d\n%d" % (dn, max(v), v.index(max(v))))

Measured memory_bytes: 7820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

struct edge {
    ll cost; char type;
    bool operator<(edge a) {
        return cost < a.cost;
    }
};

int main() {
    init();

    int w, h; cin >> w >> h;
    VL p(w), q(h); cin >> p >> q;
    vector<edge> e;
    FOR(i, 0, w)e.push_back({ p[i],'p' });
    FOR(i, 0, h)e.push_back({ q[i],'q' });
    int n = e.size();
    SORT(e);

    //辺を追加=行(列)を減らす
    ll ans = 0;
    int a = w + 1, b = h + 1;//行(列)の数
    FOR(i, 0, n) {
        if (e[i].type == 'p') {
            ans += e[i].cost * b;
            a--;
        }
        else {
            ans += e[i].cost * a;
            b--;
        }
    }
    cout << ans << "\n";
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int imos[125252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int a,b;
    scanf("%d%d",&a,&b);
    imos[a]++;
    imos[b]--;
  }
  REP(i,125251){
    imos[i+1] += imos[i];
    if(imos[i]%2){
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


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

void fnInput(vector<int>& rvnBallCnt, int& rnVarie)
{
  int nBallSiz;
  cin >> nBallSiz >> rnVarie;

  rvnBallCnt.resize(nBallSiz);
  for (int i = 0; i < nBallSiz; i++)
  {
    int nBall;
    cin >> nBall;
    rvnBallCnt[nBall - 1]++;
  }
}

int fnRewCount(vector<int>& rvnBallCnt, int nVarie)
{
  sort(begin(rvnBallCnt), end(rvnBallCnt));
  int nRewCnt = 0;

  for (int i = 0; i < rvnBallCnt.size() - nVarie; i++)
    nRewCnt += rvnBallCnt[i];

  return nRewCnt;
}

int main()
{
  vector<int> vnBallCnt;
  int nVarie;

  fnInput(vnBallCnt, nVarie);
  cout << fnRewCount(vnBallCnt, nVarie) << endl;

  return 0;
}

Measured memory_bytes: 1024
from collections import Counter
N = int(input())

A = list(map(int, input().split()))
ans = 0

plus = []
minus = []

for i, j in enumerate(A):
    # print(i, j)
    plus.append(i+j)
    minus.append(i-j)

# print(plus)
# print(minus)

plus_count = Counter(plus)
minus_count = Counter(minus)
# print(plus_count)
# print(minus_count)


for i,j in plus_count.items():
    # print(i, j)
    if i in minus_count:
        ans += j * minus_count[i]
        # print(i, j)
print(ans)

Measured memory_bytes: 63432
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> island(n,0);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;  b--;
    //cout << a << ' ' << b << endl;
    if(a == 0){
      island[b]++;
      if(island[b] == 2){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }else if(b == n-1){
      island[a]++;
      if(island[a] == 2){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 1024
'''
以下解説を参考に回答
https://qiita.com/drken/items/dc53c683d6de8aeacf5a
'''

N = int(input())
H = list(map(int, input().split()))

# DPテーブル
dp = [10 ** 9] * N

# 初期条件
dp[0] = 0
dp[1] = abs(H[1] - H[0])

# ループ
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

# 解を出力
print(dp[N - 1])


Measured memory_bytes: 13924
#include <stdio.h>

int main(void) {
	int n, k, c;
	scanf("%d%d", &n, &k);
	int i;
	for (i=0; i<n; i++) {
		scanf("%d", &c);
	}
	c = (n-2)/(k-1) + 1;
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			needH = -1
			for i in range(n):
				if h[i] > 0:
					tmp = h[i] + abs(x[i]-s) + abs(y[i]-t)
					if needH == -1:
						needH = tmp
					elif needH != tmp:
						needH = -2
						break
			if needH == -2:
				continue
			for i in range(n):
				if h[i] == 0 and needH > abs(x[i]-s) + abs(y[i]-t):
					needH = -2
					break
			if needH == -2:
				continue
			else:
				print("{} {} {}".format(s, t, needH))

if __name__ == '__main__':
	main()


Measured memory_bytes: 42352
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	if(k-a>=0)
		ans+=a*1;
	else{
		ans+=k*1;
		cout<<ans<<endl;
		return 0;
	}
	k=max(k-a-b,0LL);
	if(k-c>=0)
		ans+=c*(-1);
	else{
		ans+=k*(-1);
		cout<<ans<<endl;
		return 0;
	}
	cout<<ans;
	return 0;
}

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

int main(){ 

    Int N,M,A[100000],sum;

    cin >> N >> M;
    rep1(i,M) cin >> A[i];

    sum = 0;
    rep1(i,M) sum += A[i];

    if (sum > N) cout << -1 << endl;
    else cout << N - sum << endl;



}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<vector>
#define rep(i, n) for(int i = 0; i < n; i++ )
using namespace std;


int main() {
  int k, x;
  cin >> k >> x;
  if ( k == 1 ) cout << x;
  else {
    rep(i, 2*k-1) {
      cout << (x - k + 1) + i << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
s = int(input())

x1,y1 = 0,0

x2 = s//10**9
y3 = 10**9

if x2*10**9<s:
    x2 += 1

x3 = x2*10**9-s
y2 = 1



print(x1,y1,x2,y2,x3,y3)



Measured memory_bytes: 2940
# C - City Savers

N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

total = 0
for i in range(N):
    attack = min(A[i], B[i])
    A[i] -= attack
    B[i] -= attack
    total += attack
    if 0 < B[i]:
        attack2 = min(B[i], A[i + 1])
        A[i + 1] -= attack2
        B[i] -= attack2
        total += attack2

print(total)


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve() {
	int n, k;
	
	cin >> n >> k;
	vector<int> p(n);
	for(int i = 0; i < n; ++i) cin >> p[i];
	
	sort(all(p));
	
	int sum = 0;
	for(int i = 0; i < k; ++i) {
		sum += p[i];
	}
	cout << sum;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	solve();
    
    return 0;
}


Measured memory_bytes: 3668
#include <algorithm>
#include <cstdio>
#include <initializer_list>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <vector>

#define REPI(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPD(i, n) for (int i = static_cast<int>(n); i >= 0; --i)
#define FOR(i, c) for (auto i : (c))
#define FOR_REF(i, c) for (auto &i : (c))
#define ALL(c) (c).begin(), (c).end()
#define LEN(c) static_cast<int>((c).size())

int main() {
  using namespace std;

  int dp[101][10001] = {};
  int n, W;
  int weight[100] = {}, value[100] = {};

  cin >> n >> W;

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

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= W; ++j) {
      dp[i + 1][j] =
          (j >= weight[i] ? max(dp[i][j - weight[i]] + value[i], dp[i][j])
                          : dp[i][j]);
    }
  }

  cout << dp[n][W] << endl;

  return 0;
}


Measured memory_bytes: 7048
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,cou;
    char S[100000];
    scanf("%d %d",&A,&B);
    if((A<=8)&&(B<=8)){
        printf("Yay!");
    }else{
        printf(":(");
    }
    return 0;
}

Measured memory_bytes: 128