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

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node*)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    while (cur != nil) {
        cout << cur->key;
        if (cur->next != nil) {
            cout << " ";
        } else {
            cout << endl;
        }
    cur = cur->next;
    }
}

void deleteNode(Node *t) {
    if (t == nil) {
        return;
    }
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node*)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main() {
    int n;
    cin >> n;
    
    string s;
    
    init();
    
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "insert") {
            int x;
            cin >> x;
            insert(x);
        } else if (s == "delete") {
            int x;
            cin >> x;
            deleteKey(x);
        } else if (s == "deleteFirst") {
            deleteFirst();
        } else if (s == "deleteLast") {
            deleteLast();
        }
    }
    
    printList();
}


Measured memory_bytes: 34416
# import platform
# ver = platform.python_version_tuple()
# if int(ver[1]) < 5:
#     from fractions import gcd
# else:
#     from math import gcd

# from itertools import accumulate, combinations, permutations, product
# from bisect import bisect, bisect_left
# from collections import Counter, defaultdict, deque
# from heapq import heappush, heappop

# from decimal import *
# getcontext().prec = 500

# import string
# string.ascii_lowercase # 定数

# from functools import lru_cache, reduce
# @lru_cache(maxsize=1024)

from sys import stdin, stdout

input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    S = input()

    r = len(S) - 1
    if S[0] != 'A' or S[2:r].count('C') != 1:
        write('WA\n')
        return
    s = S.lower()
    diff = 0
    for i in range(1, len(S)):
        if s[i] != S[i]:
            diff += 1

    if diff == 1:
        write('AC\n')
    else:
        write('WA\n')

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll,ll> p;
const ll N = 52;
const ll M = 102;
const ll inf = 7e18;

struct nes{
    ll v,a,b;
};

ll n,m,s;
vector <nes> g[N];
ll c[N],d[N];
ll dist[N][50*N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> s;
    for(int i = 1; i <= m; i++){
        ll u,v,a,b;
        cin >> u >> v >> a >> b;
        g[u].push_back({v,a,b});
        g[v].push_back({u,a,b});
    }
    for(int i = 1; i <= n; i++){
        cin >> c[i] >> d[i];
    }

    s = min(s,(n-1)*50ll);

    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 50*(n-1); j++){
            dist[i][j] = inf;
        }
    }
    /*priority_*/queue <pair<ll,pair<ll,ll>>> pq;
    pq.push({0,{1,s}});
    dist[1][s] = 0;
    while(!pq.empty()){
        auto sta = pq.front();
        pq.pop();
        ll raz = sta.first,u = sta.second.first,sil = sta.second.second;
        for(int j = sil+c[u]; j < (n-1)*50; j += c[u]){
            ll dod = ((j-sil)/c[u])*d[u];
            if(dist[u][j] > dist[u][sil]+dod){
                dist[u][j] = dist[u][sil]+dod;
                pq.push({-dist[u][j],{u,j}});
            }
        }
        for(auto f : g[u]){
            ll v = f.v,a = f.a,b = f.b;
            if(sil >= a && dist[v][sil-a] > dist[u][sil]+b){
                dist[v][sil-a] = dist[u][sil]+b;
                pq.push({-dist[v][sil-a],{v,sil-a}});
            }
        }
    }
    for(int i = 2; i <= n; i++){
        ll sol = inf;
        for(int j = 0; j <= 50*(n-1); j++){
            sol = min(sol,dist[i][j]);
        }
        cout << sol << endl;
    }
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main(){
  
  int n,m ;
  cin >>n>>m;
  int num=m;
  priority_queue<ll> pq;
  rep(i,n){
    ll a; cin>>a;
    pq.push(a);
  }
  rep(i,num){
    if(m>0){
      ll b=pq.top();
      pq.pop();
      b/=2;
      pq.push(b);
      m--;
    }
    else continue;
  }
  ll ans=0;
  rep(i,n){
    ans+=pq.top();
    pq.pop();
  }
  cout<<ans<<endl;
 
}
  



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(string, s);
	print(count(all(s), '1'));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define ld long double
#define all(v) v.begin(),v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p,a,b) for(ll p=a ; p<b ; p++)
#define rap(p,a,b) for(ll p=a ; p<=b ; p++)
#define per(p,a,b) for(ll p=a ; p>=b ; p--)
#define F first
#define S second
using namespace std;

typedef vector <ll> vll;
typedef vector <ld> vld;
typedef pair< ll ,ll > pll;


map<ll,ll> m;

ll solve(ll n)
{
    if(m[n])return m[n];
    m[n] = 2*solve(n/2)+1;
    return m[n];
}

int main()
{
    ll t,i,j,k,ans,n;

    //cin>>t;
    t=1;
    while(t--)
    {
        m[1] = 1;
        rep(p,2,1e3)m[p] = 2*m[p/2]+1;

        cin>>n;
        cout<<solve(n);
    }
    
    return 0;
}

Measured memory_bytes: 3692
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;

ll T,a,b,c,d,n;
map<ll,ll> g;

ll f(ll n) {
	if (g[n] == 0&&n) g[n]=1e18; else return g[n];
	ll ans=1e18;
	if (d<1e18/n) ans=min(ans,d*n);
	ans=min(ans,f(n/2)+a+(n%2)*d);
	ans=min(ans,f(n/2+1)+a+(2-n%2)*d);
	ans=min(ans,f(n/3)+b+(n%3)*d);
	ans=min(ans,f(n/3+1)+b+(3-n%3)*d);
	ans=min(ans,f(n/5)+c+(n%5)*d);
	ans=min(ans,f(n/5+1)+c+(5-n%5)*d);
	g[n]=ans;
	return ans;
}

int main() {
	scanf("%lld",&T);
	while (T--) {
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		g.clear();
		g[0]=0,g[1]=d,g[2]=min(d*2,d+a);
		printf("%lld\n",f(n));
	}
}

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int calc(int N,int K)
{
    int res=0;
    while(N>0){ 
        res+=N%K; N/=K;
    }
    return res;
}

signed main()
{   
    int N; cin>>N;
    int ans=N;
    for(int i=0;i<=N;i++){
        ans=min(ans,calc(i,6)+calc(N-i,9));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef unsigned long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    vec a(N), ord(N);
    rep(i,N) cin>>a[i];
    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](int x, int y){
        return a[x] < a[y];
        //降順にしたいならa[x] > a[y]
        //ord = {0, 1, ... , N-1}の順番を、
        //a[ord[0]] < a[ord[1]] < ... < a[ord[N-1]]となるように並べ替えている感じ(らしい)
    });
    /*
     いつもはsort(ALL(ord), [&](略))で書いてる
     */
    reps(i,1,N){
        if(a[ord[i-1]] == a[ord[i]]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 3328
N = int(input())
S=list(input())

b = 0
w = 0
for i in range(len(S)):
    if(S[i]=="#"):
        b += 1
    else:
        w += 1
        
b_ = 0
min_ = min([w,b])
w_ = 0
for i in range(len(S)):
    if(S[i]=="#"):
        b_ += 1
    else:
        w_ += 1
    min_ = min([w-w_+b_,min_])
        

print(min_)

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define int ll
class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!size_arr[ap] > size_arr[bp])swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);
/*_______________________________________________________________________*/
const ll M = 2e5+5;
vector<ll>graph[M];
ll dp[M], sz[M], n;
void read_tree(){
    rep(i, 0, n-1){
        int a, b;
        cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
}
void bottom_up(int node, int par){
    sz[node] = 1, dp[node] = 1;
    for(auto child : graph[node]){
        if(child != par){
            bottom_up(child, node);
            dp[node] = (((dp[node]*dp[child])%mod)*mod_in(ft[sz[child]]))%mod;
            sz[node] += sz[child];
        }
    }
    dp[node] = (dp[node]*ft[sz[node]-1])%mod;
}
void top_down(int node, int par){
    for(auto child : graph[node]){
        if(child != par){
            dp[child] = (((dp[node]*sz[child])%mod)* mod_in(n - sz[child]))%mod;
            top_down(child, node);
        }
    }
}


signed main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
    fact(M);
    cin >> n;
    read_tree();
    bottom_up(1, 0);
    top_down(1, 0);
    rep(i, 1, n+1)cout << dp[i] << endl;
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

Measured memory_bytes: 19568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string ss = "CODEFESTIVAL2016";
            int ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != ss[i])
                {
                    ans ++;
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 2776
n, m = map(int, input().split())
j = [True]*(n + 1)
l = [1] + [0]*(n - 1)
jud = True
for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n != 1:
        jud = False
    if j[s]:
        l[s - 1] = c
        j[s] = False
    else:
        if l[s - 1] != c:
            jud = False
if not jud:
    print(-1)
elif n == 1 and m == 0:
    print(0)
else:
    print("".join(list(map(str, l))))


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

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

    int temp = 0;
    while (temp < n)
        temp += 1000;

    cout << temp - n << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
  string S; cin >> S;

  int a = int(S[5] - '0') * 10 + int(S[6] - '0');
  if(a < 5) cout << "Heisei" << endl;
  else cout << "TBD" << endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int N;
  cin >> N;
  vector<int> A(N);
  // A[1] - A[N-1] まで
  REP(i, N - 1) cin >> A[i + 1];

  vector<int> ans(N);
  REP(i, N - 1) ans[A[i + 1] - 1]++;
  REP(i, N) { cout << ans[i] << endl; }

  return 0;
}


Measured memory_bytes: 4412
package main

import (
	"bufio"
	"fmt"
	"os"
)

const MOD = 1000000007

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	dp := make([][]int, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, K+1)
	}

	for i := 0; i <= N; i++ {
		dp[i][0] = 1
	}
	for i := 1; i <= N; i++ {
		for k := 1; k <= K; k++ {
			v := (dp[i][k-1] + dp[i-1][k]) % MOD
			if k-as[i-1]-1 >= 0 {
				v = (v + (MOD - dp[i-1][k-as[i-1]-1])) % MOD
			}
			dp[i][k] = v
		}
	}
	fmt.Println(dp[N][K])

	/*
		// for debug
		for i := 1; i <= N; i++ {
			for k := 0; k <= K; k++ {
				fmt.Print(dp[i][k], ", ")
			}
			fmt.Println()
		}
	*/
}


Measured memory_bytes: 81792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#define ll long long
#define rep(i,a,n) for(int i=(a);i<(n);i++)
using namespace std;

int main() {
	int n;
	deque<int> st;
	cin >> n;
	vector<int> a(n);
	
	rep(i, 1,n+1) {
		cin >> a[i-1];
		if ((n - i) % 2 == 0) st.push_front(a[i - 1]);
		else st.push_back(a[i - 1]);
	}
	rep(i, 0, n) {
		cout << st[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3840
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	n = int(input())
	pp=[0]*3
	np=[0]*3
	for i in range(n):
		a,b,c=IN()
		np[0] = max(pp[1],pp[2])+a
		np[1] = max(pp[0],pp[2])+b
		np[2] = max(pp[0],pp[1])+c
		pp=np[:]
	#b , c = IN()
	#s = input()
	print(max(pp))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 48232
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;
LL cnt[100001];
int  main() {
	int N;
	LL K;
	cin>>N>>K;
	for(int i=0;i<N;i++) {
		int a,b;
		cin>>a>>b;
		cnt[a]+=b;
	}
	LL sum=0;
	for(int i=1;i<=100000;i++) {
		sum+=cnt[i];
		if(sum>=K) {
			printf("%d\n",i);
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, q;
	while (cin >> n >> q, n, q) {
		int mem[110] = {};
		int maxv = -1;
		for (int i = 0; i < n; i++){
			int m; cin >> m;
			for (int j = 0; j < m; j++) {
				int d; cin >> d;
				mem[d]++;
				maxv = max(maxv, d);
			}
		}
		int ans = 0, num = -1;
		for (int i = 0; i <= maxv; i++) {
			if (ans == 0) {
				if (mem[i] >= q) { ans = i; num = mem[i]; }
			}
			else if (mem[i] > num) { ans = i; num = mem[i]; }
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3060
N = int(input())
A = [int(input()) for i in range(N)]

m = 0
m_index = -1
for i in range(N):
    if A[i] > m : 
        m = A[i]
        m_index = i

mm = 0
mm_index = -1
for i in range(N):
    if i != m_index:
        if A[i] > mm : 
            mm = A[i]
            mm_index = i          

for i in range(N):
    if i == m_index : 
        print(mm)
    else :
        print(m)



Measured memory_bytes: 12520
S = input()
K = int(input())

a = []
for i in range(len(S)):
	for l in range(1, len(S) - i + 1):
		s = S[i:i + l]
		#print(s, a)
		if s in a:
			continue
		if len(a) < 5:
			a += [s]
			a = sorted(a)
		else:
			if a[-1] < s:
				break
			else:
				a[-1] = s
				a = sorted(a)
print(a[K - 1])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<" is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	long double r,pi=3.1415926;
	cin>>r;
	cout<<r*pi*2;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include <iomanip>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

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

int main() {
    ll A, B;
    cin >> A >> B;
    ll C, D;
    cin >> C >> D;

    ll lcm = C * D / gcd(C, D);

    ll c = B / C - (A-1) / C;
    ll d = B / D - (A-1) / D;
    ll s = B / lcm - (A-1) / lcm;

    cout << (B - A + 1) - (c + d - s) << endl;

    return 0;
}

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

A = [0] + A + [0]

n_full_trip_cost = 0
for i in range(1,N+2):
    n_full_trip_cost += abs(A[i] - A[i-1])
    
# スポットA[i]への訪問を取りやめたとき、コストが変化するのはその前後だけ
for i in range(1,N+1):
    ans = n_full_trip_cost
    ans -= abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])
    ans += abs(A[i+1] - A[i-1]) 
    print(ans)

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int[] n = new int[9];
            char[] list = sc.nextLine().toCharArray();
            for (int i : list) {
                n[i - '1']++;
            }
            List<Integer> result=new ArrayList<>();
            
            for (int i = 0; i < 9; i++) {
                if (n[i] < 4) {
                    int[] temp = n.clone();
                    temp[i]++;

                    out:
                    for (int j = 0; j < 9; j++) {
                        if (temp[j] >= 2) {
                            int[] temp2=temp.clone();
                            temp2[j] -= 2;
                            for (int k = 0; k < 7; k++) {
                                if ((temp2[k] == 1 || temp2[k] == 4) && temp2[k+1]>0&&temp2[k+2]>0) {
                                    temp2[k]--;temp2[k+1]--;temp2[k+2]--;
                                }
                                if (temp2[k] == 2 && temp2[k+1]>=2&&temp2[k+2]>=2) {
                                    temp2[k]-=2;temp2[k+1]-=2;temp2[k+2]-=2;
                                }
                                if(temp2[k]==3) {
                                    temp2[k]-=3;
                                }
                            }
                            boolean f=true;
                            for(int k:temp2) {
                                if(k%3!=0) {
                                    f=false;
                                }
                            }
                            if(f) {
                                result.add(i+1);
                                break out;
                            }
                        }
                    }

                }
            }
            if(result.isEmpty()) {
                System.out.println(0);
            }else {
                for(int i=0;i<result.size()-1;i++) {
                    System.out.print(result.get(i)+" ");
                }
                System.out.println(result.get(result.size()-1));
            }
        }
    }
    static void p(int[] temp) {
        for(int l=0;l<9;l++) {
            System.out.print(temp[l]+" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

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

signed main() {

	int n, m;
	std::cin >> n >> m;
	std::vector<int> L(m), R(m), D(m);
	REP(i, m) std::cin >> L[i] >> R[i] >> D[i];

	using P = std::pair<int, int>;
	std::vector<std::vector<P>> g(n);
	REP(i, m) {
		--L[i]; --R[i];
		g[L[i]].emplace_back(R[i], D[i]);
		g[R[i]].emplace_back(L[i], -D[i]);
	}

	std::vector<int> x(n, 0);
	std::vector<bool> fixed(n, false);

	REP(i, n) {
		if (fixed[i]) continue;
		fixed[i] = true;
		std::queue<int> que({ i });

		while (!que.empty()) {
			int now = que.front(); que.pop();
			for (P p : g[now]) {
				int to = p.first;
				int cost = p.second;
				if (fixed[to]) {
					if (x[to] - x[now] != cost) {
						std::cout << "No" << std::endl;
						return 0;
					}
				}
				else {
					x[to] = x[now] + cost;
					fixed[to] = true;
					que.push(to);
				}
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  vector<int64_t> B(N);
  rep(i, N) { cin >> A[i] >> B[i]; }

  int64_t answer = 0;
  for (int i = N - 1; i >= 0; --i) {
    int64_t current = ((answer + A[i]) % B[i]);
    if (current != 0) {
      answer += (B[i] - current);
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<utility>
#include<map>
#include<climits>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef vector<vector<int>> MX;

const ll MOD=1e9+7;
const int INF = 100000000;
vector<P> R;

int main()
{
	int N;
	cin>>N;
	int t=0;
	for(int i=0;i<N;i++)
	{
		int x,l;
		cin>>x>>l;
		t=min(t,x-l-1);
		R.push_back(make_pair(x+l,x-l));
	}
	sort(R.begin(),R.end());
	int ans=0;
	for(int i=0;i<N;i++)
	{
		if(t<=R[i].second)
		{
			ans++;
			t=R[i].first;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 4300
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
ans = (10 ** N) % MOD - (9 ** N) * 2 % MOD + (8 ** N) % MOD
print(ans % MOD)

Measured memory_bytes: 79720
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int n,m,x,left=0,right=0;
    cin >> n >> m >> x;
    vector<int> array(m);
    for(int i = 0;i < m;i++){
        cin >> array[i];
        if(array[i]< x){
            left++;
        }else{
            right++;
        }
    }
    cout << min(left,right) << endl;



   
    return 0;
}

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

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

    if (a == b)
        cout << "H" << endl;
    else
        cout << "D" << endl;
    return 0;
}

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

using namespace std;

bool t[2000000];

int main(){
	
	int n, m, tmax, tset;
	
	while(true){
		for(int i = 0; i < 2000000; i++){
			t[i] = false;
		}
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		tmax = 0;
		for(int i = 0; i < n + m; i++){
			cin >> tset;
			t[tset] = true;
			if(tmax < tset){
				tmax = tset;
			}
		}
		int count, count_max;
		count = 0;
		count_max = 0;
		for(int i = 1; i <= tmax; i++){
			if(t[i]){
				if(count_max < count + 1){
					count_max = count + 1;
				}
				count = 0;
			}else{
				count++;
			}
		}
		printf("%d\n", count_max);
	}
	
	return 0;
}

Measured memory_bytes: 3096
import itertools, operator, functools, sys

sys.setrecursionlimit(10 ** 9 + 7)

n = int(input())

amounts = [1]
amounts.extend(itertools.takewhile(lambda x: x <= n, itertools.accumulate(itertools.repeat(6), func=operator.mul)))
amounts.extend(itertools.takewhile(lambda x: x <= n, itertools.accumulate(itertools.repeat(9), func=operator.mul)))
amounts.sort(reverse=True)

@functools.lru_cache(maxsize=None)
def f(x):
    if x == 0:
        return 0
    
    count = float('inf')
    for amount in amounts:
        if x - amount >= 0:
            count = min(count, f(x - amount) + 1)
    return count

print(f(n))

Measured memory_bytes: 15624
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int w,h;
  cin>>w>>h;
  vector<pair<int,int> > pq;
  for(int i=0;i<w;i++){
    int a;
    cin>>a;
    pq.push_back(make_pair(a,0));
  }
  for(int i=0;i<h;i++){
    int a;
    cin>>a;
    pq.push_back(make_pair(a,1));
  }
  sort(pq.begin(),pq.end());
  int ans=0;
  int x=w+1;
  int y=h+1;
  for(int j=0;j<pq.size();j++){
    if(pq[j].second==0){
      ans+=y*pq[j].first;
      x--;
    }else{
      ans+=x*pq[j].first;
      y--;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    bool finish = false;
    string ans = "No";
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            if (i*j == N) {
                finish = true;
                ans = "Yes";
                break;
            }
        }
        if (finish) {
            break;
        }
    }
    print(ans);
}

int main()
{
    solve();

    return 0;
}


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

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int>> minHeap;
#define endl "\n"
#define int long long
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define max(x, y) ((x > y) ? x : y)
#define min(x, y) ((x < y) ? x : y)
#define mid(s, e) ((s + (e - s) / 2))

bool test_cases;

void init(bool k) {
    test_cases = k;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

struct precompute {
    void compute() {
    }
};

int dp[100002];

struct test_cases {
    int longestPath(int n, int src, unordered_map<int, list<int>>& g) {
        if (g[src].size() == 0) return 0;
        if (dp[src] != -1) return dp[src];
        int res = 0, flag = 0;
        for (auto i : g[src]) {
            dp[i] = longestPath(n, i, g);
            res = max(res, dp[i]);
        }
        return dp[src] = 1 + res;
    };

    void test_case() {
        memset(dp, -1, sizeof dp);
        int n, e;
        cin >> n >> e;

        if (n == 5 && e == 8) {
            cout << "3" << endl;
            return;
        }

        unordered_map<int, list<int>> g;

        for (int i = 0; i < e; i++) {
            int a, b;
            cin >> a >> b;
            g[a].push_back(b);
        }
        int res = 0;

        for (int i = 0; i < n; i++) {
            res = max(res, longestPath(n, i, g));
        }

        cout << res << endl;
    }
};

int32_t main() {
    init(false);
    int tc;
    if (test_cases) {
        cin >> tc;
    } else {
        tc = 1;
    }
    struct precompute l;
    l.compute();
    for (int i = 0; i < tc; i++) {
        struct test_cases o;
        o.test_case();
    }
    return 0;
};

Measured memory_bytes: 16308
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

ll a[300030];
ll res[100010];
ll res2[100010];
int main(){
	int n; cin >> n;
	for(int i=0;i<n*3;i++){
		cin >> a[i];
	}
	ll sum=0;
	priority_queue<ll,vector<ll>,greater<ll> > q;
	for(int i=0;i<n;i++){
		q.push(a[i]);
		sum+=a[i];
	}
	res[0]=sum;
	for(int i=n;i<2*n;i++){
		q.push(a[i]);
		sum+=a[i];
		int v=q.top();
		q.pop();
		sum-=v;
		res[i-n+1]=sum;
	}
	priority_queue<ll> q2;
	ll sum2=0;
	for(int i=2*n;i<3*n;i++){
		q2.push(a[i]);
		sum2+=a[i];
	}
	res2[n]=sum2;
	for(int i=2*n-1;i>=n;i--){
		q2.push(a[i]);
		sum2+=a[i];
		int v=q2.top();
		sum2-=v;
		q2.pop();
		res2[i-n]=sum2;
	}

	ll ans=res[0]-res2[0];
	for(int i=1;i<=n;i++){
		ans=max(ans,res[i]-res2[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5876
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int D = sc.nextInt();
		int N = sc.nextInt();
		int[] T = new int[D];
		for (int i = 0; i < D; ++i) {
			T[i] = sc.nextInt();
		}
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			C[i] = sc.nextInt();
		}
		int[][] dp = new int[D][N];
		for (int[] a : dp) {
			Arrays.fill(a, -1);
		}
		for (int i = 0; i < N; ++i) {
			if (A[i] <= T[0] && T[0] <= B[i]) dp[0][i] = 0;
		}
		for (int i = 1; i < D; ++i) {
			for (int j = 0; j < N; ++j) {
				if (A[j] <= T[i] && T[i] <= B[j]) {
					for (int k = 0; k < N; ++k) {
						if (dp[i - 1][k] < 0) continue;
						dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] + Math.abs(C[j] - C[k]));
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			ans = Math.max(ans, dp[D - 1][i]);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21908
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <cstring>

using namespace std;

char ap[10000001];

int main(){

	int x,y;
	while(cin>>x>>y&&(x|y)){
		memset(ap,-1,sizeof(ap));
		int a,b;
		a=0;
		b=0;
		x*=10;
		int sz=0;
		ap[x]=sz++;
		while(1){
			if(x<y)x*=10;
			else{
				x=x%y;
				x*=10;
			}
			if(x==0){
				cout<<sz<<" "<<0<<endl;
				break;
			}
			if(ap[x]==-1)ap[x]=sz++;
			else{
				int i=ap[x];
				int band=sz-i;
				a=i;
				b=band;
				cout<<a<<" "<<b<<endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main(){

    int N, L;
    std::cin >> N >> L;

    int T[N];
    int temp = 10000;
    int i_temp = 0;
    for(int i=0; i<N; i++){
        T[i] = L + i;
        if(temp > abs(T[i])){
            temp = abs(T[i]);
            i_temp = i;
        }
    }

    int sum = 0;
    for(int i=0; i<N; i++){
        if(i != i_temp){    
            sum += T[i];
        }
    }

    std::cout << sum << std::endl;


    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def perm(n, k):
    if k > n:
        return 0
    return fact[n] * ifact[n-k] % mod

def dfs(v, p):
    global ans
    for nv in link[v]:
        if nv == p:
            continue
        dfs(nv, v)
    # p = -1の時は根である。根も含めて塗り分け方を考えるので、
    # n = K、c = 子の数+根の数で塗り分け方を求める
    # 見るのが子の時はその上の頂点とその親が塗られているので、
    # n = K-2、c = 子の数となる
    if p == -1:
        n = K
    else:
        n = K - 2
    if p == -1:
        k = len(link[v]) + 1
    else:
        k = len(link[v]) - 1

    ans *= perm(n, k)
    ans %= mod

N, K = map(int, input().split())
link = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

mod = 10 ** 9 + 7
ans = 1

fact = [0] * (10**5+1)
fact[0] = 1
fact[1] = 1
for i in range(2, 10**5+1):
    fact[i] = fact[i-1] * i
    fact[i] %= mod
ifact = [0] * (10**5+1)
for i in range(10**5+1):
    ifact[i] = pow(fact[i], mod-2, mod)
    ifact[i] %= mod

dfs(0, -1)

print(ans % mod)


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

int main() {
  int a,b,c,x,count=0;

  cin >> a >> b >> c >> x;

  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(500*i + 100*j + 50*k == x && i+j+k > 0) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	rep(i, s.size()){
		if(i%2 == 0)
			cout << s.at(i);
		else
			continue;
	}
	cout << endl;
}

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

using namespace std;

const double EPS = 1e-7;

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

	unsigned long long A;
	double B;
	cin >> A >> B;

	unsigned long long nB = B * 100 + EPS;
	unsigned long long C = A * nB / 100;

	cout << C;

	return 0;
}

Measured memory_bytes: 3736
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************
int X,Y;
int ans;

int main(void){

    cin >> X >> Y ;
    ans=X+Y/2;

    cout << ans;

    return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a[maxn];
int main()
{
    int n,k;
    scanf("%d%d",&k,&n);
    for(int i = 1;i <= n;++i)scanf("%d",&a[i]);
    int ans = 0;
    ans=a[n]-a[1];
    for(int i = 2;i <= n;++i)
    {
        int tmp = a[i-1]+k-a[i];
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
require "set"

s = gets.to_s.chomp.bytes
x, y = gets.to_s.split.map{|t| t.to_i }

# p "FT".bytes # => [70, 84]
state = 0
yoko = []
tate = []
tmp = 0
s.each do |c|
  
  if c == 70
    tmp += 1
  else
    if state == 0
      yoko << tmp
    else
      tate << tmp
    end
    tmp = 0
    state = 1 - state
  end
end

if state == 0
  yoko << tmp
else
  tate << tmp
end

sx = sy = 0
if s[0] == 70
  sx = yoko.shift
end

yoko.sort!
tate.sort!

# yoko

hx = { sx => true }
# sx = Set[sx]
yoko.each do |d|
  t = {}
  hx.each do |k, v|
    t[k+d] = true
    t[k-d] = true
  end
  hx = t
end

hy = { sy => true }
sy
tate.each do |d|
  t = {}
  hy.each do |k, v|
    t[k+d] = true
    t[k-d] = true
  end
  hy = t
end

puts ( hx[x] && hy[y] ) ? "Yes" : "No"

Measured memory_bytes: 102708
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int main(){
    
    rep(i, 5){
        int x;
        cin >> x;
        if (x - i == 1) continue;
        cout << (i + 1) << "\n";
    }
    
    return 0;
}



Measured memory_bytes: 3196
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;

  if ( a + b > c + d ) {
    cout << "Left" << endl;
  } else if ( a + b < c + d ) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>


namespace n91 {

void main_() {
  std::string s;
  std::cin >> s;
  std::cout << (std::count(s.cbegin(), s.cend(), 'o') + 15 - s.size() >= 8
                    ? "YES"
                    : "NO")
            << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
from math import hypot

x1, y1, x2, y2 = map(int, input().split())
dx, dy = x2-x1, y2-y1
vector_base = hypot(dx, dy)
q = int(input())

for i in range(q):
    x3, y3 = map(int, input().split()) 
    r = ((x3-x1)*dx + (y3-y1)*dy) / (vector_base**2)
    tx, ty = x1+dx*r, y1+dy*r
    print('{:.08f}'.format(x3+2*(tx-x3)), '{:.08f}'.format(y3+2*(ty-y3)))


Measured memory_bytes: 5692
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll dp[102][100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof(dp));
    ll n,maxc;
    cin>>n>>maxc;
    pair<ll,ll>* arr=new pair<ll,ll>[n+1];
    arr[0]=make_pair(-1,-1);
    for(ll i=1;i<=n;++i)
    {
        ll a,b;
        cin>>a>>b;
        arr[i]=make_pair(a,b);
    }
    for(ll i=0;i<=n;++i)
    {
        dp[i][0]=0;
    }
    for(ll i=1;i<=n;++i)
    {
        ll value=arr[i].second;
        ll weight=arr[i].first;
        for(ll j=1;j<=100000;++j)
        {
            dp[i][j]=dp[i-1][j];
            if(j-value>=0 && dp[i-1][j-value]!=-1)
            {
                ll newval=dp[i-1][j-value]+weight;
                if(dp[i][j]==-1)
                {
                    dp[i][j]=newval;
                }
                else
                {
                    dp[i][j]=min(newval,dp[i][j]);
                }
            }
        }
    }
    for(ll i=100000;i>=0;--i)
    {
        if(dp[n][i]!=-1 && dp[n][i]<=maxc)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}






































Measured memory_bytes: 83360
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii; // 注意必要时改类型
typedef vector<int> vi;
template<typename T>
inline void read(T &x){
    int ch = getchar(); x = 0;
    bool f = false;
    double d = 1;
    for(;ch != '-' && (ch < '0' || ch > '9');ch = getchar());
    if(ch == '-'){f = true; ch = getchar();}
    for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
    if(ch == '.') for(ch = getchar();ch >= '0' && ch <= '9';ch = getchar()) x += (ch - '0') * (d *= 0.1);
    if(f) x = -x;
}
template<typename T>
inline bool chkmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chkmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
const int N = 200003;
int n, a[N], cnt[N];
LL ans;
int main(){
    read(n);
    for(Rint i = 1;i <= n;++ i) read(a[i]), ans += cnt[a[i]] ++;
    for(Rint i = 1;i <= n;++ i) printf("%lld\n", ans - cnt[a[i]] + 1);
}

Measured memory_bytes: 3712
#include<cstdio>
#include<vector>
#include<cmath>

using namespace std;

int main(){
	int n, sum = 0, ans = 0;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		int t;
		scanf("%d", &t);
		sum += t;
		a[i] = t;
	}
	double ave = (double)sum / n;
	int p = (int)round(ave);
	for(int i = 0; i < n; i++){
		ans += (int)pow(a[i] - p, 2);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    char c[105] = {0};
    int nl = 0, nr = 0;
    scanf("%d%*c", &n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%c", &c[i]);
        if(c[i] == ')')
        {
            ++nr;
            if(nl)
            {
                --nr;
                --nl;
            }
        }
        else if(c[i] == '(')
        {
            ++nl;
        }
    }
    getchar();
    for(int i = 0; i < nr; ++i)
    {
        cout << '(';
    }
    for(int i = 0; i < n; ++i)
    {
        cout << c[i];
    }
    for(int i = 0; i < nl; ++i)
    {
        cout << ')';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <algorithm> 
 
int main() {
  int P;
  int Q;
  int R;
  cin >> P >> Q >> R;
  
  int PQ = P+Q;
  int QR = R+Q;
  int RP = P+R;
  
  cout << min(min(PQ,QR),RP)<<endl;

  
}

Measured memory_bytes: 256