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

#define int long long

using namespace std;
const int N = 200000;

int n, lim;
int a[N], sum[N], S[N+10];

void add(int x,int v) {
	for (int i=x;i<=N;i+=(i&-i))
		S[i] += v;
	return;
}

int ask(int x,int cnt) {
	for (int i=x;i>=1;i-=(i&-i))
	    cnt += S[i];
	return cnt;
}

bool check(int x)
{
	sum[0] = 0;
	for (int i=1;i<=n;++i)
		sum[i] = sum[i-1] + (a[i] >= x ? 1 : -1);
	int v = n+1, ans = 0;
	for (int i=1;i<=n;++i)
	{
		ans += ask(sum[i]+v,0);
		add(sum[i]+v,1);
		ans += sum[i] >= 0;
	}
	for (int i=1;i<=n;++i)
		add(sum[i]+v,-1);
	if (lim % 2 == 1) return ans > lim/2;
	if (lim % 2 == 0) return ans >= lim/2;
}

signed main(void)
{
	scanf("%lld", &n);
	for (int i=1;i<=n;++i)
		scanf("%lld", a+i);
	lim = 1LL*n*(n+1)/2;
	int l = 1, r = 1e9, mid;
	while (l+1 < r) {
		mid = l+r >> 1;
		check(mid) ? l = mid : r = mid;
	}
	printf("%lld\n", check(r) ? r : l);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 28 21:00:07 JST 2020
 **/

signed main() {
    Int X;
    std::cin >> X;
    Int ans = X / 500 * 1000 + X % 500 / 5 * 5;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        String S = scanner.nextLine();

        int max_sum = 0;
        int max_index = 0;
        for (int i = 0; i < N; i++) {
            String sub1 = S.substring(0, i);
            String sub2 = S.substring(i);

            int sum = 0;
            List<Character> chars = new ArrayList<>();
            for (int i1 = 0; i1 < sub1.length(); i1++) {
                char char1 = sub1.charAt(i1);
                if (chars.contains(char1)) {
                    continue;
                }
                for (int i2 = 0; i2 < sub2.length(); i2++) {
                    char char2 = sub2.charAt(i2);
                    if (chars.contains(char1)) {
                        continue;
                    }
                    if (char1 == char2) {
                        chars.add(char1);
                        sum++;
                    }
                }
            }

            if (sum > max_sum) {
                max_index = i;
                max_sum = sum;
            }
        }

        System.out.println(max_sum);
    }
}


Measured memory_bytes: 23636
a = int(input())
b = int(input())
c = int(input())
x = int(input())
# a,b=map(int,input().split())
# l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
count=0
for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            if i*500+j*100+k*50==x:
                count+=1
print(count)


Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>

using namespace std;

#define ll long long
#define MAX 500000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int c[MAX + 5], freq[MAX + 5], blockSize;
struct node {
    int l, r, id;
} query[MAX + 5];
int ans[MAX + 5];

bool compare(node a, node b) {
    if (a.l / blockSize == b.l / blockSize) {
        return a.r < b.r;
    }
    return a.l < b.l;
}

void toggle(int pos, int &curr, int flag) {
    int temp = freq[c[pos]];
    freq[c[pos]] += flag;
    curr += temp == 0;
    curr -= freq[c[pos]] == 0;
}

void executeMO(int q) {
    int l, r, curr, i;
    l = 1, r = 0, curr = 0;
    for (i = 0; i < q; ++i) {
        while (r < query[i].r) {
            toggle(++r, curr, 1);
        }
        while (r > query[i].r) {
            toggle(r--, curr, -1);
        }
        while (l < query[i].l) {
            toggle(l++, curr, -1);
        }
        while (l > query[i].l) {
            toggle(--l, curr, 1);
        }
        ans[query[i].id] = curr;
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, q, i, l, r;
    cin >> n >> q;
    for (i = 1; i <= n; ++i) {
        cin >> c[i];
    }
    blockSize = 1000;
    for (i = 0; i < q; ++i) {
        cin >> l >> r;
        query[i] = {l, r, i};
    }
    sort(query, query + q, compare);
    executeMO(q);
    for (i = 0; i < q; ++i) {
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 15520
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "Heisei";
		if(s.compareTo("2019/04/30") > 0) result = "TBD";

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


Measured memory_bytes: 23508
#include <iostream>

using namespace std;

class Cube{
    public:
        int f[6];
        void roll_z(){roll(1, 2, 4, 3);}
        void roll_y(){roll(0, 2, 5, 3);} // to W
        void roll_x(){roll(0, 1, 5, 4);} // to N
        void roll(int i, int j, int k, int l){
            int tmp = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = tmp;
        }
};

int getRight(Cube c1, int f1, int f2){
    for(int i = 0; i < 6; i++){
        for(int j = 0; j< 4; j++){
            if(c1.f[0] == f1 && c1.f[1] == f2){
                return c1.f[2];
            }
            c1.roll_z();
        }
        if(i%2 == 0){
            c1.roll_y();
        }else{
            c1.roll_x();
        }
    }
    return -1;
}

int main(){
    
    Cube c;
    int f1, f2;

    for(int i = 0; i < 6; i++){
        cin >> c.f[i];
    }
    int q;
    cin >> q;

    for(int i = 0; i < q; i++){
        cin >> f1 >> f2;
        cout << getRight(c, f1, f2) << endl;
    }

    return 0;
}




Measured memory_bytes: 3112
// AOJ CGL_4_A Convex Hull
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef struct { int x, y; } PP;

PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
//long long cross(PP a, PP b) { return (long long)a.x * b.y - (long long)a.y * b.x; }
int cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) { pc('0'); return; }
	if (n < 0) pc('-'), n = -n;
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

int cmp(PP *a, PP *b)
{
	if (a->y - b->y) return a->y - b->y;
	return a->x - b->x;
}

int convex_hull(int n, PP *ps, PP *po)
{
	int i, k, j = 0;

	qsort(ps, n, sizeof(PP), cmp);
	for (i = 0; i < n; i++) {
		while (j > 1 && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) < 0) j--;
		po[j++] = ps[i];
	}
	k = j;
	for (i = n - 2; i >= 0; i--) {
		while (j > k && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) < 0) j--;
		po[j++] = ps[i];
	}
	return j-1;
}

PP p[100005], poly[100005];

int main()
{
	int n, k, i;

	n = in();
	for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in();
	k = convex_hull(n, p, poly);
	out(k), pc('\n');
	for (i = 0; i < k; i++) {
		out(poly[i].x), pc(' '), out(poly[i].y), pc('\n');
	}
	return 0;
}


Measured memory_bytes: 2956
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define N 200200
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
ll ans;
int n,a[N];
ll buc[N];
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
		++buc[a[i]];
	}
	for(int i=1;i<=n;++i){
		ans+=buc[i]*(buc[i]-1)/2;
	}
	for(int i=1;i<=n;++i){
		printf("%lld\n",ans-buc[a[i]]+1);
	}
	return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll int gcd(ll int a,ll int b)
{
  if(a==0)
  return b;
  return gcd(b%a,a);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    ll int a,b;
    cin>>a>>b;
cout<<(a*b)/gcd(a,b);

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n, m;
    cin >> n >> m;
    map<ll, ll> res;
    for (ll i = 2; i * i <= m; i++)
    {
        while (m % i == 0)
        {
            res[i]++;
            m /= i;
        }
    }
    if (m != 1)
        res[m]++;
    ll ans = 1;
    for (auto p : res)
    {
        if (p.second >= n)
        {
            ans *=(ll)pow(p.first,p.second/n);
        }
    }
        cout << ans << endl;
}

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

int main(){
    int X;
    cin >> X;
    int ple = 0;
    int a = X / 500;
    ple += a * 1000;
    X -= a * 500;
    int b = X / 5;
    ple += b * 5;
    cout << ple << endl;
    return 0;
}

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

int main(){
    ll n;
    cin>>n;
    ll cnt[4]={};
    string s;
    rep(i,n){
        cin>>s;
        if(s=="AC") cnt[0]++;
        else if(s=="WA") cnt[1]++;
        else if(s=="TLE") cnt[2]++;
        else cnt[3]++;
    }
    cout<<"AC x "<<cnt[0]<<endl;
    cout<<"WA x "<<cnt[1]<<endl;
    cout<<"TLE x "<<cnt[2]<<endl;
    cout<<"RE x "<<cnt[3]<<endl;
    return 0;
}

Measured memory_bytes: 3624
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto n = s[0];
    auto q = s[1];
    auto st = new SegmentTree!(int, (a,b)=>a+b, 0)(n);

    while (q--) {
        s = readln.split.map!(to!int);
        auto t = s[0];
        auto x = s[1];
        auto y = s[2];
        if (t == 0) {
            st.add(x, y);
        } else {
            st.query(x, y).writeln;
        }
    }
}

class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, T val) {
        pos += offset;
        table[pos] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}



Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
bool cmp(string x,string y)
{
	return(x+y<y+x);
	
}
string lcg(string s[],int N)
{int i;
	sort(s,s+N,cmp);
	string g="";
	for(i=0;i<N;i++)
	{
		g+=s[i];
	}
	return g;
}
main()
{
	int i,N,L;
    cin>>N>>L;
    string s[N],j;
    for(i=0;i<N;i++)
    {
    	cin>>s[i];
	}
	j=lcg(s,N);
	cout<<j;
    
}

Measured memory_bytes: 256
#include <iostream>                                             
using namespace std;                                            
                                                                
int main() {                                                    
  int S;                                                        
  cin >> S;                                                     
  int h = S/3600;                                               
  int m = S%3600/60;                                            
  int s = S%3600%60;                                            
  cout << h << ":" << m << ":" << s << endl;                    
  return 0;                                                     
}                                                               
                              

Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<ctime>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 7e4+7;
const int inf = 1e5;
const int modn = 1e9+7;
const ld eps = 1e-8;
const long double PI = acos(-1.0);
void qRead(ll &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
void qRead(int &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
ll qpow(ll a,ll b,ll mo = modn){
//    printf("%lld\n",mo);
    ll res = 1;
    while(b){
        if(b & 1)res = (res*a) % mo;
        a = (a*a) % mo;
        b >>= 1;
    }
    return res;
}
ld qpow(ld a,ll b){
    ld res = 1;
    while(b){
        if(b & 1)res *= a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
//ll vis[maxn],prime[maxn],cnt,smallP[maxn];
//void getPrime(int n){
//    cnt = 0;
//    for(int i = 1;i <= n;i++)vis[i] = 0;
//    for(ll i = 2;i <= n;i++){
//        if(!vis[i]){
//            prime[++cnt] = i;
//            smallP[i] = i;
//        }
//        for(int j = 1;j <= cnt && i*prime[j] <= n;j++){
//            vis[prime[j]*i] = 1;
//            smallP[prime[j]*i] = prime[j];
//            if((i % prime[j]) == 0)break;
//        }
//    }
//}
//ll cnm[maxn][maxn];
//void getCnm(){
//    cnm[0][0] = 1;
//    for(int i = 1;i < maxn;i++){
//        for(int j = 0;j <= i;j++){
//            cnm[i][j] = cnm[i-1][j];
//            if(j)cnm[i][j] += cnm[i-1][j-1];
//            cnm[i][j] %= (modn-1);
//        }
//    }
//}
//ll f[maxn],invF[maxn];
//void getF(){
//    f[0] = invF[0] = 1;
//    for(int i = 1;i < maxn;i++)f[i] = f[i-1]*i % modn;
//    invF[maxn-1] = qpow(f[maxn-1],modn-2);
//    for(int i = maxn-2;i >= 1;i--)invF[i] = invF[i+1]*(i+1) % modn;
//}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    ll cnt = n/k;
    ll ans = cnt;
    if(cnt > 1)ans += cnt*(cnt-1)*3;
    if(cnt > 2)ans += cnt*(cnt-1)*(cnt-2);
    if(k % 2)printf("%lld\n",ans);
    else{
        if((n - cnt*k)*2 >= k)cnt++;
//        printf("%lld\n",ans);
        ans += cnt;
//        printf("%lld\n",ans);
        if(cnt > 1)ans += cnt*(cnt-1)*3;
//        printf("%lld\n",ans);
        if(cnt > 2)ans += cnt*(cnt-1)*(cnt-2);
        printf("%lld\n",ans);
    }
}


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

int main(void) {
	string S;
	cin >> S;
	int min = 999;
	for (int i = 0; i < S.length() - 2; i++) {
		int num = 100 * (S[i] - '0') + 10 * (S[i + 1] - '0') + (S[i + 2] - '0');
		int diff = abs(num - 753);
		if (diff < min) {
			min = diff;
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        x: usize,
    }

    let ans = solve(n, x);

    println!("{}", ans);
}

fn solve(n: usize, x: usize) -> usize {
    if n == 0 {
        return if x >= 1 { 1 } else { 0 };
    }

    let mut height = 1;
    for _ in 0..n {
        height = 3 + height * 2;
    }

    if x == 1 {
        0
    } else if x <= height / 2 {
        solve(n - 1, x - 1)
    } else if x == height / 2 + 1 {
        solve(n - 1, x - 1) + 1
    } else {
        let mut low = 1;
        for _ in 0..n - 1 {
            low = 1 + low * 2;
        }
        solve(n - 1, x - height / 2 - 1) + 1 + low
    }
}


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

int main(){
    string s;
    cin >> s;
    if ((s.at(2) == s.at(3)) && (s.at(4) == s.at(5))){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc094/tasks/arc095_a"

def main():
    N = int(input())
    Xs = list(map(int, input().split()))
    sort_Xs = sorted(Xs)
    front = len(sort_Xs) // 2 - 1
    rear = len(sort_Xs) // 2
    for X in Xs:
        if sort_Xs[rear] > X:
            print(sort_Xs[rear])
        else:
            print(sort_Xs[front])



if __name__ == '__main__':
    main()


Measured memory_bytes: 26772
#include <stdio.h> 
#include <stdlib.h> 
#include <math.h>
#define max 50000000
 
typedef struct stuff_mono{ 
  double x; 
  double y; 
  struct stuff_mono *next; 
}stuff_mono; 
int comcom[max];
stuff_mono *create_stuff(double , double );
void create_next_stuff(double , double , stuff_mono *);
void rotation_stuff(stuff_mono *,double );
void koch_curve_stuff(stuff_mono *);
 
int main() 
{ 
  int i,n; 
  stuff_mono *begin,*p; 
  begin = create_stuff(0,0); 
  create_next_stuff(100,0,begin); 
  scanf("%d", &n);
  for(i=0;i<max;i++){comcom[max]=i;}
  for (i = 0; i < n; i++) { 
     koch_curve_stuff(begin);  
  } 
   
  p = begin; 
  while(p != NULL) { 
    printf("%lf %lf\n", p->x, p->y); 
    p = p->next; 
  } 
   
  return 0; 
}


  
stuff_mono *create_stuff(double x, double y) { 
  stuff_mono *p = (stuff_mono*)malloc(sizeof(stuff_mono)); 
  p->x = x; 
  p->y = y; 
  p->next = NULL;for(int i=0;i<max;i++){comcom[max]=i;} 
  return p; 
} 
 
void create_next_stuff(double x, double y, stuff_mono *p0) { 
  stuff_mono *p = create_stuff(x,y); 
  p->next = p0->next; 
  p0->next = p;for(int i=0;i<max;i++){comcom[max]=i;} 
} 
 
void rotation_stuff(stuff_mono *r,double seta) { 
  double temp_x,temp_y; 
  temp_x = r->x;temp_y = r->y; 
  r->x = cos(seta)*temp_x-sin(seta)*temp_y; 
  r->y = sin(seta)*temp_x+cos(seta)*temp_y;for(int i=0;i<max;i++){comcom[max]=i;} 
} 
 
void koch_curve_stuff(stuff_mono *begin) { 
  stuff_mono *p1,*p2; 
  p1 = begin; 
  while(p1->next != NULL) { 
    p2 = p1->next; 
    stuff_mono *r = create_stuff((p2->x-p1->x)/3,(p2->y-p1->y)/3); 
    create_next_stuff(p1->x+r->x,p1->y+r->y,p1);for(int i=0;i<max;i++){comcom[max]=i;} 
    create_next_stuff(p1->next->x+r->x,p1->next->y+r->y,p1->next); 
    rotation_stuff(r,M_PI/3);for(int i=0;i<max;i++){comcom[max]=i;} 
    create_next_stuff(p1->next->x+r->x,p1->next->y+r->y,p1->next); 
    p1 = p2; for(int i=0;i<max;i++){comcom[max]=i;}
  } 
} 



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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

const int nax = 51;
vector<pair<pll,ll>> adj[nax];
vector<pll> ex(nax);  
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, m, s;
    cin >> n >> m >> s;
    ex.resize(n);
    ll x = -1;
    for(int i = 0; i < m; i++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        x = max(a,x);
        adj[u].pb(mp(mp(b,a),v));
        adj[v].pb(mp(mp(b,a),u));
    }
    x = x * (n);
    s = min(s,x);

    for(int i = 1; i <= n; i++) {
        ll c, d;
        cin >> c >> d;
        ex[i] = mp(c,d);
    }

    vector<vector<bool>> vis(n + 1, vector<bool>(x + 2, false));
    vector<vll> dist(n + 1, vll(x + 2, 1LL << 60));
    priority_queue<pll, vector<pll>, greater<pll>> q;
    q.push(mp(0,1*(x+1) + s));
    dist[1][s] = 0;

    while(!q.empty()) {
        pll p = q.top(); q.pop();
        ll minutes = p.first;
        ll code = p.second;
        ll index = code / (x+1);
        ll coins = code % (x+1);
        if(minutes > dist[index][coins]) continue;
        assert(minutes == dist[index][coins]);
        //cout << index << endl << flush;
        vis[index][coins] = true;
        ll cnt = 0;
        for(ll val = coins; val <= x; val = min(val + ex[index].first, x)) {
            //cout << "at index " << index << " and about to go to " << val << endl; 
            if(!vis[index][val] && minutes + cnt*ex[index].second < dist[index][val]) {
                dist[index][val] = minutes + cnt*ex[index].second;
                q.push(mp(dist[index][val], index*(x+1) + val)); // sending nodes to itself?????
            }
            cnt++;
            if(val == x) break;
        }
        for(auto& v : adj[index]) {
            ll time = v.first.first;
            ll need = v.first.second;
            ll dest = v.second;
            if(need <= coins) {
                ll nxt = coins - need;
                if(!vis[dest][nxt] && minutes + time < dist[dest][nxt]) {
                    dist[dest][nxt] = minutes + time;
                    q.push(mp(dist[dest][nxt], nxt + dest*(x+1)));
                }
            }      
        }
    }

    for(int i = 2; i <= n; i++) {
        ll y = 1LL << 60;
        for(int j = 0; j <= x; j++) {
            y = min(dist[i][j],y);
        }
        cout << y << endl;
    }

    return 0;
}


Measured memory_bytes: 37144
#include <stdio.h>

int main() {
  int x, y;

  while(1) {
    scanf("%d%d", &x, &y);

    if(x==0 && y==0) { // 2数が0なら終了
      break;
    }

    if(x<y) {
      printf("%d %d\n", x, y);
    } else {
      printf("%d %d\n", y, x);
    }
  }

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll N,A,B,C;
  cin>>N>>A>>B>>C;
  vector<ll> L(N);
  FORi(N){
    cin>>L[i];
  }
  ll mp=LLONG_MAX;
  for(ll i=0;i<(ll)pow(4,N);++i){
    bitset<16> bit(i);
    //cout<<(int)bit[0]<<endl;
    ll tmpa=0,tmpb=0,tmpc=0,tmpmp=0;
    for(ll ii=0;ii<N;++ii){
      ll sel = (int)bit[ii*2] + 2*(int)bit[ii*2+1];
      if(sel==0){
        if(tmpa!=0){
          tmpmp+=10;
        }
        tmpa+=L[ii];
      }else if(sel==1){
        if(tmpb!=0){
          tmpmp+=10;
        }
        tmpb+=L[ii];
      }else if(sel==2){
        if(tmpc!=0){
          tmpmp+=10;
        }
        tmpc+=L[ii];
      }
    }
    if(tmpa==0||tmpb==0||tmpc==0)continue;
    tmpmp+=abs(A-tmpa);
    tmpmp+=abs(B-tmpb);
    tmpmp+=abs(C-tmpc);
    mp=min(tmpmp,mp);
  }
  cout<<mp<<endl;
  return 0;
}

Measured memory_bytes: 256
import Foundation

func main(){
   let line = (readLine()!).split(separator: " ")
   let l = Int(line[0])!
   let r = Int(line[1])!
   let d = Int(line[2])!
   
   var i = l
   var answer = 0
   while i <= r {
      if i % d == 0 {
         answer += 1
         i += d
      } else {
         i += 1
      }
   }
   print(answer)
}
main()

Measured memory_bytes: 13592
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        k: usize,
        s: String
    }

    if s.len() <= k {
        println!("{}", s);
    } else {
        println!("{}...", &s[..k]);
    }
}


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

bool is_prime(long long x){
  if(x < 2) return false;
  if(x == 2 || x == 3) return true;
  for(int i = 2; i * i <= x; i++){
    if(x % i == 0) return false;
  }
  return true;
}
  
int main() {
  long long n;
  cin >> n;
  
  while(!(is_prime(n))) n++;
  
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


using Graph = vector<vector<int>>;

int main() {
  int N, M; cin >> N >> M;

  Graph G(N);
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }


  vector<int> dist(N, INF);
  queue<int> que;
  int num_cc = 0;
  rep(s, N) {
    if (dist[s] < INF) continue;
    dist[s] = 0;
    que.push(s);
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (auto nv : G[v]) {
        if (chmin(dist[nv], dist[v] + 1)) {
          que.push(nv);
        }
      }
    }
    ++num_cc; 
  }
  cout << num_cc << endl;
  return 0;
}

Measured memory_bytes: 6904
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int k,s;
	cin>> k >> s;
	int count = 0;

	for(int x = 0;x<=k;x++){
		for(int y = 0;y<=k;y++){
			int z = s - x - y;
				if(z >= 0 && z<=k)
				count++;
			}
	}
	cout<< count <<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int H,W,i,j,count;
  char S[51][51];

  scanf("%d %d",&H,&W);

  for(i=0;i<H;i++){
    scanf("%s",S[i]);
  }

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      count=0;
      if(S[i][j]=='#'){
	printf("#");
      } else if(S[i][j]=='.'){
	if(S[i][j+1]=='#'){
	  count++;
	}
	if(S[i][j-1]=='#'){
	  count++;
	}
	if(S[i+1][j]=='#'){
	  count++;
	}
	if(S[i-1][j]=='#'){
	  count++;
	}
	if(S[i+1][j+1]=='#'){
	  count++;
	}
	if(S[i+1][j-1]=='#'){
	  count++;
	}
	if(S[i-1][j+1]=='#'){
	  count++;
	}
	if(S[i-1][j-1]=='#'){
	  count++;
	}
	printf("%d",count);
      }
    }
    printf("\n");
  }
  return 0;
}


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

int main() {
	//input
	string N;
	cin >> N;

	//calculation
	int len = N.length();
	char zero = '0';
	int sum = 0;
	for (int i = 0; i < len; i++) {
		sum += N[i] - zero;
	}

	//output
	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


	return 0;
}


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

using namespace std;

bool is_palindrome(string s) {
  string rs = s;
  reverse(rs.begin(), rs.end());
  return s == rs;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int N = (int)S.size();
  if (is_palindrome(S) && is_palindrome(S.substr(0, (N - 1) / 2)) &&
      is_palindrome(S.substr((N + 3) / 2 - 1))) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;cin>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    int ans = 0;
    rep(i,N) rep(j,N) ans = max(ans, abs(A[i]-A[j]));
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
//O(N^2)
#include<cstdio>
#define ll long long
const int N=2005,mo=1e9+7;
int n,k,i,j,f[N][N][2];
void add(int &x,int k){x=(x+k)%mo;}
int main(){
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&k);f[n+1][0][0]=1;
	for (i=n+1;i>=3;i--){
		for (j=n+1-i;j>=0;j--){
			add(f[i-1][j+1][1],f[i][j][0]);
			add(f[i-1][j+1][1],f[i][j][1]);
			add(f[i][j][0],f[i][j+1][0]);
			add(f[i][j][1],f[i][j+1][1]);
			add(f[i-1][j][0],f[i][j][0]);
			add(f[i-1][j][0],f[i][j][1]);
		}
	}
	int ans=(f[2][n-k][0]+f[2][n-k][1])%mo;
	for (i=n-k-1;i>=1;i--) ans=2ll*ans%mo;
	printf("%d",ans);
}

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

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

const int maxN = 111;

int n, m, X, Y, x[maxN], y[maxN];

void run() {
    cin >> n >> m >> X >> Y;
    REP(i, n) {
        cin >> x[i];
    }
    REP(i, m) {
        cin >> y[i];
    }
    sort(x, x + n);
    sort(y, y + m);
    bool noWar = false;
    FOR(Z, X + 1, Y) {
        if (x[n - 1] < Z && y[0] >= Z) {
            noWar = true;
            break;
        }
    }

    cout << (noWar ? "No War" : "War") << "\n";
}

static void run_with_stack_size(void (*func)(), size_t stackSize) {
    char *stack, *send;
    stack = (char*) malloc(stackSize);
    send = stack + stackSize - 16;
    send = (char*) ((uintptr_t) send / 16 * 16);
    asm volatile(
    "mov %%rsp, (%0)\n"
    "mov %0, %%rsp\n"
    :
    : "r" (send));
    func();
    asm volatile(
    "mov (%0), %%rsp\n"
    :
    : "r" (send));
    free(stack);
}

int main() {
#ifdef LOCAL
    freopen("input", "r", stdin);
#endif
    run_with_stack_size(run, 256*1024*1024);
#ifdef LOCAL
    fclose(stdin);
#endif
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

 int dp[101][100001];


int32_t main()
{
    IOS
    
        
 
     int n,w;
     cin>>n>>w;
     int a[n],b[n];
     for(int i=0;i<n;++i)
        cin>>a[i]>>b[i];
    memset(dp,0,sizeof(dp));
    
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=w;++j)
        {
            if(i==0 or j==0)
                {
                    dp[i][j]=0;
                    continue;
                }
            dp[i][j]=dp[i-1][j];
            if(a[i-1]<=j)
            {
                dp[i][j]=max(dp[i][j],dp[i-1][j-a[i-1]]+b[i-1]);
            }
            
        }
    }
    
     cout<<dp[n][w];
    

    
}


Measured memory_bytes: 79232
import collections
n=int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=collections.Counter()
for i in range(2,n+1):
    c+=collections.Counter(prime_factorize(i))
#print(list(c.values()))
cnt1=0
cnt2=0
cnt3=0
cnt4=0
cnt5=0
cnt6=0
cnt7=0
for a in list(c.values()):
    if a>=4:
        cnt1+=1
    if a>=2:
        cnt2+=1

    if a>=14:
        cnt3+=1
    if a>=4:
        cnt4+=1

    if a>=24:
        cnt5+=1
    if a>=2:
        cnt6+=1

    if a>=74:
        cnt7+=1
print(cnt1*(cnt1-1)*(cnt2-2)//2+cnt3*(cnt4-1)+cnt5*(cnt6-1)+cnt7)


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

int main() {
  int m, k;
  cin >> m >> k;
  if (k >= (1 << m)) {
    cout << "-1\n";
    return 0;
  }
  if (m == 1) {
    if (k == 0) cout << "0 0 1 1\n";
    else cout << "-1\n";
    return 0;
  }
  cout << k << ' ';
  for (int i = 0; i < (1 << m); ++i) {
    if (i != k) cout << i << ' ';
  }
  cout << k << ' ';
  for (int i = (1 << m) - 1; i >= 0; --i) {
    if (i != k) cout << i << ' ';
  }
  cout << "\n";
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <limits>
using namespace std;
typedef long long ll;
 
#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 FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
 
template <class T> struct MaxFlow {
   const T INF = 1e9;
   struct  Edge {
      int to,rev; T cap;
      Edge(int t, int r, T c) : to(t), rev(r), cap(c) {}
   };
   vector< vector<Edge> > G;
   vector< bool > used;
   MaxFlow(int n) : G(n+1), used(n+1) {}
   void add_edge(int from, int to, int cap) {
      G[from].push_back(Edge(to,(int)G[to].size(),cap));
      G[to].push_back(Edge(from,(int)G[from].size()-1,0));
   }
   T dfs(int v, int t, T f) {
      if (v == t) return f;
      used[v] = true;
      for (int i=0; i<G[v].size(); i++) {
         Edge &e = G[v][i];
         if (!used[e.to] && e.cap > 0) {
            T d = dfs(e.to, t, min(f,e.cap));
            if (d > 0) {
               e.cap -= d;
               G[e.to][e.rev].cap += d;
               return d;
            }
         }
      }
      return 0;
   }
   T get_max (int source, int sink) {
      T flow = 0;
      while (true) {
         for (int i=0; i<used.size(); i++) used[i]=false;
         T f = dfs(source, sink, INF);
         if (f == 0) return flow;
         flow += f;
      }
   }
};

int H,W;
char a[110][110];
 
int sx,sy;
int gx,gy;
 
MaxFlow<int> inst(20000);
set<pair<int,int> >  used;
 
int main() {
 
    cin >> H >> W;
    REP(i,H)REP(j,W) cin >> a[i][j];
 
    sx = sy = gx = gy = -1;
    REP(i,H)REP(j,W) {
        if(a[i][j] == 'S') {
            sx = j;
            sy = i;
        }
        if(a[i][j] == 'T') {
            gx = j;
            gy = i;
        }
    }
 
    if(gx == sx || gy == sy) {
        cout << -1 << endl;
        return 0;
    }
 
    REP(i,H)REP(j,W) {
        if(a[i][j] == 'S') {
          inst.add_edge(0,i+1000,100000);
          inst.add_edge(0,j+2000,100000);
        } else if(a[i][j] == 'T') {
          inst.add_edge(i+1000,1,100000);
          inst.add_edge(j+2000,1,100000);
        } else if(a[i][j] == 'o') {
          inst.add_edge(i+1000,j+2000,1);
          inst.add_edge(j+2000,i+1000,1);
        }
    }
 
    cout << inst.get_max(0,1) << endl;
 
    return 0;
}

Measured memory_bytes: 1408
N, M = gets.split.map(&:to_i)
 
a = Array.new(N + 1, 0)
pt, pn = 0, 0
M.times do
  p, s = gets.split
  p = p.to_i
  next if a[p] == -1
  if s == 'AC'
    pn += a[p]
    pt += 1
    a[p] = -1
  elsif s == 'WA'
    a[p] += 1
  end
end
puts "#{pt} #{pn}"

Measured memory_bytes: 2556
n, T = map(int, input().split())
food = []
for _ in range(n):
    a, b = map(int, input().split())
    food.append((a, b))

dp1 = [[0]*T for _ in range(1+n)]
dp2 = [[0]*T for _ in range(1+n)]

for i in range(n):
    for j in range(T):
        dp1[i+1][j] = dp1[i][j]
        if j - food[i][0] >= 0:
            dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j-food[i][0]] + food[i][1])

for i in range(n-1, -1, -1):
    for j in range(T):
        dp2[i][j] = dp2[i+1][j]
        if j - food[i][0] >= 0:
            dp2[i][j] = max(dp2[i][j], dp2[i+1][j-food[i][0]] + food[i][1])

res = 0
for i in range(n):
    for j in range(T):
        res = max(res, food[i][1] + dp1[i][j] + dp2[i+1][T-1-j])
print(res)

Measured memory_bytes: 178948
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toLong)
    val bList = readLine()!!.split(" ").map(String::toLong)

    if (aList.sum() < bList.sum()) {
        print(-1)
        return
    }

    val diffList = (0 until n).map {aList[it] - bList[it]}.sortedDescending()
    val minusDiffList = diffList.filter { it < 0 }
    val minusCount = minusDiffList.size
    if (minusCount == 0) {
        print(0)
        return
    }
    val minusSum = minusDiffList.sum()
    var plusCurrentSum = 0L
    for (i in 0..diffList.size) {
        plusCurrentSum += diffList[i]
        if (plusCurrentSum >= -minusSum) {
            print(minusCount + i + 1)
            return
        }
    }
}

Measured memory_bytes: 84776
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int b[3100];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	long long ret=0;
	for(int i=0;i<a;i++){
		ret+=b[i]-1;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

signed f(int num){
    if(num%2==0)return num/2;
    else return num*3+1;
}

void run(){
    int d;
    cin >> d;
    cout << "Christmas";
    rep(i,25-d)cout << " Eve";
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define ll long long
#define pb push_back
#define INF (int)10000


int main()
{
    //fast;
	int n;
	cin>>n;
	string s,p,t;
	cin>>s;
	if(n%2 == 1){
		cout<<"No";
		return 0;
	}
	int start = n/2-1;
	int end = n-1;
	bool cond = true;
	while(start>=0){
		if(s[start] != s[end]){
			cond =false;
			break;
		}
		start--;
		end--;
	}
	if(cond){
		cout<<"Yes";
	}
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(5) << hypot(x2 - x1, y2 - y1) << endl;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
int main()
{
    string s;cin>>s;
    int c = 0;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'A') c++;
    }
    if(c == 0 || c== 3) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
def count_0_and_1(S):
    cnt_0 = 0
    cnt_1 = 0
    for i in S:
        if i == '0':
            cnt_0 += 1
        if i == '1':
            cnt_1 += 1
    return cnt_0, cnt_1


S = input()
minRB = min(count_0_and_1(S))

print(2*minRB)

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

int main(){

  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++)
    cin >> L[i];

  sort(L.begin(),L.end());

  int sum=0;

  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(L[j] == L[i]) continue;
      for(int k=j+1;k<N;k++){
        if(L[k] == L[j]) continue;
        if(L[i] + L[j] > L[k])
          sum++;
      }
    }
  }

  cout << sum << endl;

}


Measured memory_bytes: 3628
#include <stdio.h>

int main() {

	int N, M, C;
	int B[20];
	int A[20][20];
	int i, j;
	int total = 0;
	int count = 0;

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

	for (i = 0; i<M; i++) {
		scanf("%d", &B[i]);
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			scanf("%d", &A[i][j]);
		}
	}


	for (i = 0; i < N; i++) {
		total = 0;
		for (j = 0; j < M; j++) {
			total = (A[i][j] * B[j]) + total;
			
		}
		total = total + C;
		if (total > 0) {
			count++;
		}
	}

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

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[][] A = new int[2][N];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < N; j++) {
				A[i][j] = in.nextInt();
			}
		}
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int sum = 0;
			for (int j = 0; j <= i; j++) {
				sum += A[0][j];
			}
			for (int j = i; j < N; j++) {
				sum += A[1][j];
			}
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
		in.close();
	}
}

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

#define ll long long
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int H, W;
int b[30][30];
int ans;

void dfs(int y, int x, int turn) {
   if (turn > 10) return; // 判定は > でいいの？

   for (int i = 0; i < 4; i++) {
      int ty = y+dy[i], tx = x+dx[i];
      if (ty<0 || ty>=H || tx<0 || tx>=W || b[ty][tx]==1) continue;

      int ny = y, nx = x;
      while (1) {
         ny += dy[i], nx += dx[i];
         if (ny<0 || ny>=H || nx<0 || nx>=W) break;
         if (b[ny][nx] == 1) {
            b[ny][nx] = 0;
            dfs(ny-dy[i], nx-dx[i], turn+1);
            b[ny][nx] = 1;
            break;
         }
         if (b[ny][nx] == 3) {
            ans = min(ans, turn);
            break;
         }
      }
   }
}

int main() {
   while (cin >> W >> H, W) {
      int sy = 0, sx = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            cin >> b[i][j];
            if (b[i][j] == 2) {
               sy = i, sx = j;
            }
         }
      }
      ans = 100;
      dfs(sy, sx, 1);
      cout << (ans==100 ? -1 : ans) << endl;

   }

   return 0;
}


Measured memory_bytes: 3048
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    h = list(map(int, input().split()))
    m = h[0]
    ans = 0
    for i in range(1,n):
        if h[i] >= m:
            ans += 1
            m = h[i]
    print(ans+1)
    return 0

if __name__ == '__main__':
    solve()

Measured memory_bytes: 27256
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

void input(std::vector<int> *vector) {
  for (auto iv = vector->begin(); iv != vector->end(); ++iv) {
    std::cin >> *iv;
  }
  std::sort(vector->begin(), vector->end());
}

int main() {
  int n;
  std::cin >> n;

  std::vector<int> a(n);
  std::vector<int> b(n);
  std::vector<int> c(n);
  
  input(&a);
  input(&b);
  input(&c);
  
  long b_counter[n];
  long sum = 0;
  for (int i = n - 1; 0 <= i; i--) {
    const auto c_upper = std::upper_bound(c.begin(), c.end(), b[i]);
    sum += c.end() - c_upper;
    b_counter[i] = sum;
  }
  
  long ans = 0;
  for (auto ai : a) {
    const auto b_upper = std::upper_bound(b.begin(), b.end(), ai);
    if (b_upper == b.end()) {
      break;
    }
    ans += b_counter[b_upper - b.begin()];
  }
  
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);

int main(){
  int n,l;
  cin >> n >>l;
  string s="";
  vector<string>vec(n);
  rep(i,n) cin >> vec[i];
  sort(vec.begin(),vec.end());
  rep(i,n){
    s+=vec[i];
  }
  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 256