akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
using u128 = __uint128_t;
using u64 = uint64_t;
u128 in()
{
	u128 temp=0;
	string s;
	cin>>s;
	for(char c:s)
	{
		temp*=10;
		temp+=(c-'0');
	}
	return temp;
}
ll out(u128 x)
{
	ll num=0ll;
	stack<char>s;
	while(x)
	{
		num*=10;
		num = num + x%10;
	//	s.push((x%10 +'0'));
		x/=10;
	}
/*	while(!s.empty())
	{
		cout<<s.top();
		s.pop();
	}		*/
	return num;
}
u128 fun(u128 a,u128 b,u128 mod)	{	return (a*a+b)%mod+1;	}
u128 pollard_rho(u128 num,u128 comp)
{
	if(num==1) 			return 1;
	if(num%2==0) 		return 2;
	srand(time(0));
	u128 y = rand()%num+1;
	u128 c = rand()%num+1;
	u128 x = y,gcd=1;
	u128 count=0;
	while(gcd==1)
	{
		if(count*count>=num+10000) return num;
		count++;
		x=fun(x,c,num);
		y=fun(fun(y,c,num),c,num);
		u128 ABS =x-y;
		if(ABS<0)		ABS = -ABS;
		if(x==y) 		gcd = num;
		else			gcd = __gcd(ABS,num);
		if(gcd!=1)
		{
			if(gcd==num||gcd==comp)
			{
				y=rand()%num+1;
				x=y;
				gcd=1;
			}
			else	break;
		}
	}
	return gcd;
}
u128 binPow(u128 base,u128 Power,u128 mod=1000000007)
{
	u128 res=1;
	while(Power)
	{
		if(Power&1) res=(res*base)%mod;
		Power>>=1;
		base=(base*base)%mod;
	}
	return res;
}
bool miller_rabin(u128 num, u128 k)
{
	u128 s=0,d=num-1,one=1,temp;
	while(d%2==0) 
	{
		d>>=1;
		s++;
	}
	bool flag=true;
	temp=binPow(k,d,num);
	if(temp==1||temp==num-1) 	return 1;
	for(int i=0;i<s;i++)
	{
		temp=(temp*temp)%num;
		if(temp==1) 		return 0;
		if(temp==num-1) 	return 1;
	}
	return 0;
}
bool prime(u128 num)
{
	vector<int> A {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67};
	for(int i=0;i<A.size();++i) 
	{
		if(A[i]==num) 
		{
			return 1;
		}
	}
	if(num%2==0) 	return 0;
	bool flag=true;
	for(int i=0;i<A.size();++i) flag &= miller_rabin(num,A[i]);
	return flag;
}
int main()
{
	u128 x=in();
	if(x==1)		
	{
		printf("0");
		return 0;
	}
	vector<pair<u128,int> >factor;
	while(x!=1)
	{
		u128 y=pollard_rho(x,0);
		int count=1;
		while(prime(y)==0)  y=pollard_rho(y,y);
		x/=y;
		while(x%y==0)
		{
			x/=y;
			count++;
		}
		factor.push_back({y,count});
	}
	sort(factor.begin(),factor.end());
	vector<pair<ll,int>> a;
	for(int i=0;i<factor.size();++i)
	{
		a.push_back(make_pair(out(factor[i].first),factor[i].second));
	}
	ll cnt = 0ll;
	for(int i=0;i<a.size();++i)
	{
	//	printf("%lld %d\n",a[i].first,a[i].second);
		int num = 0,j=1;
		while(num+j<=a[i].second)
		{
			num+=j;
			j++;
			++cnt;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c; cin>>c;
    if((int)c>=97) cout<<'a';
    else           cout<<'A';
}


Measured memory_bytes: 3588
N = int(input())
flag=1 

words=[]
for i in range(N):
  word=input()
  words.append(word)

for i in range(N-1):
  #print(words[i])
  if words[i][-1] != words[i+1][0]:
    flag=0

sets=set(words)
if len(sets) != len(words):
  flag=0
  
if flag:
  print('Yes')
else:
  print('No')

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

char last(char word[11])
{
	char ret;

	for(int i=0;word[i] != '\0';i++	)
	{
		ret = word[i];
	}
	//printf("        %c\n",ret );
	return ret;
}

int main(void)
{
	char word[101][11];
	int num;
	scanf("%d",&num);
	for(int i=0;i<num;i++)
	{
		scanf("%s",word[i]);
	}

	for(int i=1;i<num;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(strcmp(word[i],word[j]) == 0)
			{
				printf("No\n");
				return 0;
			}
		}
		if(word[i][0] != last(word[i-1]))
		{
			printf("No\n");
			return 0;	
		}
		if(i != num-1 && last(word[i]) != word[i+1][0])
		{
			//printf("    %c    %c\n",last(word[i]),word[i+1][0]);
			printf("No\n");
			return 0;		
		}
	}
	printf("Yes\n");

return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int i,j,a[29],s,k,w,flg;
	s=0; k=0;
	for(i=1;i<=28;i++){
		scanf("%d",&a[i]);
	}
	for(j=1;j<=30;j++){
		flg=1;
		for(i=1;i<=28;i++){
			if(j==a[i]){
				flg=0;
			}
		}
		if(flg==1){
			if(s==0){
				s=j;
			}
			else{
				k=j;
			}
		}
	}
	printf("%d\n",s);
	printf("%d\n",k);
	return 0;
}
	


Measured memory_bytes: 2756
// Problem : M - Candies
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_m
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int n,k;
int dp[N];

void solve(){
    cin>>n>>k;
    dp[0] = 1;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        vi cur(k+1);
        for(int j=k;j>=0;j--){
            int l = j+1;
            int r = j+min(x,k-j);
            if(l <= r){
                (cur[l] += dp[j]) %= mod;
                if(r+1 <= k) cur[r+1] = (cur[r+1] - dp[j] + mod)%mod;
            }
        }
        int pre = 0;
        for(int i=0;i<=k;i++){
            (pre += cur[i]) %= mod;
            (dp[i] += pre) %= mod;
        }
    }
    cout<<dp[k];
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5156
void main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a==1)a=100; if(b==1)b=100;
	if(a>b)writeln("Alice");
	else if(a<b)writeln("Bob");
	else writeln("Draw");
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2516
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt(), r = in.nextInt();
			if(n==0 && r==0) return ;
			int ps[] = new int[r], cs[] = new int[r];
			for(int i=r-1; i>=0; i--){
				ps[i] = in.nextInt();
				cs[i] = in.nextInt();
			}
			int pos = n;
			for(int i=0; i<r; i++){
				if(n-pos+1 <= cs[i]){
					pos -= ps[i] - 1;
				}
				else if(n-pos+1 < cs[i] + ps[i]){
					pos += cs[i];
				}
			}
			System.out.println(pos);
		}
	}
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> ar(N);
    for(int i = 0; i < N; i++) {
        cin >> ar[i];
        if(i > K-1) {
            if(ar[i] > ar[i - K]) {
                cout << "Yes"<<endl;
            } else {
                cout << "No" <<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3984
import sys
 
def eat(i,j,candies,counter):
    s=candies[i]+candies[j]
    if s>x:
        if candies[i]>=s-x:
            candies[i]-=s-x
        else:
            candies[j]-=s-x-candies[i]
            candies[i]=0
        counter+=s-x
    return counter
 
def main(n,x,candies):
    counter=0
    for i in range(1,n):
        counter=eat(i,i-1,candies,counter)
    return counter
 
n,x=map(int,sys.stdin.readline().strip().split())
candies=list(map(int,sys.stdin.readline().strip().split()))
print(main(n,x,candies))

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

using ll = long long;

int main() {
    ll x;

    std::cin >> x;

    ll lh = 1, rh = 2e9;
    while(lh < rh) {
        auto mid = (lh + rh) / 2;
        
        if((1 + mid) * mid / 2 >= x) {
            rh = mid;
        }else {
            lh = mid + 1;
        }
    }

    std::cout << lh << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000
#define MAX2 99999999

int h,data[MAX+1];
int left(int l){
  return 2*l;
}
int right(int r){
  return 2*r+1;
}
void maxHeapify(int i){
  int l,r,largest,t;
  l=left(i);
  r=right(i);
  if(l<=h && data[l]>data[i])largest=l;
  else largest=i;
  if(r<=h && data[r]>data[largest])largest=r;
  if(largest!=i){
    t=data[i];
    data[i]=data[largest];
    data[largest]=t;
    maxHeapify(largest);
  }
}
int alg(){
    int max;
    if(h<1)return -MAX2;
    max=data[1];
    data[1]=data[h--];
    maxHeapify(1);
    return max;
}
void increase(int i,int key){
    int t;
    if(key<data[i])return;
    data[i]=key;
    while(data[i/2]<data[i]&&i>1){
        t=data[i];
        data[i]=data[i/2];
        data[i/2]=t;
        i=i/2;
    }
}
void insert(int x){
    h++;
    data[h]=-MAX2;
    increase(h,x);
}
int main(){
    int x;
    char s[10];
    while(1){
        scanf("%s",s);
        if(s[1]=='n' && s[0]=='e')break;
        if(s[0]=='i'){
            scanf("%d",&x);
            insert(x);
        }else{
            printf("%d\n",alg());
        }
    }
    return 0;
}


Measured memory_bytes: 5676
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int base = 0;
		int n = sc.nextInt();
		int[] b = new int[n];
		for (int i = 0; i < n; ++i) {
			b[i] = sc.nextInt();
			if (b[i] == 0)
				++base;
		}
		int Q = sc.nextInt();
		int[][] q = new int[Q][2];
		for (int i = 0; i < Q; ++i) {
			q[i][0] = sc.nextInt();
			q[i][1] = sc.nextInt();
		}
		Arrays.sort(q, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[0], o2[0]);
			}
		});
		RMQ rmq = new RMQ(n + 1);
		rmq.set(0, 0);
		int p = 0;
		for (int i = 0; i < Q; ++i) {
			while (q[i][0] - p > 1) {
				int c = b[p] == 1 ? 1 : -1;
				rmq.set(p + 1, Math.min(c + rmq.query(p), rmq.query(p + 1)));
				++p;
			}
			rmq.set(q[i][1], rmq.query(p, q[i][1] + 1));
		}
		while (n - p > 0) {
			int c = b[p] == 1 ? 1 : -1;
			rmq.set(p + 1, Math.min(c + rmq.query(p), rmq.query(p + 1)));
			++p;
		}
		System.out.println(base + rmq.query(n));
	}

	class RMQ {
		int n;
		int[] v;

		public RMQ(int n_) {
			n = 1;
			while (n < n_)
				n *= 2;
			v = new int[2 * n];
			Arrays.fill(v, Integer.MAX_VALUE / 3);
		}

		void add(int k, int val) {
			k += n;
			v[k] += val;
			while (k > 1) {
				k = k / 2;
				v[k] = Math.min(v[2 * k], v[2 * k + 1]);
			}
		}

		void set(int k, int val) {
			k += n;
			v[k] = val;
			while (k > 1) {
				k = k / 2;
				v[k] = Math.min(v[2 * k], v[2 * k + 1]);
			}
		}

		int query(int a) {
			return v[a + n];
		}

		int query(int a, int b) {
			a += n;
			b += n;
			int ret = Integer.MAX_VALUE / 3;
			while (a < b) {
				if (a % 2 == 1) {
					ret = Math.min(ret, v[a++]);
				}
				if (b % 2 == 1) {
					ret = Math.min(ret, v[--b]);
				}
				a /= 2;
				b /= 2;
			}
			return ret;
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

long long rev(long long n){

	long long ans = 0;
	while(n > 0){

		ans = ans*10 + n%10;
		n = n / 10;
	}
	return ans;
}

int main(){

	long long n;
	cin >> n;

	if(n == rev(n)){

		cout << "Yes\n";
	}
	else{

		cout << "No\n";
	}
}

Measured memory_bytes: 256
a= Array.new(3).map{Array.new(10,0)}
e= Array.new(3).map{Array.new(10,0)}
c= Array.new(3).map{Array.new(10,0)}
d= Array.new(3).map{Array.new(10,0)}
n=gets.to_i
n.times do
  b,f,v,r = gets.split.map(&:to_i)
  if b == 1
    a[f-1][v-1] = a[f-1][v-1] + r
  elsif b==2
    e[f-1][v-1] = e[f-1][v-1] + r
  elsif b==3
    c[f-1][v-1] = c[f-1][v-1] + r
  elsif b==4
    d[f-1][v-1] = d[f-1][v-1] + r
  end
end
puts " "+a[0].map(&:to_s).join(" ")
puts " "+a[1].map(&:to_s).join(" ")
puts " "+a[2].map(&:to_s).join(" ")
puts "####################"
puts " "+e[0].map(&:to_s).join(" ")
puts " "+e[1].map(&:to_s).join(" ")
puts " "+e[2].map(&:to_s).join(" ")
puts "####################"
puts " "+c[0].map(&:to_s).join(" ")
puts " "+c[1].map(&:to_s).join(" ")
puts " "+c[2].map(&:to_s).join(" ")
puts "####################"
puts " "+d[0].map(&:to_s).join(" ")
puts " "+d[1].map(&:to_s).join(" ")
puts " "+d[2].map(&:to_s).join(" ")


Measured memory_bytes: 8876
/* 
 * Project: AtCoder Beginners Contest 171 B - Mix Juice
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/21
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <algorithm>
#include <numeric>
using namespace std;

int n;
int k;
int p[1000];

void solve() {

    sort(p, p+n);
    int sum = accumulate(p, p+k, 0);
    printf("%d\n", sum);

}

int main() {

    scanf("%d", &n);
    scanf("%d", &k);
    for (int i=0;i<n;i++) {
        scanf("%d", &p[i]);
    }

    solve();

}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll sum[101010], kogo[101010];

int main() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    for (int i=1; i<=N; ++i) {
        sum[i] = sum[i-1] + A[i-1];
        kogo[i] = A[i-1];
        if (i>=2) kogo[i] += kogo[i-2];
    }

    vector<ll> X, S;
    for (int p=N/2; p>=1; --p) {
        ll x = (A[N-p-1] + A[N-2*p-1])/2 + 1;
        ll sc = (sum[N] - sum[N-p]) + kogo[N-2*p];
        X.push_back(x);
        S.push_back(sc);
    }

    //rep(i, S.size()) cout << S[i] << " \n"[i == S.size()-1];

    X.push_back(1e10);
    rep(i, Q) {
        ll x;
        cin >> x;
        int cur = upper_bound(X.begin(), X.end(), x) - X.begin();
        if (cur == 0) {
            cout << sum[N] - sum[N-N/2-bool(N%2)] << endl;
        }
        else {
            cout << S[cur-1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
string a[101];
int n,i;
int main()
{
    scanf("%d%*d",&n);
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rgi register int
#define rgl register long long
#define ll long long
#define il inline

using namespace std;

il ll read() {
	rgl x = 0, f = 0, ch;
	while(!isdigit(ch = getchar()))	f |= ch == '-';
	while(isdigit(ch))	x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int main() {
	int n = read(), ans = 0;
	int a[100];
	for(rgi i = 1; i <= n; ++i)	a[i] = read();
	for(rgi i = 1; i <= n; ++i)	for(rgi j = i + 1; j <= n; ++j)
		ans += a[i] * a[j];
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
  int n, m;
  char s[50][51];
  int counter[50][3];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) {
    counter[i][0] = counter[i][1] = counter[i][2] = 0;
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'W') counter[i][0]++;
      if (s[i][j] == 'B') counter[i][1]++;
      if (s[i][j] == 'R') counter[i][2]++;
    }
  }
  int ans = 1000000;
  for (int i = 1; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int sum = 0;
      for (int r = 0; r < n; r++) {
        if (r < i) sum += counter[r][0];
        else if (r < j) sum += counter[r][1];
        else sum += counter[r][2];
      }
      ans = min(ans, n * m - sum);
    }
  }
  printf("%d\n", ans);
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<string> w(n), w_u(n);

    rep(i, n){
        cin >> w[i];
        w_u[i] = w[i];
    }

    sort(w_u.begin(), w_u.end());
    w_u.erase(unique(w_u.begin(), w_u.end()), w_u.end());

    if(w.size() != w_u.size()){
        cout << "No" << endl;
        return 0;
    }

    bool flag= true;
    rep(i, n){
        if(i==0){
            continue;
        }
        int size = w[i-1].size();
        if(w[i-1][size-1] != w[i][0]){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define len_string_max 4

int calculate_points (char* data_string)
{
    // constants for `calculate_points`
    const char* sym_pls1 = '+';
    const char* sym_mns1 = '-';

    // variables for `calculate_points`
    int points;

    // STEP.01
    // initialize the points
    points = 0;

    // STEP.02
    // calculate the points using given string
    for (size_t itr = 0; itr < len_string_max; itr++)
    {
        if (data_string[itr] == sym_pls1) points++;
        if (data_string[itr] == sym_mns1) points--;
    }

    // STEP.END
    return points;
}

int main (void)
{
    // variables for `main`
    char given_string[len_string_max];
    int  rtvl_scanf;

    // STEP.01
    // read out the given string
    rtvl_scanf = scanf("%s", given_string);

    // STEP.02
    // calcualte & output the points
    printf("%d\n", calculate_points(given_string));

    // STEP.END
    return 0;
}

Measured memory_bytes: 128
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int T;
	cin >> T;
	if (T < 1200) {
		puts("ABC");
	} else if (T < 2800) {
		puts("ARC");
	} else {
		puts("AGC");
	}
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
int a[3];
cin>>a[0]>>a[1]>>a[2];
if(a[0]==1&&a[1]==1&&a[2]==0||a[0]==0&&a[1]==0&&a[2]==1){
cout<<"Open"<<endl;
}
else {
cout<<"Close"<<endl;
}
}

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

int main(){
    constexpr unsigned long MOD = 1000000007;
    unsigned long N;
    cin >> N;
    unsigned long dp{N};
    vector<unsigned long> sum(N + 3, (N - 1) * N % MOD);
    sum[0] = 0;
    for(unsigned long i = 3; i != N + 3; ++i)sum[i] = (sum[i - 1] - 1 + ((dp += sum[i - 3]) %= MOD)) % MOD;
    cout << dp << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<cstdio>
#include<cstring>
using namespace std;
#define N 10
int n,k;
bool f[N+5];

int PD(int x)
{
	while(x!=0)
	{
		if(!f[x%10]) x/=10;
		else return 1;
	}
	return 0;
}
int main()
{
	int l;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)
	scanf("%d",&l),f[l]=1;
	int x=n;
	while(PD(x))
	{
		x++;
	}
	printf("%d",x);
	
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  string T;
  cin >> T;

  if (S.size() + 1 != T.size()) {
    cout << "No" << endl;
  } else {
    rep(i, S.size()) {
      if (S[i] != T[i]) {
        cout << "No" << endl;
        return 0;
      }
    }

    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}


vl fact,finv;
ll mdpow(ll x,ll k){
	ll res=1;
	while(k!=0){
		if(k&1)res=res*x%MOD;
		x=x*x%MOD;
		k=k>>1;
	}
	return res;
}

ll comb(ll n,ll k) {
	if(n==0&&k==0)return 1;
	if(n<k||n<0)return 0;
	return fact[n]*finv[n-k]%MOD*finv[k]%MOD;
}

struct ferm{
	ferm(ll n){
		fact.resize(n);
		finv.resize(n);
		fact[0]=1;
		finv[0]=1;
		rep(i,n-1){
			fact[i+1]=(fact[i]*(i+1))%MOD;
			finv[i+1]=mdpow(fact[i+1],MOD-2);
		}
	}
};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ferm(200010);
	ll n,k,ans;
	cin>>n>>k;
	range(i,1,k+1){
		ans=comb(k-1,k-i)*comb(n-k-(i-1)+i,i);
		//puta(comb(k-1,k-i),comb(n-k-(i-1)+i,i));
		puta(ans%MOD);
	}
}


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

int main(){
    int N;
    int A,B,A_sum,B_sum,ans=100000000,tmp,dig;
    cin>>N;
    for(int i=1;i<N;i++){
        A = N-i;
        B = i;
        A_sum=0;
        B_sum=0;
        
        while(A){
            dig = A % 10;
            A_sum = A_sum + dig;
            A = A / 10;
        }
         while(B){
            dig = B % 10;
            B_sum = B_sum + dig;
            B = B / 10;
        }
        tmp = A_sum + B_sum;

        if(tmp<ans){
            ans = tmp;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long ll;

int main(void) {
  ll a, b;
  scanf("%lld%lld", &a, &b);
  if(a == b-1 || a == b || a == b+1) {
    puts("Brown");
  } else {
    puts("Alice");
  }
  
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
	
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		int n = sc.nextInt();
		List<Info> list = new ArrayList<>(n);
		for(int i = 0; i < n; ++i){
			list.add(new Info(i + 1, sc.nextInt()));
		}
		
		list.sort((info0, info1) -> info0.num - info1.num);
		
		for(int i = 0; i < n; ++i){
			char c = (i == n - 1) ? '\n' : ' ';
			System.out.print(list.get(i).id);
			System.out.print(c);
		}
	}
}

class Info {
	int id;
	int num;
	
	public Info(int id, int num){
		this.id = id;
		this.num = num;
	}
}

Measured memory_bytes: 68320
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;

const int N = 100+10;
const int V = 1e3+10;
const LL INF = 1e18+10;

int n,w;
LL DP[N*V];

int main(){
  scanf("%d%d",&n,&w);
  for(int i=1; i<N*V; i++)DP[i] = INF;
  int a,v;
  for(int i=1; i<=n; i++){
    scanf("%d%d",&a,&v);
    for(int j = N*V-1; j-v>=0; j--){
      DP[j] = min(DP[j], DP[j-v] + a);
    }
  }
  for(int i=N*V-1; i>0; i--){
    if(DP[i]<=w){
      printf("%d\n",i);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
s = list(input())
k = int(input())
z_asc = ord('z')
for i in range(len(s)):
    tmp = ord(s[i])
    if 1 + z_asc - tmp <= k and s[i] != 'a':
        k -= 1 + z_asc - tmp
        s[i] = 'a'
if k % 26 != 0:
    s[-1] = chr(ord(s[-1]) + k%26)
ans = "".join(s)
print(ans)


Measured memory_bytes: 4152
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
#define P pair<int,int>
using namespace std;

P e[100000];
int main() {
	int a, b, c, d;
	while (cin >> a >> b >> c >> d, a | b || c || d) {
		int f[1000], j[1000], sum = 0;
		for (int g = 0; g < a; g++)f[g] = g;
		for (int g = 0; g < a; g++)scanf("%d", &j[g]);
		for (int g = 0; g < b; g++) {
			int h, i; scanf("%d%d", &h, &i);
			h--; e[g] = P(i, h);
		}
		sort(e, e + b);
		for (int g = 0; g < b; g++) {
			swap(f[e[g].second], f[e[g].second + 1]);
		}
		int MAX = 0, k[1000];
		for (int l = 0; l < a; l++) { k[l] = l; if (f[l] < d)sum += j[l]; }
		for (int g = b - 1; g >= 0; g--) {
			if (f[k[e[g].second]] < d) {
				if (f[k[e[g].second + 1]] >= d) {
					MAX = max(MAX, j[k[e[g].second]] - j[k[e[g].second+1]]);
				}
			}
			else {
				if (f[k[e[g].second + 1]] < d) {
					MAX = max(MAX, j[k[e[g].second+1]] - j[k[e[g].second]]);
				}
			}
			swap(k[e[g].second], k[e[g].second + 1]);
		}
		cout << sum - MAX << endl;
	}
}

Measured memory_bytes: 3884
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#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 )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

struct Point
{
  uint32_t y, x;
  Point(uint32_t y, uint32_t x) : y(y), x(x) {}
  bool operator==(const Point &rhs) const {
    return y == rhs.y && x == rhs.x;
  }
  bool operator<(const Point &rhs) const {
    return y == rhs.y ? x < rhs.x : y < rhs.y;
  }
};

struct QueueItem
{
  Point p;
  int32_t c;

  QueueItem(const Point p, int32_t c)
    : p(p), c(c) {}
};

int main()
{
  uint32_t H, W;
  cin >> H >> W;
  
  uint32_t Ch, Cw, Dh, Dw;
  cin >> Ch >> Cw >> Dh >> Dw;
  --Ch; --Cw; --Dh; --Dw;

  vector<string> S(H);
  N_TIMES(h, H) { cin >> S[h]; }

  vector<vector<int32_t>> P(H, vector<int32_t>(W, -1));
  
  const auto isInMaze = [&](const Point &p) {
    return p.y < H && p.x < W;
  };

  queue<QueueItem> q;
  q.emplace(Point(Ch, Cw), 0);
  P[Ch][Cw] = 0;
  while (!q.empty()) {
    list<Point> ps;

    while (!q.empty()) {
      QueueItem item = q.front(); q.pop();

      const uint32_t D = 4;
      int32_t dy[D] = {-1, +1, 0, 0}, dx[D] = {0, 0, -1 ,+1};
      N_TIMES(d, D) {
        Point new_point(item.p.y + dy[d], item.p.x + dx[d]);
        QueueItem new_item(new_point, item.c);
        if (isInMaze(new_point) && P[new_point.y][new_point.x] < 0) {
          if (S[new_item.p.y][new_item.p.x] == '.') {
            P[new_point.y][new_point.x] = new_item.c;
            q.emplace(new_item);
          } else {
            if (P[new_point.y][new_point.x] == -1) {
              ps.push_back(item.p);
              --P[new_point.y][new_point.x];
            }
          }
        }
      }
    }

    for (const Point &p : ps) {
      for (int32_t dy = -2; dy <= +2; ++dy) {
        for (int32_t dx = -2; dx <= +2; ++dx) {
          Point new_point(p.y + dy, p.x + dx);
          QueueItem new_item(new_point, P[p.y][p.x] + 1);
          if (isInMaze(new_point) && P[new_point.y][new_point.x] < 0) {
            if (S[new_point.y][new_point.x] == '.') {
              P[new_point.y][new_point.x] = new_item.c;
              q.emplace(new_item);
            }
          }
        }
      }
    }
  }
  
  cout << P[Dh][Dw] << endl;

  return 0;
}

Measured memory_bytes: 9792
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1e+9 + 7;

long long gcd(long long a, long long b){

    if (a== 0){
        return b;
    }else if (b == 0){
        return a;
    }

    if (a%b == 0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}

int main()
{
    ll x;
    cin >> x;
    ll g = gcd(x,360);
    ll lcm = x*360/g;
    cout << lcm/x << endl;
    return 0;
}

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

int main() {
  int n;cin>>n;vector<int>v(n);
  int s=0;
  for(int i=0;i<n;i++){
    cin>>v.at(i);
    if(i%2==0){
      if(v.at(i)%2==1){
        s++;
      }
    }
  }cout<<s<<endl;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class UnionFind{
	vector<ll> rank;
	vector<ll> diff_weight;
	vector<ll> num;
public:
	vector<ll> par;

	UnionFind(ll N):par(N),num(N),rank(N),diff_weight(N){
		for(ll i=0;i<N;i++){
			par[i]=i;
			num[i]=1;
			rank[i]=0;
			diff_weight[i]=0;
		}
	}

	ll root(ll x){
		if(par[x]==x){
			return x;
		}
		ll r = root(par[x]);
		diff_weight[x]+=diff_weight[par[x]];
		return par[x]=r;
	}

	void unite(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]) swap(rx,ry);
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		num[rx] += num[ry];
	}

	void relate(ll x,ll y,ll w){
		w+=weight(x),w-=weight(y);
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]){
			swap(rx,ry);
			w = -w;
		}
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		diff_weight[ry] = w;
		num[rx] += num[ry];
	}

	bool same(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll getsize(ll x){
		return num[root(x)];
	}

	ll weight(ll x){
		root(x);
		return diff_weight[x];
	}

	ll diff(ll x,ll y){
		return weight(y)-weight(x);
	}
};

class Data{
public:
	int u,v,d;
};

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int N=in();
		if(!N) break;
		int M=in();
		UnionFind uf(N);
		vector<Data> D(M);
		REP(i,M){
			int u,v,d;
			scanf("%d,%d,%d",&u,&v,&d);
			D[i].u=u,D[i].v=v,D[i].d=(d-100)/100;
		}
		sort(ALL(D),[](Data& l,Data& r){return l.d<r.d;});
		int sum = 0;
		REP(i,M){
			if(!uf.same(D[i].u,D[i].v)){
				uf.unite(D[i].u,D[i].v);
				sum += D[i].d;
			}
		}
		out(sum);
	}
	return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
int main ()
{

int W , H, i, j, k, N, h[10000][2];
i  = 0;
k = 0;
do{

	cin >> W >> H;
	h[i][0] = W;
	h[i][1] = H;
	i++;
	k++;
	
}while(W != 0 && H != 0);

for (i = 0; i < k-1;i++)
{

	if(h[i][0] != 0 && h[i][1] != 0)
		{
			for(j = 0;j < h[i][0];j++)
				{	
					if(j % 2 == 0)
					{
							for(N = 0;N < h[i][1];N++)
								{	if(N % 2 == 0)
									{
									cout << "#";
									}
									else
									{
										cout << ".";
									}
								}
					}
					if(j % 2 == 1)
					{
							for(N = 0;N < h[i][1];N++)
								{	if(N % 2 == 1)
									{
									cout << "#";
									}
									else
									{
										cout << ".";
									}
								}
					}
						cout  << endl;
				}
		
		cout  << endl;
		}
}

return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int a = x, b = y, c = z;
    int temp1 = a;
    a = b;
    b = temp1;
    int temp2 = a;
    a = c;
    c = temp2;
    cout << a << " " << b << " " << c << endl;
    return 0;
}

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

int main() {
queue<int> red;
queue<int> blue;
string s;
cin >> s;
for(int i=0;i<s.size();i++){
    if(s[i]=='0')red.push(s[i]);
    if(s[i]=='1')blue.push(s[i]);
}
cout << 2*min(red.size(),blue.size()) << endl;
}


Measured memory_bytes: 768
from collections import deque

def bfs(s_l, sy, sx, h, w):
    visited = [ [-1]*w for i in range(h)]
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    last_dist = -1
    while q:
        y, x = q.popleft()
        # if [y, x] == [gy, gx]:
        #     return visited[gy][gx]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            n_y, n_x = y+j, x+k
            if n_y >= h or n_x >= w or n_y < 0 or n_x < 0:
                continue
            if s_l[n_y][n_x] == '.' and visited[n_y][n_x] == -1:
                visited[n_y][n_x] = visited[y][x] + 1
                last_dist = visited[n_y][n_x]
                q.append([n_y,n_x])
    return last_dist

def main():
    h, w = map(int, input().split()) 
    s_l = []
    all_dot_cnt = 0
    for i in range(h):
        row = list(input())
        s_l.append(row)
        all_dot_cnt += row.count('.')
    
    curr_ans = -1
    visited = [ [-1]*w for i in range(h)]
    for i in range(h):
        for j in range(w):
            if s_l[i][j] == '.':
                res = bfs(s_l, i, j, h, w)
                if res > curr_ans:
                    curr_ans = res
    print(curr_ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  vl l, p, c;
  ll now = 0, n = s.size();
  l.push_back(0);
  rep(i, n - 1) {
    now++;
    if(s[i] == 'R' && s[i + 1] == 'L') {
      p.push_back(i);
    } else if(s[i] == 'L' && s[i + 1] == 'R') {
      c.push_back(now);
      now = 0;
      l.push_back(i + 1);
    }
  }
  c.push_back(now + 1);
  vl ans(n, 0);
  rep(i, p.size()) {
    ans[p[i]] = ans[p[i] + 1] = c[i] / 2;
    ans[p[i] + (p[i] - l[i]) % 2] += c[i] % 2;
  }
  rep(i, n) cout << ans[i] << ' ';
  cout << endl;
  // rep(i, p.size()) cout << l[i] << ' ' << p[i] << ' ' << c[i] << endl;
}

Measured memory_bytes: 5616
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
inp_list = [a,b,c,d,e]
ans = 1000
inp_sum = 0
for i in range(5):
    inp_sum += math.ceil((inp_list[i])/10)*10
#print(inp_sum)

for i in range(5):
    ans = min(ans,(inp_sum - math.ceil((inp_list[i])/10)*10) + inp_list[i])
print(ans)


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

using namespace std;

int main(void){
    int MAX_N = 100002;
    int n;
    cin >> n;
    int xs[MAX_N];
    int a;

    for(int i=0; i<MAX_N; i++){
        xs[i] = 0;
    }

    for(int i=0; i<n; i++){
        cin >> a;
        if(a > 0)
            xs[a-1]++;
        if(a < MAX_N-1)
           xs[a+1]++;
        xs[a]++;
    }
    cout << *max_element(xs,&xs[MAX_N]) << endl;
}



Measured memory_bytes: 640
import bisect

n=int(input())
alist = list(map(int, input().split()))
blist=sorted(alist)
clist=[]
dlist=[]
mae=0
for bl in blist:
    if bl==mae:
        clist[-1][1]+=1
    else:
        clist.append([bl, 1])
        dlist.append(bl)
    mae=bl

wa=0
for cl in clist:
    wa+=(cl[1]*(cl[1]-1))//2
for al in alist:
    pos=bisect.bisect_left(dlist, al)
    moto=clist[pos][1]
    if moto==0:
        print(wa)
    else:
        print(wa-moto+1)

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

int main() {
    long long a, b, k;
    cin >> a >> b >> k;
    if (a >= k) cout << a - k << " " << b << endl;
    else if (a + b < k) cout << 0 << " " << 0 << endl;
    else cout << 0 << " " << a + b - k << endl;
}

Measured memory_bytes: 256
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX=2*1e5+2;
ll n,valeurs[NMAX],prefixSum[NMAX],prefixXor[NMAX];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> valeurs[i];
		prefixSum[i]=prefixSum[i-1]+valeurs[i];
		prefixXor[i]=prefixXor[i-1]^valeurs[i];
	}
	
	ll ans=0;
	
	for(int l=1;l<=n;l++){
		
		int inf=l,sup=n,milieu;
		
		while(sup>inf){
			milieu=(inf+sup)/2;
			
			if( (prefixSum[milieu+1]-prefixSum[l-1])==(prefixXor[milieu+1]^prefixXor[l-1])){
				inf=milieu+1;
			}
			else{
				sup=milieu;
			}
		}
		
		ans+=inf-l+1;
	}
	
	cout << ans << '\n';
	
	
	
	
	
	
	
}


Measured memory_bytes: 4992
S = input()

AA = S[:2]
BB = S[2:]
a = []
for i in range(1, 13):
    if 1 <= i <= 9:
        a.append('0' + str(i))
    else:
        a.append(str(i))
if not AA in a and not BB in a:
    print('NA')
elif AA in a and BB in a:
    print('AMBIGUOUS')
elif AA in a:
    print('MMYY')
else:
    print('YYMM')

Measured memory_bytes: 3188
from math import ceil
d,g = map(int, input().split())
PC = [list(map(int, input().split())) for i in range(d)]
#print(PC)

fans = 10**10
for i in range(1<<d):
    su = 0
    ans = 0
    temp = [True for i in range(d)]
    #print("i=",i)
    for j in range(d):
        if (i>>j)&1 == 1:
            #print(PC[j],"を追加")
            su += (j+1)*100*PC[j][0] + PC[j][1]
            ans += PC[j][0]
            temp[j] = False
    if su < g:
        #print("su<g",su,ans)
        fnd = d
        while fnd >= 0:
            fnd += -1
            if temp[fnd] is False:
                continue
            else:
                if (fnd+1)*100*(PC[fnd][0]-1) + su >= g :
                    ans += ceil((g - su) / ((fnd+1) * 100))
                    fans = min(ans, fans)
                    #print("ans=", ans,"fnd=",fnd)

    else:
        fans = min(ans,fans)
        #print("ans=",ans)
    #print(fans)
print(fans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	long long int m,n,ans;
	cin>>m>>n;
	if(m>1&&n>1) ans=(m-2)*(n-2);
	else if(m==1&&n==1) ans=1;
	else ans=max(m,n)-2;
	cout<<ans;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[100000];

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	
	sort(a, a+n);
	int cnt = 0;
	reps(i,1,n) if (a[i]==a[i-1]) cnt++;
	cout << n - (cnt+1)/2*2 << ln;
}

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

int main(){
    int A, B, C, N, M ,K;
    int t = 0, t1 = 0;
    string s;
    cin >> s;

    for(int i = 0; i < 4; i++){
        if(s.at(0) == s.at(i)) {
            t++;
        }
    }
    if(s.at(0) != s.at(1)){
        for(int i = 0; i < 4; i++){
        if(s.at(2) == s.at(i)) {
            t1++;
        }
        }
    }
    else if(s.at(0) != s.at(2)){
        for(int i = 0; i < 4; i++){
        if(s.at(2) == s.at(i)) {
            t1++;
        }
        }
    }
    else if(s.at(0) != s.at(3)){
        for(int i = 0; i < 4; i++){
        if(s.at(3) == s.at(i)) {
            t1++;
        }
        }
    }
    if(t==2 && t1 == 2) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
//=============================
void input()
{
    cin>>N;
    A.resize(N);
    rep(i,0,N-1){
        cin>>A[i];
    }
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    int ans = 1;
    for (auto x : A){
        int l = max(ans,x);
        int s = min(ans,x);

        for(int k=1; k<=s; ++k){
            if (l*k % s == 0){
                ans = (l*k);
                break;
            }
        }
    }
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, K;
const ll MAX_K = 100, MAX_RN = 70000;
static int dp[MAX_K][MAX_RN];

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

  vll vec;
  for(ll i = 1; i * i <= N; i++) {
    vec.pb(i);
    if(i * i != N) {
      vec.pb(N / i);
    }
  }

  sort(ALL(vec));

  ll M = vec.size();

  dp[0][0] = 1;
  REP(i, M - 1) {
    dp[0][i + 1] = vec[i + 1] - vec[i];
  }

  REP(i, K - 1) {
    ll s = 0;
    for(int j = M - 1; j >= 0; j--) {
      s += dp[i][M - j - 1];
      s %= MOD;
      dp[i + 1][j] = dp[0][j] * s % MOD;
    }
  }

  ll ans = 0;
  REP(j, M) {
    ans += dp[K - 1][j];
    ans %= MOD;
  }

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


Measured memory_bytes: 28024
/**
 * 
 * AOJ No. 0014 Integral
 * 
 * @author 	yuichirw <y.iky917@gmail.com+>
 * @see		http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0014&lang=jp
 */

import java.util.*;
public class Main {
	
	static Scanner sc = new Scanner(System.in);
	static int d;
	
	static boolean read() {
		if(!sc.hasNextInt()) return false;
		d = sc.nextInt();
		return true;
	}
	
	static int solve() {
		int ans,n;
		ans = 0; n = 600 / d;
		for(int x = d; x < 600; x += d) {
			ans += d * ((x * x));
		}
		return ans;
	}
	
	
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}
	}

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    bool ok[1111]={};
    ok[1]=1;
    for(int i=2;i<=1000;i++){
        int x=i;
        while(true){
            x*=i;
            if(x>1000)break;
            ok[x]=true;
        }
    }

    int X;cin>>X;
    for(int i=X;i>=1;i--){
        if(ok[i]){
            cout<<i<<endl;
        break;
        }
    }
    return 0;
}


Measured memory_bytes: 256