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

int main() {
    int N, A, W, T, R;
    cin >> N;
    A = 0;
    W = 0;
    T = 0;
    R = 0;
    string S;
    
    for (int i = 0; i < N; i++) {
        cin >> S;
        if (S == "AC") {
            A++;
        }
        else if (S == "WA") {
            W++;
        }
        else if (S == "TLE") {
            T++;
        }
        else {
            R++;
        }
    }

    cout << "AC x " << A << endl;
    cout << "WA x " << W << endl;
    cout << "TLE x " << T << endl;
    cout << "RE x " << R << endl;
}

Measured memory_bytes: 3632
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

map<lf,int> is;
int n;
int cnt[33][33];

ll gcd(ll a,ll b){
	return !b?a:gcd(b,a%b);
}

int main(){
	scanf("%d",&n);
	ll res=0;
	cont(i,n){
		lf a;scanf("%Lf",&a);
		ll A,B;A=a*1000000000+1e-5;B=1000000000+1e-5;
		ll C=gcd(A,B);A/=C;B/=C;
		int s2=0,s5=0;
		while(A%2==0)s2++,A/=2;
		while(A%5==0)s5++,A/=5;
		while(B%2==0)s2--,B/=2;
		while(B%5==0)s5--,B/=5;
		s2+=15;s5+=15;
		s2=min(s2,30);s5=min(s5,30);
		loop(i,s2+1)loop(j,s5+1)res+=cnt[i][j];
		cnt[30-s2][30-s5]++;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3820
def main():
    n = int(input())
    matrix = []
    matrix.append([int(num) for num in input().split()])
    matrix.append([int(num) for num in input().split()])
    # RE:  matrix = [int(num) for num in (input().split() for i in range(2))]

    candies = [sum(matrix[0][:d+1]) + sum(matrix[1][d:]) for d in range(n)]
    print(max(candies))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	vector<ll> ra(n + 1, 0), rb(m + 1, 0);
	rep(i, n) ra[i + 1] = a[i] + ra[i];
	rep(i, m) rb[i + 1] = b[i] + rb[i];
	int ans = 0;
	rep(i, n + 1)
	{
		ll temp = k - ra[i];
		if (temp < 0)
			continue;
		int j = upper_bound(all(rb), temp) - rb.begin() - 1;
		ans = max(ans, i + j);
	}
	cout << ans << endl;
}

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

typedef long long ll;
ll MOD = 1000000007;

vector <int> to[200005];
vector <int> ans;

void dfs (int v, int p = -1) {
    for (int u = 0; u < int(to[v].size()); u++) {
        int x = to[v][u];
        if (x == p) continue;
        ans[x] += ans[v];
        dfs(x, v);
    }
}

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

    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
    return 0;  
}


Measured memory_bytes: 29696
n = input()
A = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
#a = [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]
if n in A:
    print('A')
else:
    print('a')

Measured memory_bytes: 9116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class296
    {
        static void Main()
        {
            string s = Console.ReadLine();
            int t = 0;
            int[] nums = new int[2019];
            nums[0]++;

            for(int i = s.Length - 1; i >= 0; i--)
            {
                t = (t +  (s[i]-'0')*ModPow(10, s.Length - i-1, 2019)) % 2019;
                nums[t]++;
            }

            long ans = 0;
            for (int i = 0; i < 2019; i++)
                ans += nums[i] * (nums[i] - 1) / 2;

            Console.WriteLine(ans);
        }
        public static int ModPow(int x, int n, int mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) > 0) res = res * x % mod;
                x = x * x % mod;
                n >>= 1;
            }
            return (int)res;
        }
    }
}


Measured memory_bytes: 26516
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,A;
    cin >> N >> A;
    int B=A*2+1;
    if(N%B==0)
    {
        cout << N/B <<endl;
    }
    else
    {
        cout << N/B+1 <<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 101
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> d(N);
  d[a]++;
  d[b]++;
  d[c]++;
  cout << N-count(d.begin(),d.end(),0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String first_input[] = br.readLine().split("\\s+");

			int N = Integer.parseInt(first_input[0]);
			int quantum = Integer.parseInt(first_input[1]);

			Queue<Process> Q = new ArrayDeque<Process>();

			for(int loop = 0; loop < N; loop++){
				String input[] = br.readLine().split("\\s+");
				Q.add(new Process(input[0],Integer.parseInt(input[1])));
			}

			StringBuilder ans = new StringBuilder();
			Process tmp = new Process();

			int current_time = 0;

			while(!Q.isEmpty()){
				tmp = Q.peek();
				Q.poll();

				if(tmp.getTime() <= quantum){
					current_time += tmp.getTime();
					ans.append(tmp.getName()).append(" ").append(Integer.toString(current_time)).append("\n");
				}else{
					current_time += quantum;
					Q.add(new Process(tmp.getName(),tmp.getTime()-quantum));
				}
			}

			System.out.printf("%s",ans.toString());

		}catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Process{

	private String name;
	private int time;

	Process(){
		//Do nothing
	}

	Process(String arg_name,int arg_time){
		name = arg_name;
		time = arg_time;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getTime() {
		return time;
	}
	public void setTime(int time) {
		this.time = time;
	}
}


Measured memory_bytes: 71804
<?php

fscanf(STDIN, "%d", $n);

$total_count = 0;
for ($i = 1; $i <= $n; $i += 2) {
    $count = 0;
    for ($j = 1; $j <= $i; ++$j) {
        if ($i % $j === 0) {
            ++$count;
        }
    }

    if ($count === 8) {
        ++$total_count;
    }
}

echo $total_count;


Measured memory_bytes: 4728
#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>;

int main() {
  int n, a;
  cin >> n;
  int cnt = 0, now = 1;
  rep(i, n) {
    cin >> a;
    if (now == a) {
      now++;
    } else {
      cnt++;
    }
  }
  if (cnt == n) {
    cout << "-1" << endl;
  } else {
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
const int maxn=100005;
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    int n;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        if(111*i>=n)
        {
            cout<<111*i<<endl;
            return 0;
        }
    }

}


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

int main() {
    double n, sum = 0;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    
    int fac = 1;
    for (int i = 2; i <= n; i++)
    {
        fac *= i;
    }
    
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            double X, Y;
            X = pow(x[i] - x[j], 2.0);
            Y = pow(y[i] - y[j], 2.0);
            sum += sqrt(X + Y) * (fac * 2.0 / n);
        }
        
    }
    cout << fixed << setprecision(10);
    cout << sum / fac << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.println(Math.min(b / a, c));
  }
}

Measured memory_bytes: 21460
#include <iostream>

int main() {
    int a = 0;
    std::cin >> a;
    std::string jg[4] = {"AC", "WA", "TLE", "RE"};
    std::string tmp;
    int jgc[4] = {0, 0, 0, 0};

    for (int i = 0; i < a; ++i) {
        std::cin >> tmp;
        if (tmp == jg[0]) {
            ++jgc[0];
        } else if (tmp == jg[1]) {
            ++jgc[1];
        } else if (tmp == jg[2]) {
            ++jgc[2];
        } else if (tmp == jg[3]) {
            ++jgc[3];
        }
    }

    for (int j = 0; j < 4; ++j) {
        std::cout << jg[j] << " x " << jgc[j] << std::endl;
    }

    return 0;
}

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

int main(){
        ll n; scanf("%lld", &n);
        if(n%2){
                puts("0");
                return 0;
        }

        ll cnt=0, fi=1;
        for(ll i=1; fi<=n; i++){
                fi *= 5;
                cnt += n/fi/2;
        }
        printf("%lld\n", cnt);
        return 0;
}

Measured memory_bytes: 256
S = input()

if len(S) > 9:
    print("NO")
    exit()
if not (S.count("K") == 1 and S.count("I") == 1 and S.count("H") == 1 and S.count("B") == 1 and S.count("R") == 1):
    print("NO")
    exit()
if "AA" in S or "KA" in S or "IA" in S:
    print("NO")
    exit()
S = S.replace("A", "")
if not S == "KIHBR":
    print("NO")
    exit()
print("YES")


Measured memory_bytes: 3064
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let B = read::<i32>();
    let C = read::<i32>();

    /* Aの倍数の和 をBで割った余りが C */
    let rem = A % B;
    let mut boolean = false;
    for n in 0..B {
        if C == (rem*n) % B {
            boolean = true;
        }
    }
    if boolean {
        println!("YES");
    } else {
        println!("NO");
    }

}


Measured memory_bytes: 4352
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 5e5 + 10;
char s[maxn];

int n;

int read() {
  if (scanf("%s", s) < 1) {
    return 0;
  }
  return 1;
}

int a[maxn];

void solve() {
  int n = (int) strlen(s);
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
  }
  reverse(a, a + n);
  
  for (int i = 0; i < n; ++i) {
    a[i] *= 9;
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] >= 10) {
      int k = a[i] / 10;
      a[i] %= 10;
      if (i + 1 == n) {
        a[n++] = k;
      } else {
        a[i + 1] += k;
      }
    }
  }

  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
  }

  for (int res = 0;; ++res) {
    /*eprintf("res = %d (sum=%d): ", res, sum);
    for (int i = 0; i < n; ++i) {
      assert(0 <= a[i] && a[i] < 10);
      eprintf("%d", a[i]);
    }
    eprintf("\n");
    */
    if (res >= sum && a[0] == 0) {
      printf("%d\n", (res + 8) / 9);
      return;
    }

    ++sum;
    a[0] += 1;
    for (int i = 0; i < n && a[i] >= 10; ++i) {
      a[i] -= 10;
      sum -= 10;
      ++sum;
      if (i + 1 == n) {
        a[n++] = 1;
        break;
      }
      a[i + 1] += 1;
    }
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2688
/*-- ILSH  --*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double ld;

#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll > 
#define pii pair< ll, ll > 
#define len length 
#define fi first
#define se second
#define dt cout<<"HEre\n";
#define sz(x) (ll)x.size()
const ll inf=1e18+1e17;
const ll mod = 1e9+7;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
const ll N=2e5+5;

void solve(){
	string s;
	cin>>s;
	ll arr[(ll)( s.len())];
	for ( ll i=0;i<s.len();i++){
		arr[i]=s[i]-'0';
	}
	ll ans=0;
	for ( ll i=0;i<(1<<(s.len()-1));i++){
		ll tot=arr[0],j=0,kal=0;
		while ( j<(s.len()-1)){
			if ( (i&(1<<j))==0)
				tot=tot*10+arr[j+1];
			else{
				kal=kal+tot;
				tot=arr[j+1];
			}
			j++;
		}
		kal=kal+tot;
		ans+=kal;
	}
	cout<<ans<<'\n';



}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
//	cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
    //	cout << clock() / double(CLOCKS_PER_SEC) << endl;
}


Measured memory_bytes: 3616
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;

int n;
int main(){
      string s;
      cin>>s;
      ll ans=0;
      ll cntw=0;
      rep0(i,s.size()){
            if(s[i]=='W'){
                  cntw++;
                  ans+=i;
            }
      }
      cout<<ans-(cntw*(cntw-1))/2<<endl;
      return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    set<int> s(all(a));
    cout << s.size() << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        int K=sc.nextInt();

        int max=0;
        int end1=0;
        int end2=0;

        if(A>=K){
            max=K;
            System.out.println(max);
        }else{
            max=max+A;
            end1=K-A;

            if(B>=end1){
                System.out.println(max);
            }else{
                end2=end1-B;

                if(C>=end2){
                    max=max-end2;
                    System.out.println(max);
                }else{
                    max=max-C;
                    System.out.println(max);
                }
            }
        }

        //END
    }
}


Measured memory_bytes: 35728
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,k,a[N];
int get(int x) {
	return a[x+k-1]-a[x]+min(abs(a[x+k-1]),abs(a[x]));
}
int main() {
	int re=1e9;
	cin>>n>>k;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<=n-k+1;++i) re=min(re,get(i));
	cout<<re;
}

Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n=in.nextInt();
        int a=n-1,b=1;
        int ans=(int)1e9;
        while(a>=b){
            ans=Math.min(dif(a)+dif(b),ans);
            a--;
            b++;
        }
        System.out.println(ans);
    }
    static int dif(int a){
        int ans=0;
        while(a>0){
            int x=a%10;
            ans+=x;
            a=a/10;
        }
        return ans;
    }
}






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

int main()
{
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int res = 1, l = 0, r = 1, t = (s[0] == '1') ? 0 : 1;
	while (r < n) {
		if (s[r - 1] == '1' && s[r] == '0') {
			t++;
			if (t > k) {
				while (1) {
					l++;
					if (s[l - 1] == '0' && s[l] == '1') break;
				}
				t--;
			}
		}
		res = max(res, r - l + 1);
		r++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#define max(A,B) (A>B?A:B)
int l,a,b,c,d;
main(){scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);printf("%d\n",l-max(a/c+!!(a%c),b/d+!!(b%d)));return 0;}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(void) {
	
	int X, N;
	scanf("%d %d", &X, &N);
	int* p = new int[N];


	if (N != 0)// 0이면 입력을 안 받아
	{
		for (int i = 0; i < N; i++) {
			scanf("%d", &p[i]);
		}
	}

	bool okay = false;
	int test[2];
	int answer;
	int count = 0;
	while (!okay) {
		//빼기 먼저
		test[0] = X + count; // X 자체도 답이 될 수 있어 -> count = 0; -> 더하기
		test[1] = X - count; // 빼기
		if (N == 0) {
			answer = X;
			okay = true;
		}
		else // test_m과 test_p가 sequence에 있는지 확인
		{
			bool exist[2] = { false, false };
			for (int i = 0; i < N; i++) {
				if (exist[0] == false && test[0] == p[i]) { // 있으면 넘어가야지
					exist[0] = true;
				}
				if (exist[1] == false && test[1] == p[i]) {
					exist[1] = true;
				}
			}
			if (!exist[0]) // 없어
			{
				answer = test[0];
				okay = true;
			}
			if (!exist[1])
			{
				answer = test[1];
				okay = true;
			}
		}
		count++;
	}
	printf("%d", answer);
	delete p;

	


	return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long 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; }

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 210000;
int N;
ll A[Max], B[Max];
pair<ll, ll> BA[Max];

int main(int argc, const char * argv[]) {
    cin >> N;
    rep(i, N) {
        cin >> A[i] >> B[i];
        BA[i] = make_pair(B[i], -A[i]);
    }

    sort(BA, BA+N);

    string ans = "Yes";
    ll time = 0;
    rep(i, N) {
        auto& ba = BA[i];
        time += -ba.second;
        if (time > ba.first) {
            ans = "No";
            break;
        }
    }

    output(ans);

    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

bool bsort(vector<int> g,int r){
   int right = g.size()-1,left=0;
   if(g[left]==r || g[right] == r) return true;
   while(right-left > 1){
      int mid = (left + right)/2;
      if(g[mid] == r) return true;
      if(g[mid] > r) right = mid;
      else left = mid;
   }
   return false;
}

int main(){
   int n,q,cnt = 0;
   cin >> n;
   vector<int> s;
   for(int i=0;i<n;i++){
      int a;
      cin >>a; 
      s.push_back(a);
   }
   
   cin >> q;
   for(int i=0;i<q;i++){
      int a;
      cin >> a;
      if(bsort(s,a)) cnt ++;
   }

   cout << cnt << endl;
   return 0;
}



Measured memory_bytes: 3680
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,X,T;
  cin>>N>>X>>T;
  cout<<((N+X-1)/X)*T<<endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
//import static java.lang.System.*;
import java.io.*;

public class Main {
    //???????????§??????    
    public static void main (String[] args) {
		
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        
        // ??°??????????¶???????????????§
        while(true){
            
            int n = sc.nextInt();
            // 0?????\?????????????????????????????????????????????
            if(n==0){
                System.exit(0);
            }
            // ??????????????°???????????°????????????????´??????????
            int[] point =  new int[n];
            for(int i=0; i<n; i++){
                point[i] = sc.nextInt();    
            }
            Arrays.sort(point);
            
            // ?????§??¨????°???\???????????°???????¨??????????
            int sum = 0;
            for (int j=1; j<n-1; j++){
                sum += point[j];
            }
            
            // ?????§??¨????°?????????°???????????????????????????????????????????????????????????????
            int average = sum / (n-2);
            System.out.println(average);
        }
    }
}

Measured memory_bytes: 29292
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		T operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	rep(const T first, const T last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(f); }
	itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		T operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	revrep(const T first, const T last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(l - 1); }
	itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool maxi(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool mini(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool smaxi(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool smini(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }



#include <algorithm>
#include <iostream>
#include <utility>
#include <array>
#include <numeric>

int main() {
	usize n;
	::std::cin >> n;
	::std::vector<u32> a(n), b(n), c;
	for (const auto i : rep<>(0, n))
		::std::cin >> a[i] >> b[i];

	c.insert(c.cend(), a.cbegin(), a.cend());
	c.insert(c.cend(), b.cbegin(), b.cend());
	::std::sort(c.begin(), c.end());

	usize s, l;
	const usize mid = c.size() / 2;
	for (const auto i : rep<>(0, n)) {
		if (a[i] == c[mid - 1] || b[i] == c[mid - 1])
			s = i;
		if (a[i] == c[mid] || b[i] == c[mid])
			l = i;
	}
	const u64 sum =
		::std::accumulate(c.cbegin(), c.cbegin() + mid, u64(0));

	::std::array<usize, 4> cnt = {};

	for (const auto i : rep<>(0, n)) {
		++cnt[(a[i] > c[mid-1]) << 1 | (b[i] > c[mid-1])];
	}

	if (cnt[0] || !cnt[1] || !cnt[2])
		::std::cout << sum << ::std::endl;
	else if (s != l)
		::std::cout << sum + c[mid] - c[mid - 1] << ::std::endl;
	else
		::std::cout << sum + ::std::min(c[mid + 1] - c[mid - 1], c[mid] - c[mid - 2]) << ::std::endl;

	return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    set<int> c;
    irep(i, 3) {
        int tmp;
        cin >> tmp;
        c.insert(tmp);
    }
    cout  << c.size() << endl;
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
H = list(map(int, input().split()))
max_n = H[0]; f = True;
for n in range(1, N):
    if max_n - H[n] >= 2:
        f = False
        break;
    elif max_n < H[n]:
        max_n = H[n]

if f: print ("Yes")
else: print ("No")


Measured memory_bytes: 14252
#include<bits/stdc++.h> 
	using namespace std; 
	#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"

	void inputoutput()
	{
	    ios_base::sync_with_stdio(0);
	    cin.tie(0); 
	    #ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	    #endif
	    
	}

	int32_t main()
	{
	    inputoutput();
	   
	   	int x;
	   	cin>>x;
	   	if(x)
	   		cout<<0;
	   	else
	   		cout<<1;
	    

	    return 0;
	}




Measured memory_bytes: 3608
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, _ := sc.nextInt(), sc.nextInt()
	S := make([]string, N)
	for i := 0; i < N; i++ {
		S[i] = sc.nextStr()
	}
	sort.Strings(S)

	for i := 0; i < N; i++ {
		fmt.Fprint(wtr, S[i])
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}


Measured memory_bytes: 640
s=input()
n=len(s)
a=[0]*(n+1)
for i in range(n):
    if s[i]=="<":
        a[i+1]=a[i]+1
for i in reversed(range(n)):
    if s[i]==">":
        a[i]=max(a[i+1]+1,a[i])
print(sum(a)) 

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

using namespace std;

int hday[1000][11][21]={};

int main(){
  int cnt=0;
  for(int i=1;i<1000;++i){
    for(int j=1;j<=10;++j){
      for(int k=1;k<=20;++k){
	if(i%3 && j%2==0 && k>19) break;
	hday[i][j][k]=cnt;
	cnt++;
      }
    }
  }
  
  int n; cin >>n;
  int y,m,d;
  for(int i=0;i<n;++i){
    cin>>y>>m>>d;
    cout << cnt - hday[y][m][d] << endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 3940
#include<iostream>
#include<string>
using namespace std;
#define MAX 1100
#define INF ((int)1e9+9)

int main(){
	int A[MAX],temp[MAX], n, q, b, e, m, t;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>A[i];
	}
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>b>>e>>t;
		for(int j = 0; j < e-b; j++){
			swap(A[j+b], A[j+t]);
		}
	}

	for(int i = 0; i < n; i++){
		cout<<(i?" ":"")<<A[i];
	}
	cout<<endl;
	
	return 0;
}


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

using namespace std;

int main() {
	int n,temp,sum;
	
	while(scanf("%d",&n))
	{
		if(n==0)
		break;
		sum = 0;
		for(int i=0;i<n/4;i++)
		{
			scanf("%d",&temp);
			sum+=temp;
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 3128
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll K;
    cin >> K;
    vector<ll> Ais(K);
    rep(i,0,K) {
        cin >> Ais[i];
    }
    ll start = 2;
    ll last = 2;
    rrep(i,K,0) {
        ll Ai = Ais[i];
        start = (start / Ai + (start % Ai != 0)) * Ai;
        last = (last / Ai) * Ai + (Ai - 1);
        if (last < start) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << start << " " << last << endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
 #define ll long long int
 using namespace std;
 int main()
 {
    ll n,m;
    ll p=1000000007;
    cin>>n>>m;
    char a[n][m];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    if(a[0][0]=='#')
    {
        cout<<"0\n";
        return 0;
    }
    ll dp[n+1][m+1];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='.')
                dp[i+1][j+1]=0;
            else
                dp[i+1][j+1]=-1;
        }
    }
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(a[i][0]=='.'&&f==0)
            dp[i+1][1]=1;
        else
            {
                f=1;
                dp[i+1][1]=-1;
            }
    }
    f=0;
    for(int i=0;i<m;i++)
    {
        if(a[0][i]=='.'&&f==0)
            dp[1][i+1]=1;
        else
            {
                f=1;
                dp[1][i+1]=-1;
            }
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=2;j<=m;j++)
        {
            if(dp[i][j]==0)
            {
                if(dp[i-1][j]>=0)
                    dp[i][j]=dp[i][j]+dp[i-1][j];
                if(dp[i][j-1]>=0)
                    dp[i][j]=dp[i][j]+dp[i][j-1];
                dp[i][j]=dp[i][j]%p;
            }
        }
    }
    if(dp[n][m]<=0)
        cout<<"0\n";
    else
        cout<<dp[n][m]%p<<endl;
 }

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

using namespace std;

const int N = 2e5 + 5, INF = 1e9 + 5;

int dp[3][N];

int main(){
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		int a, b, c;	cin >> a >> b >> c;
		dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a;
		dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b;
		dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c;
	}
	cout << max({dp[0][n], dp[1][n], dp[2][n]}) << "\n";
}


Measured memory_bytes: 4772
#include <stdio.h>

int main(void){
  int N, p, sum=0, max=0;
  int i;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&p);
    sum+=p;
    if(p>max) max=p;
  }
  printf("%d\n",sum-max/2);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	string s;
	cin >> s;
	SORT(s);
	YesNo(s == "abc");
}



Measured memory_bytes: 3080
N=gets.to_i
ls=Array.new
N.times do |i|
  a,b=gets.split
  a=a.chomp
  b=b.to_i
  ls << [a,b,i+1]
end
ls.sort_by{|e,f|[e,N-f]}.each do |e,f,g|
  puts g
end


Measured memory_bytes: 1788
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int length = str.length();
		System.out.println(str.substring(0,1) + "" + (length - 2) + "" + str.substring(length - 1, length));
		
	}
}

Measured memory_bytes: 22484
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")


def solve(N: int, a: "List[int]"):
    counter = Counter(a)

    ans = 0
    for key in counter:
        if counter[key] < key:
            ans += counter[key]
        else:
            ans += counter[key]-key
    print(ans)
    return


a = []
for i in range(1, 10):
    a.extend([i]*3)

counter = Counter(a)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24244
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
	int n;cin>>n;
	vector<ll> a(n+1);
	vector<ll> b(n);
	rep(i,n+1) cin>>a[i];
	rep(i,n) cin>>b[i];

	ll ans = 0;

	for (int i = 0; i < n; ++i) {
		int B=b[i];
		ans+=min(a[i],b[i]);
		b[i]=max(b[i]-a[i],0ll);
		a[i]=max(a[i]-B,0ll);
		if (b[i]>0) {
			ans+=min(a[i+1],b[i]);
			a[i+1]=max(a[i+1]-b[i],0ll);
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
	ll H,W,M;cin >> H >> W >> M;
	vector<ll> row(H),col(W);
	set<P> s;
	rep(i,M){
		ll r,c;cin >> r >> c;
		--r;--c;
		row[r]++;
		col[c]++;
		s.insert({r,c});
	}
	ll mrow = 0;
	ll mcol = 0;
	rep(i,H) mrow = max(mrow,row.at(i));
	rep(i,W) mcol = max(mcol,col.at(i));

	vector<ll> is,js;
	rep(i,H) if( mrow == row.at(i) ) is.push_back(i);
	rep(i,W) if( mcol == col.at(i) ) js.push_back(i);

	ll ans = mrow + mcol;
	for(ll i : is ){
		for(ll j : js ){
			// i,jが重ならない(=ansがそのまま)のパターンを探す
			if( s.find({i,j}) != s.end() ) continue;
			cout << ans <<  endl;
			return 0;
		}
	}
	cout << --ans << endl;
}

Measured memory_bytes: 35084
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- replicateM n readLn :: IO [Int]
  print $ solve ns

solve :: [Int] -> Int
solve = length .
        filter ((/= 0) . (`mod` 2) . length) .
        group . sort


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

using namespace std;

int num[9] = {5,3,3,3,3,3,4,3,4};
char one[5] = {'\'', ',', '.', '!', '?'};
char lower[8] = {'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'};
char upper[8] = {'A', 'D', 'G', 'J', 'M', 'P', 'T', 'W'};
int main(){
    string str;
    while(cin >> str){
        char tmp=-1;
        int cnt = 0;
        for(int i=0;i<str.size()+1;i++){
            if(i != str.size() && (tmp == -1 || tmp == str[i])){
                tmp = str[i];
                cnt++;
            }else{
                int div,index;
                if(tmp != '0'){
                    div = (cnt-1)/num[tmp-'1'];
                    index = (cnt-1)%num[tmp-'1'];
                }
                if(tmp == '1'){
                    cout << one[index];
                }else if('2' <= tmp && tmp <= '9'){
                    if(div % 2){
                        cout << (char)(upper[tmp - '2'] + index);
                    }else{
                        cout << (char)(lower[tmp - '2'] + index);
                    }
                }else{
                    for(int j=0;j<cnt-1;j++){
                        cout << " ";
                    }
                }
                tmp = str[i];
                cnt = 1;
            }
        }
        cout << endl;
    }
} 

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  vector<P> a(n), b(n);
  rep(i, n) cin >> a[i].first >> a[i].second;
  rep(i, n) cin >> b[i].first >> b[i].second;
  sort(ALL(a));
  sort(ALL(b));
  int ans = 0;
  rep(i, n){
    int maxv = -1, num = -1;
    rep(j, a.size()){
      if (a[j].first < b[i].first && a[j].second < b[i].second){
        if (a[j].second > maxv){
          num = j;
          maxv = a[j].second;
        }
      }
    }
    if (maxv != -1){
      a.erase(a.begin() + num);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int main(){
	ll A, B, N; cin >> A >> B >> N;
	if(N < B){
		ll x = A*N/B;
		cout << x << endl;
	}else{
		ll x = A*(B-1)/B;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3584