akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

struct UnionFind{
    
    vector<int> M_par;
    vector<int> M_rank;
    vector<int> M_size;

private:
    void init(int n = 1){
        M_par.resize(n);
        M_rank.resize(n);
        M_size.resize(n);
        for(int i = 0; i < n; i++){
            M_par[i] = i;
            M_rank[i] = 0;
            M_size[i] = 1;
        }
    }

public:

    UnionFind(size_t n = 1){
        init(n);
    }

    size_t find(size_t x){
        if(M_par[x] == x) return x;
        size_t r = find(M_par[x]);
        return M_par[x] = r;
    }
    
    bool same(size_t x, size_t y){
        return find(x) == find(y);
    }

    bool unite(size_t x, size_t y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(M_rank[x] < M_rank[y]) swap(x, y);
        if(M_rank[x] == M_rank[y]) M_rank[x]++;
        M_par[y] = x;
        M_size[x] = M_size[x] + M_size[y];
        return true;
    }

    size_t size(size_t x){
        return M_size[find(x)];
    }

};

int main() {
  
  int n, m, k; cin >> n >> m >> k;
  UnionFind uf(n);
  vector<set<int>> dame(n);
  
  for(int i = 0; i < n; i++) dame[i].insert(i);

  for(int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
    dame[a].insert(b);
    dame[b].insert(a);
  }

  for(int i = 0; i < k; i++) {
    int a, b; cin >> a >> b;
    a--;
    b--;
    if(uf.same(a, b)) {
      dame[a].insert(b);
      dame[b].insert(a);
    }
  }
  
  for(int i = 0; i < n; i++) {
    cout << uf.size(i) - dame[i].size();
    if(i == n - 1) cout << endl;
    else cout << " ";
  }
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    unsigned long long N=in();
    unsigned long long K=in();
    unsigned long long ans;
    ans=K;
    REP(i,N-1){
        ans*=K-1;
    }
    cout<<fixed;
    print(ans);
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    a,b = LI()
    if not (a*b)%2:
        print("Even")
    else:
        print("Odd")
    return

#B
def B():
    s = S()
    print(s.count("1"))
    return

#C
def C():
    n = I()
    a = LI()
    f = 0
    for j in range(100000):
        for i in range(n):
            if a[i]%2:
                f = 1
                break
            a[i] //= 2
        if f:break
    print(j)
    return

#D
def D():
    a,b,c,x = IR(4)
    su = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 500*i+100*j+50*k == x:su += 1
    print(su)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 43888
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
ll n,m,x;
ll a[100][100];
ll c[100];
int main()
{
    ll sum=inf;
    cin>>n>>m>>x;
    for(int i=0; i<n; i++)
    {
        cin>>c[i];
        for(int j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<(1<<n);i++)
    {
        ll ans=0;
        int k[100];
        memset(k,0,sizeof(k));
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                ans+=c[j];
                for(int y=0;y<m;y++)

                {
                    k[y]+=a[j][y];
                }
            }
        }
        int t=1;
        for(int j=0;j<m;j++)
        {
            if(k[j]<x)
            {
                t=0;
                break;
            }
        }
        if(t==1)
        {
            sum=min(sum,ans);
        }
    }
    if(sum==inf)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,temp=1,temp1=1;
    cin>>x;
    for(long long int i=0;i<=1000;i++)
    {
        temp=1;
        for(int k=0;k<5;k++)
        temp=temp*i;
        for(long long int j=-1000;j<=1000;j++)
        {
            temp1=1;
            for(long long int m=0;m<5;m++)
            temp1=temp1*j;
            if(temp-temp1==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1,s2;
	cin>>s;
	for(int t=0;t<=7;t++)
	{
		s1=s.substr(0,7-t);
		s2=s.substr(s.size()-t,t);
		if(s1+s2=="keyence")
		{ 
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

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

struct dat {
  string name;
  int id, point;
};

int n;
vector<dat> v;

bool asc(const dat l, const dat r) {
  if (l.name != r.name) return l.name < r.name;
  return l.point > r.point;
}

int main() {
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].name >> v[i].point;
    v[i].id = i + 1;
  }
  sort(v.begin(), v.end(), asc);
  for (int i = 0; i < n; ++i) cout << v[i].id << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int):
    print(min(A, B) + min(C, D))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int a[] = new int[n];

		long sum = 0;
		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);
			sum += a[i];
		}

		long ans = Long.MAX_VALUE;
		long left = 0;
		for (int i = 0; i < n; i++) {
			ans = Math.min(ans, Math.abs(sum - left - left));

			left += a[i];
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 57428
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    while(N > 0){
        N-=1000;
    }
    cout << -N;
    return 0;
}

Measured memory_bytes: 3648
def main():
    A, B, C = (int(x) for x in input().split(" "))
    K = int(input())
    for i in range(K):
        if A < B:
            if B < C:
                print("Yes")
                exit()
            C = 2*C
        else:
            B = 2*B

    if A < B and B < C:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
from math import gcd
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n == 1:
    print(1)
    quit()
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
M = max(a)
cnt = [0]*(M+1)
ans = 0
for i in range(n):
    if cnt[a[i]]:
        continue
    j = a[i]
    if i == 0:
        if a[i] == a[i+1]:
            1
        else:
            ans += 1
    elif i == n-1:
        if a[i-1] == a[i]:
            1
        else:
            ans += 1
    elif a[i] == a[i+1] or a[i-1] == a[i]:
        1
    else:
        ans += 1
    while j <= M:
        cnt[j] = 1
        j += a[i]
print(ans)


Measured memory_bytes: 33940
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int fl[100006];
void dfs(vector<int> v[], int n, int u){
	fr(i,0,v[u].size(),1){
		if(fl[v[u][i]]==0){
			fl[v[u][i]]=1;
			dfs(v,n,v[u][i]);
		}
	}
}
int main()
{
	fastio();
	int n,m;
	cin>>n>>m;
	vector<int> ed[n+1];
	fr(i,0,m,1){
		int u,v;
		cin>>u>>v;
		ed[u].pb(v);
		ed[v].pb(u);
	}
	fr(i,0,n+1,1) fl[i]=0;
	int ans=0;
	fr(i,1,n+1,1){
		if(fl[i]==0){
			ans++;
			fl[i]=1;
			dfs(ed,n,i);
		}
	}
	cout<<ans-1<<endl;
}

Measured memory_bytes: 10376
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define SORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_a - *(t *)_b; } _f; }))
#define RSORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_b - *(t *)_a; } _f; }))
#define SUM(a, n) ({ ll _s = 0; REP(_i, n) _s += a[_i]; _s; })
#define CNT(x, a, n) ({ ll _c = 0; REP(_i, n) if (a[_i] == x) _c++; _c; })
#define MAXM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MAX(_m, a[_i]); _m; })
#define MINM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MIN(_m, a[_i]); _m; })
#define INF 9223372036854775807
typedef long long ll;

typedef struct { ll from, to, cost; } edge;

edge es[114514];
ll d[114514];
ll n, m;

bool solve() {
    REP1(i, n) d[i] = INF;
    d[1] = 0;
    ll update = -1, tmp;
    REP(i, n * 2) {
        REP(j, m) {
            edge e = es[j];
            tmp = d[n];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
            if (d[n] != tmp) update = i;
        }
    }
    return update >= n;
}

int main() {
    scanf("%lld %lld", &n, &m);
    REP(i, m) {
        edge e;
        scanf("%lld %lld %lld", &e.from, &e.to, &e.cost);
        e.cost *= -1;
        es[i] = e;
    }
    if (solve()) puts("inf");
    else printf("%lld\n", -d[n]);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3                                                          
# -*- coding utf-8 -*-

n = int(input())
d = list(map(int,input().split()))

ans = 0 

for i in range(0,n):
    for j in range(0,n):
        if(i < j): 
            ans += d[i]*d[j]

print(ans)


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

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int N; cin >> N;
    ll X; cin >> X;
    ll g = 0;
    for(int i = 0; i < N; i++){
        ll x; cin >> x;
        g = gcd(g, abs(x - X));
    }
    cout << g << endl;
}


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

using namespace std;

int main(){
    while(true){
        int n; cin >> n;
        if(n == 0) break;
        int a,b,c,x; cin >> a >> b >> c >> x;
        vector<int> y(n);
        for(int i = 0; i < n; i++)cin >> y[i];
        int frame = 0, i = 0;
        if(x == y[i]){
            i++;
        }
        for(; frame < 10001 && i < n;){
            frame++;
            x = (a*x + b)%c;
            if(x == y[i])i++;
        }
        if(frame > 10000)cout << -1 << endl;
        else cout << frame << endl;
    }
    return 0;
}




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

using namespace std;

int main(){
  string s;
  cin >> s;
  bool is_A = false , is_B = false;
  for(char c : s){
  	if(c == 'A')is_A = true;
    else is_B = true;
  }
  if(is_A && is_B)
    cout << "Yes\n";
  else 
    cout << "No\n";
  
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i=0; i<n; ++i) cin >> v[i];
  for(int i=k; i<n; ++i){
    cout << (v[i-k] < v[i] ?"Yes":"No") << endl;
  }
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}	

void hawawa()
{
	string str;
	cin >> str;
	cout << count(begin(str), end(str), '+') - count(begin(str), end(str), '-') << "\n";
}

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


Measured memory_bytes: 256
S = input()
# 2019 = 3 * 673
# using mod ?
# 0 mod 2019 の個数を求めたいが…
p=2019
h=0
d=1
total = 0
counts = [0]*p
counts[0]=1
for s in reversed(S):
  m = (int(s)*d) % p
  h = (h+m) % p
  total += counts[h]
  counts[h] += 1
  d = (d*10) % p
print(total)

Measured memory_bytes: 9356
from sys import stdin

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# A,B = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]
temp = A
A = B
B = temp
temp = C
C = A
A = temp
print(A, B, C)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>

static int h[200000];
static inline int comparator(const void *a, const void *b)
{
    return ( *(int*)a - *(int*)b );
}
int main(n, k)
{
    scanf("%d%d", &n, &k);

    if(k>=n) printf("0\n");
    else 
    {
        for(int i=0; i<n; ++i)
            scanf("%d", &h[i]);

        qsort(h, n, sizeof(int), comparator);

        unsigned long x=0;
        for(int i=n-k-1; i>=0; --i)
            x += h[i];

        printf("%lu\n", x);
    }

    return 0;
}

Measured memory_bytes: 1788
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b=get_i
puts yn_judge((a*b).odd?,"Odd","Even")

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int n, t[100010], x[100010], y[100010];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];

    for (int i = 1; i <= n; i++) {
        int dt = t[i] - t[i - 1];
        int dx = abs(y[i] - y[i - 1]) + abs(x[i] - x[i - 1]);
        int tmp = dt - dx;
        cerr << dt << " " << dx << " " << tmp << endl;
        if (tmp < 0 or tmp % 2) return cout << "No" << endl, 0;
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1408
from collections import *
k=int(input())
q=deque([(1,1)])
v=[0]*(k+1)
while True:
    i,c=q.popleft()
    if i==0:
        break
    if v[i]:
        continue
    v[i]=True
    q.append(((i+1)%k,c+1))
    q.appendleft(((i*10)%k,c))
print(c)

Measured memory_bytes: 14440
#include <iostream>
using namespace std;
#define REP(i,n,m) for(int i=(n);i<(m);i++)
#define REP_EQ(i,n,m) for(int i=(n);i<=(m);i++)
#define CNT(i,n) for(int i=(n);i>0;i--)
#define REP_two(i,n,m) for(int i=(n);i<(m);i+=2)
#define ll long long
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
long long MAX=0;
int MOD=1e9+7;


int main(){
  string s;
  cin>>s;
  int n=s.size(), numA=0, numC=0,index;
  bool islarge=false;
  for(int i=0;i<n; i++){
    if(s[i] == 'A') numA++;
  }
  for(int i=2;i<n-1; i++){
    if(s[i] == 'C'){
      numC++;
      index=i;
    }
  }

  if(s[0]!='A'){
    cout << "WA" << endl;
    return 0;
  }
  if(numC != 1 ){
    cout << "WA" << endl;
    return 0;
  }

  for(int i=0;i<n;i++){
    if( i==0 || i== index ) continue;
    if('a' > s[i] || s[i] > 'z'){
      islarge=true;
    }
  }
  if(islarge){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
}


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

int main()
{
	vector<string> s;
	string input;
	for (int i = 0; i < 3; i++)
	{
		cin >> input;
		s.push_back(input);
	}
	sort(s.begin(), s.end());

	if (s[0] == "5" && s[1] == "5" &&s[2] == "7")
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
using namespace std;
#define Would
#define you

int main() {
	int a, b, c;
	cin >> a;
	for (int i = 0; i < a; ++i) {
		cin >> b >> c;
		if (b%c == 0) { cout << c; }
		else { cout << b % c; }
		cout << endl;
	}
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#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;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int H,W;
int sx,sy;
int gx,gy;
vector<string> S;

const int INF=1e9;
typedef tuple<int,int,int> T;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int dijkstra(){
  vector<vector<int>> dist(H,vector<int> (W,INF));
  dist[sx][sy]=0;
  priority_queue<T,vector<T>,greater<T>> PQ;
  PQ.push(mkt(0,sx,sy));
  while(!PQ.empty()){
    auto f=PQ.top();
    PQ.pop();

    int cost=get<0>(f);
    int x=get<1>(f);
    int y=get<2>(f);
    if(dist[x][y]<cost) continue;

    rep(k,4){
      int nx=x+dx[k];
      int ny=y+dy[k];
      if(nx<0||ny<0||nx>=H||ny>=W) continue;
      if(S[nx][ny]=='#') continue;
      if(dist[nx][ny]>cost){
        dist[nx][ny]=cost;
        PQ.push(mkt(cost,nx,ny));
      }
    }

    for(int i=-2;i<=2;i++) for(int j=-2;j<=2;j++){
      int nx=x+i;
      int ny=y+j;
      if(nx<0||ny<0||nx>=H||ny>=W) continue;
      if(S[nx][ny]=='#') continue;
      if(dist[nx][ny]>cost+1){
        dist[nx][ny]=cost+1;
        PQ.push(mkt(cost+1,nx,ny));
      }
    }
  }

  return dist[gx][gy];
}

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

  cin>>H>>W;
  cin>>sx>>sy;
  cin>>gx>>gy;
  S.resize(H);
  rep(i,H) cin>>S[i];

  sx--;sy--;
  gx--;gy--;

  int ans=dijkstra();
  if(ans==INF) cout<<-1<<endl;
  else cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 8572
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int n, m;
	cin >> n >> m;
	int cnt = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) { 
			int k = i + j;
			if (m - k >= 0 && m - k <= n) {
				cnt++;
			}
		}  
	}
	cout << cnt;
}



















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    ll N, M;
    cin >> N >> M;

    ll ans = min(N, M / 2);
    ll a   = (M - 2 * ans) / 4;
    if (0 < a)
        ans += a;

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int dp[300005][2];
char str[300005];
int n;

bool same(int a,int b,int c,int d){
	if(b-a != d-c) return false;
	for(int i=a;i<=b;i++){
		if(str[i] != str[c+i-a]) return false;
	}
	return true;
}
int main(){
	scanf("%s",&str); n = strlen(str);
	rep(i,300005)rep(j,2) dp[i][j] = -INF;
	dp[0][0] = dp[1][1] = 1;
	rep(i,n){
		rep(j,2){
			if(dp[i][j] == -INF) continue;
			int x = i-j, y = i;
			for(int k=i+1;k<=i+2;k++){
				if(k >= n) break;
				int a = i+1, b = k;
				if(same(x,y,a,b) == false) dp[k][b-a] = max(dp[k][b-a],dp[i][j]+1);
			}
		}
	}
	int ans = 0;
	rep(j,2) ans = max(ans,dp[n-1][j]);
	cout << ans << endl;
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;


void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化

  ll a,b,c;
  cin>>a>>b>>c;

  ll ans=c-(a-b);
  if(ans<0)ans=0;

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long A, B;
	int K;
	cin >> A >> B >> K;
	for (long long i = A; i <= B; i++) {
		if (i - A <= K - 1|| B - i <= K - 1) cout << i << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 200000
#define ll long long
#define Trav(p) for(rint u = first[p], v; ~u; u = e[u].nex)
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
#define BUF_SIZE 1000000
#define _END fwrite(_Ob,1,_O-_Ob,stdout), _O = _Ob
#define Outc(a) (*_O++ = a)
char _Ob[BUF_SIZE+5], *_O = _Ob, _Os[25], *_Ot;
template <typename T> inline void Out(T x)
{
	if(!x){Outc('0'); return;} if(x < 0) Outc('-'), x = -x;
	for(_Ot = _Os; x; *_Ot++ = x%10+'0', x /= 10);
	for(; _Ot != _Os; Outc(*--_Ot)); if(_O-_Ob >= BUF_SIZE-50) _END;
}
int first[MAXN+5], sz[MAXN+5], mx[MAXN+5], o[MAXN+5], fa[MAXN+5], X[MAXN+5], sum, tot, top, rt, n, m; ll d[MAXN+5], ans; bool book[MAXN+5];
struct Edge{int to,nex,w; Edge(){} Edge(int _to, int _nex, int _w){to=_to,nex=_nex,w=_w;}}e[(MAXN<<1)+5];
struct E{int u,v; ll w; E(){} E(int _u, int _v, ll _w){u=_u,v=_v,w=_w;}}ed[(MAXN<<5)+5]; inline bool operator < (E a, E b){return a.w < b.w;}
inline void Add(int a, int b, ll w){e[tot] = Edge(b,first[a],w), first[a] = tot++, e[tot] = Edge(a,first[b],w), first[b] = tot++;}
void DFS_sz(int p, int fa){sz[p] = 1, mx[p] = 0; Trav(p) if(!book[v=e[u].to] && v-fa) DFS_sz(v,p), sz[p] += sz[v], mx[p] = max(mx[p],sz[v]);}
void DFS_rt(int p, int fa){(mx[p]=max(mx[p],sum-sz[p]))<mx[rt]?rt=p:0; Trav(p) if(!book[v=e[u].to] && v-fa) DFS_rt(v,p);}
void DFS_d(int p, int fa){o[++top] = p; Trav(p) if(!book[v=e[u].to] && v-fa) d[v] = d[p]+e[u].w, DFS_d(v,p);}
void DCT(int p)
{
	DFS_sz(p,0), sum = sz[p], rt = p, DFS_rt(p,0), p = rt, book[p] = true, d[p] = top = 0, DFS_d(p,0);
	rt = p, d[p] += X[p]; for(rint i = 2; i <= top; (d[o[i]]+=X[o[i]])<d[rt] ? rt = o[i] : 0, i++);
	for(rint i = 1; i <= top; ed[++m] = E(rt,o[i],d[rt]+d[o[i]]), i++); Trav(p) if(!book[v=e[u].to]) DCT(v);
}
inline int getf(int x){return x-fa[x] ? fa[x] = getf(fa[x]) : x;} inline bool Union(int x, int y){return (x=getf(x))-(y=getf(y)) ? fa[x] = y, true : false;}
int main()
{
	n = read(), memset(first+1,-1,n<<2); for(rint i = 1; i <= n; fa[i] = i, X[i++] = read());
	for(rint i = 2, u, v; i <= n; u = read(), v = read(), Add(u,v,read()), i++); DCT(1), sort(ed+1,ed+m+1);
	for(rint i = 1, c = ~-n; i <= m && n; Union(ed[i].u,ed[i].v) ? --c, ans += ed[i].w : 0, i++); printf("%lld\n",ans); return 0;
}

Measured memory_bytes: 75648
#include<cstdio>
#include<algorithm>
#define MOD 1000000007
#define MAXN 200006
using namespace std;
long long fac[MAXN],inv[MAXN],ans;
int n,m,a,b;
long long ksm(long long a,long long m)
{
	if(m==0) return 1;
	long long nex=ksm(a,m/2);
	nex=(nex*nex)%MOD;
	if(m%2==0) return nex;
	else return (nex*a)%MOD;
}
void waiting()
{
	fac[0]=1;
	for(long long i=1;i<MAXN;i++)
		fac[i]=(fac[i-1]*i)%MOD;
	inv[MAXN-1]=ksm(fac[MAXN-1],MOD-2);
	for(long long i=MAXN-2;i>=0;i--)
		inv[i]=(inv[i+1]*(i+1))%MOD;
}
long long C(int n,int m)
{
	return (((fac[m]*inv[n])%MOD)*inv[m-n])%MOD;
}
int main()
{
	waiting();
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(int i=1;i<=n-a;i++)
	{
		long long p1=C(b-1,b+i-2);
		long long p2=C(m-b-1,m-b+n-i-1);
		long long p=(p1*p2)%MOD;
		ans=(ans+p)%MOD;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;
const ll Z = 26;

ll k;
ll fact[2000010], rev[2000010];

string s;

ll binpow (ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow (a, n-1) * a) % mod;
    else {
        ll b = binpow (a, n/2);
        return (b * b) % mod;
    }
}

ll cnk(ll n, ll k) {
    ll res = (fact[n] * rev[k]) % mod;
    res = (res * rev[n - k]) % mod;
    return res;
}

void solve() {
    fact[0] = rev[0] = 1;
    for (int i = 1; i <= 2000000; ++i) {
        fact[i] = (fact[i - 1] * i) % mod;
        rev[i] = binpow(fact[i], mod - 2);
    }

    cin >> k >> s;
    ll len = (ll)s.size();

    ll ans = binpow(Z, len + k);
    for (ll m = 0; m <= len - 1; ++m) {
        ll sub = (cnk(len + k, m) * binpow(Z - 1, len + k - m)) % mod;
        ans = (ans - sub + mod) % mod;
    }
    cout << ans << "\n";
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 35496
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p;
    int i;
    for(i=0;i<n;i++){
        int f;
        cin >> f;
        p.push_back(f);
    } 

    sort(p.begin(),p.end());
    int sum=0;;
    for(i=0;i<k;i++){
        sum += p.at(i);
    } 

    cout << sum << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

// union-find
int N_MAX = 100000;
vi par(N_MAX + 1), dep(N_MAX + 1);
vector<ll> siz(N_MAX + 1); // 連結成分のサイズ ※根にだけ使う

void init(int n) { // 要素数n, 1-ind	
	rep2(i, 1, n + 1) {
		par[i] = i;
		dep[i] = 0;
		siz[i] = 1;
	}
}

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;

	if (dep[x] < dep[y]) {
		par[x] = y;
		siz[y] += siz[x];
	}	else if (dep[x] > dep[y]) {
		par[y] = x;
		siz[x] += siz[y];
	} else if (dep[x] == dep[y]) {
		par [y] = x;
		siz[x] += siz[y];
		dep[x] ++;
	}
}

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

int main () {
	ll N, M; cin >> N >> M;
	vector<pii> b; // 橋
	int A, B;
	rep(i, M) { // 0-ind
		cin >> A >> B;		
		pii p(A, B);
		b.push_back(p);
	}
	init(N);
	vector<ll> conv(M + 1); // conv[i]:番号の大きい方から橋を架けていき(b[M-1], b[M-2],..., b[M-i])，i本目の橋b[M-i]まで掛けたときの便利さ
	// conv[0]は橋を架ける前
	int rA, rB;
	rep(i, M) {
		tie(A, B) = b.at(M - 1 - i);
		rA = find(A); rB = find(B);
		if (rA == rB) conv[i + 1] = conv[i];
		else {
			conv[i + 1] = conv[i] + siz.at(rA) * siz.at(rB);
			unite(rA, rB);
		}
	}
	ll conv_max = N * (N - 1) / 2;
	rep2(i, 1, M + 1) {
		cout << conv_max - conv.at(M - i) << endl;
	}	 
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n & 1){
            (res *= a) %= mod;
        }else{
            (a *= a) %= mod;
        }
        n >>= 1;
    }
    return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, k;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
        a[i]--;
    }

    vector<ll> q(n, -1);
    q[0] = 0;
    ll from = 0;
    ll loop = 0;
    ll index = 0;
    while(true){
        loop++;
        ll to = a[from];
        if(q[to] != -1){
            index = q[to];
            loop -= q[to];
            from = to;
            break;
        }else{
            q[to] = q[from] + 1;
            from = to;
        }
    }

    ll ans = 0;
    if(k >= index){
        k = (k - index) % loop;
        ans = from;
    }
    for(ll i=0;i<k;++i){
        ans = a[ans];
    }
    ans++;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6380
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int n;
    cin >> n;
    vector <int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector <int> v(n);
    rep(i,n) v[i] = i+1;

    int cnt = 0;
    int p_num, q_num;
    do {
        ++cnt;
        bool p_flag = true;
        bool q_flag = true;
        rep(i,n) {
            if (p[i] != v[i]) p_flag = false;
            if (q[i] != v[i]) q_flag = false;
        }
        if (p_flag) p_num = cnt;
        if (q_flag) q_num = cnt;

    } while (next_permutation(v.begin(), v.end()));


    out(max(p_num - q_num, q_num - p_num));


    return 0;
}









Measured memory_bytes: 256
# 整数1個だけ
N = int(input().strip())

# 別変数の整数複数個
A = [int(x) for x in input().strip().split(" ")]

cnt = 0

for i, v in enumerate(A):
    if i % 2 != 0:
        continue
    if v % 2 == 0:
        continue
    cnt += 1

print(cnt)

Measured memory_bytes: 9172
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

a,b,x=map(int,input().split())
v=a*a*b-x
maxh=v/(a*a)*2
import math
if maxh<=b:
  print(math.degrees(math.atan(maxh/a)))
else:
  maxh=2*x/(a*b)
  print(math.degrees(math.atan(b/maxh)))

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
const int N=25;
int a[N],b[N],c[N],n;
pair<int,int> d[N];
int cal(int x) {
	int num=0;
	for(int i=0;i<n;i++) {
		if((1<<i)&x) c[i]=b[i],d[i]={b[i],1},num++;
		else c[i]=a[i],d[i]={a[i],0};
	}
	if(num&1) return 1e9;
	sort(c,c+n);
	int ans=0;
	for(int i=n-1;i>=0;i--) {
		bool f=false;
		for(int j=i;j>=0;j--) {
			if(c[i]!=d[j].first||d[j].second!=((i-j)&1)) continue;
			f=true;
			ans+=i-j;
			for(int k=j;k<i;k++) {
				d[k+1].second^=1;
				swap(d[k],d[k+1]);
			}
			break;
		}
		if(!f) return 1e9;
	}
	return ans;
}
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<n;i++) scanf("%d",&b[i]);
	int ans=1e9;
	for(int i=0;i<1<<n;i++) {
		ans=min(ans,cal(i));
	}
	if(ans==1e9) ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int i,j;
	while(b<=a)
	{
		b*=2;
		k--;
		if(k<0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	while(c<=b)
	{
		c*=2;
		k--;
		if(k<0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(k>=0)
	{
		cout<<"Yes"<<endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int n = 1000000;
	int x; cin >> x;
	vector<bool> dp(x+1, false);
	dp[0] = true;
	rep(i,x){
		for(int p = 100; p<=105; p++){
			if(dp[i] && i+p<=x) dp[i+p] = true;
		}
	}
	cout << (dp[x] ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

int main()
{
    Fast;

    ll a,b;
    cin>>a>>b;
    cout<<max(a-b,max(a+b,a*b));
}

Measured memory_bytes: 256
n, x = map(int, input().split())
A = [int(i) for i in input().split()]

cnt = 0
for i in range(n - 1):
    if A[i] + A[i + 1] > x:
        cnt += (A[i] + A[i + 1]) - x
        A[i + 1] = max(0, A[i + 1] - ((A[i] + A[i + 1]) - x))
        #print(A, cnt)
        
print(cnt)

Measured memory_bytes: 14252
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] L = new int[M+1];
    int[] R = new int[M+1];
    for (int i = 1; i <= M; i++) {
      L[i] = sc.nextInt();
      R[i] = sc.nextInt();
    }

    int mostL = 1;
    int mostR = N;
    for (int i = 1; i <= M; i++) {
      if (mostL < L[i]) {
        mostL = L[i];
      }
      if (R[i] < mostR) {
        mostR = R[i];
      }
    }

    int ans = 0;
    for (int i = mostL; i <= mostR; i++) {
      ans++;
    }
        
    //System.out.println("L: " + Arrays.toString(L));
    //System.out.println("R: " + Arrays.toString(R));
    //System.out.println("cards: " + Arrays.toString(cards));
    
    System.out.println(ans);
  }
}



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


int main (){
    long double W, H, X, Y;
    cin>>W>>H>>X>>Y;
    long double S=W*H/2;
    cout<<S<<" ";
    if(W/2==X&&H/2==Y){
        cout<<1;
    }
    else{
        cout<<0;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;

char left_s[15]={'q', 'a', 'z', 'w', 's', 'x', 'e', 'd', 'c', 'r', 'f', 'v', 't', 'g', 'b'};
char right_s[11]={'y', 'h', 'n', 'u', 'j', 'm', 'i', 'k', 'o', 'l', 'p'};
int main() {
    string str;
    while(cin >> str, str!="#"){
        int n = str.size();
        int flag=-1, cnt=0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<15; ++j){
                if(str[i]==left_s[j]){
                    if(i>0&&flag == 1){
                        cnt++;
                    }
                    flag = 0;
                }
            }
            for(int j=0; j<11; ++j){
                if(str[i]==right_s[j]){
                    if(i>0&&flag == 0){
                        cnt++;
                    }
                    flag = 1;
                }
            }

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


Measured memory_bytes: 3144
#include<stdio.h>

int main(){
    int input;
    int sum = 0;

    scanf("%d", &input);
    sum += input;

    scanf("%d", &input);
    sum += input;

    scanf("%d", &input);
    sum += input;

    if(sum >= 22){
        printf("bust\n");
    }else{
        printf("win\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
12    34
  abcd
12-ab cd-34は自由　2*2=4
→にあるなら順番とわないみたいな

1 2 3 4
 a b c d
 
1   2 3 4
 a b c d
1  2  3 4
  a bc d
  
 1  2  34
a  b cd
123
    abc
3*2=6

12 3
  a bc
順番どおりにとるのが最短ではある
12...3
    a bc
4+5+2=11

逆か
   321   321 *
      -
123210123210
123      456
   abcdef
*/
int main(){
  ll N; cin>>N;
  ll MOD=1e9+7;
  vector<pair<ll,ll>>C;
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    C.push_back({a,1LL});
  }
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    C.push_back({a,-1LL});
  }
  sort(C.begin(), C.end(), [](auto& x, auto& y){return x.first < y.first;});
  ll N2=N*2, ans=1, tmp=0, cnt=0;
  for(ll i=0; i<N2; i++){
    ll c2=C[i].second;
    if(cnt*c2<0) (ans*=abs(cnt))%=MOD;
    cnt+=c2;
//cout<<"i:"<<i<<" tmp:"<<tmp<<" ans:"<<ans<<endl;    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7432
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (610)
#define P (1000000007)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,a[N],b[N],cnt,sum,f[N][310][310]; bool vis[N],ins[N],gg[N];
int main(){
	read(n);
	for(int i=1;i<=2*n;i++)read(a[i]),vis[a[i]]=1;
	for(int i=2;i<=2*n;i+=2)if((~a[i])&&(~a[i-1]))gg[a[i]]=gg[a[i-1]]=1;
	else if(a[i]<0&&a[i-1]<0)sum++;
	for(int i=1;i<=2*n;i++)if(!gg[i])ins[++cnt]=vis[i];
	f[cnt][0][0]=1;
	for(int i=cnt;i;i--)
	for(int j=0;j<=cnt/2;j++)
	for(int k=0;k<=cnt/2;k++)
	if(f[i][j][k]){
		if(j)(f[i-1][j-1][k]+=f[i][j][k])%=P;
		if(ins[i])(f[i-1][j][k+1]+=f[i][j][k])%=P;
		else{
			(f[i-1][j+1][k]+=f[i][j][k])%=P;
			if(k)(f[i-1][j][k-1]+=1ll*f[i][j][k]*k%P)%=P;
		}
	}
	int ans=f[0][0][0];
	for(int i=1;i<=sum;i++)ans=1ll*ans*i%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 229632
from math import sqrt
from itertools import combinations
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

def calc_dist(l1,l2):
  return sqrt( (l1[0]-l2[0])**2 + (l1[1]-l2[1])**2 )

result = 0
for v in combinations(xy,2):
  result += calc_dist(*v)
print(result*2/N)

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

int main() {
  int a=1,b=0,c=0,temp;
  char x,y;
  while(scanf(" %c,%c",&x,&y) == 2) {
    //   cout << x << y << endl;
    if(x == 'A') {
      temp = a;
      if(y == 'B'){
        a = b;
        b = temp;
      }
      else {
        a = c;
        c = temp;
      }
    }
    else if(x == 'B') {
      temp = b;
      if(y == 'A') {
        b = a;
        a = temp;
      }
      else {
        b = c;
        c = temp;
      }
    }
    else {
      temp = c;
      if(y == 'A') {
        c = a;
        a = temp;
      }
      else {
        c = b;
        b = temp;
      }
    }
  }
  if(a == 1)
    cout << "A" << endl;
  else if(b == 1)
    cout << "B" << endl;
  else
    cout << "C" << endl;
}

Measured memory_bytes: 0