akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        String P = scanner.next().toLowerCase();
        char p[] = P.toCharArray();
 
        String tmp;
        int ans = 0;
        boolean FLG;
 
        while(!(tmp = scanner.next()).equals("END_OF_TEXT")){
 
            char line[] = tmp.toLowerCase().toCharArray();
 
            if(line.length != p.length)continue;
 
            FLG = true;
            for(int i = 0; i < P.length(); i++){
                if(p[i] != line[i]){
                    FLG = false;
                    break;
                }
            }
            if(FLG)ans++;
        }
 
        System.out.println(ans);
    }
}


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a<=x&&a+b>=x)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [(Int, Int)] -> Double
solve n as = (/len) . sum $ calcRoute <$> allRoute where
    len = fromIntegral $ length allRoute
    vec :: UV.Vector (Int, Int)
    vec = GV.fromList as
    routes a = do
        b <- [0..n-1]
        guard $ S.notMember b a
        case routes $ S.insert b a of
            [] -> pure [b]
            rx -> do 
                r <- rx
                pure $  b : r
    allRoute :: [[Int]]
    allRoute = routes S.empty
    calcDist (x, y) (xx, yy) = sqrt . fromIntegral $ (xx - x) ^2  + (yy - y) ^2
    calcRoute :: [Int] -> Double
    calcRoute rx = foldl' (\t (p, n) -> calcDist (vec GV.! p) (vec GV.! n) + t ) 0 $ zip rx $ tail rx




main = do
    n <- readInt
    as <- replicateM n readTuple2
    print $ solve n as


Measured memory_bytes: 17660
#include <cstdio>

#define min(a, b) (a < b ? a : b)

int digit_sum(int n)
{
    int sum = 0;

    while(n)
    {
        sum += n%10;
        n /= 10;
    }

    return sum;
}

int main()
{
    int n;
    scanf("%d", &n);

    const int oo = 1e9;

    int max_digit_sum = oo;
    for(int i = 1; 2*i <= n; i++)
        max_digit_sum = min(max_digit_sum, digit_sum(i) + digit_sum(n - i));

    printf("%d\n", max_digit_sum);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
	int a,b,c;
	int r = 0;
	while(scanf("%d %d", &a, &b) != EOF) {
		c = a+b;
		r = 0;

		while(1){
			if(c/10 == 0)break;
			c/=10;
			r++;
		}
		r++;
		printf("%d\n", r);
	}
	return 0;
}

Measured memory_bytes: 600
//18
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
  for(double x,h;cin>>x>>h,x!=0||h!=0;){
    cout<<fixed<<setprecision(5)<<x*x+2*x*sqrt(x*x/4+h*h)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	rep(i,n){
		string x=s.substr(0,i),y=s.substr(i);
		set<char> cnt,cnt2;
		rep(j,x.size()){
			cnt.insert(x[j]);
		}
		rep(j,y.size()){
			if(cnt.find(y[j])!=cnt.end()) cnt2.insert(y[j]);
		}
		chmax(ans,(int)cnt2.size());
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const int max_N = 1000000000;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int h,w,m;
int main(){
    cin >> h >> w >> m;
    set<P> v;
    vector<int> h_bomb(h,0),w_bomb(w,0);
    rep(i,m){
        int a,b; cin >> a  >> b;
        a--,b--;
        v.insert(P(a,b)); 
         h_bomb[a]++;
         w_bomb[b]++;
    } 
    int hmax=0,wmax=0;
    rep(i,h){
        chmax(hmax,h_bomb[i]);
    }
    rep(i,w){
        chmax(wmax,w_bomb[i]);
     }
    vector<int> hmax_list,wmax_list;
    rep(i,h){
        if(hmax==h_bomb[i]) hmax_list.push_back(i);
    }
    rep(i,w){
        if(wmax==w_bomb[i]) wmax_list.push_back(i);
    }
    int ans = hmax+wmax;
    bool bomb_is_null = false;
    for(auto i:hmax_list){
        for(auto j:wmax_list){
            if(v.find(P(i,j)) == v.end()){
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans - 1 << endl;
    return 0;
}


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

const int inf = 1e9+5;

int main() {

    int n,k;
    cin>>n>>k;

    int arr[n];
    for(int i=0;i<n;++i)
        cin>>arr[i];

    vector<int> dp(n,inf);
    dp[0] = 0;
    for(int i=0;i<n;++i){
            for(int j=i+1;j<=i+k;++j){
                if(j<n)
                    dp[j] = min(dp[j],dp[i]+abs(arr[i]-arr[j]));
            }

    }

    cout<<dp[n-1];
    return 0;
      }


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

std::vector<std::vector<std::pair<int, int> > > hen;
std::vector<bool> res;
void dfs(int i, int prev, int64_t dist = 0) {
	res[i] = dist & 1;
	for (auto j : hen[i]) if (j.first != prev) dfs(j.first, i, dist + j.second);
}

int main() {
	int n = ri();
	hen.resize(n);
	for (int i = 1; i < n; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		int c = ri();
		hen[a].push_back({b, c});
		hen[b].push_back({a, c});
	}
	res.resize(n);
	dfs(0, -1);
	for (auto i : res) printf("%d\n", (int) i);
	
	return 0;
}


Measured memory_bytes: 10488
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

vector<vector<int>> v;
int ans=0;

void dfs(vector<bool> &visit,int cnt) {
    visit[cnt] = true;
    bool all = true;
    if (count(ALL(visit),true) == visit.size() ) {
        ans++;
        return;
    }
    for(auto x: v[cnt]) {
        if (!visit[x]) {
            vector<bool> vi(visit);
            dfs(vi,x);
        }
    }
    return;
}

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    v.resize(n);
    REP(i,m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    vector<bool> vi(n);
    dfs(vi,0);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
using namespace std;
int main ()
{
    int n;
    cin >> n;
    string s = "No";
    for (int i = 1; i < 10; i ++){
        for (int j = 1; j < 10; j ++){
            if (n == i * j)
            s = "Yes";
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	c=a-2*b;
	if(c>=0)
	{
		cout<<c<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	return 0;
 } 

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

int N;
vector<int> A;

int main(void) {
	cin >> N;
	A.resize(N + 1);
	for (int i = 1; i <= N; ++i)
		cin >> A[i];

	int ans = 0;
	for (int i = 1; i <= N; i += 2) {
		if (A[i] % 2 == 1)
			++ans;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>

typedef long long ll;
const ll m = 1e9 + 7;


int main(int argc, char **argv)
{
    int S;
    std::cin >> S;

    std::vector<ll> A(2001, 0);

    A[3] = 1;

    for (int i = 4; i < S + 1; i++)
    {
        A[i] = A[i - 3] + A[i - 1];
        A[i] %= m;
    }


    std::cout << A[S] << std::endl;
}

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

int main(){
	while(1){
		int n, m[100]; 
		long a[100], b[100], merge[200];
		
		//入力
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i){
			scanf(" %d %ld %ld", &m[i], &a[i], &b[i]);
			merge[2*i] = a[i];
			merge[2*i+1] = b[i];
		}
		
		//a, b両方の数を合わせてソートし，座標圧縮する
		sort(merge, merge+(2*n));
		
		for(int i=0; i<n; ++i){
			for(int j=0; j<2*n; ++j){
				if(b[i] == merge[j]){
					b[i]=j;	
					merge[j]=-1;
					break;
				}
			}
		}
		
		for(int i=0; i<n; ++i){
			for(int j=0; j<2*n; ++j){
				if(a[i] == merge[j]){
					a[i]=j;	
					merge[j]=-1;
					break;
				}
			}
		}
		
		//for(int i=0; i<n; ++i) printf("%d; a=%ld, b=%ld\n", i, a[i], b[i]);
	
		//いもす法
		long imos[201]={0};
		for(int i=0; i<=200; ++i) imos[i]=0;
		
		for(int i=0; i<n; ++i){
			imos[a[i]] += m[i];
			imos[b[i]] -= m[i];
		}	
	
		for(int i=0; i<2*n; ++i) imos[i+1] += imos[i];
		//for(int i=0; i<2*n; ++i) printf("%d:%ld\n",i,imos[i]);	
		sort(imos, imos+(2*n), greater<long>());
		
		//printf("max=%ld\n", imos[0]);
		if(imos[0]>150) printf("NG\n");
		else printf("OK\n");
	}
	return 0;
}

Measured memory_bytes: 1192
# https://atcoder.jp/contests/abc085/tasks/abc085_b
# setを使わない解き方
n = int(input().split()[0])
length_list = []

for _ in range(n):
    x = int(input().split()[0])
    length_list.append(x)

length_list = sorted(length_list)
no_dup_list = []

for i in range(len(length_list)):
    if i == len(length_list) - 1:
         no_dup_list.append(x)
    else:
        x = length_list[i]
        next_x = length_list[i + 1]
        if x != next_x:
            no_dup_list.append(x)
        else:
            continue

print(len(no_dup_list))

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

void printans(vector<int> v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        if (v[i] == 0) cout << 'S';
        else        cout << 'W';
    }
    cout << endl;
}

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

    vector<int> v(N + 1);

    rep(i, 4) {
        v[0] = i & 1;
        v[1] = (i >> 1) & 1;
        for(int j = 2; j <= N; ++j) {
            int res;
            if ((v[j - 1] == 0 && s[j - 1] == 'o') || (v[j - 1] == 1 && s[j - 1] == 'x')) {
                res = v[j - 2];
            } else {
                res = 1 - v[j - 2];
            }
            v[j] = res;
        }

        // rep(i, N + 1) cout << v[i] << ", ";
        // cout << endl;

        if (v[0] == v[N]) {
            if ((v[0] == 0 && s[0] == 'o') || (v[0] == 1 && s[0] == 'x')) {
                if (v[1] == v[N - 1]) {
                    printans(v);
                    return 0;
                }
            } else {
                if (v[1] != v[N - 1]) {
                    printans(v);
                    return 0;
                }
            }
        }
    }
    cout << "-1" << endl;
}

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

/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

using namespace std;

typedef long long ll;

int n, x, t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << "\n";
    return 0;
}



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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);

	int lo=0,hi=1e4;
	vector<int> Ans;
	while(hi-lo>1){
		int mi=(lo+hi)/2;
		int sum=0;
		vector<int> S;
		for(int x=mi;x>0;x--) if(sum+x<=n) {
			sum+=x;
			S.emplace_back(x);
		}
		if(sum==n) hi=mi, Ans=S;
		else       lo=mi;
	}

	for(int x:Ans) printf("%d\n",x);

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, K;
    cin >> N >> K;
    int h[N];
    int dp[N];
    for(int i = 0; i < N; i++) cin >> h[i];
    
    dp[0] = dp[1] = 0;
    for(int i = 1; i < N; i++){
        dp[i+1] = 1000000000;
    }
    
    for(int i = 1; i < N; i++){
        for(int j = 0; j < K; j++){
            if(i-j >= 1){
                dp[i+1] = min(dp[i+1], dp[i-j] + abs(h[i] - h[i-1-j]));
            }
        }
    }
    
    cout << dp[N] << endl;
}


Measured memory_bytes: 1024
//#include "pch.h"
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <math.h>
#define OO INT_MAX
#define mp(x,y) make_pair(x,y)
#define x first
#define y second
#define ll unsigned long long int
#define pp pair<int,int>
#define heap priority_queue<pp, vector<pp>, greater<pp>>
using namespace std;

int ans;
string  s;
string s1;
void check(string str, int i) {
	if (i == s.size()) {
		if (str == "ABC")
			ans++;
		return;
	}
	s1 = str;
	check(s1, i + 1);
	s1 = str + s[i];
	check(s1, i + 1);
}

int main()
{
	///freopen("test.txt", "r", stdin);

	int n, k;
	cin >> n >> k;
	vector<ll> H(n);
	ll in;
	for (int i = 0; i < n; i++) {
		cin >> in;
		H[i] = in;
	}
	sort(H.begin(), H.end());
	if (k >= n) {
		cout << 0;
		return 0;
	}
	ll ans = 0;
	for(int i=(n-1)-k;i>=0;i--){
		ans += H[i];
	}
	cout << ans;
}


Measured memory_bytes: 1792
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n;cin>>n;
  vector<int> p(n);
  rep(i, n) {
    cin>>p[i];
  }
  dump(p);

  string ans = "";
  int k = 0;
  int m = 0;
  multiset<int> st;
  rep(i, 0, n+1) st.insert(i);
  rep(i, n){
    while (k<p[i]){
      ans+="(";
      m++;

      k = m;
    }
    if (k>p[i]){
      cout << ":(" << endl;
      return 0;
    }
    ans += ")";
    auto it = st.find(p[i]);
    it = st.erase(it);
    k = *(prev(it));
  }
  dump(ans);

  int lev = 0;
  rep(i, sz(ans)){
    if (ans[i]=='(') lev++;
    if (ans[i]==')') lev--;
    if (lev<0){
      cout << ":(" << endl;
      return 0;
    }
  }
  if (lev==0){
    cout << ans << endl;
  }
  else{
    assert(false);
    cout << ":(" << endl;
  }

  return 0;
}



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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    for (int i = 0; i < n - 1; ++i) {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; ++i) {
        cout << a[i] << "\n";
    }
    return 0;
}

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

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

  vector<ll> A(N), B(N);
  ll a_sum = 0, b_sum = 0;
  rep(i,0,N-1)
  {
    cin >> A[i];
    a_sum += A[i];
  }
  rep(i,0,N-1)
  {
    cin >> B[i];
    b_sum += B[i];
  }

  if (a_sum < b_sum)
  {
    cout << -1 << endl;
    return 0;
  }

  bool ok = true;
  rep(i,0,N-1)
    if (A[i] < B[i])
      ok = false;

  if (ok)
  {
    cout << 0 << endl;
    return 0;
  }

  vector<ll> pool;
  rep(i,0,N-1)
  {
    if (A[i] > B[i])
      pool.push_back(A[i] - B[i]);
  }
  
  sort(pool.begin(), pool.end());

  bool is_touched = false;
  rep(i,0,N-1)
  {
    if (A[i] < B[i])
    {
      ll deficit = B[i] - A[i];
      while (0 < deficit)
      {
        ll last = *pool.rbegin();
        if (deficit < last)
        {
          last -= deficit;
          deficit = 0;
          pool.pop_back();
          pool.push_back(last);
          is_touched = true;
        }
        else
        {
          deficit -= last;
          pool.pop_back();
          is_touched = false;
        }
      }
    }
  }

  ll ans = N - pool.size();
  if (is_touched) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5388
S = input()

Sr = ""

for i in range(len(S)):
    Sr += S[-i-1]

while len(Sr) >= 7:
    if Sr[0:5] == "maerd" :
        Sr = Sr[5:]
    elif Sr[0:5] == "esare":
        Sr = Sr[5:]
    elif Sr[0:6] == "resare":
        Sr = Sr[6:]
    elif Sr[0:7] == "remaerd":
        if len(Sr) != 7:
            Sr = Sr[7:]
        else:
            print("YES")
            break
    else:
        print("NO")
        break
else:
    if len(Sr) == 6:
        if Sr[0:6] == "resare":
            print("YES")
        else:
            print("NO")
    elif len(Sr) == 5:
        if Sr[0:5] == "maerd" :
            print("YES")
        elif Sr[0:5] == "esare":
            print("YES")
        else:
            print("NO")
    elif len(Sr) == 0:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 3316
#include<iostream>

using namespace std;

typedef long long ll;

int main(){
	ll ans = 0;
	int n; 
	scanf("%d", &n);
	int a[n + 1], b[n];
	for(int i = 0 ; i < n + 1 ; i++){
		scanf("%d", a + i);
	}
	for(int i = 0 ; i < n ; i++){
		scanf("%d", b + i);
	}
	for(int i = 0, j = 0 ; i < n + 1 && j < n ; ){
		if(a[i] <= b[j]){
			ans += a[i];
			b[j] -= a[i];
			j += (i - j == 1);
			++i;
		}else{
			ans += b[j];
			a[i] -= b[j];
			i += (i - j == 0);
			++j;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
B = list(map(int,input().split()))

ans = []
while(len(B) > 0):
  for i in range(len(B)):
    if B[i] > i+1:
      print(-1)
      exit()
    if B[i] == i+1:
      a = i+1
  ans.append(a)
  if a == 1:
    B = B[a:]
  elif a == len(B):
    B = B[:a-1]
  else:
    B = B[:a-1]+B[a:]
for i in range(len(ans)):
  print(ans[-i-1])


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

using namespace std;

int main() {
  long long A, B, K; cin >> A >> B >> K;
  long long takahashi = max((long long)0, A - K);
  long long aoki = max((long long)0, min(B, A + B - K));
  cout << takahashi << " " << aoki << endl;
}

Measured memory_bytes: 3608
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <memory.h>

// pi = atan(1)*4;

#define INTMAX 2100000000

using namespace std;

int main(void)
{
	int n, m;
	long long int t1, t2;
	vector <long long int> x, y, cx, cy;

	cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		cin >> t1 >> t2;
		x.push_back(t1);
		y.push_back(t2);
	}

	for (int i = 0; i < m; i++)
	{
		cin >> t1 >> t2;
		cx.push_back(t1);
		cy.push_back(t2);
	}

	for (int i = 0; i < n; i++)
	{
		long long int min = INTMAX;
		int res = -1;
		long long int dist;
		for (int j = 0; j < m; j++)
		{
			dist = abs(cx[j] - x[i]) + abs(cy[j] - y[i]);
			if (min > dist)
			{
				min = dist;
				res = j+1;
			}
		}
		cout << res << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define MSI map<string,int>
#define VI vector<int>
#define VII vector<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << ((a + b)*h) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
H , W = map(int,input().split())
N = int(input())

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

ans = [0] * (H * W)

index = 0

for color , a in enumerate(A) :
    for _ in range(a) :
        ans[index] = color + 1
        index += 1

for i in range(H) :
    sub = ans[i * W : (i + 1) * W]
    if i % 2 == 0 :
        for j in range(W) :
            print('{} '.format(sub[j]), end='')
    else :
        sub.reverse()
        for j in range(W) :
            print('{} '.format(sub[j]), end='')
    print('')


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int64 res = 0;
	REP(i, s.size()) {
	    res += (s[i] == t[i]);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int n,t[4],ans,a,b,m,c;
int main(){
  cin>>n;
  c=n;
  while(c)b+=c%10,c/=10;
  if(n%b==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}


typedef long long ll;

const int MAXN = 105;
const int MAXV = 100005;
const ll inf = 1e18;

ll DP[MAXN][MAXV];
int vs[MAXN];
ll wss[MAXN];

ll dp(int i, int v){
    if(i==0) return v==0 ? 0 : inf;
    if(DP[i][v] != -1) return DP[i][v];
    ll rta = dp(i-1, v);
    if(v >=vs[i]) rta = min(rta, wss[i]+dp(i-1, v-vs[i]));
    return DP[i][v] = rta;
}


int main(){
    memset(DP, -1, sizeof(DP));
    int n, w;
    cin>>n>>w;
    for(int i = 1; i<=n; ++i){
        cin>>wss[i];
        cin>>vs[i];
    }
    int rta = 0;
    for(int i = 0; i<MAXV; ++i){
        if(dp(n, i)<=w) rta = i;
    }
    cout<<rta<<"\n";
}



Measured memory_bytes: 85664
#include <iostream>
using namespace std;
int a[100005];
int main() {
	int n;
	cin >> n;
	int k = 1, ans = -1;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 2; i <= n; ++i) {
		if (a[i] > a[i - 1]) {
			ans = max(ans, k - 1);
			k = 0;
		}
		++k;
	}
	ans = max(ans, k - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(int)(n);i++)
using namespace std;
int main(){
 int N,M;
  cin>>N>>M;
  priority_queue<int> que;
  rep(i,N){
    int A;
    cin>>A;
  que.push(A);
  }
  rep(i,M){
    int b=que.top();que.pop();
    que.push(b/2);
  }
  long long ans=0;
  rep(i,N){
    ans+=que.top();que.pop();
}
  cout<<ans<<endl;
}

    
    

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;

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

  if ((n-1) % (k-1) > 0) {
    ans += (n-1) / (k-1) + 1;
  } else {
    ans += (n-1) / (k-1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
n=int(input())
s=input()
x=[0]
if s[0]=="#":
    x.append(1)
else:
    x.append(0)
for i in range(1,n):
    if s[i]=="#":
        x.append(x[-1]+1)
    else:
        x.append(x[-1])
y=[0]
if s[-1]==".":
    y.append(1)
else:
    y.append(0)
for i in range(2,n+1):
    if s[-i]==".":
        y.append(y[-1]+1)
    else:
        y.append(y[-1])
y=y[::-1]
z=[x[i]+y[i] for i in range(n+1)]
print(min(z))

Measured memory_bytes: 60692
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int i = 1;
        while(i <= n){
            if(checkNum(i)){ System.out.print(" " + i); }
            i++;
        }
        System.out.println();
    }
    public static boolean checkNum(int i){
        if(i % 3 == 0){ return true; }
        else{
            while(i > 0){
                if(i % 10 == 3){ return true; }
                i /= 10;
            }
        }
        return false;
    }
}


Measured memory_bytes: 28852
n,m,x=gets.split.map(&:to_i)
cas=n.times.map{gets.split.map(&:to_i)}
ans=Float::INFINITY
(2**n).times do |i|
  sums=Array.new(m+1,0)
  n.times do |j|
    if i[j]==1
      (m+1).times do |k|
        sums[k]+=cas[j][k]
      end
    end
  end

  if ans>sums[0] && sums[1..-1].all?{|v| v>=x}
    ans=sums[0]
  end
end

puts ans==Float::INFINITY ? -1:ans


Measured memory_bytes: 14404
import java.util.Scanner;

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

	private void start() {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		if(a < b && b < c){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
	}

}

Measured memory_bytes: 17300
import java.util.*;
public class Main {
	public static void main(String[] args){
		// get numbers
		Scanner sc = new Scanner(System.in);     
        int a = sc.nextInt();

        if (a >= 1200) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }

        sc.close();
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
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 int long long

void solve() {
    int l; cin >> l;
    int a[200200];
    int cost[200200][6], dp[200200][20];
    rep(i, l) {
        cin >> a[i];
        rep(j, 5) {
            if(j == 0 || j == 4) {
                cost[i][j] = a[i];
            } else if(j == 1 || j == 3) {
                if(a[i] == 0) cost[i][j] = 2;
                else if(a[i] % 2 == 1) cost[i][j] = 1;
                else cost[i][j] = 0;
            } else {
                if(a[i] % 2 == 1) cost[i][j] = 0;
                else cost[i][j] = 1;
            }
        }
    }
    rep(i, l + 1) {
        rep(j, 5) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(i, l) {
        rep(j, 5) {
            chmin(dp[i + 1][j], dp[i][j] + cost[i][j]);
            if(j + 1 <= 4) chmin(dp[i + 1][j + 1], dp[i][j] + cost[i][j + 1]);
            if(j + 2 <= 4) chmin(dp[i + 1][j + 2], dp[i][j] + cost[i][j + 2]);
            if(j + 3 <= 4) chmin(dp[i + 1][j + 3], dp[i][j] + cost[i][j + 3]);
        }
    }
    cout << min({dp[l][0], dp[l][1], dp[l][2], dp[l][3], dp[l][4]}) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 42496
//BINARY_BOY!!
//THINK TWICE CODE ONCE { TRUE }
// #####   ###  ##   #   ###   #####   #   #  #####	#####
// #    #   #   # #  #  #   #  #    #   # #   #	#	#	#	
// #####    #   #  # #  #####  #####     #    #####	#	#		
// #    #   #   #   ##  #   #  #   #     #    #	#	#	#
// #####   ###  #    #  #   #  #    #    #    #####	#####	
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 10000 + 5;
vector < pair < int  , pair < int , int > > > v ;
vector< int > v2 [ MAXN ];
int n , m, sum = 0, num [ MAXN ];
bool cmd(pair < int , pair<int , int> > p1 , pair < int , pair<int , int> > p2 )
{
	return p1.first < p2.first;
}
int main() {
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin >> n >> m;
	for(int i = 0 ; i < m ; i++)
	{
		int a , b, c;
		cin >> a >> b >> c;
		v.push_back(make_pair(c , make_pair(a , b)));
	}
	sort(v.begin() , v.end() , cmd);
	for(int i = 0 ; i <= n ; i++)
	{
		v2[ i ].push_back(i);
		num [ i ] = i;
	}
	for(int i = 0 , j = 0 ; i < v.size() && j < n - 1; i++)
	{
		if(num [ v [ i ].second.first ] != num [ v [ i ].second.second ] )
		{
			sum += v [ i ].first;
			j++;
			if(v2 [ num [v [ i ].second.first ]].size() <  v2 [num[ v [ i ].second.second ]].size())
			{
				for(int f = 0 , l = v2 [ num [v [ i ].second.first ] ].size() , k = num [v [ i ].second.first]; f < l ; f++)
				{
					v2 [ num [v [ i ].second.second ] ].push_back(v2 [ k ][ f ]);
					num [v2 [ k ][ f ]] = num [v [ i ].second.second];
				}
			}
			else {
				for(int f = 0 , l = v2 [ num [v [ i ].second.second ] ].size() , k = num [v [ i ].second.second] ; f < l ; f++)
				{
					v2 [ num [v [ i ].second.first] ].push_back(v2 [ k ][ f ]);
					num [v2 [ k ][ f ]] = num [v [ i ].second.first];
				}
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x==500*i+100*j+50*k) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)



int main() {
	int n;
	cin >> n;
	int x = (int)(n / 100);
	int sa = n - (x * 100);
	if (x * 5 >= sa) cout << 1;
	else cout << 0;
}


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

class Solve {
private:
	using vpi = std::vector<std::pair<int, int64_t>>;
	using i3 = std::array<int, 3>;
	using vi64 = std::vector<int64_t>;

	int n, k, s;
	std::vector<i3> box;
	std::vector<vpi> edge;
	std::vector<bool> visited;

	bool areAdjacent(int a, int b)
	{
		for (int i{}; i < 3; i++)
			if (std::abs(box[a][i] - box[b][i]) >= s)
				return false;
		return true;
	}

	int64_t calcWeight(int a, int b)
	{
		int64_t sum{};
		for (int i{}; i < 3; i++)
			sum += 2 * (s - std::abs(box[a][i] - box[b][i])) * (s - std::abs(box[a][(i + 1) % 3] - box[b][(i + 1) % 3]));
		return sum;
	}

	void makeLine(int index, vi64& table)
	{
		visited[index] = true;
		for (auto& e: edge[index])
			if (!visited[e.first])
			{
				table.push_back(e.second + table.back());
				makeLine(e.first, table);
			}
	}

	void makeCircle(int index, int begin, int prev, vi64& table)
	{
		visited[index] = true;
		for (auto& e: edge[index])
			if (!visited[e.first] || (prev != begin && e.first == begin))
			{
				table.push_back(e.second + table.back());
				makeCircle(e.first, begin, index, table);
			}
	}

public:
	bool is_last_query{};
	Solve()
	{
		scanf("%d%d%d", &n, &k, &s);
		if (n == 0)
		{
			is_last_query = true;
			return;
		}
		box.resize(n);
		for (auto& e: box)
			for (auto& f: e)
				scanf("%d", &f);
		
		edge.resize(n);
		for (int i{}; i < n; i++)
			for (int j{i + 1}; j < n; j++)
				if (areAdjacent(i, j))
				{
					int64_t weight{calcWeight(i, j)};
					edge[i].push_back({j, weight});
					edge[j].push_back({i, weight});
				}
		
		visited.resize(n);
		int64_t max{-1};
		for (int i{}; i < n; i++)
		{
			if (visited[i] || edge[i].size() == 2) continue;
			vi64 table(1);
			makeLine(i, table);
			for (int j{k - 1}; j < (int)table.size(); j++)
				max = std::max(max, table[j] - table[j - (k - 1)]);
		}
		for (int i{}; i < n; i++)
		{
			if (visited[i]) continue;
			vi64 table(1);
			makeCircle(i, i, -1, table);
			if (table.size() < k) continue;
			if (table.size() == k + 1)
				max = std::max(max, table.back());
			else
			{
				int size{(int)table.size()};
				for (int i{1}; i < size; i++)
					table.push_back(table[size - 1] + table[i]);
				for (int j{k - 1}; j < (int)table.size(); j++)
					max = std::max(max, table[j] - table[j - (k - 1)]);
			}
		}
		if (max == -1) puts("-1");
		else printf("%lld\n", (int64_t)6 * s * s * k - max);
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3272
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

public class Main {
    
    static final String rightkeys = "yuiophjklnm";
    static int cnt = 0;
    static List<String> hands = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine().trim()) != null && !"#".equals(line)) {
            output(line);
            clear();
        }
    }

    public static void output(String line) {
        IntStream.range(0, line.length()).mapToObj(i->line.substring(i,i+1)).forEach(key -> {
            if(rightkeys.indexOf(key) != -1) {
                hands.add("r");
            } else {
                hands.add("l");
            };
        });
        IntStream.range(0, hands.size()).filter(i->0<i).forEach(i -> {
            if(!hands.get(i-1).equals(hands.get(i))) cnt++;
        });
        System.out.println(cnt);
    }

    public static void clear() {
        hands.clear();
        cnt = 0;
    }
}


Measured memory_bytes: 31632
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn main() {
    let n: usize;
    input!(n);
    println!("ABC{:<03}", n);
}

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

int main() {
	int n;
	scanf("%d",&n);
	char s[n+5],t[n+5];
	scanf("%s%s",s,t);
	for(int i=0;i<n;i++){
		printf("%c%c",s[i],t[i]);
	}
}


Measured memory_bytes: 256
n, m = map(int, input().split())

results = {}

for i in range(m):
    line = input().split()
    
    if not line[0] in results:
        results[line[0]] = [0, 0]
    elif results[line[0]][1] == 1:
        continue
    
    if line[1] == "WA":
        results[line[0]][0] += 1
    elif line[1] == "AC":
        results[line[0]][1] = 1

ac_num = 0
wa_in_ac = 0

for key in results:
    if results[key][1] == 1:
        ac_num += 1
        wa_in_ac += results[key][0]

print(ac_num, wa_in_ac)

Measured memory_bytes: 25292
n,x,y=map(int,input().split())
ans = [0] * n
for i in range(n-1):
    for j in range(i+1,n):
        z = min(j-i,abs(i-x+1)+1+abs(j-y+1),abs(i-y+1)+1+abs(j-x+1))
        ans[z] += 1

for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 9152
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> s;
	rep(i, 3) {
		if (s[i] == 'o')cnt += 100;
	}
	cout << cnt + 700 << rt;
	please AC;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// input
uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

// dijkstra
template<typename T, int MAXN>
struct dijkstra {
  struct edge {
    T cost; int to; 
    edge(T const& c, int id): cost(c), to(id){}
  };
  typedef std::pair<T, int> GP; // dist, id
  std::vector<edge> G[MAXN];
  T d[MAXN], INF_;
  int N_;
  dijkstra(int N, T inf) : N_(N), INF_(inf) {}
  void search(int s) {
    std::priority_queue<GP, std::vector<GP>, std::greater<GP>> q;
    std::fill_n(d, N_, INF_);
    d[s] = 0;
    q.push(GP(0, s));
    while(!q.empty()) {
      GP p = q.top(); q.pop();
      int v = p.second;
      if(d[v] < p.first) continue;
      for(auto e: G[v]) {
        T newd = d[v]+e.cost;
        if(newd >= d[e.to]) continue;
        if(newd >= INF_) continue;
        d[e.to] = newd;
        q.push(GP(d[e.to], e.to));
      }
    }
  }
};

int const MAXN = 50;
int const MAXM = 100;
int const MAXA = 50;
int const MAXS = (MAXN-1)*MAXA;
int64_t const INF = 1e18;
int N, M, S, U[MAXM], V[MAXM], A[MAXM];
int64_t B[MAXM];

int main() {
  std::cin >> N >> M >> S;
  int maxa = 0, maxs;
  for(int i = 0; i < M; ++i) {
    std::cin >> U[i] >> V[i] >> A[i] >> B[i]; --U[i]; --V[i];
    maxa = std::max(maxa, A[i]);
  }
  maxs = maxa*(N-1);
  dijkstra<int64_t, (MAXS+1)*MAXN> dj(N*(maxs+1), INF);
  for(int i = 0; i < M; ++i) {
    // add train edge; (U,S)->(V,S-A) and (V,S)->(U,S-A) cost B
    for(int s = A[i]; s <= maxs; ++s) {
      dj.G[s*N+U[i]].emplace_back((int64_t)B[i], (s-A[i])*N+V[i]);
      dj.G[s*N+V[i]].emplace_back((int64_t)B[i], (s-A[i])*N+U[i]);
    }
  }
  for(int i = 0; i < N; ++i) {
    // add exchange edge; (i,S)->(i,min(S+C, maxs)) cost D
    int C, D; std::cin >> C >> D;
    for(int s = 0; s < maxs; ++s) {
      dj.G[s*N+i].emplace_back((int64_t)D, std::min(maxs, s+C)*N+i);
    }
  }
  dj.search(std::min(maxs, S)*N);
  for(int i = 1; i < N; ++i) {
    int64_t ans = INF;
    for(int s = 0; s <= maxs; ++s) ans = std::min(ans, dj.d[i+N*s]);
    std::cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 23340
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] ps = new int[n][d];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < d; j++){
				ps[i][j] = sc.nextInt();
			}
		}
		int res = 0;
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				if(calc(ps, n, d, i, j)) {
					res++;
				}
			}
		}
		System.out.println(res);
	}
	static boolean calc(int[][] ps, int n, int d, int i, int j){
		int s = 0;
		for(int k = 0; k < d; k++){
			s += (ps[i][k] - ps[j][k])*(ps[i][k] - ps[j][k]);
		}
		int sq = (int)Math.sqrt(s);
		return sq*sq == s;
	}

}


Measured memory_bytes: 23252
var n, x;

function main(){
	while(n = scan()){
		x = scan();
		var ans = 0;
		rep(1, n + 1, function(i){
			rep(i + 1, n + 1, function(j){
				var k = x - i - j;
				if(j < k && k <= n){
					++ans;
				}
			});	
		});
		print(ans);
	}
}

function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}

var input = '';

function scan(){
	return +input.pop();
}
function scan_string(){
	return input.pop();
} 
function print(val){
	console.log(val);
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/).reverse();
	main();
});

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

int main() {
    int N;
    cin >> N;
    N %= 1000;
    if(N == 0) N = 1000;
    cout << 1000 - N << endl;
}

Measured memory_bytes: 3628