akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

//
// Minimum cost flow (primal-dual)
//
// Complexity:
//     O(FE log V) time
//

template <typename T, typename U> struct PrimalDual {
    struct edge {
        int to, rev;
        T cap;
        U cost;
        bool isrev;
        edge(int to, T cap, U cost, int rev, bool isrev) :
            to(to), cap(cap), cost(cost), rev(rev), isrev(isrev) {}
    };

    const U INF;
    vector<U> h, d;
    vector<int> prevv, preve;
    vector<vector<edge>> g;

    PrimalDual(int n) : g(n), INF(numeric_limits<T>::max()) {}

    void add_edge(int from, int to, T cap, U cost) {
        g[from].emplace_back(to, cap, cost, g[to].size(), false);
        g[to].emplace_back(from, 0, -cost, g[from].size() - 1, true);
    }

    U min_cost_flow(int s, int t, T f) {
        int n = (int)g.size();
        U res = 0;
        using P = pair<U, int>;
        priority_queue<P, vector<P>, greater<P>> que;
        h.assign(n, 0);
        prevv.assign(n, -1);
        preve.assign(n, -1);

        while (f > 0) {
            d.assign(n, INF);
            que.emplace(0, s);
            d[s] = 0;
            while (!que.empty()) {
                P p = que.top(); que.pop();
                int v = p.second;
                if (d[v] < p.first) continue;
                for (int i = 0; i < g[v].size(); ++i) {
                    edge& e = g[v][i];
                    if (e.cap > 0 && d[e.to] > d[v] + e.cost + h[v] - h[e.to]) {
                        d[e.to] = d[v] + e.cost + h[v] - h[e.to];
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        que.emplace(d[e.to], e.to);
                    }
                }
            }
            if (d[t] == INF) return -1;
            for (int v = 0; v < n; ++v) h[v] += d[v];
            T flow = f;
            for (int v = t; v != s; v = prevv[v]) {
                flow = min(flow, g[prevv[v]][preve[v]].cap);
            }
            f -= flow;
            res += flow * h[t];
            for (int v = t; v != s; v = prevv[v]) {
                edge& e = g[prevv[v]][preve[v]];
                e.cap -= flow;
                g[v][e.rev].cap += flow;
            }
        }
        return res;
    }

    void output() {
        for (int i = 0; i < g.size(); ++i) {
            for (auto& e : g[i]) {
                if (e.isrev) continue;
                auto& rev_e = g[e.to][e.rev];
                cout << i << " -> " << e.to << " (flow: " << rev_e.cap << "/" << rev_e.cap + e.cap << ")" << endl;
            }
        }
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int V, E, F;
    cin >> V >> E >> F;
    PrimalDual<int, int> g(V);
    REP (i, E) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        g.add_edge(u, v, c, d);
    }
    cout << g.min_cost_flow(0, V - 1, F) << endl;
}


Measured memory_bytes: 3352
#include <stdio.h>

int main(){

    int array[10][10];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d", &array[i][j]);
        }
    }
/*    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            printf("%d ", array[i][j]);
        }
        printf("\n");
    }
*/
    int brpKali;
    scanf("%d", &brpKali);
    int percobaan[100];
    for(int k=0;k<brpKali;k++){
        scanf("%d", &percobaan[k]);
    }
/*    for(int k=0;k<brpKali;k++){
        printf("%d", percobaan[k]);
    }
*/

    for(int l=0;l<brpKali;l++){
        for(int m=0;m<3;m++){
            for(int n=0;n<3;n++){
                if(percobaan[l]==array[m][n]){
                    array[m][n]=0;
                }
            }
        }
    }

if(array[0][0]+array[1][1]+array[2][2]==0){
        printf("Yes\n");
    }
    else if(array[0][2]+array[1][1]+array[2][0]==0){
        printf("Yes\n");
    }
    else if(array[0][0]+array[0][1]+array[0][2]==0){
        printf("Yes\n");
    }
    else if(array[1][0]+array[1][1]+array[1][2]==0){
        printf("Yes\n");
    }
    else if(array[2][0]+array[2][1]+array[2][2]==0){
        printf("Yes\n");
    }
    else if(array[0][0]+array[1][0]+array[2][0]==0){
        printf("Yes\n");
    }
    else if(array[0][1]+array[1][1]+array[2][1]==0){
        printf("Yes\n");
    }
    else if(array[0][2]+array[1][2]+array[2][2]==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }


    return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

vector<int> par, sz;

    void init(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i =0; i < n; i++)
            par[i] = i, sz[i] = 0;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else 
            return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);

        if (x == y) return ;

        else if (sz[x] < sz[y])
            par[x] = y;
        else {
            par[y] = x;
            if (sz[x] == sz[y])
                sz[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

int main() {
    int n, m;   cin >> n >> m;
    init(n);
    for (int i = 0; i < m; i++) {
        int a, b;   cin >> a >> b;
        unite(a-1, b-1);
    }

    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        mp[find(i)]++;
    }

    int ans = 0;
    for (auto ite = mp.begin(); ite != mp.end(); ite++)
        ans = max(ans, (*ite).second);

    cout << ans << endl;

    return 0;
}

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

using namespace std;

// insert
void sort(vector<int>& v){
    for(int i=1; i<v.size(); i++){
        for(int j=i; j>0; j--){
            if (v[j] < v[j-1]) {
                int t = v[j];
                v[j] = v[j-1];
                v[j-1] = t;
            }
        }
    }
}

int main() {
    // input
    int N, x;
    cin >> N >> x;
    vector<int> a;
    for(int i=0; i<N; i++){
        int l;
        cin >> l;
        a.push_back(l);
    }

    // sort
    sort(a);

    int answer=0;
    for(int i=0; i<N; i++){
        x -= a[i];
        if (x < 0) break;
        answer++;
    }
    if (x > 0) answer--;

    cout << answer << endl;

    return 0;
}

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

int main() {
	int c1, c2, c3;
	while(cin >> c1 >> c2 >> c3){
		int s = c1 + c2, cnt = 0;
		bool check[16] = {0};
		check[c1] = check[c2] = check[c3] = true;
		for(int i = 1; i <= 10; ++i){
			if(s + i > 20)
				break;
			if(s + i <= 20 && !check[i])
				cnt++;
		}
		if(cnt >= 4)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    
    int s[] = new int[N];
    int t[] = new int[N];
    int c[] = new int[N];
    
    for (int i = 0; i < N; i++) {
      s[i] = Integer.parseInt(sc.next());
      t[i] = Integer.parseInt(sc.next());
      c[i] = Integer.parseInt(sc.next());
    }
    
    final int maxTime = 100000;
    byte table[][] = new byte[C][maxTime * 2 + 2];
    for (int i = 0; i < N; i++) {
      for (int j = s[i]; j <= t[i]; j++) {
        table[c[i] - 1][j] = 1;
      }
    }
    int ans = 0, count = 0;
    for (int i = 0; i < maxTime; i++) {
      count = 0;
      for (int j = 0; j < C; j++) {
        count += table[j][i];
      }
      if (ans < count) {
        ans = count;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 63532
#include <cstdio>
#include <set>
#include <tuple>

int main() {
    int n;
    std::set<std::tuple<int, int, int, int>> s;
    while (~scanf("%d", &n)) {
        for (int a = 0; a < 10 && a <= n; ++a) {
            for (int b = 0; b < 10 && a + b <= n; ++b) {
                for (int c = 0; c < 10 && a + b + c <= n; ++c) {
                    for (int d = 0; d < 10 && a + b + c + d <= n; ++d) {
                        if (a + b + c + d == n) {
                            s.insert(std::make_tuple(a, b, c, d));
                        }
                    }
                }
            }
        }
        printf("%lu\n", s.size());
        s.clear();
    }
}

Measured memory_bytes: 1060
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a =int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換


    if op=="?": # opが"?"の時は終了
        break
    else:    #opが"?"以外の時
        if op=="+":
            print(a+b)
        if op=="-":
            print(a-b)
        if op=="*":
            print(a*b)
        if op=="/":
            print(a//b)



Measured memory_bytes: 5596
//
//  cakes.cpp
//  Competitions
//
//  Created by macbook on 10/23/16.
//  Copyright © 2016 LiorCohen. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef unsigned long long ULL;

int main() {
    
    std::ios_base::sync_with_stdio(false);  //make input/output faster!!!
    
    ULL N;
    cin >> N;
    
    vector<ULL> Tak(N),Aoki(N),Sure(N,0);
    
    for (ULL i = 0; i<N; i++) {
        cin >> Tak[i];
        if (i == 0) {
            Sure[i] = Tak[i];
        } else {
            if (Tak[i] > Tak[i-1]) {
                Sure[i] = Tak[i];
            }
            if (Tak[i] == 1) {
                Sure[i] = 1;
            }
        }
    }
    for (ULL i = 0; i<N; i++) {
        cin >> Aoki[i];
    }
    
    //traverse aoki from right to left:
    for (ULL i=N; i>0; i--) {
        if (i-1 == N-1) {
            //  this is sure
            if ((Aoki[i-1] > Tak[i-1]) || ( Sure[i-1] != 0 && Sure[i-1] != Aoki[i-1] )) {
                // illegal
                cout << 0 << endl;
                return 0;
            }
            Sure[i-1] = Aoki[i-1];
        }
        if (Aoki[i-1] == 1 || Aoki[i-1] > Aoki[i]) {
            if (( Sure[i-1] != 0 && Sure[i-1] != Aoki[i-1] )) {
                // illegal
                cout << 0 << endl;
                return 0;
            }
            Sure[i-1] = Aoki[i-1];
        }
        
    }
    
    for (int i=0; i<N; i++) {
        if (Sure[i] != 0 && Sure[i] > Aoki[i]) {
            //  illegal
            cout << 0 << endl;
            return 0;
        }
        if (Sure[i] != 0 && Sure[i] > Tak[i]) {
            //  illegal
            cout << 0 << endl;
            return 0;
        }
    }
    
    ULL psbl = 1;
    for (ULL i=0; i<N; i++) {
        if (Sure[i] == 0) {
            ULL curPsbl = (Aoki[i] < Tak[i]) ? Aoki[i] : Tak[i];
            curPsbl = curPsbl % (ULL) (pow(10, 9)+7);
            psbl = psbl * curPsbl;
            psbl = psbl % (ULL)(pow(10,9)+7);
        }
    }
    
    
    
    cout << psbl << endl;
    
    return 0;
}

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

int dat[400000], lazy[400000], N;
inline void push(int k) {
	if (lazy[k] == -1)return;
	dat[k] = lazy[k];
	if (k < N - 1) {
		lazy[2 * k + 1] = lazy[k];
		lazy[2 * k + 2] = lazy[k];
	}
	lazy[k] = -1;
}
inline void update_node(int k) {
	dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
}
inline void update(int a, int b, int x, int k, int l, int r) {
	push(k);
	if (r <= a || b <= l)return;
	if (a <= l&&r <= b) {
		lazy[k] = x; push(k); return;
	}
	update(a, b, x, k * 2 + 1, l, (l + r) / 2); update(a, b, x, k * 2 + 2, (l + r) / 2, r);
	update_node(k);
}
inline int query(int a, int b, int k, int l, int r) {
	push(k);
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l&&r <= b)return dat[k];
	int lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
	int rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
	update_node(k);
	return min(lb, rb);
}
int main() {
	int n, q; scanf("%d%d", &n, &q);
	N = 1; while (N < n)N <<= 1;
	rep(i, 2 * N - 1)dat[i] = INT_MAX, lazy[i] = -1;
	rep(i, q) {
		int t; scanf("%d", &t);
		if (t == 0) {
			int a, b, x; scanf("%d%d%d", &a, &b, &x);
			update(a, b + 1, x, 0, 0, N);
		}
		else {
			int a, b; scanf("%d%d", &a, &b);
			printf("%d\n", query(a, b + 1, 0, 0, N));
		}
	}
}

Measured memory_bytes: 5280
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    def nibutan(ok,ng):
        while abs(ok-ng) > 1:
            mid = (ok + ng) // 2
            if solve(mid,2):
                ok = mid
            else:
                ng = mid
        return ok
    
    def solve(mid,n):
        dif=(d_0+d_1)*(mid-1)
        c=0
        if dif*(dif+d_0) == 0:
            c+=1
        elif dif*(dif+d_0) < 0:
            c+=1
            if (dif+d_0)*(dif+d_0+d_1) < 0:
                c+=1
        if c==n:
            return True
        else:
            return False
    
    T=list(map(int,input().split()))
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    d_0=T[0]*(A[0]-B[0])
    d_1=T[1]*(A[1]-B[1])
    if d_0==-d_1:
        print('infinity')
    elif d_0*(d_0+d_1)<0:
        if (d_0*2+d_1)*(d_0*2+d_1*2)<0:
            n=nibutan(2,10**40)
            ans=n*2-1
            ans+=solve(n+1,1)
            print(ans)
        else:
            print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int MOD=1e5+3;
const int INF=0x3f3f3f3f;
const int N=1e5+5;
int main()
{
    int n,a,b;
    while(~scanf("%d%d%d",&n,&a,&b))
    {
        int d1=b-a;
        if(d1%2==0) puts("Alice");
        else puts("Borys");
    }
    return 0;
}


Measured memory_bytes: 256
function main()
  
  S = split(chomp(readline()),"")
  
  ans = 1000
  
  for i in 1:length(S)-2
    
    check = parse(Int,join(S[i:i+2]))
    ans = min(ans,abs(753-check))
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 110756
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

const ll MOD = 1'000'000'007;

ll Bikkuri(ll n){
  ll ret = 1;
  for (ll i=1; i<=n; i++){
    ret *= i;
    ret %= MOD;
  }
  ret %= MOD;
  //cout << n << ":" << ret << endl;
  return ret;
}

int main(){
  ll n,m; cin>>n>>m;
  if (abs(n-m) >= 2){
    cout << 0 << endl;
    return 0;
  }
  else if (n == m){
    ll ans = Bikkuri(n) * Bikkuri(m);
    ans %= MOD;
    ans *= 2;
    ans %= MOD;
    cout << ans << endl;
    return 0;
  }
  else{
    ll ans = Bikkuri(n) * Bikkuri(m);
    ans %= MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAXOP 100
#define NUMBER '0'

int getop(char []);
void push(double);
double pop(void);

int main(){
	int type;
	double op2;
	char S[MAXOP];

	while((type = getop(S)) != EOF) {
		switch (type) {
		case NUMBER:
			push(atof(S));
			break;
		case '+':
			push(pop() + pop());
			break;
		case '*':
			push(pop() * pop());
			break;
		case '-':
			op2 = pop();
			push(pop() - op2);
			break;
		case '/':
			op2 = pop();
			if (op2 != 0.0)
				push(pop() / op2);
			else
				printf("error: zero divisor\n");
			break;
		case '\n':
			printf("%g\n", pop());
			break;
		default:
			printf("error: unknown command %s\n", S);
			break;
		}
	}
	return 0;
}

#define MAXVAL 100

int sp = 0;
double val[MAXVAL];


void push(double f){
	if (sp < MAXVAL)
		val[sp++] = f;
	else
		printf("error: stack full, can't push %g\n", f);
}

double pop(void){
	if (sp > 0)
		return val[--sp];
	else {
		printf("error: stack empty\n");
		return 0.0;
	}
}

#include <ctype.h>

int getch(void);
void ungetch(int);
int getop(char s[]){
	int i, c;

	while ((s[0]= c = getch()) == ' ' || c == '\t')
		;
	s[1] = '\0';
	if (!isdigit(c) && c != '.')
		return c;
	i = 0;
	if (isdigit(c)) 
		while (isdigit(s[++i] = c = getch()))
			;
	if (c == '.') 
		while (isdigit(s[++i] = c = getch()))
			;
	s[i] = '\0';
	if (c != EOF)
		ungetch(c);
	return NUMBER;
}

#define BUFsIZE 100

char buf[BUFsIZE];
int bufp =0;

int getch(void) {
	return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c) {
	if (bufp >= BUFsIZE)
		printf("ungetch: too many characters\n");
	else
		buf[bufp++] = c;
}

Measured memory_bytes: 568
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	string s, t;
	cin >> s >> t;
	int ans = MOD;
	for (int i = 0; i + t.size() <= s.size(); i++) {
		int box = 0;
		auto u = s.substr(i, t.size());
		for (int j = 0; j < t.size(); j++) {
			box += u[j] != t[j];
		}
		ans = min(ans, box);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000+10
typedef long long LL;
int n,a[MAXN],b[MAXN],c[MAXN];
LL ans=0,sum[MAXN];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	for(int i=1;i<=n;i++){
		int t=upper_bound(c+1,c+n+1,b[i])-c;
		sum[i]=n-t+1;
	}	
	for(int i=n;i;i--)sum[i]+=sum[i+1];
	for(int i=1;i<=n;i++)	{
		int t=upper_bound(b+1,b+n+1,a[i])-b;
		ans+=sum[t];
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    int N, V, P;
    long long M;
    cin>>N>>M>>V>>P;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    vector<long long> S(N+1);
    S[0] = 0;
    for (int i=0; i<N; i++)
        S[i+1] = S[i]+A[i];

    int N2 = 1;
    while (N2<N)
        N2 *= 2;

    auto f = [&](long long x)
    {
        int a = 0;
        for (int b=N2; b>0; b/=2)
            if (a+b<N && A[a+b]>=x)
                a += b;
        if (A[a]>=x)
            return a;
        else
            return -1;
    };

    int ans = 0;
    for (int i=0; i<N; i++)
    {
        if (A[i]>=A[P-1])
            ans++;
        else if (A[i]+M<A[P-1])
            ;
        else if (V<=(N-i)+(P-1))
        {
            if (A[i]+M>=A[P-1])
                ans++;
        }
        else
        {
            long long d = (V-(N-i)-(P-1))*M;
            int p = max(P-1, f(A[i]+M)+1);

            long long x = (i-p)*(A[i]+M) - (S[i]-S[p]);
            if (x>=d)
                ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace Atcoder
{
    public class Program
    {
        public static List<string> input;
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            string result;
            
            input = ReadTexts();
            long cnt = input[0].ToLong();

            List<string> l = new List<string>();
            for (int i = 0; i < cnt; i++)
            {
                l.Add(ReadTexts()[0]);
            }

            result = l.Distinct().Count().ToString();

            return result;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }

        #endregion
    }

    public static class CastExtention
    {
        public static long ToLong(this string a) { return long.Parse(a); }
    }
}



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

int main(){
    ll t[2], a[2], b[2];
    cin >> t[0] >> t[1];
    cin >> a[0] >> a[1];
    cin >> b[0] >> b[1];

    ll p = (b[0]-a[0])*t[0];
    ll q = (b[1]-a[1])*t[1];
    if(p + q == 0){
        cout << "infinity\n";
    } else if (abs(q) < abs(p) || (q > 0 && p > 0) || (q < 0 && p < 0)){
        cout << 0 << endl;
    } else {
        ll dx = abs(p + q);
        ll n = abs(p) / dx;
        if(abs(p) == n * dx){
            cout << 2 * n << endl;
        } else {
            cout << 2 * n + 1 << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    map<int,int> c;
    int n;
    cin>>n;
    REP(i,n){
        int d;
        cin>>d;
        c[d]++;
    }

    cin>>n;
    REP(i,n){
        int d;
        cin>>d;
        c[d]--;
        if(c[d]<0){
            YES(0);
            return 0;
        }
    }
    YES(1);
    
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	int a, b;
	cin >> a >> b;

	if (a >= 9 || b >= 9) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#define MYDEBUG
/*
 * C.cpp
 *
 *  Created on: 2018/07/10 14:27
 *      Author: jln
 */

#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	out << endl;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
	out << "{" << p.first << "," << p.second << "}";
	return out;
}
struct edge {
	int from, to, cost;
	edge(int f, int t, int c) {
		from = f;
		to = t;
		cost = c;
	}
	edge() {
		from = -1;
		to = -1;
		cost = -1;
	}
	bool operator<(const edge& e) const {
		return cost < e.cost;
	}
};
struct vertex {
	int id, val1, val2;
	vertex(int id_, int val1_, int val2_) {
		id = id_;
		val1 = val1_;
		val2 = val2_;
	}
	vertex() {
		id = 0;
		val1 = val2 = 0;
	}
};
ostream& operator<<(ostream& out, const edge& e) {
	out << "(";
	out << e.from << "->" << e.to << ": ";
	out << e.cost;
	out << ")";
	return out;
}
ostream& operator<<(ostream& out, const vertex& v) {
	out << "<";
	out << v.id << ": ";
	out << v.val1 << ", "; //なにかの要素，値
	out << v.val2; //なにかの要素，値
	out << ">";
	return out;
}
typedef struct edge edge;
typedef struct vertex vertex;
ll N, b;
vector<ll> a, diff;
void solve() {
	cin >> N;
	a = vector<ll>(N);
	rep(i,0,N)
	{
		cin >> a[i];
		diff.push_back(a[i] - (i + 1));
	}
	sort(all(diff));
	if (N % 2 == 0) {
		b = (diff[N / 2 - 1] + diff[N / 2]) / 2;
	} else {
		b = diff[N / 2];
	}
	ll sum = 0;
	rep(i,0,N)
	{
		sum += abs(a[i] - (i + 1) - b);
	}
	cout << sum << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 3956
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    a = ri()
    print (a + a*a + a*a*a)





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


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

const int inf = -1000;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}
void bubble(vector<int> &v){
int n = v.size();
  for(int k=1;k<=n-1;++k){
    for(int i=1;i<n;++i){
        if(v[i]<v[i-1])
            swap(v[i],v[i-1]);
    }
  }
}
int main() {

   int a,p;
   cin>>a>>p;
   
   cout<<(3*a + p)/2;

    return 0;

      }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 1005;

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

int n, m, i, j, maxx, res[N][N], tab[N][N];
ii w;
queue<ii> q;
char t[N];

bool ok(int a, int b) {
	return a >= 0 && b >= 0 && a < n && b < m && res[a][b] == -1;
}


int main() {
scanf("%d %d", &n, &m);
while (!q.empty()) q.pop();
for (i=0;i<n;i++) {
	scanf("%s", t);
	for (j=0;j<m;j++) {
		tab[i][j] = (t[j] == '#');
		if (tab[i][j]) {
			res[i][j] = 0;
			q.push(ii(i, j));
		} else res[i][j] = -1;
	}
}
maxx = 0;
while (!q.empty()) {
	w = q.front();
	q.pop();
	for (i=0;i<4;i++) if (ok(w.first + dx[i], w.second + dy[i])) {
		q.push(ii(w.first + dx[i], w.second + dy[i]));
		res[w.first + dx[i]][w.second + dy[i]] = res[w.first][w.second] + 1;
		maxx = max(maxx, res[w.first + dx[i]][w.second + dy[i]]);
	}
}
printf("%d\n", maxx);
}




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

const long long MOD = 1000000007;

void solve(long long N){
    ll ans = 1;
    for(ll i=0; i< N; i++){
        ans = (ans * (i+1)) % MOD;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
def yakusuu(N):
    P = [1,N]
    for k in range(2,math.floor(math.sqrt(N))+1):
        if N % k == 0:
            P.append(k)
            P.append(N//k)
    return len(set(P))
ans = 0
for k in range(1,N+1,2):
    if yakusuu(k) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
 
int main(){
  int x,a,b,sum,n;
  
  scanf("%d", &x);
  scanf("%d", &a);
  scanf("%d", &b);
  
  sum=x-a;
  
  n=sum/b;
  
  sum=sum-b*n;
  
  printf("%d",sum);
  
  return 0;
}

Measured memory_bytes: 128
#include"iostream"
#include"algorithm"
#include"string"
using namespace std;

int main(){
  int n;
  int temp;
  int a[5][10000]={-1};
  int ans[10000];
  int b,c;
  int digit;
  int digit_now=0;
  int count=0;
  int digit_num[5]={0};
  bool flag=true;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>temp;
    digit=to_string(temp).length();
    a[digit-1][digit_num[digit-1]++]=temp;
  }
  for(int i=0;i<5;++i){
    sort(a[i],a[i]+digit_num[i]);
    if(digit_num[i]==n)flag=false;
  }
  if(flag){
    while(1){
      for(int i=0;i<digit_now+1;++i){
        //cout<<"i: "<<i<<endl;
        for(int j=0;j<digit_num[i];++j){
          b=a[i][j];
          //cout<<"b: a["<<i<<"]["<<j<<"]: "<<b<<endl;
          int k=digit_now-i;
          if(k<0)break;
          for(int l=0;l<digit_num[k];++l){
            if(k==i && l==j)continue;
            if(a[k][l]!=-1)count++;
            c=a[k][l];
            //cout<<"c: a["<<i<<"]["<<j<<"]: "<<c<<endl;
            ans[count-1]=stoi(to_string(b)+to_string(c));
          }
        }
      }
      if(count>3){
        sort(ans,ans+count);
        //for(int i=0;i<count;++i)
        //cout<<"ans["<<i<<"]: "<<ans[i]<<endl;
        cout<<ans[2]<<endl;
        return 0;
      }
      digit_now++;
    }
  }else{
    while(1){
      for(int i=0;i<digit_now+1;++i){
        //cout<<"i: "<<i<<endl;
        for(int j=0;j<digit_num[i];++j){
          b=a[i][j];
          //cout<<"b: a["<<i<<"]["<<j<<"]: "<<b<<endl;
          int k=digit_now-i;
          if(k<0)break;
          for(int l=0;l<digit_num[k];++l){
            if(k==i && l==j)continue;
            if(a[k][l]!=-1)count++;
            c=a[k][l];
            //cout<<"c: a["<<i<<"]["<<j<<"]: "<<c<<endl;
            if(count==3){
              cout<<to_string(b)+to_string(c)<<endl;
              return 0;
            }
          }
        }
      }
      digit_now++;
    }
  }
}



Measured memory_bytes: 3468
package main

import "fmt"

func main() {
	var a, b, ans int
	fmt.Scanf("%d %d", &a, &b)
	if a >= b {
		ans += a
		a--
	} else {
		ans += b
		b--
	}

	if a >= b {
		ans += a
		a--
	} else {
		ans += b
		b--
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    r = 2*m+1
    if m%2:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2+1):
            ans.append([i,m+1+r-i])
    else:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2):
            ans.append([i,m+1+r-i])            
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 22604
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<int> v[100100];
map<int,int> de[100100];
int p[100100],y[100100];
int main()
{
	int n,m;
	cin>>n>>m;
	rep(i,m){
		cin>>p[i]>>y[i];
		v[p[i]].pb(y[i]);
	}
	rep(i,n+10){
		if(v[i].size()<1) continue;
		sort(All(v[i]));
		rep(j,v[i].size()) de[i][v[i][j]]=j+1;
	}
	rep(i,m){
		//printf("%12f\n",p[i]*1000000+de[p[i]][y[i]]);
		if(p[i]<10) cout<<"00000";
		else if(p[i]<100) cout<<"0000";
		else if(p[i]<1000) cout<<"000";
		else if(p[i]<10000) cout<<"00";
		else if(p[i]<100000) cout<<"0";
		cout<<(lint)p[i]*1000000+de[p[i]][y[i]]<<endl;
	}
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  for(int i = 1; i < 100000; i++){
    if((B * i + C) % A == 0){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
ll  x;
cin >> x;
ll m = x / 500;
x = x - m*500;
ll n = x / 5;
ll ans = 1000*m + 5 * n;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3636
import math

a, b, c = map(int, input().split())
print('{:f}'.format(a * b * math.sin(math.radians(c)) / 2))
print('{:f}'.format(a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(c)))))
print('{:f}'.format(b * math.sin(math.radians(c))))


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

const ll MX = 1e18;

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    
    bool ng = false;
    rep(i,n){
        ll a;
        cin >> a;
        if (a==0){
            cout << 0;
            return 0;
        }
        if(ng || MX/ans < a || ans*a > MX){
            ng = true;
        }
        ans*=a;
    }
    if(ng)cout << -1;
    else cout << ans;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == 'L' && i%2 == 0){
            cout << "No";
            return 0;
        }
        if(s[i] == 'R' && i%2 == 1){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    
    ll a = 0;
    rep(i, n) a += v[i];
    
    ll b = 0;
    rep(i, n) {
        b += v[i];
        if (2 * b == a) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    b = 0;
    ll ans = INF;
    rep(i, n) {
        b += v[i];
        chmin(ans, abs(2 * b - a));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N = int(input())
s,t = input(),input()
i = N
while i>0 and s[N-i:]!=t[:i]:
    i -= 1
print(2*N-i)

Measured memory_bytes: 65572
n = int(input())
a = list(map(int,input().split()))

import collections

e = collections.Counter(a)

count = 0
for i in e.keys():
    m = e[i]
    count += m*(m-1)//2

for k in range(n):
    b = a[k]
    c = e[b] - 1
    ans = count - c
    print(ans)

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

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

  int ans = 0;
  for (int i = 0; i < s.size() - 2; i++) {
    if (s.substr(i, 3) == "ABC") ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        String inputs[] = input.split(" ");
          long k = Long.valueOf(inputs[0]);
          long a = Long.valueOf(inputs[1]);
      	  long b = Long.valueOf(inputs[2]);
        if(b-a<=2) {
        	System.out.println(k+1);
          	return;
        }
       if(k-(a-1)<=0) {
       		System.out.println(k+1);
         	return; 
       }
      	long totalBiscuits = a; 
      	k = k-(a-1);
        totalBiscuits += (b-a)*(k/2); 
      	if(k%2==1)
          totalBiscuits++;
      	
      	System.out.println(totalBiscuits);
      
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
const int mxn=1e9+5;
int main()
{
    fast;
    ll a;
    ll b1,b2;
    char c;
    cin>>a>>b1>>c>>b2;
    ll b=b1*100+b2;
    //ll c=b;
    //cout<<b<<endl;
    ll ans=a*b;
    ans=ans/100;
    cout<<ans<<endl;

}



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

int main(){
  int N;
  cin >> N;
  vector<int> d(N+1);
  for(int i=0;i<N+1;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  if(d[N/2]==d[N/2+1]){
    cout << 0 << endl;
  }
  else{
    cout << d[N/2+1]-d[N/2] << endl;
  }
}

Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var X = sc.ReadIntArray(3);
        Array.Sort(X);
        var ans = 10 * X[2] + X[0] + X[1];
        Console.WriteLine(ans);
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class Vec{
public:
  double x, y;
  Vec(double x = 0, double y = 0):x(x),y(y){}

  void read(){
    cin >> x >> y;
  }
  
  Vec operator+(const Vec &other)
  {
    Vec result = *this;
    result.x += other.x;
    result.y += other.y;
    return result;
  }

  Vec operator-(const Vec &other)
  {
    Vec result = *this;
    result.x -= other.x;
    result.y -= other.y;
    return result;
  }

  Vec operator*(const float &k)
  {
    Vec result = *this;
    result.x *= k;
    result.y *= k;
    return result;
  }

  Vec operator/(const float &k)
  {
    Vec result = *this;
    result.x /= k;
    result.y /= k;
    return result;
  } 
  
  double cross(const Vec &other)
  {
    return x*other.y - y*other.x;
  }

  double dot(const Vec &other){
    return x*other.x + y*other.y;
  }
  
  bool operator==(const Vec &other) const
  {
    return abs(x - other.x) < EPS && abs(y - other.y) < EPS;
  }

  float norm()
  {
    return sqrt(x*x+y*y);
  }

  float norm2()
  {
    return x*x+y*y;
  }

  Vec standard(){
    Vec result = *this;
    return result/result.norm();
  }
};

class Line{
public:
  Vec a, b;
  Vec vect;
  Line(Vec a = Vec(), Vec b = Vec()):a(a),b(b),vect(b-a){}

  //projection
  Vec proj(Vec p){
    p = p - a;
    return a + vect * vect.dot(p) / vect.norm2();
  }
};

int main(){
  Vec p1, p2, p0;
  Int q;
  p1.read();
  p2.read();
  Line l(p1, p2);
  cin >> q;
  while(q--){
    p0.read();
    Vec ans = l.proj(p0);
    printf("%.10lf %.10lf\n",ans.x, ans.y);
  }
  return 0;
}


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

int main()
{
  int n;
  double t, a, b, c;
  int d = 1;
  cin >> n >> t >> a;
  double h[n];
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  b = abs(t - h[0] * 0.006 - a);
  for (int i = 1; i < n; i++)
  {
    c = abs(t - h[i] * 0.006 - a);
    if (b > c)
    {
      b = c;
      d = i + 1;
    }
    else
    {
      continue;
    }
  }
  cout << d << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mxN =150000;
int32_t main(){
  ios_base::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);

     int x; cin>>x;
     int res=x+x*x+x*x*x;
     cout<<res<<endl;




 return 0;}



Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int D,ans = 60000;
  long long G;
  scanf("%d%lld",&D,&G);

  int p[D];
  long long c[D];
  for(int i = 0;i < D;i++){
    scanf("%d%lld",&p[i],&c[i]);
  }

  int sample,counter,restmax,num;
  long long sum;
  int length = 0;
  sample = pow(2,D)-1;
  while(sample > 0){
    sample /= 2;
    length++;
  }
  for(int i = 0;i < pow(2,D);i++){
    sample = i;
    counter = 0;
    sum = 0;
    num = 0;
    while(counter < length){
      if(sample%2 != 0){
        sum += 100*(counter+1)*p[counter]+c[counter];
        num += p[counter];
      }else{
        restmax = counter;
      }
      sample /= 2;
      counter++;
    }
    if(sum >= G){
      ans = min(ans,num);
    }else if(sum + 100*(restmax+1)*(p[restmax]-1) >= G){
      int need = 0;
      while(sum+100*(restmax+1)*need < G){
        need++;
      }
      num += need;
      if(need < p[restmax]){
        ans = min(ans,num);
      }
    }
  }

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

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    int N, M, i, A, B, count=0;

    scanf("%d",&N);
    scanf("%d",&M);
    long H[N], H2[N];

    for(i=0; i<N; i++) {
        scanf("%ld",&H[i]);
        H2[i] = 0;
    }

    for(i=0;i<M;i++) {
        scanf("%d",&A);
        scanf("%d",&B);
        if(H[A-1] < H[B-1]) {
            H2[A-1] = 1;
        } else if(H[A-1] > H[B-1]) {
            H2[B-1] = 1;
        } else {
            H2[A-1] = 1;
            H2[B-1] = 1;
        }
    }

    for(i=0;i<N;i++) {
        if(H2[i] == 0) {
            count++;
        } 
    }

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

    return 0;
}


Measured memory_bytes: 3236
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main(){
  int x;
  cin >> x;
  if(x >= 30){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int N;
    cin >> N;
    vector<pair<ll,ll>> range(N);
    // vll left(N),right(N);
    ll X,L;
    rep(i,N){
        cin >> X >> L;
        range[i].fi = X+L;
        range[i].sc = X-L;
    }
    sort(ALL(range));
    ll ans = 1;
    ll left, right, line=range[0].fi;
    rng(i,1,N){
        left = range[i].sc;
        right = range[i].fi;
        if(left >= line) {
            ans++;
            line = right;
        }
    }
    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(){
	string S;
	cin >> S;
	int samei=0;
	string ans = "No";

	for (int i = 1; i < 4; i++){
		if (S[0] == S[i])
		{
			samei = i;
			if (samei == 1)
			{
				if(S[2]== S[3] && S[samei] != S[2])
					ans = "Yes";
			}
			else if(samei == 2){
				if(S[1] == S[3] && S[samei] != S[1] )
					ans = "Yes";
			}
			else if(samei == 3){
				if(S[1] == S[2] && S[samei] != S[1] )
					ans = "Yes";
			}
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256