akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = 1e5 + 5;
int a[N], dp[N];

void solve(int test) {
	int n , k ; cin >> n >> k ;
	rep(i,0,n) cin >> a[i] ;

	dp[0] = 0 ; 

	for(int i = 1 ; i < n ; ++i) {
		int ans = INF ; 
		for(int j = i-1 ; j >= max(0ll, i-k) ; --j ){
			ans = min(ans, dp[j] + abs(a[i]- a[j]));
		}
		dp[i] = ans ;
	}

	cout << dp[n-1] ;
}
 
int32_t main() {
 

    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  cin >> N >> K;
  int a,m,g;
  cin >> a;
  m=a;
  g=a;
  for(int i=1;i<N;i++){
    cin >> a;
    m=max(a,m);
    g=__gcd(a,g);
  }
  if(K<=m && K%g==0){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

vector<ll> X;

ll R[100010];
ll T[100010];

int L;

void search(ll c, ll crt, int now) {
	if (crt <= X[0]) {
		R[crt] += c;
		return;
	}
	int s = 0, b = now;
	while (s + 1 < b) {
		int m = s + (b - s) / 2;
		if (X[m] > crt) b = m;
		else s = m;
	}
	T[s] += c * (crt / X[s]);
	search(c, crt % X[s], s);
	return;
}

int main() {
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    ll q;
    X.clear();
    X.push_back(N);
    for (int i = 1;i <= Q;i++) {
    	cin >> q;
    	while (X.size() > 0 && X[X.size() - 1] >= q) X.pop_back();
    	if (X.size() == 0 || X[X.size() - 1] < q) X.push_back(q);
    }
    L = X.size();
    memset(R, 0, sizeof(R));
    memset(T, 0, sizeof(T));
    ll a = X[0];
    T[L - 1] = 1;
    for (int n = L - 1;n > 0;n--) {
    	search(T[n], X[n], n);
    }
    R[a] += T[0];
    memset(T, 0, sizeof(T));
    ll crt = 0;
    for (int n = N;n > 0;n--) {
    	crt += R[n];
    	T[n] = crt;
    }
    for (int n = 1;n <= N;n++) {
    	cout << T[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    REP(i,K){
        if(A>=B){
            B=B*2;
        }else if(B>=C){
            C=C*2;
        }else{
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(A<B && B<C){
        cout <<"Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
    return 0;  
}


Measured memory_bytes: 3632
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

x,a,b=get_i
if (x-a).abs>(x-b).abs
    puts "B"
else
    puts "A"
end

Measured memory_bytes: 1788
def solve2():
    n, m = map(int, input().split())
    L = 1
    R = n
    for _ in range(m):
        l, r = map(int, input().split())
        L = max(L, l)
        R = min(R, r)
    if L <= R:
        print(R - L + 1)
    else:
        print(0)
solve2()


Measured memory_bytes: 3060
#include<iostream>
int main(){
    using namespace std;
        int a,b;
        cin>>a;
        cin>>b;
        if(a>b)
            cout << "a > b" << endl;
        else if(a<b)
            cout <<"a < b"<< endl;
        else
            cout <<"a == b"<< endl;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
const int N=5e5+5;
typedef long long ll;
int n,m;
bool vis[N];
vector<int>edge[N];
map<int,int>f[N];
int dist[N];
int fa[N];
int cnt;
int find_father(int x){
    if(x==fa[x]) return x;
    return fa[x]=find_father(fa[x]);
}
void Merge(int x,int y){
    int f1=find_father(x),f2=find_father(y);
    fa[f1]=f2;
}
void bfs(){
    queue<int>q;
    for(int i=1;i<=cnt;i++)
        dist[i]=-1;
    q.push(1);
    vis[1]=1;
    dist[1]=0;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0,sz=edge[u].size();i<sz;i++){
            int v=edge[u][i];
            v=find_father(v);
            if(!vis[v]){
                dist[v]=dist[u]+1;
                q.push(v);
                vis[v]=1;
            }
        }
    }
}
void Read(int &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
int main()
{
    while(~scanf("%d%d",&n,&m)){
        cnt=0;
        for(int i=1;i<=n;i++){
            f[i].clear();
            f[i][0]=++cnt;
        }
        for(int i=1;i<=n+2*m;i++)
            fa[i]=i;
        for(int i=1;i<=m;i++){
            int u,v,w;
            //scanf("%d%d%d",&u,&v,&w);
            Read(u),Read(v),Read(w);
            if(f[u].find(w)==f[u].end()){
                f[u][w]=++cnt;
            }
            u=f[u][w];
            u=find_father(u);
            if(f[v].find(w)==f[v].end()){
                f[v][w]=++cnt;
            }
            v=f[v][w];
            v=find_father(v);
            Merge(u,v);
        }
        for(int i=1;i<=cnt;i++)
            vis[i]=0,edge[i].clear();
        for(int i=1;i<=n;i++)
            for(map<int,int>::iterator it=f[i].begin();it!=f[i].end();it++){
                int j=it->second;
                j=find_father(j);
                edge[i].push_back(j);
                edge[j].push_back(i);
            }
        bfs();
        if(dist[n]==-1)
            puts("-1");
        else
            printf("%d\n",dist[n]/2);
    }
}


Measured memory_bytes: 74496
#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 N, A[3][3], b[10];
  bool appear[3][3];

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  cin >> N;
  for (int i = 0; i < N; i++) cin >> b[i];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      appear[i][j] = false;
      for (int k = 0; k < N; k++) {
        if (A[i][j] == b[k]) appear[i][j] = true;
      }
    }
  }
  string ANS = "No";
  for (int i = 0; i < 3; i++) {
    if (appear[i][0] && appear[i][1] && appear[i][2]) ANS = "Yes";
  }
  for (int i = 0; i < 3; i++) {
    if (appear[0][i] && appear[1][i] && appear[2][i]) ANS = "Yes";
  }
  if (appear[0][0] && appear[1][1] && appear[2][2]) ANS = "Yes";
  if (appear[0][2] && appear[1][1] && appear[2][0]) ANS = "Yes";
  cout << ANS << endl;
  return 0;
}


Measured memory_bytes: 3628
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int X;
	cin>>X;
	int Y;
	Y=X*X*X;
	cout << Y << endl; // prints !!!Hello World!!!
	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
	int N, A, B, C, X;
	int x, y;
	int Y[100];
	int n;
	int i;
	int count;
	
	while (1){
		scanf("%d%d%d%d%d", &N, &A, &B, &C, &X);
		if ((N | A | B | C | X) == 0){
			break;
		}
		
		for (i = 0; i < N; i++){
			scanf("%d", &Y[i]);
		}
		
		count = 0;
		x = X;
		n = 0;
		while (1){
			if (x == Y[n]){
				if (n == N - 1){
					printf("%d\n", count);
					break;
				}
				n++;
			}
			x = (A * x + B) % C;
// printf("<%d>", x);
			count++;
			if (count == 10001){
				printf("-1\n");
				break;
			}
		}
	}
	return (0);
}

Measured memory_bytes: 612
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    X = int(input())
    ans = 100
    i = 0
    while True:
        if ans >= X:
            break
        ans += int(ans * 0.01)
        i += 1
    print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,T,K;
  cin>>T>>A>>K;
  rep(i,0,K){
    if(i%2==0){
      A+=T/2;
      T/=2;
      }
    else{
      T+=A/2;
      A/=2;
      }
    }
  cout<<T<<" "<<A<<endl;
  }


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,n) for(auto& (x) : n)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define inf 1000000000
#define llinf 1000000000000000
#define MAX 1000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
typedef pair<int,pint> P;

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> table(n);
    vint color(n);
    rep(i,n)color[i]=0;
    rep(i,m){
        int p,q,r;
        cin>>p>>q>>r;
        table[p-1].pb(q-1);
        table[q-1].pb(p-1);
    }
    int ans=0;
    rep(i,n){
        if(color[i]>0)continue;
        ans++;
        color[i]=ans;
        queue<int> que;
        que.push(i);
        while(!que.empty()){
            int q=que.front();
            que.pop();
            forin(x,table[q]){
                if(color[x]==0){
                    color[x]=ans;
                    que.push(x);
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

int main() {
	// your code goes here
	const int N = 1e6;
	vector <ll> div(N+1,0);
	for(int i=1;i<=N;i++){
		for(int j=1;i*j<=N;j++){
			div[i*j]++;
		}
	}
	ll n;
	cin>>n;
	ll ans = 0;
	for(ll c = 1;c<=n-1;c++){
		ll rem = n - c;
		ans += div[rem];
	}
	cout<<ans<<"\n";
	return 0;
}

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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int a, b, k;
      a=Integer.parseInt(sc.next());
      b=Integer.parseInt(sc.next());
      k=Integer.parseInt(sc.next());

      LinkedList<Integer> ans=new LinkedList<Integer>();
      for(int i=1; i<=100; i++){
        if(a%i==0 && b%i==0){
          ans.add(i);
        }
      }

      System.out.println(ans.get(ans.size()-k));
    
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
ll pos[200005], neg[200005];
double psum[200005], nsum[200005];
int main () {
  int n, k;
  scanf("%d %d", &n, &k);
  int ps = 0, ns = 0, zs = 0;
  FOR(i, 1, n) {
    int t;
    scanf("%d", &t);
    if (t > 0) pos[++ps] = t;
    else if (t < 0) neg[++ns] = -t;
    else ++zs;
  }
  if (ps + ns < k) {
    printf("0\n"); return 0;
  }
  sort(pos + 1, pos + ps + 1, greater<int>());
  sort(neg + 1, neg + ns + 1, greater<int>());
  psum[0] = nsum[0] = 0.0;
  FOR(i, 1, ps) psum[i] = psum[i - 1] + log(pos[i]);
  FOR(i, 1, ns) nsum[i] = nsum[i - 1] + log(neg[i]);
  int idp = 0, idn = 0;
  for (int i = 0; i <= min(k, ns); i += 2) {
    int j = k - i;
    if (j <= ps) {
      idn = i; idp = j;
      if (i <= ns - 2 && j >= 2 && neg[i + 1] * neg[i + 2] < pos[j] * pos[j - 1]) break;
    }
  }
  if (!idn && !idp) {
    if (zs) {
      printf("0\n"); return 0;
    }
    reverse(pos + 1, pos + ps + 1);
    reverse(neg + 1, neg + ns + 1);
    psum[0] = nsum[0] = 0.0;
    FOR(i, 1, ps) psum[i] = psum[i - 1] + log(pos[i]);
    FOR(i, 1, ns) nsum[i] = nsum[i - 1] + log(neg[i]);
    for (int i = 1; i <= min(k, ns); i += 2) {
      int j = k - i;
      if (j <= ps) {
        idn = i; idp = j;
        if (i <= ns - 2 && j >= 2 && neg[i + 1] * neg[i + 2] > pos[j] * pos[j - 1]) break;
      }
    }
  }
  ll ans = 1;
  FOR(i, 1, idp) ans = ans * pos[i] % mod;
  FOR(i, 1, idn) ans = ans * (-neg[i]) % mod;
  ans = (ans + mod) % mod;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 7160
#include <bits/stdc++.h>
#define LL long long

int n, k;
long long ans; 

int main()
{
	scanf("%d%d", &n, &k);
	for(int i=k+1; i<=n; i++)
	{
		ans+=((i-k)*(n/i));
		for(int j=k; j<=n%i; j++) ans++;
	}
	if(k==0) ans-=n;
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

long long f(long long b, long long n)
{
	if (n < b) return n;
	else return f(b, n / b) + n % b;
}

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

	long long N, S;
	cin >> N >> S;

	if (N < S)
	{
		cout << -1;
		return 0;
	}
	else if (N == S)
	{
		cout << N + 1;
		return 0;
	}
	else
	{
		long long b = 2;
		while (b <= sqrt(N))
		{
			if (f(b, N) == S)
			{
				cout << b;
				return 0;
			}

			b++;
		}

		while (b > 0)
		{
			if ((N - S) % b == 0 && f((N - S) / b + 1, N) == S)
			{
				cout << (N - S) / b + 1;
				return 0;
			}
			b--;
		}
	}

	cout << -1;
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    int N; cin >> N;
    vector<int> T(N,0);
    for (int i=0;i<N;i++){
        cin >> T[i];
    }

    int M; cin >> M;
    pair<int,int> D[M];
    for (int i=0;i<M;i++){
        int p_i,x_i; cin >> p_i >> x_i;
        D[i]=make_pair(p_i,x_i);
    }
    for (int i=0;i<M;i++){
        vector<int > T_tmp=T;
        T_tmp[D[i].first-1 ] = D[i].second;
        int sum_tmp=0;
        for (int i=0;i<N;i++){
            sum_tmp += T_tmp[i];
        }
        cout << sum_tmp << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, k;
    cin >> n >> k;
    vector<int> cnt(n, 0);
    for(int i = 0; i < k; ++i){
        int d;
        cin >> d;
        for(int j = 0; j < d; ++j){
            int foo;
            cin >> foo;
            --foo;
            ++cnt[foo];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(cnt[i] == 0) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
program abc
	implicit none
	integer(8) :: n,a,b,c,d,e,x

	read(*,*) n,a,b

	c = a + b
    
    d = mod(n,c)
    
    e = (n - d) / c
    
    if(d < a) then
    	x = a * e + d
    else
    	x = a * e + a
    endif
 
	write(*,*) x
    
end program abc

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

int main(){

    int L, R, D; cin >> L >> R >> D;
    int count = 0;

    for(int i=L; i<=R; i++){
        if(0 == i % D){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  auto cal=[&](ll xa,ll xb,ll ya,ll yb){
    return sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
  };
  vector<double>x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];
  double dist[10][10];
  rep(i,n)rep(j,n){
    dist[i][j]=cal(x[i],x[j],y[j],y[i]);
    dist[j][i]=dist[i][j];
  }
  double  res=0;
  function<void(bitset<10>,string)>dfs=[&](bitset<10> f,string s){
    if(f==(1LL<<n)-1){
      //cout<<s<<endl;
      double tres=0;
      rep(i,n-1){
        ll ts=s[i]-'0',tt=s[i+1]-'0';
        tres+=dist[ts][tt];
      }
      res+=tres;
      return;
    }
    rep(i,n){
      if(f[i])continue;
      f[i]=1;
      dfs(f,s+(char)('0'+i));
      f[i]=0;
    }
  };
  ll fact=1;
  repi(i,1,n+1){
    fact*=i;
  }
  dfs(0,"");
  cout<<setprecision(12)<<res/fact<<endl;
  return 0;

}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

ll arr[100001] = {};

signed main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        arr[a] += b;
    }

    for (int i = 1; i <= 100000; i++)
    {
        if (k <= arr[i])
        {
            cout << i << endl;
            break;
        }
        k -= arr[i];
    }
}


Measured memory_bytes: 1024
def main():
    N = input()
    hon = (2, 4, 5, 7, 9)
    pon = (0, 1, 6, 8)
    bon = (3,)
    if int(N[-1]) in hon:
        print('hon')
    elif int(N[-1]) in pon:
        print('pon')
    elif int(N[-1]) in bon:
        print('bon')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9076
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n, m; cin >> n >> m;
	vector<p> a(n);
	rep(i, n) cin >> a[i].first >> a[i].second;
	vector<ll> v(1000 * n + 10, m + 1);
	v[0] = 0;
	rep(i, n) {
		rep(j, 1000 * n + 10) {
			int k = 1000 * n + 9 - j;
			if (v[k] != m + 1 && k + a[i].second <= 1e5) {
				v[k + a[i].second] = min(a[i].first + v[k], v[k + a[i].second]);
			}
		}
	}
	ll ans = 0;
	rep(i, v.size()) {
		if (v[i] <= m) ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);
    let a = if a == 1 { 14 } else { a };
    let b = if b == 1 { 14 } else { b };
    if a > b {
        println!("Alice");
    } else if a < b {
        println!("Bob");
    } else {
        println!("Draw");
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 5e8

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	while(1){
		int n, m;
		cin>>n>>m;
		if(n==0 && m==0) return 0;
		int l[200][200], s[200][200];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(i==j){
					l[i][j]=0, s[i][j]=0;
				}else{
					l[i][j]=INF, s[i][j]=INF;
				}
			}
		}
		for(int i=0; i<m; i++){
			int x, y, t;
			char sl;
			cin>>x>>y>>t>>sl;
			x--; y--;
			if(sl=='L'){
				l[x][y]=min(l[x][y], t);
				l[y][x]=l[x][y];
			}else{
				s[x][y]=min(s[x][y], t);
				s[y][x]=s[x][y];
			}
		}
		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(l[i][j]>l[i][k]+l[k][j]) l[i][j]=l[i][k]+l[k][j];
					if(s[i][j]>s[i][k]+s[k][j]) s[i][j]=s[i][k]+s[k][j];
				}
			}
        }
		int r;
		cin>>r;
		int z, w;
		cin>>z;
		z--;
		int ans[1000][200];
		for(int i=0; i<r; i++){
			for(int j=0; j<n; j++){
				if(i==0 && j==z) ans[i][j]=0;
				else ans[i][j]=INF;
			}
		}
		for(int i=1; i<r; i++){
			cin>>w;
          w--;
			for(int j=0; j<n; j++){
				for(int k=0; k<n; k++){
					if(j==k){
						ans[i][j]=min(ans[i][j], ans[i-1][j]+l[z][w]);
					}else{
						ans[i][j]=min(ans[i][j], ans[i-1][k]+l[z][k]+s[k][j]+l[j][w]);
					}
				}
			}
			z=w;
		}
		int ans0=INF;
		for(int i=0; i<n; i++){
			ans0=min(ans0, ans[r-1][i]);
		}
		cout<<ans0<<endl;
	}
	return 0;
}


Measured memory_bytes: 4200
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{
    int d, n;
    cin >> d >> n;
    vi a(n);
    int k = 0;
    
    for (int i = 0; i < n; ++i) cin >> a[i];
    
    rep (i, n) {
        k += a[i];
        if (k > d) {
            cout << -1;
            return 0;
        }
    }
    
    cout << d - k;
    
    
    
   
    
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
	"math"
	"sort"
)

var N, K int
var ans int = 9999999999

func main() {
	fmt.Scan(&N)
	a := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	for i := a[0]; i <= a[N-1]; i++ {
		var res int
		for j := 0; j < N; j++ {
			res += pow(i-a[j], 2)
		}
		ans = min(ans, res)
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  if (n % 10 == 3) {
    cout << "bon\n";
  }
  else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
    cout << "pon\n";
  }
  else cout << "hon\n";
  return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

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

    private void solve() {
        try {
            String S = sc.next();

            String res = "";

            if(S.charAt(1)=='R') {
                res = "ABC";
            } else if(S.charAt(1)=='B') {
                res = "ARC";
            }

            System.out.println(res);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 32720
#include<stdio.h>

int main(){
  int A[250],i,j,n;
  int pkey=0,lkey=0,rkey=0;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);

  for(i=1;i<=n;i++){
    pkey = i/2;
    lkey = 2*i;
    rkey = 2*i+1;
    printf("node %d: key = %d, ",i,A[i]);
    if(pkey >= 1)
      printf("parent key = %d, ",A[pkey]);
    if(lkey <=n)
      printf("left key = %d, ",A[lkey]);
    if(rkey <=n)
      printf("right key = %d, ",A[rkey]);
    printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2052
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define mx 2000000
//#define mod 1000000007
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
int main(){
	ll a,b;
	in2(a,b);a*=b;
	if(a&1)printf("Odd\n");
	else printf("Even");
}
/*

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;
typedef struct {
    double x, y, z;
} P;

double dot(P a, P b)
{
    return a.x * b.x + a.y * b.y + a.z * b.z;
}

P diff(P f, P t)
{
    return P{ t.x - f.x, t.y - f.y, t.z - f.z };
}

P mul(P a, double s)
{
    return P{ a.x*s, a.y*s, a.z*s };
}

double dist(P a)
{
    return pow(dot(a, a), 0.5);
}

const double EPS = 1e-8;

int main()
{
    int n, q; cin >> n >> q;
    vector<P> p(n);
    vector<double> r(n);
    vector<ll> l(n);
    loop (n, i) cin >> p[i].x >> p[i].y >> p[i].z >> r[i] >> l[i];

    // あいうえお
    loop (q, i) {
        P s, t;
        cin >> s.x >> s.y >> s.z >> t.x >> t.y >> t.z;

        // かきくけこ
        P st = diff(s, t), ts = diff(t, s);
        P n_st = mul(st, 1.0/dist(st));
        ll ans = 0;
        loop (n, j) {
            P sp = diff(s, p[j]), tp = diff(t, p[j]);
            if (dot(sp, st) < 0 || dot(tp, ts) < 0) continue;
            P n_sp = mul(n_st, dot(sp, n_st));
            double R = dist(diff(sp, n_sp));
            if (R < r[j] + EPS) ans += l[j];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3400
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
from typing import List

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


class Card:
    def __init__(self, suit: str, value: int):
        self.suit = suit
        self.value = value


def partition(cards: List[Card], p: int, r: int) -> int:
    x = cards[r].value
    i = p - 1
    for j in range(p, r):
        if cards[j].value <= x:
            i += 1
            cards[i], cards[j] = cards[j], cards[i]
    cards[i + 1], cards[r] = cards[r], cards[i + 1]
    return i + 1


def quick_sort(cards: List[Card], p: int, r: int):
    if p < r:
        q = partition(cards, p, r)
        quick_sort(cards, p, q - 1)
        quick_sort(cards, q + 1, r)


def merge(cards: List[Card], left: int, mid: int, right: int):
    n1 = mid - left
    n2 = right - mid
    L, R = [Card('Z', 0)] * (n1 + 1), [Card('Z', 0)] * (n2 + 1)
    for i in range(n1):
        L[i] = cards[left + i]
    for i in range(n2):
        R[i] = cards[mid + i]

    L[n1] = Card('Z', float('INF'))
    R[n2] = Card('Z', float('INF'))

    i, j = 0, 0
    for k in range(left, right):
        if L[i].value <= R[j].value:
            cards[k] = L[i]
            i += 1
        else:
            cards[k] = R[j]
            j += 1


def merge_sort(cards: List[Card], left: int, right: int):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(cards, left, mid)
        merge_sort(cards, mid, right)
        merge(cards, left, mid, right)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A, B = [], []
    for n in range(N):
        suit, value = sl()
        A.append(Card(suit, int(value)))
        B.append(Card(suit, int(value)))

    # ソート
    quick_sort(A, 0, N - 1)
    merge_sort(B, 0, N)

    # 回答
    for a, b in zip(A, B):
        if a.suit != b.suit or a.value != b.value:
            print('Not stable')
            break
    else:
        print('Stable')
    for a in A:
        print(a.suit, a.value)


if __name__ == '__main__':
    main()



Measured memory_bytes: 49640
N, M = list(map(lambda n: int(n), input().split(" ")))
E = []
for i in range(N):
  tmp = input().split(" ")
  E.append({
    "price": int(tmp[0]),
    "count": int(tmp[1])
  })

E.sort(key=lambda e: e["price"])

totP = 0
totC = 0
for i in range(len(E)):
  if totC + E[i]["count"] >= M:
    totP += (M - totC) * E[i]["price"]
    break
  else:
    totC += E[i]["count"]
    totP += E[i]["price"] * E[i]["count"]

print(totP)


Measured memory_bytes: 41180
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=19;
int n,a[1<<N],ans[1<<N];
pair<int,int>dp[1<<18];
unordered_map<int,int>vis;
int main()
{
    scanf("%d",&n);
    int up=1<<n;
    for(int i=0;i<up;i++)
        scanf("%d",&a[i]);
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<up;i++)
    {
        for(int j=0;j<n;j++)
        if(i>>j&1)
        {
            int st=i^(1<<j);
            if(dp[st].fi!=dp[i].fi&&dp[st].fi!=dp[i].se)
            {
                if(a[dp[st].fi]>a[dp[i].fi])
                    dp[i].se=dp[i].fi,dp[i].fi=dp[st].fi;
                else if(a[dp[st].fi]>a[dp[i].se])
                    dp[i].se=dp[st].fi;
            }
            if(dp[st].se!=dp[i].fi&&dp[st].se!=dp[i].se)
            {
                if(a[dp[st].se]>a[dp[i].fi])
                    dp[i].se=dp[i].fi,dp[i].fi=dp[st].se;
                else if(a[dp[st].se]>a[dp[i].se])
                    dp[i].se=dp[st].se;
            }
        }
        if(a[i]>a[dp[i].fi])
            dp[i].se=dp[i].fi,dp[i].fi=i;
        else if(a[i]>a[dp[i].se])
            dp[i].se=i;
    }
    int mx=0;
    for(int i=1;i<up;i++)
    {
        int s=0;
        if(dp[i].fi!=-1) s+=a[dp[i].fi];
        if(dp[i].se!=-1) s+=a[dp[i].se];
        mx=max(mx,s);
        printf("%d\n",mx);
    }
}


Measured memory_bytes: 9216
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c = nm()

    if a + b >= c:
        print('Yes')
    else:
        print('No')
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 3824
s = gets

months = 1..12
a = s[0, 2].to_i
b = s[2, 2].to_i

case [months.include?(a), months.include?(b)]
when [true, true]
  puts 'AMBIGUOUS'
when [false, true]
  puts 'YYMM'
when [true, false]
  puts 'MMYY'
else
  puts 'NA'
end


Measured memory_bytes: 1788
#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

n = input_one_number()
a = input_multiple_number_as_list()

mod = 10**9+7
ssum = 0

sumA = sum(a)

for _a in a:
	ssum += _a * (sumA-_a)

print(ssum//2%mod)

Measured memory_bytes: 31420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    if(int(a.find('C'))!=-1 and int(a.rfind('F'))!=-1&&a.find('C')<a.rfind('F'))//个人码风问题，习惯用and而不是&&
        cout<<"Yes";
    else
        cout<<"No";
}

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

const int N=2e5+20;

int n,a[N];
long long ans;
map <int,int> m;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans+=m[a[i]-i];
		m[-a[i]-i]++;
	}

	cout<<ans;
}

Measured memory_bytes: 21460
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator

import queue


inf = float('inf')


# globals
N = 0
A, B, C, D = [], [], [], []


def set_inputs():
    global N, A, B, C, D
    N = get_int()
    A, B = get_data(N, [int, int])
    C, D = get_data(N, [int, int])
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    reds = [(a, b) for a, b in zip(A, B)]
    blues = [(c, d) for c, d in zip(C, D)]
    b2r = defaultdict(list)
    for i in range(N):
        for j in range(N):
            a, b = reds[i]
            c, d = blues[j]
            if a < c and b < d:
                b2r[j].append(i)
    r2b = dict()
    for b, rs in sorted(b2r.items(), key=lambda x: blues[x[0]][0]):
        for r in sorted(rs, key=lambda i: reds[i][1], reverse=True):
            if r2b.get(r, None) is None:
                r2b[r] = b
                break
    print(len(r2b.keys()))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


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

def getNum(n, m):
    num = [-1] * n
    for i in range(m):
        digits = list(map(int, input().split()))
        if (digits[0] == 1 and digits[1] == 0 and n != 1) or (num[digits[0] - 1] != -1 and num[digits[0] - 1] != digits[1]):
            return -1
        else:
            num[digits[0] - 1] = digits[1]
    if num[0] == -1 and len(num) == 1:
        num[0] = 0
    elif num[0] == -1:
        num[0] = 1
    number = ""
    for item in num:
        if item == -1:
            item = 0
        number += str(item)
    return number

print(getNum(n[0], n[1]))

Measured memory_bytes: 3064
// 6/26 解き直し → 6/30
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

int main() {
    ll L, R;
    cin >> L >> R;

    // map<ll, ll> mp;
    // for (ll i = L; (i <= R) && (i <= L + 2019*2); i++) {
    //     mp[i % 2019] += 1;
    // }

    // ll res = -1;
    // for (auto p : mp) {
    //     // printf("mp[%d] = [%d]\n", p.first, p.second);

    //     if (res == -1) {
    //         if (p.first == 0) {
    //             res = 0;
    //             break;
    //         }
    //         else if (p.second > 1) {
    //             res = (p.first * p.first) % 2019;
    //             break;
    //         }
    //         else {
    //             res = p.first;
    //         }
    //     }

    //     else {
    //         res = (res * p.first) % 2019;
    //         break;
    //     }

    //     // if (p.first == 0) {
    //     //     res = 0;
    //     //     break;
    //     // }
    //     // else if ()
    // }

    // cout << res << endl;

    R = min(R, L + 4038);
    ll ans = 2018;
    for (ll i = L; i <= R; i++) {
        for (ll j = i + 1; j <= R; j++) {
            ans = min(ans, i*j%2019);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

vector<ll> prime_factorize(ll n) {
    vector<ll> res;
    for (int i = 2; (ll)i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(1);
            while (n % i == 0) {
                n /= i;
                res.back() *= i;
            }
        }
    }
    if (n > 1) {
        res.emplace_back(n);
    }
    return res;
}

ll extended_euclid(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extended_euclid(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

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

    ll n;
    cin >> n; n *= 2;

    auto factor = prime_factorize(n);

    ll min_k = LLONG_MAX;
    for (int mask = 0; mask < (1 << factor.size()); mask++) {
        ll a = 1, b = 1;
        for (int i = 0; i < factor.size(); i++) {
            if (mask & (1 << i)) {
                b *= factor[i];
            } else a *= factor[i]; //p1, p2, b*p2 = a*p1 + 1 = by - ax = 1
        }
        //-a(x - k*b) + b(y - k*a) = 1, ax + by = 1
        ll x0, y0;
        extended_euclid(a, b, x0, y0);
        x0 = -x0;

        ll limit = (ll)1e18 / max(a, b);
        ll lo = -limit, hi = limit;
        while (lo < hi) {
            ll mid = lo + (hi - lo + 1) / 2;
            if (x0 - mid * b > 0 and y0 - mid * a > 0)
                lo = mid;
            else hi = mid - 1;
        }
        min_k = min(min_k, b * (y0 - lo * a) - 1);
    }
    cout << min_k << '\n';
    return 0;
}

Measured memory_bytes: 3660
n = int(input())
block = list(map(int, input().split()))

ans = 0
cnt = 0

for i in range(n - 1):
    #print("i:{0} i + 1:{1}".format(i, i + 1))#
    if(block[i] >= block[i + 1]):
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0


print(max(ans, cnt))

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

int main() {
    int a,b,c,d,n;
    cin>>n;
    a = n % 10;
    n /=10;
    b = n % 10;
    n /=10;
    c = n % 10;
    n /=10;
    d = n % 10;
    if(a == b){
        if(b == c){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }else{
        if(b == c && c ==d){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    
}


Measured memory_bytes: 256