akhauriyash/Code-Regression huggingface dataset:
/*
g++ -std=c++14 -o2 -Wall ABC120A.cpp -o .\out\ABC120A.out
.\out\ABC120A.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  int ans = min(b / a, c);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

bool tbl[1000000];
int d[100000];

int pow10(int a) {
    if(!a) return 1;
    return 10 * pow10(a-1);
}
int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&d[i]);
    for(int k=0; ; k++) { // k+1 digits
        for(int i=0; i+k<n; i++) {
            int t=0;
            for(int j=i; j-i<=k; j++) {
                t*=10;
                t+=d[j];
            }
            tbl[t] = true;
        }
        for(int i=0; i<pow10(k+1); i++) {
            if(!tbl[i]) {
                printf("%d\n",i);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1040
N = int(input())
A = list(map(int,input().split()))

ans = 1
up = down = False
for a,b in zip(A,A[1:]):
    if a<b:
        if down:
            ans += 1
            up = down = False
        else:
            up = True
            down = False
    elif a>b:
        if up:
            ans += 1
            up = down = False
        else:
            up = False
            down = True
print(ans)

Measured memory_bytes: 14252
#include <stdio.h>

int main(){
  int n,j,h;
  scanf("%d",&n);
  h=n/100*100;
  j=n/10*10-h;
    if(n-h-j==3){
    printf("bon\n");
  }else if(n-h-j==0||n-h-j==1||n-h-j==6||n-h-j==8){
    printf("pon\n");
  }else{
    printf("hon\n");
  }

  return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  ll ans=0;
  ll a[n+1];
  rep(i,0,n+1) a[i]=0;
  rep(i,1,n+1){
    int j=i;
    while(j<=n){
      a[j]++;
      j+=i;
    }
  }
  rep(i,1,n+1){
    ans+=i*a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 81752
#include <stdio.h>

int main(void)
{
	int n,i;
	int sum=0,a;
	int b[7]={0};
	
	while(scanf("%d",&n)&&n!=0){
		for(i=0;i<n;i++){
			scanf("%d",&a);
			if(a<60)
			b[a/10]++;
			else
			b[6]++;
		}
		for(i=0;i<7;i++){
			printf("%d\n",b[i]);
		}
		for(i=0;i<7;i++)
		b[i]=0;
	}
	return 0 ;
}

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

typedef pair<int, int> PAIR;

PAIR a[222222];

bool cmp(PAIR v1, PAIR v2)
{
	if (v1.second == v2.second)
		return v1.first > v2.first;
	return v1.second < v2.second;
}

int main(void)
{
	int n, i;

	scanf("%d" ,&n);
	for (i = 1; i <= n; i++)
		scanf("%d %d" ,&a[i].first, &a[i].second);

	sort(a + 1, a + n + 1, cmp);

	int sum = 0;
	for (i = 1; i <= n; i++)
	{
		sum += a[i].first;
		if (sum > a[i].second)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int arr[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n;
    cin >> n;
    cout << n * n << endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
int main(){
    fastio;
    file();
    int t;
    cin>>t;
    map<string,int> mp;
    for(int i=0;i<t;++i){
      string x;
      cin>>x;
      mp[x]++;
    }
    int maxval=0;
    for(auto x: mp){
      if(x.second>maxval){
        maxval=x.second;
      }
    }
    for(auto x:mp){
      if(x.second==maxval){
        test(x.first);
      }
    }
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;

int A,B,T;

int main(){
    cin >> A >> B >> T;
    int ans = 0;
    for(int i = A; i <= T; i+=A) ans += B;
    cout << ans << endl;
}

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

int solve(string str, map<string, int> &atom){
    int p = 0;
    int ans = 0;
    while(str[p] != '.'){
        if(str[p]=='('){
            int depth = 1;
            p++;
            int s = p;
            for(; depth!=0; p++){
                if(str[p]=='(') depth++;
                if(str[p]==')') depth--;
            }
            int subans = solve(str.substr(s, p-s-1) +".", atom);
            if(subans == -1) return -1;
            int num = str[p] - '0';
            p++;
            if('0' <= str[p] && str[p] <= '9'){
                num = num*10 + str[p]-'0';
                p++;
            }
            ans += subans * num;
        }else{
            string name = "";
            name += str[p];
            p++;
            int subans;
            if('a' <= str[p] && str[p] <= 'z'){
                name += str[p];
                p++;
                if(atom.count(name)==0) return -1;
                subans = atom[name];
            }else{
                if(atom.count(name)==0) return -1;
                subans = atom[name];
            }
            int num=1;
            if('0' <= str[p] && str[p] <= '9'){
                num = str[p]-'0';
                p++;
                if('0' <= str[p] && str[p] <= '9'){
                    num = num*10 + str[p]-'0';
                    p++;
                }
            }
            ans += subans * num;
        }
    }
    return ans;
}

int main(){
    map<string, int> atom;
    while(1){
        string name;
        cin >> name;
        if(name == "END_OF_FIRST_PART") break;
        int weight;
        cin >> weight;
        atom[name] = weight;
    }

    while(1){
        string molecule;
        cin >> molecule;
        if(molecule == "0") break;
        int ans = solve(molecule +".", atom);
        if(ans == -1){
            cout << "UNKNOWN" << endl;
        }else{
            cout << ans << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b;cin>>a>>b;
  if(a<=0&&b>=0) cout<<"Zero";
  else
  {
    int neg=b;
    if(a<0) {neg=min(b, 0);
    	if((neg-a+1)%2==0) cout<<"Positive";
        else cout<<"Negative";
    }
    else
    {
      cout<<"Positive";
    }
  }
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

d = Counter(D)
t = Counter(T)

for k, v in t.items():
    if k not in d  or d[k]<v:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 57056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<char,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    for(ll i=0;i<M;i++){
        ll a;
        cin>>a;
        N-=a;
    ;}
    if(N>=0)cout<<N<<endl;
    else cout<<-1<<endl;

return 0;
}


Measured memory_bytes: 3636
n,c=map(int,input().split())
d=[list(map(int,input().split())) for i in range(c)]
cli=[list(map(int,input().split())) for i in range(n)]

x0=[0]*c #余りが0のグループで、元の色が1～Cまでのやつがそれぞれ何個あったか記録
x1=[0]*c
x2=[0]*c


for i in range(n):
  for j in range(n):
    num=(i+j+2)%3
    if num==0:
      x0[cli[i][j]-1]+=1
    elif num==1:
      x1[cli[i][j]-1]+=1
    elif num==2:
      x2[cli[i][j]-1]+=1

import itertools
ans=float("inf")
rng=list(range(c))
for x,y,z in itertools.permutations(rng, 3):
  temp=0
  for j in range(c): #1～cまでの色それぞれについて、個数*x,y,zの遷移コストを求める
    temp+=x0[j]*d[j][x]
    temp+=x1[j]*d[j][y]
    temp+=x2[j]*d[j][z]
  #print(temp)
  ans=min(ans,temp)
print(ans)

Measured memory_bytes: 5620
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x = sc.nextLong();
		long[] a = new long[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
		}

		long answer = 0;
		if (a[0] > x) {
			answer += a[0] - x;
			a[0] = x;
		}

		long t = a[0];
		for (int i = 1; i < a.length; i++) {
			if (t + a[i] > x) {
				answer += a[i] - (x - t);
				a[i] = (x - t);
			}

			t = a[i];
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 50396
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int K, S;
    cin >> K >> S;
    int res = 0;
    for(int i = 0; i <= K; i++) {
        for(int j = 0; j <= K; j++) {
            if(S - i - j <= K && S - i - j >= 0)
                res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    Map<Integer, Integer> map = new HashMap<>();


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

    long sum = 0;

    void run() {

        for (int i=1; i<=n; i++) {
            long tmp = 0;
            long cnt = n / i;
            tmp = (long)i * cnt * (cnt+1) / 2L;
            sum += tmp;
        }

        System.out.print(sum);


    }
    Map<Integer, Integer> primes(int n) {
        List<Integer> list = new ArrayList<>();
        Map<Integer, Integer> map = new HashMap<>();

        while (n >= 4 && n % 2 == 0) {
            list.add(2);
            n /= 2;
        }
        int d = 3;
        int q = n / d;
        while (q >= d) {
            if (n % d == 0) {
                list.add(d);
                n = q;
            } else {
                d += 2;
            }
            q = n / d;
        }
        list.add(n);

        for (int t: list) {
            if (map.containsKey(t)) {
                map.put(t, map.get(t) + 1);
            } else {
                map.put(t, 1);
            }
        }
        return map;

    }


}



Measured memory_bytes: 35572
use input::{Input, ReadMode};
type ABCD = (usize, usize, usize, usize);

fn main() {
    let mut input = Input::new(ReadMode::Line);

    let n: usize = input.parse();
    let m: usize = input.parse();
    let q: usize = input.parse();
    let v = (0..q)
        .map(|_| (input.parse(), input.parse(), input.parse(), input.parse()))
        .collect::<Vec<ABCD>>();

    let mut ans = 0;
    dfs(n, m, &v, vec![1], &mut ans);
    println!("{}", ans);
}

fn dfs(n: usize, m: usize, v: &Vec<ABCD>, mut a: Vec<usize>, ans: &mut usize) {
    if a.len() == n + 1 {
        let mut tmp = 0;
        for e in v {
            if a[e.1] - a[e.0] == e.2 {
                tmp += e.3;
            }
        }
        *ans = *ans.max(&mut tmp);
        return;
    }
    let l = a.len();
    a.push(a[l - 1]);
    while a[l] <= m {
        dfs(n, m, v, a.clone(), ans);
        a[l] += 1;
    }
}

#[allow(dead_code)]
pub mod input {
    use std::io::{BufRead, Read};

    pub enum ReadMode {
        Full,
        Line,
    }

    pub struct Input<'a> {
        lock: std::io::StdinLock<'static>,
        iter: Option<std::str::SplitAsciiWhitespace<'a>>,
        mode: ReadMode,
    }

    impl<'a> Input<'a> {
        fn naive_read(&mut self) -> Option<std::str::SplitAsciiWhitespace<'a>> {
            let mut s = Box::leak(Box::new(String::new()));
            let res = match self.mode {
                ReadMode::Full => self.lock.read_to_string(&mut s),
                ReadMode::Line => self.lock.read_line(&mut s),
            };
            res.ok().expect("failed to read");
            Some(s.split_ascii_whitespace())
        }
        pub fn new(mode: ReadMode) -> Self {
            let lock = Box::leak(Box::new(std::io::stdin())).lock();
            let iter = None;
            Self { lock, iter, mode }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.lock.read_line(&mut s).ok().expect("failed to read");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            match &mut self.iter {
                Some(iter) => {
                    let x = match iter.next() {
                        Some(x) => x,
                        None => {
                            self.iter = self.naive_read();
                            self.iter.as_mut().unwrap().next().expect("reached EOF")
                        }
                    };
                    x.parse().ok().expect("failed to parse")
                }
                None => {
                    self.iter = self.naive_read();
                    self.parse()
                }
            }
        }
    }
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    
    int a,b;
    cin >> a >> b;
    rep(i,max(a,b)){
        cout << min(a,b);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,x,a=0;
 
  while(1){
    
    a=0;

    cin >>n>>x;

    if(n == 0 && x == 0) break;

    for( int i=0; i < n ; i++ ){
      for( int j=0; j < n ; j++ ){
	for( int k=0; k < n ; k++ ){
	  
	  if( x == (i+j+k+3) && i != j && j != k && i != k ){
	    a=a+1;
	  }
	}
      }
    }
    cout <<a/6<< "\n";
  }
	    
return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  if(a[0]!=0){
    cout<<-1<<endl;
    return 0;
  }
  rep(i,n-1){
    if(a[i]+1<a[i+1]){
      cout << -1 << endl;
      return 0;
    }
  }
  ll cnt=0;
  rep(i,n-1){
    if(a[i+1]==a[i]+1)cnt++;
    else cnt+=a[i+1];
  }
  cout << cnt << endl;
    
}


Measured memory_bytes: 13824
#![allow(dead_code)]

use std::io::stdin;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let mut str = String::new();
    stdin().read_line(&mut str).ok();
    str.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut str = String::new();
    stdin().read_line(&mut str).ok();
    str.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_n_vec<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v_outer = Vec::new();
    for _ in 0..n {
        let v_inner = read_vec();
        v_outer.push(v_inner);
    }
    v_outer
}

fn main() {
    let line: Vec<u32> = read_vec();
    print!("{} {} {}", line[2], line[0], line[1]);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String n = scan.next();

		if (n.charAt(0) == n.charAt(1) && n.charAt(0) == n.charAt(2)) {
			System.out.println("Yes");
		} else if (n.charAt(3) == n.charAt(1) && n.charAt(3) == n.charAt(2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 25172
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    uf.union(*(int(x) - 1 for x in input().split()))
print(max(uf.size(x) for x in range(n)))

Measured memory_bytes: 14772
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,n,a,b);
    p((n/(a+b))*a+min(n%(a+b),a));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;
long MOD=1000000007;
int main(void){
    long N;
    cin>>N;
    
    long ans=0;
    for(int n=1;n<=N;n++){
        long count=0;
        for(int i=1;i<=n;i++){
            if(n%i==0) count++;
        }
        if(count==8&&n%2==1) ans++;
        
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        long n = Read();
        var a = new long[n];
        var input = Reads();

        for (long i = 0; i < n; i++)
        {
            a[i] = input[i];
        }
        for(int i = 0; i < n - 1; i++)
        {
            a[i + 1] = Gcd(a[i], a[i + 1]);
        }
        Console.WriteLine(a[n - 1]);





        Console.Out.Flush();
    }
}

Measured memory_bytes: 25184
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int a,b;cin>>a>>b;
  if(b%a)cout << b-a<<endl;
  else cout << a+b << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int x;
    cin >> x;
    vector<bool> e(x+1, false);
    e[1] = true;
    for(int b = 2; b <= x; b++){
        int v = b * b;
        while(v <= x){
            e[v] = true;
            v *= b;
        }
    }
    for(int i = x; i >= 1; i--){
        if(e[i]){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [True]*N
for _ in range(M):
  a = int(input())
  A[a-1] = False # 壊れてるところはfalse

waru = 10**9 + 7
dp = [0]*(N+1)

dp[0], dp[1] = 1, 1 # 初期条件
if not A[0]: # 1段目が壊れてたら
  dp[1] = 0

for i in range(2,N+1):
  # 壊れてるところはdp=0にする
  if not A[i-1]:
    dp[i] = 0
  else:
    dp[i] = (dp[i-1] + dp[i-2])%waru
print(dp[-1])

Measured memory_bytes: 13316
X = int(input())
ans = 0

if X < 2**2:
  print(1)
  exit()
  
for b in range(2, 32):
    p = 2
    if b ** p > X:
      continue
    while b ** (p+1) <= X:
        p += 1
    ans = max(ans, b**p)

print(ans)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,a;
    cin >> n >> a;
    vector<ll> x(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i);
        x.at(i) -= a;
    }
    vector<vector<ll>> dp(n+1,vector<ll>(5001,0));
    dp.at(0).at(2500) = 1;
    for(i = 1;i <= n;++i){
        rep(j,5001){
            if(dp.at(i-1).at(j)){
                dp.at(i).at(j) += dp.at(i-1).at(j);
                dp.at(i).at(j + x.at(i-1)) += dp.at(i-1).at(j);
            }
        }
    }
    cout << dp.at(n).at(2500)-1 << endl;
    
    return 0;
}

Measured memory_bytes: 2304
n=gets.to_i

arr=gets.split.map(&:to_i)

arr2=arr.sort

a=arr2[n/2-1]
b=arr2[n/2]

i=0

n.times{
    c=arr[i]
   if a==b 
       puts a
       elsif b<=c
       puts a
       elsif c<=a
       puts b
   end
    
    
    i+=1
}

Measured memory_bytes: 23396
var a,b,k:int64;
Begin
    Readln(a,b,k);
    If (a<k) and (a+b>=k) then writeln(0,' ',b-k+a)
    Else if (a<k) and (a+b<k) then writeln(0,' ',0)
    Else writeln(a-k,' ',b);
End. 

Measured memory_bytes: 128
N = int(input())
A = [0] + list(map(int, input().split()))
Ans = [0] * (N+1)
for i, a in zip(range(N, 0, -1), A[:0:-1]):
    n = 0
    for aj in Ans[i*2::i]:
        n ^= aj
    Ans[i] = n ^ a
Ans = [i for i, a in enumerate(Ans[1:], 1) if a]
print(len(Ans))
print(" ".join(map(str, Ans)))


Measured memory_bytes: 26996
import java.util.*;

public class Main {
    static Map<Character, Integer> mapping = new HashMap<>();

    static long[][] generatePrefix(String word) {
        long[][] res = new long[word.length() + 1][3];

        for (int i = word.length()-1; i >= 0; i--) {
            res[i][0] = res[i + 1][0];
            res[i][1] = res[i + 1][1];
            res[i][2] = res[i + 1][2];
            res[i][mapping.get(word.charAt(i))]++;
        }
        return res;
    }

    static long search(char a, char b, long[][] prefix, int idx, String word) {
        long res = 0;
        long ln = word.length();
        for (int i = idx; i < ln; i++) {
            char ch = word.charAt(i);
            int diff = i + (i - (idx - 1));
            if (ch == a) {
                res += prefix[i][mapping.get(b)];
                if (diff < ln && word.charAt(diff) == b) res--;
            }
            if (ch == b) {
                res += prefix[i][mapping.get(a)];
                if (diff < ln && word.charAt(diff) == a) res--;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String word = sc.next();
        mapping.put('R', 0);
        mapping.put('G', 1);
        mapping.put('B', 2);
        long[][] prefix = generatePrefix(word);
        long res = 0;
        for (int i = 0; i < n; i++) {
            char a = word.charAt(i);
            if (a == 'R') res += search('G', 'B', prefix, i + 1, word);
            else if (a == 'G') res += search('R', 'B', prefix, i + 1, word);
            else res += search('R', 'G', prefix, i + 1, word);
        }
        System.out.print(res);
    }
}


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

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

    int x[n+1];
    for(int i = 0; i < n+1; i++)    x[i] = 0;

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

    int b;
    for(int i = 0; i < m; i++){
        int hit = 0;
        for(int j = 1; j <= n; j++){
            cin >> b;
            if(b == target[i]){
                x[j]++;
                hit++;
            }
        }

        x[target[i]] += n-hit;
    }

    for(int i = 1; i <= n; i++) cout << x[i] << endl;

    return 0;
}


Measured memory_bytes: 3092
function main(input)
    mod = 10^9 + 7
    arr = [parse.(Int, i) for i in split.(input)]
    N = arr[1][1]
    A_true = N%2==0 ? [2div(n-1,2)+1 for n in 1:N] : [n==1 ? 0 : 2div(n, 2) for n in 1:N]
    return println(A_true==sort(arr[2]) ? (BigInt(2)^div(N,2))%mod : 0)
end
main(readlines())

Measured memory_bytes: 213348
<?php
  fscanf(STDIN,"%d %d",$h,$w);
  for($i=0; $i<$h; $i++){
      $s[] = trim(fgets(STDIN));
  }
  
  for($i=0; $i<$h; $i++){
      for($j=0; $j<$w; $j++){
          if($s[$i][$j] == "."){
              $count = 0;
              for($p=$i-1; $p<=$i+1; $p++){
                  for($q=$j-1; $q<=$j+1; $q++){
                      if($s[$p][$q] == "#"){
                          $count++;
                      }
                  }
              }
              $s[$i][$j] = $count;
          }
      }
  }
  
  for($i=0; $i<$h; $i++){
      echo $s[$i]."\n";
  }

Measured memory_bytes: 4732
d=list(map(int,input().split()))
for o in list(input()):
 s={'N':(0,1,5,4),'W':(0,2,5,3),'E':(0,3,5,2),'S':(0,4,5,1)}[o]
 for i in range(3):
  d[s[i+1]],d[s[i]]=d[s[i]],d[s[i+1]]
print(d[0])

Measured memory_bytes: 5600
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int main(void) {
	//Program Start

	int N;
	cin >> N;

	vector<int> V(N);
	vector<int> C(N);

	rep(i, N) cin >> V[i];
	rep(i, N) cin >> C[i];

	vector<int> VmC(N);

	rep(i, N) VmC[i] = V[i] - C[i];

	int sum = 0;

	rep(i, N)
		if (VmC[i] > 0)
			sum += VmC[i];

	cout << sum << endl;


ProgramEndPointLabel:;


	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,inv[N],a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	for(int i=0;i<n;i++)a[i]=read();
	while(m--)
	{
		int A=read(),B=read(),mod=read();
		int ans=0,S=0;
		for(int i=0;i<n;i++)
		{
			b[i]=a[i]%mod;
			if(b[i]==0)b[i]=mod;
			S+=b[i];
		}
		ans=B;
		ans+=S*((A-1)/n);
		for(int i=0;i<(A-1)%n;i++)ans+=b[i];
		printf("%lld\n",A-1-(ans/mod-B/mod));
	}
	return 0;
}

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

alist = []
clist = []

for i in range(n):
  q = list(map(int,input().split()))
  alist.append(q[1:])
  clist.append(q[0])
  
total = sum(clist)
ans = float('inf')

def plus(x, y):
  return x+y


for i in range(2**n):
    money = 0 
    sum = [0]*m

    for j in range(n):
        if (i>>j)&1:
            sum = list(map(plus, sum, alist[j]))
            money += clist[j]

    for k in range(m):
      if sum[k] < x:
        break
    else:
      if ans >= money:
        ans = money

        
if ans <= total:
  print(ans)
else:
  print(-1)
      

Measured memory_bytes: 9240
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int a[4];
	for(int i=1;i<=3;i++)scanf("%d",&a[i]);
	sort(a+1,a+4);
	printf("%d\n",a[3]-a[1]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// G - Longest Path

using namespace std;

vector<int> adj1[100005];
vector<int> adj2[100005];
vector<int> top;
bool vis[100005];
int dp[100005];

void dfs(int cur) {
    vis[cur] = true;

    for (int nxt : adj1[cur])
        if (!vis[nxt])
            dfs(nxt);

    top.push_back(cur);
}

int main() {
    int N,M,i,x,y,ans;

    scanf("%d%d",&N,&M);

    for (i = 0;i < M;i++) {
        scanf("%d%d",&x,&y);
        adj1[x].push_back(y);
        adj2[y].push_back(x);
    }

    for (i = 1;i <= N;i++) {
        if (!vis[i])
            dfs(i);
    }

    reverse(top.begin(),top.end());

    ans = 0;
    for (int t : top) {
        for (int s : adj2[t])
            dp[t] = max(dp[t],dp[s] + 1);
        ans = max(ans,dp[t]);
    }

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

    return 0;
}


Measured memory_bytes: 14204
#D
from collections import deque
N,K = map(int,input().split())
numbers = [i for i in range(0,N+1)]
large  = deque([N])
small = deque([0])
for i in range(1,N+1):
    large.append(large[-1]+numbers[-i-1])
    small.append(small[-1]+numbers[i])

mod = 10**9+7

ans = 1
for i in range(K,N+1):
    ans += (large[i-1] - small[i-1] + 1)%mod
print(ans%mod)

Measured memory_bytes: 38552
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            double n = sc.nextDouble();
            if(n==-1.0) break;

            n = n * 2 * 2 * 2 * 2;
            if(n%1.0!=0){
                System.out.println("NA");
                continue;
            }

            String bit = Integer.toBinaryString((int)n);
            if(bit.length()>12){
                System.out.println("NA");
                continue;
            }
            String seisu = bit.substring(0, bit.length()-4);
            String syousu = bit.substring(bit.length()-4, bit.length());
            while(seisu.length()<8) seisu = "0" + seisu;
            System.out.println(seisu+"."+syousu);
        }
    }

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

Measured memory_bytes: 27900
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main(){
  vector<ll>a(6);
  for(int i=0;i<6;i++){
    cin>>a.at(i);
  }
  ll min=a.at(0);
  for(int i=1;i<6;i++){
    if(a.at(i)<a.at(i-1)&&min>a.at(i)){
      min=a.at(i);
    }
  }
  ll ans=(a.at(0)-min)/min+5;
  if((a.at(0)-min)%min!=0)ans++;
  cout <<ans<<endl;
}

Measured memory_bytes: 3608
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Akshay Vashishtha 

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
//than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define ps push_back
#define le length
#define in insert
#define vint vector<int>
#define vlld vector<long long int>
#define pii pair<int,int>
#define mk make_pair
#define vst vector<string>
#define lld long long int 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
 
int main()
{
	int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	int deta[3];
	int square;

	cin >> n;
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 3; j++){
			cin >> deta[j];
		}
		
		sort (deta, deta + 3);

		square = (deta[0] * deta[0]) + (deta[1] * deta[1]);

		if (square == deta[2] * deta[2]){
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

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

int main() {
  int N, M, C;
  int count = 0;
  cin >> N >> M >> C;
  vector<vector<int>> data(1+N, vector<int>(M));
  for (int i = 0; i < 1+N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> data.at(i).at(j);
    }
  }

  for (int i = 1; i < 1+N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      sum += data.at(i).at(j) * data.at(0).at(j);
    }
    if (sum + C > 0) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 3600
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        t: i32, a: i32,
        h: [i32; n]
    }
    let mut ans = 0;
    let mut temp = 1<<30;
    for i in 0..n {
        let mut d = (t*1000 - h[i]*6) - a*1000;
        if d < 0 {
            d = d.abs();
        }
        if d < temp {
            temp = d;
            ans = i;
        }
    }
    puts!("{}\n",ans + 1);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 2288
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)

ans = A[0]

for i in range(1,(N-2)//2+1):
  ans += A[i]*2
  
if N % 2 == 1:
  ans += A[(N-2)//2 + 1]

print(ans)

Measured memory_bytes: 31408
#include<stdio.h>
#include<string.h>

#define MAX 2000001
#define MAX_SCORE 10001

typedef struct {
  int id;
  int score;
  int rank;
} Info;

int n; // number of students
int counter[MAX_SCORE+1], maxi;
Info list[MAX+1], sortedList[MAX+1];


void CountingSort() {
  memset(counter,0,sizeof counter);
  int i;
  for(i=0;i<n;++i) ++counter[list[i].score];
  for(i=1;i<=maxi;++i) counter[i] += counter[i-1];
  for(i=n-1;i>=0;--i) {
    sortedList[--counter[list[i].score]] = list[i];
  }
}

int main() {
  int i, id, score;
  while( scanf("%d",&n) != EOF ) {
    maxi = 0;
    for(i=0;i<n;++i) {
      scanf("%d",&score);
      list[i].score = score;
      if( maxi < score ) maxi = score;
    }
    CountingSort();
    for(i=0;i<n;++i) {
      if( i ) printf(" ");
      printf("%d",sortedList[i].score);
    } puts("");
  }
  return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  char maze[H][W];
  rep(i, H){
    rep(j, W){
      cin >> maze[i][j];
    }
  }
  
  queue<pair<int, int>> que;
  que.push(make_pair(0, 0));
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  vector<vector<int>> dist(H, vector<int>(W, -1));
  dist[0][0] = 0;
  vector<vector<int>> prev_x(H, vector<int>(W, -1));
  vector<vector<int>> prev_y(H, vector<int>(W, -1));
  while (!que.empty()){
    pair<int, int> current_pos = que.front();
    int x = current_pos.first;
    int y = current_pos.second;
    que.pop();
    for (int i=0; i<4; ++i){
      int nx = x + dx[i];
      int ny = y + dy[i];
      
      if (nx < 0 || ny < 0 || nx >= H || ny >= W) continue;
      if (maze[nx][ny] == '#') continue;
      if (dist[nx][ny] == -1) {
        que.push(make_pair(nx, ny));
        dist[nx][ny] = dist[x][y] + 1;
        prev_x[nx][ny] = x;
        prev_y[nx][ny] = y;
      }
    }
  }
  
  int x = H-1;
  int y = W-1;
  while (x != -1 && y != -1) {
    maze[x][y] = 'o';
    int pre_x = prev_x[x][y];
    int pre_y = prev_y[x][y];
    x = pre_x;
    y = pre_y;
  }
  
  int ans = 0;
  rep(i, H){
    rep(j, W){
      if (maze[i][j] == '.') ans++;
    }
  }
  
  if (dist[H-1][W-1] != -1) cout << ans << endl;
  else cout << -1 << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#define PAD(a,b) MP(((a).first + (b).first),((a).second, (b).second))

#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //移動
	{ 0, 1 }, { -1, 0 }, { 1, 0 }, { 0, -1 },
	{ 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 }
};

	int can[5001][5001];
signed main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> num(n);
	REP(i, n){
		scanf("%d", &num[i]);
	}
	sort(ALL(num),greater<int>());
	int last = 0;
	Fill(can, -1);
	function<bool(int,int)> dfs = [&](int cur, int nok){
		bool ret = 0;
		if (nok <= 0)
			return true;
		if (cur == n)
			return false;
		if (can[cur][nok] != -1)
			return can[cur][nok] == 1 ? true : false;

		ret = dfs(cur+1, nok);
		if (dfs(cur + 1, nok - num[cur])){
			ret = 1;
			last = max(last, cur+1);
		}
		can[cur][nok] = ret;
		return ret;
	};
	dfs(0, m);
	printf("%d\n", n-last);
	return 0;
}

Measured memory_bytes: 98304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<ll> a(N);
    rep(i,N)cin>>a.at(i);
    bool j=true;
    rep(i,N){
        if(a.at(i)!=0)j=false;
    }
    if(j){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(N%3!=0){cout<<"No"<<endl;return 0;}
    sort(a.begin(),a.end());
    rep(i,N-1){
        if(i==N/3-1 || i==2*N/3-1){
            continue;
        }
        if(a.at(i)!=a.at(i+1)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    ll A,B,C;
    A=a.at(0);B=a.at(N/3);C=a.at(2*N/3);
    ll X=A;
    X^=B;X^=C;
    if(X==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3988