akhauriyash/Code-Regression huggingface dataset:
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		HashSet<Character> set = new HashSet<>();
		//使っている文字をsetに追加
		for (char c : s.toCharArray()) {
			set.add(c);
		}

		if (s.length() != 26) {
			for (char c = 'a'; c <= 'z'; c++) {
				if (set.contains(c)) {
					continue;
				} else {
					System.out.println(s + c);
					return;
				}
			}
		}

		for (int i = s.length() - 1; i > 0; i--) {
			String cutted = s.substring(i);//後ろから切り取っていく、cuttedは切り取られた文字列
			String base = s.substring(0, i - 1);//切り取られて残った文字列の末尾を取ったもの
			//切り取った部分をsetから削除
			for (char c : cutted.toCharArray()) {
				set.remove(c);
			}

			for (char c = s.charAt(i - 1); c <= 'z'; c++) {
				if (set.contains(c)) {
					continue;
				} else {
					System.out.println(base + c);
					return;
				}
			}
			//切り取った部分をsetに追加し直す
			for (char c : cutted.toCharArray()) {
				set.add(c);
			}
		}
		System.out.println(-1);
	}
}

Measured memory_bytes: 23636
using System;    
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int sum = int.Parse(input[0]);
            int max = int.Parse(input[0]);

            for (int i = 1; i < input.Length; i++)
            {
                int tmp = int.Parse(input[i]);
                sum += tmp;
                max = max < tmp ? tmp : max;
            }

            if ((3 * max) % 2 == sum % 2)
            {
                Console.WriteLine((3 * max - sum) / 2);
            }
            else
            {
                Console.WriteLine((3 * (max + 1) - sum) / 2);
            }
            Console.ReadLine();
        }
    }

Measured memory_bytes: 13140
#include <stdio.h>

int linersearch(int a[], int n, int ans)
{
	int i = 0;
	a[n] = ans;

	while (a[i] != ans)
		i++;

	return i != n;
}

int main(void)
{
	int i, n, m, ans;
	int a[100000];
	int count = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	scanf("%d", &m);
	for (i = 0; i < m; i++)
	{
		scanf("%d", &ans);
		if (linersearch(a, n, ans))
			count++;
	}

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

	return 0;
}


Measured memory_bytes: 1992
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N, K = mis()
    A = lmis()
    tmp = sum(A[:K])
    tmp_max = tmp
    for i in range(K, N):
        tmp += A[i] - A[i-K]
        tmp_max = max(tmp_max, tmp)
    print((tmp_max+K)/2)


main()


Measured memory_bytes: 27812
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  int n;
  cin>>n;
  int cur = 0;
  int ans = 0;
  REP(i,n){
    int x,y;
    cin>>x>>y;
    if( cur<x ){
      cur = x;
      ans = x+y;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n, i, sum=0;
  cin >> n;
  int p[n];
  for(i=0; i<n; i++)
    cin >> p[i];
  sort(p,p+n);
  for(i=0; i<n-1; i++)
    sum+=p[i];
  cout << sum+p[n-1]/2;
  return 0;
}


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

const int N = 105;
const int INF=0x7fffffff;

int n,m,d[N][N],f[N][N];
bool flag;

int main(){
    scanf("%d %d",&n,&m);
    for (register int i=1;i<=n;i++)
        for (register int j=1;j<=m;j++)
            scanf("%d",&d[i][j]);
    
    for (register int i=0;i<=100;i++)
        for (register int j=0;j<=100;j++)
            for (register int x=1;x<=n;x++)
                for (register int y=1;y<=m;y++)
                    f[i][j]=max(f[i][j],d[x][y]-i*x-j*y);
    
    for (register int x=1;x<=n;x++)
        for (register int y=1;y<=m;y++){
            int now=INF;
            for (register int i=0;i<=100;i++)
                for (register int j=0;j<=100;j++)
                    now=min(now,i*x+j*y+f[i][j]);
            if (now!=d[x][y]){ flag=true; goto End; }
        }
    
End:
    if (flag){ printf("Impossible\n"); return 0; }

    //S:1
    //T:202
    //X:[2,101]
    //Y:[102,202]
    printf("Possible\n");
    printf("202 10401\n");
    for (register int i=1;i<=100;i++) printf("%d %d X\n",i,i+1);
    for (register int i=102;i<202;i++) printf("%d %d Y\n",i,i+1);
    for (register int i=0;i<=100;i++)
        for (register int j=0;j<=100;j++)
            printf("%d %d %d\n",i+1,202-j,f[i][j]);
    printf("1 202\n");
    return 0;
}

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





int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    while(true){
        C-=B;
        if(C<=0){
            cout<<"Yes"<<endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout<<"No"<<endl;
            break;
        }
    }
    
}

Measured memory_bytes: 3604
import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


k = readint()
s = readstr()

if len(s)<=k:
    print(s)
else:
    print(s[:k]+'...')


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

using namespace std;

typedef long long ll;

const ll INF = 1e18;

ll N, A, B, C, D;

void solve() {
    scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
    unordered_set<ll> us;
    pq.emplace(0, N);
    vector<pair<ll, ll>> mcost = { make_pair(2, A), make_pair(3, B), make_pair(5, C) };
    while (true) {
        ll v, c; tie(c, v) = pq.top(); pq.pop();
        if (us.count(v)) continue;
        if (v == 0) {
            printf("%lld\n", c);
            return;
        }
        us.insert(v);
        for (pair<ll, ll> op : mcost) {
            ll nc = c + v % op.first * D + op.second;
            pq.emplace(nc, v / op.first);
            if (v % op.first) {
                nc = c + (op.first - v % op.first) * D + op.second;
                pq.emplace(nc, v / op.first + 1);
            }
        }
        if (double(v) * D + c <= INF) {
            pq.emplace(c + v * D, 0);
        }
    }
}

int main() {
    int T; scanf("%d", &T);
    for (int i = 1; i <= T; i++) {
        solve();
    }
}


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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int cost[4],N,cf[4];
int fac[]{8,4,2,1};

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

	for (int i=0;i<4;i++) {
		cin >> cost[i];
		cf[i]=cost[i]*fac[i];
	}
	cin >> N;

	int mi=min_element(cf,cf+4)-cf;

	ll tot = N/2 * (ll)cf[mi];

	mi=min_element(cf,cf+3)-cf;
	tot += (N%2)*cf[mi]/2;

	cout << tot << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iterator>
 
#define MOD 1000000007
#define ll long long
 
using namespace std;
 
ll N;
vector<ll> a;
 
int check(ll k){
  vector <ll> vec;
  ll inp;
  ll q,c;//商、余
  ll result=0;
  
  // copy(a.begin(), a.end(), back_inserter(vec) );
  
  for (ll i =0;i<N;i++){
    inp = a[i]+k-N+1;
    vec.push_back(inp);
  }
  for (ll i =0;i<N;i++){
    q = vec[i]/(N+1);
    c = vec[i]%(N+1);
    if(q>=0){
      result+=q;
      if(c>0) result++;
    } 
  }
  //cout << result << endl;
  //cout << k << endl;
  if(result <= k) return 1;
  else return 0;
}
 
int main(){
  ll inp;
 
  ll l=0,r=5000000000000000000;
  ll bl,br;
  ll result ;
  ll k;
  
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> N;
  for(ll i = 0;i<N;i++){
    cin >> inp;
    a.push_back(inp);
  }
 
  
  do{
    k = (l+r)/2;
    if(check(k)==1){
      r = k;
    }
    else{
      l = k;
    }
    if((l == bl)&&(r == br)){
      for(ll i = l;i<=r;i++){
	if(check(i)==1){
	  l = i;
	  break;
	}
      }
    }
    bl = l;
    br = r;
  }while(l<r);
  result = l;
 
  for(ll i =0;i<=N;i++){
    if(check(i)==1){
      l = i;
      break;
    }
  }
 
  if(result < l) l = result;


  for(ll i = N*50;i>0;i--){
    if(((result-i)>=0) && check(result-i)==1){
      cout << result-i << endl;
      return 0;
    }
  }
  
  cout << l << endl;
 
  // cout << check(1234567894858) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long long double
#define ll long long
#define mod 1000000007
#define scl(x) scanf("%lld",&x)
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}

ll power(ll a,ll b) {
    ll res=1LL;
    while(b>0){
        if(b&1) res = mul(res,a);
        b/=2;
        a = mul(a,a);
    }
    return res%mod;
}

int main(){
   ll n;
   cin >> n;
   string s;
   cin >> s;
   ll cnt = 1;
   for(ll i=1;i<n;i++) {
    if(s[i]==s[i-1])continue;
    cnt++;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 100000;

int N, C;
int x[kMaxN], v[kMaxN];
int ans = 0;

int a[kMaxN], ma[kMaxN], b[kMaxN], mb[kMaxN];

signed main() {
  cin >> N >> C;
  REP(i, N) { cin >> x[i] >> v[i]; }

  a[0] = v[0]-x[0];
  ma[0] = MAX(0, a[0]);
  FOR(i, 1, N-1) {
    a[i] = a[i-1] + v[i]-(x[i]-x[i-1]);
    ma[i] = MAX(ma[i-1], a[i]);
  }
  b[N-1] = v[N-1]-(C-x[N-1]);
  mb[N-1] = MAX(0, b[N-1]);
  RFOR(i, N-2, 0) {
    b[i] = b[i+1] + v[i]-(x[i+1]-x[i]);
    mb[i] = MAX(mb[i+1], b[i]);
  }

  RFOR(i, N-1, 0) {
    int t = b[i];
    if (i != 0) { t = MAX(t, b[i]-(C-x[i])+ma[i-1]); }
    ans = MAX(ans, t);
  }
  FOR(i, 0, N-1) {
    int t = a[i];
    if (i != N-1) { t = MAX(t, a[i]-x[i]+mb[i+1]); }
    ans = MAX(ans, t);
  }

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


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,k;
    cin >> n >> k;
    int ans = 0;
    while(n>0){
        ans++;
        n/=k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <limits>
#include <math.h>
using namespace std;
 
int main(){
    long N;
    cin>>N;
    long ans=100000000000;

    
    for(long i=1;i<=sqrt(N);i++){
        int r=0;
      	bool k=false;
        if(N%i==0){
            int s=max(i,N/i);
            while(s>0){
                s/=10;
                r++;
              	k=true;
            }
        }
        else k=false;
        if(ans>r&&k)ans=r;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	int n,m;
	cin>>n>>m;
	int t=100*(n-m)+1900*m;
	int ans=t*(int)pow(2,m);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 500000
#define SENTINEL 1000000001
void merge(int[],int,int,int);
void mergeSort(int[],int,int);
void printArray(int[],int);
int count=0;//the number of comparisons in the merge function
int main(void)
{
  int i;//counter
  int n;//the number of integers
  int arr[N];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&arr[i]);
  mergeSort(arr,0,n);
  printArray(arr,n);
  printf("%d\n",count);
  return 0;
}
void merge(int arr[],int left,int mid,int right)
{
  int i,j,k;//counter
  int n1=mid-left;//the number of elements in array l
  int n2=right-mid;//the number of elements in array r
  int *l=(int*)malloc(sizeof(int)*(n1+1));
  int *r=(int*)malloc(sizeof(int)*(n2+1));
  for(i=0;i<n1;i++) l[i]=arr[left+i];
  for(i=0;i<n2;i++) r[i]=arr[mid+i];
  l[n1]=SENTINEL;
  r[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++)
    {
      if(l[i]<=r[j])
        {
          arr[k]=l[i];
          i++;
        }
      else
        {
          arr[k]=r[j];
          j++;
        }
      count++;
    }
  free(l);
  free(r);
}
void mergeSort(int arr[],int left,int right)
{
  int mid;//separate point of array
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergeSort(arr,left,mid);
      mergeSort(arr,mid,right);
      merge(arr,left,mid,right);
    }
}
void printArray(int arr[],int n)
{
  int i;//counter
  for(i=0;i<n;i++)
    {
      if(i>0) printf(" ");
      printf("%d",arr[i]);
    }
  printf("\n");
}


Measured memory_bytes: 5468
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int n = sc.nextInt();
		String ans ="";

		if(n < 1000) {
			ans = "ABC";
		} else {
			ans = "ABD";
		}

		// 出力
		System.out.println(ans);
	}
}

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

int main(){
  int K,X;
  int place[401];
  cin >> K >> X;

  for(int i=0;i<401;i++){
    place[i] = 0;
  }
  for(int i=X+200;i<X+200+K;i++){
    place[i] = 1;
    place[i-(K-1)] = 1;
  }

  for(int i=0;i<401;i++){
    if(place[i] == 1){
       cout << i - 200 << " ";
    }
  }
  cout << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

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

    sort(ALL(s));

    Yn(s.at(0)==s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2))


    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100;
int n;
int a[MAX_N+1];

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];

  int color = a[0], count = 1, ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i == n || color != a[i]) {
      ans += count/2;
      count = 1;
      color = a[i];
    } else {
      ++count;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b=0,c,d;
scanf("%d",&a);
while(1){
	b++;
	if(b%10==3){
printf(" %d",b);
}
if(b%10!=3&&b%3==0){
printf(" %d",b);
}
c=b;
while(1){
	c/=10;
	if(b%10!=3&&b%3!=0&&c%10==3){
		printf(" %d",b);
		break;
	}
	if(c==0)
	break;
}
if(b==a)
break;

}
printf("\n");
return 0;
}

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

using namespace std;

int main(){
while(1){

	int n=0,ans;
	int t;
	cin >> ans;
	if(ans == 0)break;
	for(int i = 0;i < 9;i++)cin>>t,n+=t;
	cout << ans - n << endl;
}
	return 0;
}


Measured memory_bytes: 1160
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)


func main() {
  var N int
  fmt.Scanf("%d", &N)
  
  var sc = bufio.NewScanner(os.Stdin)
  sc.Scan() 
  
  var As []int
  for _, AStr := range strings.Split(sc.Text(), " ") {
    A, _ := strconv.Atoi(AStr)
    As = append(As, A)
  }
  
  var ftmp float64
  for _, A := range As {
    ftmp += float64(1) / float64(A)
  }
  
  fmt.Println(1 / ftmp)
}

Measured memory_bytes: 640
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
// http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
// 素集合データ構造
struct UnionFind
{
 // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
 vector<int> par;
 // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
 vector<int> sizes;

 UnionFind(int n) : par(n), sizes(n, 1) {
   // 最初は全てのデータiがグループiに存在するものとして初期化
   rep(i,n) par[i] = i;
 }

 // データxが属する木の根を得る
 int find(int x) {
   if (x == par[x]) return x;
   return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
 }

 // 2つのデータx, yが属する木をマージする
 void unite(int x, int y) {
   // データの根ノードを得る
   x = find(x);
   y = find(y);

   // 既に同じ木に属しているならマージしない
   if (x == y) return;

   // xの木がyの木より大きくなるようにする
   if (sizes[x] < sizes[y]) swap(x, y);

   // xがyの親になるように連結する
   par[y] = x;
   sizes[x] += sizes[y];
   // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
 }

 // 2つのデータx, yが属する木が同じならtrueを返す
 bool same(int x, int y) {
   return find(x) == find(y);
 }

 // データxが含まれる木の大きさを返す
 int size(int x) {
   return sizes[find(x)];
 }
};
int main() {
    ll n,m;
    std::cin >> n>>m;
    UnionFind uf(n);
    vector<vector<ll>> lang(m);
    for (int i = 0; i < n; i++) {
        ll k;
        std::cin >> k;
        for (int j = 0; j < k; j++) {
            int t;
            std::cin >> t;
            t--;
            lang[t].push_back(i);
        }
    }
    for (int i = 0; i < m; i++) {
        for (auto e : lang[i]) {
            uf.unite(lang[i][0],e);
        }
    }
    if( uf.size(0) == n){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 4736
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE -2

int row[N];
int col [N];
int dpos[N+N];
int dneg[N+N];
int k[N];

void printBoard(){
  int i,j,k;
  for(i=0;i<N;i++){
    for(k=0;k<N;k++){
      if(row[i]==k)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

int putQueen(int i){
  int j;
  
  if(i==N){
    printBoard();
    return 1; 
    }

  if(k[i]==NOT_FREE){
    if( putQueen(i+1)) return 1;
    return 0;
  }

  
  for(j=0;j<N;j++){
    if((col[j] == NOT_FREE )||( dpos[i+j]==NOT_FREE )||( dneg[i-j+N-1]==NOT_FREE)) continue;
    //put a queen at (i,j)行と列
    row[i]=j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    //try the next row
    putQueen(i+1);
    //remove the queen at (i,j) for backtracking
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
  return 0;
}




int main(){
  int i,j,n,x,y;

  for(i=0;i<2*N;i++){
    if(i<N)
      row[i] = col[i] = FREE;
    dpos[i] = dneg[i] =  FREE;
  }
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    k[x] = NOT_FREE;
    row[x]=y;
    col[y] = NOT_FREE;
    dpos[x+y] =NOT_FREE;
    dneg[x-y+N-1] =NOT_FREE;

  }
  putQueen(0);

  return 0;
}



Measured memory_bytes: 2108
/**
 *   author: Shubham Srivastava
 *   created: 04 February 2019  17:38:29
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
string s;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    ll n,m;
    n = s1.size();
    m = s2.size();
    long long dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
    	for(int j=0;j<=m;j++)
    	{
    		if(i==0 || j==0)
    			dp[i][j] = 0;
    		else if(s1[i-1] == s2[j-1])
    		{
    			dp[i][j] = 1 + dp[i-1][j-1];
    		}
    		else
    		{
    			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    		}
    	}
    }
    if(dp[n][m] == 0)
    {
    	cout<<"";
    	return 0;
    }
    while(m && n)
    {
    	if(s1[n-1] == s2[m-1])
    	{
    		s += s1[n-1];
    		m--;
    		n--;
    	}
    	else if(dp[n][m-1] > dp[n-1][m])
    	{
    		m--;	
    	}
    	else
    		n--;
    }
    for(int i=s.length()-1;i>=0;i--)
    	cout<<s[i];
return 0;
}

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

int main(){
  char c;
  cin >> c;
  string res = "consonant";

  if(c == 'a' ||
     c == 'i' ||
     c == 'u' ||
     c == 'e' ||
     c == 'o'
     ){
       res = "vowel";
  }
  cout << res << endl;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n, k; cin >> n >> k;
  vector<int> a(n, 0);
  while (k--){
    int d;  cin >> d;
    for (int i = 0; i < d; ++i){
      int idx;  cin >> idx; idx--;
      a[idx] = 1;
    }
  }
  cout << count(a.begin(), a.end(), 0) << "\n";
  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define maxn 505
using namespace std;
typedef long long ll;
int a[maxn][maxn];
int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    while (m--){
        int l, r;
        cin >> l >> r;
        ++a[l][r];
    }
    for (int i = n; i >= 1; --i){
        for (int j = 1; j <= n; ++j){
            a[i][j] += a[i + 1][j] + a[i][j - 1] - a[i + 1][j - 1];
        }
    }
    while (q--){
        int l, r;
        cin >> l >> r;
        cout << a[l][r] << '\n';
    }
    return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
int n,A,a[55];
long long int dp[55][2555];
int main(){
	scanf("%d%d",&n,&A);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	dp[0][0]=1;
	int tot=0;
	for(int i=1; i<=n; i++){
		for(int i2=i-1; i2>=0; i2--)
		for(int j=tot; j>=0; j--)
			dp[i2+1][j+a[i]]+=dp[i2][j];
		tot+=a[i];
	}
	long long int res=0;
	for(int i2=1; i2<=n; i2++)
		res+=dp[i2][i2*A];
	printf("%lld\n",res);
	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n,l;cin>>n>>l && n|l;){
		vi a(n);
		rep(i,n) cin>>a[i];

		vi res;
		rep(i,n-1) if(a[i]+a[i+1]>=l){
			rep(j,i) res.push_back(j);
			peri(j,i,n-1) res.push_back(j);
			break;
		}
		cout<<(res.size()?"Possible":"Impossible")<<endl;
		for(int x:res) cout<<x+1<<endl;
	}
}


Measured memory_bytes: 1784
<?php
$num = intval(trim(fgets(STDIN)));
$array = explode(" ",fgets(STDIN));
$error = 0;
for ($i=0; $i<$num; $i++) {
    if ($array[$i] != $i+1) {
        $error++;
    }
}
if ($error == 0 or $error == 2) {
    echo "YES";
} else {
    echo "NO";
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

// void add(ll &a, ll b){
//     a += b;
//     if(a>=MOD) a -= MOD;
// }

// int main(){
//     string S;
//     cin>>S;
//     vector<vector<ll>> dp(S.size()+1,vector<ll>(13,0));
//     dp[0][0] = 1;
//     rep(i,S.size()){
//         rep(j,13){
//             if(S[i]=='?'){
//                 rep(k,10){
//                     add(dp[i+1][(j*10+k)%13],dp[i][j]);
//                 }
//             }else{
//                 int k = S[i] - '0';
//                 add(dp[i+1][(j*10+k)%13],dp[i][j]);
//             }
//         }
//     }
//     cout<<dp[S.size()][5]<<endl;
// }

int main(){
    int a,b;cin>>a>>b;
    int ans = 0;
    int out = 1;
    while(out<b){
        --out;
        out += a;
        ++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
arr = arr[::-1]
res, ans = [arr[0]], 0
for i in range(1, n - 1):
  res.append(arr[i])
  res.append(arr[i])
for i in range(n - 1):
  ans += res[i]
print(ans)
  


Measured memory_bytes: 31552
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }

    int total_days = accumulate(a.begin(), a.end(), 0);
    int ans = n - total_days;

    if (ans < 0) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define maxn 301005
#define maxm 2018
#define maxr 101005
#define M 1000000007
#define ll long long int 
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)
using namespace std;

char buffer[maxn], *p1, *p2;
template <class T> void read(T& x){
	char ch = gc(); x = 0; bool f = 1;
	while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();
	if (ch == '-') f = 0, ch = gc();
	while ('0' <= ch && ch <= '9') x = (x << 1) + (x << 3) + ch - '0', ch = gc();
	if (!f) x = -x;
}

int n;
int x[maxn], y[maxn], num[maxm][maxm];
bool vis[maxm << 1][maxm << 1];
int dp[maxm << 1][maxm << 1];
int DP(int x, int y){
	if (x >= maxm << 1 || y >= maxm << 1) return 0;
	if (vis[x][y]) return dp[x][y];
	vis[x][y] = 1;
	int& ans = dp[x][y];
	if (x >= 1 + maxm && y >= 1 + maxm) ans = num[x - maxm][y - maxm];
	return ans = (ans + DP(x + 1, y) + DP(x, y + 1)) % M;
}
ll fac[maxn], ifac[maxn], inv[maxn];
ll cal(int m, int n){
	return (m < n) ? 0 : fac[m] * ifac[n] % M * ifac[m - n] % M;
}
void init(){
	fac[0] = ifac[0] = inv[1] = 1;
	rep(i, 1, maxn - 1) fac[i] = fac[i - 1] * i % M;
	rep(i, 2, maxn - 1) inv[i] = M - M / i * inv[M % i] % M;
	rep(i, 1, maxn - 1) ifac[i] = ifac[i - 1] * inv[i] % M;
}
int main(){
	init();
	read(n);
	rep(i, 1, n) read(x[i]), read(y[i]), num[x[i]][y[i]]++;
	int ans = 0;
	rep(i, 1, n) (ans += DP(maxm - x[i], maxm - y[i])) %= M, (ans += M - cal(2 * x[i] + 2 * y[i], 2 * x[i])) %= M;
	ans = (ll)(M + 1) / 2 * ans % M;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 104960
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define pi 3.14159265358979323846264338327950D
#define modd 1000000000
#define k 100000000

int main()
{
        fast;
        int t=1;
      //  cin>>t;
        while(t--)
        {
                int r;
                cin>>r;
                cout<<setprecision(18)<<(ld)(2*pi*r)<<endl;
        }
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
using namespace std;

int main(){
    int n;
    cin>>n;
    int i,t,ans=0;
    set<int> data;
    for(i=0;i<n;i++){
        cin>>t;
        if(data.count(t)==0){
            data.insert(t);
            ans++;
        }else{
            data.erase(t);
            ans--;
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
vector<vector<ll> >G(200010);
vector<ll>a(200010);
vector<ll>lis(200010);
vector<ll>ans(200010);
void dfs(ll i,ll p){
    auto itr=lower_bound(all(lis),a[i]);
    ll d=*itr;
    *itr=a[i];
    auto itr2=lower_bound(all(lis),inf);
    ans[i]=itr2-lis.begin();
    for(auto e:G[i]){
        if(e==p)continue;
        dfs(e,i);
    }
    *itr=d;
}
signed main(){
    ll n;cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        ll v,u;cin>>v>>u;
        v--;u--;
        G[u].pb(v);
        G[v].pb(u);
    }
    rep(i,200010){
        lis[i]=inf;
    }
    dfs(0,-1);
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 30340
h, w = map(int, input().split())
s = [input() for _ in range(h)]
hor = [[0] * w for _ in range(h)]
ver = [[0] * w for _ in range(h)]

for i in range(h):
    now = 0
    for j in range(w):
        if s[i][j] == '#':
            now = 0
        else:
            now += 1
            hor[i][j] = now

for j in range(w):
    now = 0
    for i in range(h):
        if s[i][j] == '#':
            now = 0
        else:
            now += 1
            ver[i][j] = now

for i in range(h-1, -1, -1):
    now = 0
    for j in range(w-1, -1, -1):
        if s[i][j] == '#':
            now = 0
        else:
            now = max(now, hor[i][j])
            hor[i][j] = now

for j in range(w-1, -1, -1):
    now = 0
    for i in range(h-1, -1, -1):
        if s[i][j] == '#':
            now = 0
        else:
            now = max(now, ver[i][j])
            ver[i][j] = now

res = 0
for i in range(h):
    for j in range(w):
        res = max(hor[i][j] + ver[i][j] - 1, res)
print(res)


Measured memory_bytes: 125144
#include<iostream>
using namespace std;
typedef long long ll;
 
struct Stack{
  ll table[1000];
  ll top;
  void init(){
    top=0;
  }
  bool empty(){
    return top==0;
  }
  void push(ll x){
    table[top]=x;
    top++;
  }
  ll pop(){
    if(empty())return 0;
    top--;
    return table[top];
  }
};
 
ll calc(ll x,string op,ll y){
  if(op=="+")return x+y;
  if(op=="-")return x-y;
  if(op=="*")return x*y;
}
 
 
int main(){
  string str;
  ll numA,numB;
  Stack stack;
  stack.init();
 
  while(cin>>str){
    if(str=="+"||str=="-"||str=="*"){
      numA=stack.pop();
      numB=stack.pop();
      stack.push(calc(numB,str,numA));
    }else{
      numA=0;
      for(int i=0;i<(int)str.size();i++){
    numA*=10;
    numA+=str[i]-'0';
      }
      stack.push(numA);
    }
  }
  cout<<stack.pop()<<endl;
  return 0;
}

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

using namespace std;

int main () {
  int N;
  int h[1<<17];
  int m[1<<17];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  m[0] = 0;
  m[1] = abs(h[0] - h[1]);
  for (int i = 2; i < N; i++) {
    m[i] = min(m[i-2]+abs(h[i]-h[i-2]), m[i-1]+abs(h[i]-h[i-1]));
  }
  cout << m[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
//		long b = (long)(sc.nextDouble()*100);
//		double b = sc.nextDouble();
		String[] tmpArray = sc.next().split("\\.");
		long b = Integer.parseInt(tmpArray[0])*100 + Integer.parseInt(tmpArray[1]);

		System.out.println(a*b/100);
//		System.out.println((long)(a*b));
	}
}

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

using namespace std;

typedef long long LL;

LL f[100][100][2];
int a[105];

LL dfs(int pos,int pre,int dd,bool flag)
{
	if (pos<=0) return 1;
	if (!flag&&f[pos][pre][dd]!=-1) return f[pos][pre][dd];
	int maxx;
	if (flag) maxx=a[pos];else maxx=9;
	LL now=0;
	for (int i=0;i<=maxx;++i)
	{
		int delta;
		if (dd==1) delta=0;else delta=abs(pre-i);
		if (delta<=1)now+=dfs(pos-1,i,dd&&(i==0),flag&&(i==maxx));
	}
	if (!flag) f[pos][pre][dd]=now;
	return now;
}
LL calc(LL x)
{
	memset(a,0,sizeof(a));
	while (x!=0)
	{
		++a[0];
		a[a[0]]=x%10;
		x/=10;
	}
	return dfs(a[0],0,1,true)-1;
}
int main()
{
	memset(f,-1,sizeof(f));
	LL n;
	cin>>n;
	LL l=1,r=5000000000,ans=-1,mid;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (calc(mid)>=n)
		{
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int S,h,m,s;
    scanf("%d",&S);
    h = S / 3600;
    m = S / 60 - h * 60;
    s = S - m * 60 - h * 3600;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	ll suma=0,sumb=0;
	rep(i,n){
		cin >> a.at(i);
		suma+=a.at(i);
	}
	rep(i,n){
		cin >> b.at(i);
		sumb+=b.at(i);
	}
	if(suma<sumb){
		cout << -1 << endl;
		return 0;
	}
	rep(i,n){
		if(a.at(i)>b.at(i)) c.at(i)=a.at(i)-b.at(i);
	}
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());
	ll summinus=0,ans=0;
	rep(i,n){
		if(a.at(i)<b.at(i)){
			ans++;
			summinus+=b.at(i)-a.at(i);
		}
	}
	rep(i,n){
		if(summinus<=0) break;
		ans++;
		summinus-=c.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

struct DATA {
    Int p;
    Int y;
    Int id;
    bool operator< (const DATA& d) const {
        if (p < d.p) {
            return true;
        } else if (p == d.p && y < d.y) {
            return true;
        } else {
            return false;
        }
    }
};

int main(void) {
    Int n, m;
    cin >> n >> m;
    Int p, y;
    vector<DATA> v(m);
    for (Int i = 0; i < m; ++i) {
        cin >> p >> y;
        v[i] = {--p, y, i};
    }
    sort(v.begin(), v.end());

    Int k = 0;
    map<Int, string> mp;
    for (Int i = 0; i < n; ++i) {
        Int j;
        for (j = k; j < m; ++j) {
            if (v[j].p == i) {
                mp[v[j].id] = to_string(v[j].p + 1000001).substr(1, 6) + to_string((j - k + 1) + 1000000).substr(1, 6);
            } else {
                break;
            }
        }
        k = j;
    }
    for (Int i = 0; i < m; ++i) {
        cout << mp[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 13620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,ans=0; cin >> N;
  for(int i=1; i<=N; i++) {
    int count=0;
    for(int j=1; j<=i; j++) {
      if(i%j==0) count++;
    }
    if(i%2!=0 && count==8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define endl '\12'
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ex_gcd(ll a, ll b, ll& x, ll& y){if(!b){x=1;y=0;return a;}int ret=ex_gcd(b,a%b,y,x);y-=a/b*x;return ret;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
int norm(int x) { return x >= mod ? (x - mod) : x; }
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
inline ll get_inv(ll a) { ll x, y; ex_gcd(a, mod, x, y); return norm(x + mod);}
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260817, P_2=999998639;
char a[10][10];
int main()
{
    FOR(i,1,4)FOR(j,1,4)cin>>a[i][j];
    for(int i = 1; i <= 3; i++) cout << a[i][i];
    
    return 0;
}

Measured memory_bytes: 3628
#pragma region 宣言部分
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;

#pragma endregion



int main(){
    string s,t;
    cin >> s >> t;
    int res = 0;
    REP(i,s.length()){
        if(s[i] != t[i])
            res++;
    }
    cout << res << endl;
    return 0;
}


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

int main(){
   int H, W;
   cin >> H >> W;
   vector<string> S(H);
   for (int i=0; i<H; i++){
      cin >> S.at(i);
   }

   vector<vector<int>> Si(H+2, vector<int>(W+2));
   for (int j=0; j<W+2; j++){
      Si.at(0).at(j) = 0;
      Si.at(H+1).at(j) = 0;
   }

   for (int i=1; i<H+1; i++){
      for (int j=0; j<W+2; j++){
         if ((j == 0) || (j == W+1)){
            Si.at(i).at(j) = 0;
         } else{
            if (S.at(i-1).at(j-1) == '.'){
               Si.at(i).at(j) = 0;
            } else{
               Si.at(i).at(j) = 1;
            }
         }
      }
   }

   //for (int i=0; i<H+2; i++){
   //   for (int j=0; j<W+2; j++){
   //      cout << Si.at(i).at(j);
   //   }
   //   cout << endl;
   //}

   vector<vector<int>> ans(H+2, vector<int>(W+2));
   for (int i=1; i<H+1; i++){
      for (int j=1; j<W+1; j++){
         ans.at(i).at(j) = Si.at(i-1).at(j-1)+Si.at(i-1).at(j)+Si.at(i-1).at(j+1)+Si.at(i).at(j-1)+Si.at(i).at(j+1)+Si.at(i+1).at(j-1)+Si.at(i+1).at(j)+Si.at(i+1).at(j+1);
      }
   }

   vector<vector<int>> ans2(H, vector<int>(W));
   for (int i=1; i<H+1; i++){
      for (int j=1; j<W+1; j++){
         ans2.at(i-1).at(j-1) = ans.at(i).at(j);
      }
   }

   for (int i=0; i<H; i++){
      for (int j=0; j<W; j++){
         if (S.at(i).at(j) == '#'){
            cout << '#';
         } else{
            cout << ans2.at(i).at(j);
         }
      }
      cout << endl;
   }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int INF=(int)2e9;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
const ll MOD=(ll)1e9+7;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define MAX 100005
#define wa cout<<"wa"<<endl;

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main(){
	int n,m,r,town[MAX];
	ll adj[205][205];
	cin>>n>>m>>r;
	FOR(i,0,r){
		cin>>town[i];
		town[i]--;
	}
	FOR(i,0,n+1){
		FOR(j,0,n+1){
			adj[i][j] = INF;
		}
		adj[i][i] = 0;
	}
	while(m--){
		ll u,v,cs;
		cin>>u>>v>>cs;
		u--,v--;
		adj[u][v] = min(adj[u][v],cs);
		adj[v][u] = adj[u][v];
	}
	FOR(k,0,n){
		FOR(i,0,n){
			FOR(j,0,n){
				adj[i][j] = min(adj[i][j],adj[i][k]+adj[k][j]);
			}
		}
	}
//	FOR(i,0,n){
//		FOR(j,0,n){
//			cout<<adj[i][j];		
//		}
//		cout<<endl;
//	}
	
	sort(town,town+r);
	ll ans = INF;
	do{
		ll temp = 0;
		for(int i=1;i<r;i++){
			temp+=adj[town[i-1]][town[i]];
		}
	//	printf("temp %d ans %d\n",temp,ans);
		ans = min(temp,ans);
	}while(next_permutation(town,town+r));
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列
#include <map> //map



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

int r, d, x;




int main() {
	cin >> r >> d >> x;
	REP(i,1, 11) {
		x = r * x - d;
		cout << x << endl;
	}





	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  ll a;
  priority_queue<ll> queue;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    queue.push(a);
  }

  for(int i = 0; i < M; ++i) {
    auto value = queue.top();
    queue.pop();
    queue.push(value / 2);
  }
  ll total = 0;
  while(!queue.empty()) {
    total += queue.top();
    queue.pop();
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 1400