akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	string S;
	cin >> S;
	int C = 999999, F = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == 'C') C = min(C, i);
		if (S.at(i) == 'F') F = max(F, i);
	}
	if (C < F) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i = 0;i < n;i++){
        cin >> w.at(i);
    }
    int s = 0;
    for (int i = 0;i < n;i++){
        s += w.at(i);
    }
    int s1=0;
    int s_min = 10000;
    for (int t = 0;t < n;t++){
        s1 += w.at(t);
        s_min = min(s_min,abs(s1 - (s - s1)));
    }

    cout << s_min << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[100005];
bool dp[100005];
int main() {
  int n,k;
  cin >> n >> k;

  for(int i = 0; i < n; i++) cin >> a[i];
  
  for(int i = 0; i <= k; i++) {
    for(int j = 0; j < n; j++) {
      if(i + a[j] > k) continue;
      dp[i+a[j]] |= !dp[i];
    }
  }

  cout << (dp[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin >>N>>X;
  vector<int> L(N);
  for(int t=0;t<N;t++){
    cin >>L.at(t);
  }
  vector<int> D(N+1);
  D.at(0)=0;
  for(int t=1;t<=N;t++){
    D.at(t)=D.at(t-1)+L.at(t-1);
  }
  int ans=-1;
  for(int t=0;t<N+1;t++){
    if(D.at(t)>X){
      ans = t;
      break;
    }
  }
  if(ans==-1){
    ans=N+1;
  }
  cout <<ans<<endl;
}
    

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

vll color;
bool dfs(vvll &graph, ll now, ll cur = 0){
  color[now] = cur;
  vrep(next, graph[now]){
    if(color[next] == -1){
      if(!dfs(graph, next, 1 - cur)) return false;
    }
    else{
      if(cur == color[next]) return false;
    }
  }
  return true;
}

int main(){
  ll n, m;
  cin >> n >> m;
  vvll graph(n); // あとでここを確認
  color.assign(n, -1);
  rep(i, 0, m){
    ll a, b;
    cin >> a >> b;
    graph[a - 1].push_back(b - 1);
    graph[b - 1].push_back(a - 1);
  }

  if(dfs(graph, 0, 0)){
    ll black = 0, white = 0;
    vrep(i, color){
      if(i == 0) black++;
      else white++;
    }
    cout << white * black - m << endl;
  }
  else cout << n * (n - 1) / 2 - m << endl;
}

Measured memory_bytes: 7424
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
dict={}

for i in s:
  if i not in dict.keys():
    dict[i]=1
  else:
    dict[i]+=1
for j in t:
  if j in s:
    dict[j]-=1
m=max(dict.values())
print(m if m>0 else "0")

Measured memory_bytes: 9108
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


ll n;
vector<ll> v;
multiset<ll> s;
int main()
{
        cin >> n;
        for(ll i=1;i<=(1LL << n);i++) {
                ll x;
                cin >> x;
                s.insert(x);
                //v.pb(x);
        }
        multiset<ll> S;
        S.insert(*s.rbegin());
        auto it = s.end(); it--;
        s.erase(it);
        while(S.size() != (1LL << n)) {

                vector< ll > t;
                t.clear();
                for(auto &j : S) {
                        auto it = s.lower_bound(j);
                        if(it == s.begin()) {
                                cout << "No\n"; return 0;
                        }
                        it--;
                        t.pb(*it);
                        s.erase(it);
                }
                for(auto &j : t) S.insert(j);
        }
        cout << "Yes\n";
        return 0;
}


Measured memory_bytes: 14068
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
		int a,b;
		cin>>a>>b;
		cout<<a*b-a-b+1<<endl;
} 
	

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll A,B,C,ANS;
  cin>>A>>B>>C;
  ANS=A+B+C;
  if(ANS>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
int main(){
	string a,b;
	cin>>a>>b;
	string ans="EQUAL";
	if(a.size()>b.size())ans="GREATER";
	else if(a.size()<b.size())ans="LESS";
	else{
		rep(i,0,a.size()){
			if(a[i]>b[i]){
				ans="GREATER";
				break;
			}
			else if(a[i]<b[i]){
				ans="LESS";
				break;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace ABC157_E___Simple_String_Queries
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var seg = new SegmentTree[26];
            for (int i = 0; i < 26; i++) seg[i] = new SegmentTree(N);
            for (int i = 0; i < N; i++)
            {
                seg[S[i] - 'a'].update(i, true);
            }

            var Q = int.Parse(Console.ReadLine());
            for (int i = 0; i < Q; i++)
            {
                var query = Console.ReadLine().Split(' ');
                if (query[0] == "1")
                {
                    var index = int.Parse(query[1]) - 1;
                    var alphabet = query[2][0] - 'a';
                    for (int j = 0; j < 26; j++)
                    {
                        seg[j].update(index, alphabet == j);
                    }
                }
                else
                {
                    var left = int.Parse(query[1]) - 1;
                    var right = int.Parse(query[2]);
                    int result = 0;
                    for (int j = 0; j < 26; j++)
                    {
                        if (seg[j].getValue(left, right)) result++;
                    }
                    Console.WriteLine(result);
                }
            }
        }
    }
    class SegmentTree
    {
        int size;
        bool[] node;

        public SegmentTree(int _size)
        {
            size = 1;
            while (size < _size) size *= 2;
            node = new bool[2 * size - 1];
        }
        public void update(int _index, bool value)
        {
            var index = _index + size - 1;
            node[index] = value;
            while (index > 0)
            {
                index = (index - 1) / 2;
                node[index] = node[index * 2 + 1] || node[index * 2 + 2];
            }
        }
        public bool getValue(int requestLeft, int requestRight, int currentIndex = 0, int currentLeft = 0, int currentRight = -1)
        {
            if (currentRight < 0) currentRight = size;

            if (requestLeft >= currentRight || requestRight <= currentLeft) return false;

            if (requestLeft <= currentLeft && currentRight <= requestRight) return node[currentIndex];

            bool childLeft = getValue(requestLeft, requestRight, 2 * currentIndex + 1, currentLeft, (currentLeft + currentRight) / 2);
            bool childRight = getValue(requestLeft, requestRight, 2 * currentIndex + 2, (currentLeft + currentRight) / 2, currentRight);
            return childLeft || childRight;
        }
    }
}


Measured memory_bytes: 41952
#include<iostream>
#include<string>
using namespace std;
int d[10000],p[10000];
int main(){
	int n,m;
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)
		break;
	int load=0;
	for(int i=0;i<n;i++){
		cin>>d[i]>>p[i];
		load+=d[i];
	}
	if(load<=m)
		cout<<"0"<<endl;
	else{
		int count=0;
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(p[j]<p[j-1]){
					int tmp=p[j];
					p[j]=p[j-1];
					p[j-1]=tmp;
					tmp=d[j];
					d[j]=d[j-1];
					d[j-1]=tmp;
				}
			}
		}
		int i=0;
		m=load-m;
		while(true){
			if(m<=d[i]){
				count+=m*p[i];
				break;
			}
			count+=d[i]*p[i];
			m-=d[i];
			i++;
		}
		cout<<count<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1236
a = list(input())
b = ['+', '-']

for x in range(2):
    if x % 2 == 0:
        q = int(a[1])
    else:
        q = -int(a[1])
    for y in range(2):
        if y % 2 == 0:
            w = int(a[2])
        else:
            w = -int(a[2])
        for z in range(2):
            if z % 2 == 0:
                e = int(a[3])
            else:
                e = -int(a[3])
            if int(a[0]) + q + w + e == 7:
                print(a[0],b[x],a[1],b[y],a[2],b[z],a[3],'=7', sep='')
                exit()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int N, F[100][10], P[100][11], ans{-1000000000}, g, a;
  cin >> N;
  for (int i = 0; i != N; ++i)
    for (int &f : F[i]) cin >> f;
  for (int i = 0; i != N; ++i)
    for (int &p : P[i]) cin >> p;
  for (int i = 1, n = 1 << 10; i != n; ++i) {
    g = 0;
    for (int j = 0; j != N; ++j) {
      a = 0;
      for (int t = 0; t != 10; ++t)
        if (i & (1 << t) && F[j][t]) ++a;
      g += P[j][a];
    }
    ans = max(ans, g);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap, pair
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow, sin
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd, accumlate
#include <deque>	//deque

using namespace std;

int main() {

	int N, A, B;
	cin >> N >> A >> B;

	if (N * A < B) {
		cout << N * A << endl;
	}
	else {
		cout << B << endl;
	}

	return 0;

}

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

int main() {
	int n,p,d1,d2,max_p,max_d;
	
	while(cin>>n,n){
		max_d=0;
		for(;n;--n){
			cin>>p>>d1>>d2;
			if(max_d<d1+d2){
				max_d=d1+d2;
				max_p=p;
			}
		}
		cout<<max_p<<" "<<max_d<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<23;


int main(){
    int N,T,A;cin >> N >> T >> A;
    P ans=mp(INF,-1);
    for (int i = 0; i < N; i++) {
        int x;cin >> x;
        if(abs(ans.fs)>abs(1000*T-x*6-A*1000)) ans=mp(1000*T-x*6-A*1000,i);
    }
    cout << ans.sc+1 << endl;
    return 0;
}


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

int main()
{
    int N, K, x = 1;
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
    {
        if (2 * x <= x + K)
        {
            x *= 2;
        }
        else
        {
            x += K;
        }
    }

    cout << x << endl;
}

Measured memory_bytes: 3560
#include <iostream>
using namespace std;
int main(void){
    long long N,i;
    cin>>N;
    for(i=1;;i++){
        if(i*108/100==N){
            cout<<i<<endl;
            return 0;
        }
        if(i*108/100>N){
            cout<<":("<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
S = input()
if int(S[:2]) in range(1, 13) and int(S[2:]) in range(1, 13):
  print("AMBIGUOUS")
elif int(S[:2]) in range(100) and int(S[2:]) in range(1, 13):
  print("YYMM")
elif int(S[:2]) in range(1, 13) and int(S[2:]) in range(100):
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int res = N;
    for(int i = 1; i < s.length(); i++){
        if(s[i] == s[i-1]){
            res--;
        }
    }
    cout << res << endl;



    return 0;
}


Measured memory_bytes: 512
open Printf
open Scanf

let id x = x
let pair x y = x, y

let n, m, x, y = scanf "%d %d %d %d" (fun n m x y -> n, m, x, y)

let array_cons v vs = Array.of_list (v :: Array.to_list vs)

let xs = array_cons x @@ Array.init n (fun _ -> scanf " %d" id)
let ys = array_cons y @@ Array.init m (fun _ -> scanf " %d" id)

let () = Array.sort (fun x y -> y - x) xs
let () = Array.sort (fun x y -> x - y) ys

let () =
  if xs.(0) < ys.(0) then
    print_endline "No War"
  else 
    print_endline "War"


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

const int N = 1e5 + 5;

#ifdef LOCAL 
    #include "_/debug.h"
#else 
    #define out(...) 69;
#endif

int bad[N], cnt[N], _size[N], par[N];

void init(int u) {
    par[u] = u;
    _size[u] = 1;
}

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

void join(int u, int v) {
    u = find(u), v = find(v);
    if (u != v) {
        if (_size[v] > _size[u]) swap(u, v);
        par[v] = u;
        _size[u] += _size[v];
    }
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        init(i);
    }
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        ++cnt[u], ++cnt[v];
        join(u, v);
    }
    for (int i = 0; i < k; i++) {
        int u, v;
        cin >> u >> v;
        if (find(u) == find(v)) {
            ++bad[u], ++bad[v];
        }
    }
    for (int i = 1; i <= n; i++) {
        int p = find(i);
        int frens = _size[p] - 1 - bad[i] - cnt[i];
        cout << frens << ' ';
    }        
}

Measured memory_bytes: 2432
fun main(args: Array<String>) {
    val (primaryCupLimit, primaryCupAmount, secondaryCupAmount) = readLine()!!.split(' ').map { it.toInt() }

    val primaryCupRemain = primaryCupLimit - primaryCupAmount
    val secondaryCupRemain = Math.max(secondaryCupAmount - primaryCupRemain, 0)
    
    println(secondaryCupRemain)
}

Measured memory_bytes: 38208
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int N; cin >> N;
  vi A(N); REP(i,N) cin >> A[i];
  vi B(N); REP(i,N) cin >> B[i];

  int ans = 0;
  REP(i,N) {
    int sum = 0;
    FOR(j,0,i+1) {
      sum += A[j];
    }
    FOR(j,i,N) {
      sum += B[j];
    }
    ans = max(ans,sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 class Main
{
    
     static int MAX = 1000001; 
    static int factor[]; 
  
    static void generatePrimeFactors() 
    { 
        factor[1] = 1; 
  
        // their value. 
        for (int i = 2; i < MAX; i++) 
            factor[i] = i; 
  
        for (int i = 4; i < MAX; i += 2) 
            factor[i] = 2; 
   
        for (int i = 3; i * i < MAX; i++) { 
            if (factor[i] == i) { 
                for (int j = i * i; j < MAX; j += i) { 
                     
                    if (factor[j] == j) 
                        factor[j] = i; 
                } 
            } 
        } 
    } 
  
    static int calculateNoOFactors(int n) 
    { 
        if (n == 1) 
            return 1; 
  
        int ans = 1; 
  
        int dup = factor[n]; 
  
        int c = 1; 
  
        int j = n / factor[n]; 
  
        while (j != 1) { 
            if (factor[j] == dup) 
                c += 1; 
  
            else { 
                dup = factor[j]; 
                ans = ans * (c + 1); 
                c = 1; 
            } 
  
            // prime factorizes a number 
            j = j / factor[j]; 
        } 
  
        // for the last prime factor 
        ans = ans * (c + 1); 
  
        return ans; 
    } 
    
    
    
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
	    
	    factor = new int[MAX]; 
        factor[0] = 0;
         generatePrimeFactors(); 
  
	   // BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	    int t=1;
	   // t=sc.nextInt();
	    //int t=Integer.parseInt(br.readLine());
	    while(--t>=0){
	        int n=sc.nextInt();
	        long ans=0;
	        for(int i=1;i<n;i++){
                  long temp=(long)calculateNoOFactors(n-i);
                  ans=ans+temp;
             }
	     System.out.println(ans);
	        
	    }
	    
	}
}

Measured memory_bytes: 40312
using System;
using System.Linq;

namespace FreeWorks
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] values = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(Math.Min(Solve(values[0], values[1], values[2]), Solve(values[0], values[3], values[4])));   
        }

        static int Solve(int n, int a, int b)
        {
            if (n % a == 0)
            {
                return (n / a) * b;
            }
            else
            {
                return (n / a + 1) * b;
            }
        }
    }
}


Measured memory_bytes: 20384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll INF=100000000000000;
int N,M,L,Q;
ll dp[305][305];
int main(){
  cin>>N>>M>>L;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      if(i!=j)
        dp[i][j]=INF;
  for(int i=0;i<M;i++){
  ll a,b,c;cin>>a>>b>>c;a--;b--;
    dp[a][b]=c;dp[b][a]=c;
  }for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      if(0<dp[i][j] && dp[i][j]<=L)
        dp[i][j]=1;
  else if(L<dp[i][j])
    dp[i][j]=INF;
  else{}
  for(int k=0;k<N;k++)
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
  cin>>Q;
  for(int i=0;i<Q;i++){
  int s,t;cin>>s>>t;s--;t--;
    if(dp[s][t]<INF)
    cout<<dp[s][t]-1<<endl;
    else
      cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 4336
N, Y = map(int, input().split())

ans = [-1, -1, -1]
ok = False
for x in range(N+1):
    for y in range((N+1)-x):
        if 10000 * x + 5000 * y > Y:break
        z = N - x- y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()
if not ok: print(-1, -1, -1)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<double>v(n);
    rep(i,n)cin>>v[i];
    sort(v.begin(),v.end());
    stack<double>st;
    st.push(v[0]);
    for(int i=0;i<n;++i){
        double c=st.top();
        st.push((v[i]+c)/2);
    }
    printf("%.10lf\n",st.top());
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n, k; cin >> n >> k;
  Vll a(n); cin >> a;

  rep(i, n-k) {
    if (a[i] < a[i+k]) cout << "Yes\n";
    else cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 4732
#include "bits/stdc++.h"

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;
ll dp[10004];

int main() {
    //usaco("milkvisits");

#ifdef LOCAL
    setIn("in.txt");
    setOut("out.txt");
#endif

    int h, n;
    cin >> h >> n;

    pair<int, ll> s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i].first >> s[i].second;
    }
    for(int i = 1; i <= h; i++) dp[i] = INF;
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= h; j++){
            int x = max(0, j - s[i].first);
                dp[j] = min(dp[j], dp[x] + s[i].second);
        }
    }

    cout << dp[h] << endl;
}

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

using ll = long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main(){
    int x;
    cin>>x;
    int a,b;
    a=x/500;
    b=(x-a*500)/5;
    cout<<a*1000+b*5<<endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
      d[i]%=MOD;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

#define MAXN 100
#define MAXK 100000

int dp[MAXN+1][MAXK+1];

int main(){
  int n,K;cin>>n>>K;
  vector<int>a(n);
  rep(i, n)cin>>a[i];

  BIT<ll> bit(K+1);
  bit.add(0, 1);

  dp[0][0]=1;

  rep(i, n){
    BIT<ll> tbit(K+1);
    rep(j, K+1){
      int l = max(0, j-a[i]);
      int r = j;

      // BITで累積和を求める
      ll sum = bit.sum(r);
      if(l>=1)sum-=bit.sum(l-1);
      sum %= MOD;

      tbit.add(j, sum);
//      cout<<sum<<' ';
    }
//    cout<<endl;
    swap(bit, tbit);
  }
  ll result = bit.sum(K);
  if(K){
    result = (result - bit.sum(K-1)+2*MOD)%MOD;
  }
  cout<<(result+MOD)%MOD<<endl;

  return 0;
}



Measured memory_bytes: 5144
#include<bits/stdc++.h>
#define N 1005
#define LL long long
using namespace std;
const int mo=1e9+7;
int n,m,a,b,c,B,C; LL k,x[2][2],G[2][2],z[2][2]; char st[N][N];
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
void mult(LL u[2][2],LL v[2][2])
{
	int i,j,k;
	for(i=0;i<2;i++)
		for(j=0;j<2;j++){
			z[i][j]=0;
			for(k=0;k<2;k++)
				z[i][j]+=u[i][k]*v[k][j];
		  }
	for(i=0;i<2;i++)
		for(j=0;j<2;j++)
			u[i][j]=z[i][j]%mo;
}
int main()
{
	int i,j;
	scanf("%d %d %lld\n",&n,&m,&k);
	for(i=1;i<=n;i++)
		scanf("%s",st[i]+1);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			if(st[i][j]=='#') a++;
			if(st[i][j]=='#'&&st[i][j+1]=='#') b++;
			if(st[i][j]=='#'&&st[i+1][j]=='#') B++;
		  }
	for(i=1;i<=n;i++) if(st[i][1]=='#'&&st[i][m]=='#') c++;
	for(i=1;i<=m;i++) if(st[1][i]=='#'&&st[n][i]=='#') C++;
	if(!c&&!C){ cout<<fpm(a,k-1); return 0;}
	if(c&&C){ printf("1"); return 0;}
	if(!c) swap(c,C),swap(b,B);
	G[0][0]=G[1][1]=1;
	x[0][0]=a,x[0][1]=(mo-b)%mo,x[1][1]=c,k--;
	while(k){
		if(k&1) mult(G,x);
		k>>=1 , mult(x,x);
	  }
	cout<<(G[0][0]+G[0][1])%mo;
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const ll INF = 1e9+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;}

ll A,B,C,X,Y;

int main() {
    cin >> A >> B >> C >> X >> Y;
    ll res = 0;
    ll Z = min(X,Y);
    X = X - Z; Y = Y - Z;
    res += min(A+B,2 * C) * Z;
    
    res += min(A,2 * C) * X + min(B,2 * C) * Y;
    cout << res << endl;
}


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


struct unionfind{ //構造体の定義
    vector<int> d; //メンバ変数
    unionfind(int n=0): d(n,-1) {} //コンストラクタ（構造体が呼ばれたときにすぐに実行される処理）
    int find(int x){
        if(d[x]<0) return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return false;
        if(d[x]<d[y]) swap(x,y);//d[x] is smaller. Then, connect d[x] to d[y].
        d[y]+=d[x];
        d[x]=y;
        return true;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -(d[find(x)]);   
    }
};


int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> fr(n);
    vector<int> bl[n];
    unionfind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a; --b;
        fr[a]++; fr[b]++;
        uf.unite(a,b);
    }
    rep(i,k){
        int a,b;
        cin>>a>>b;
        --a; --b;
        bl[a].push_back(b);
        bl[b].push_back(a);
    }
    rep(i,n){
        int ans;
        ans=uf.size(i)-1-fr[i];
        for(int a : bl[i]){
            if(uf.same(i,a)) ans--;
        }
        cout<<ans<<" ";
    }
    return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<string>
#include<sstream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int i,j,k;
  while(cin >> n,n){
    map<string,vector<string> > m;
    map<string,bool> b;
    string s,key,f;
    for(i=0;i<n;i++){
      cin >> s;
      for(j=0;j<s.size();j++) if(s[j]==':'||s[j]==','||s[j]=='.') s[j]=' ';
      stringstream ss(s);
      ss >> key;
      if(i==0) f=key;
      while(ss>>s) m[key].push_back(s);
    }
    vector<string> d(m[f]);
    for(i=0;i<d.size();i++) {
      //cout << d[i] << endl;
      if(m[d[i]].size()==0) continue;
      if(b[d[i]]) {
	d.erase(d.begin()+i);
	i--;
	continue;
      }
      b[d[i]]=true;
      //cout << d[i] << endl;
      for(j=0;j<m[d[i]].size();j++){
	d.push_back(m[d[i]][j]);
      }
      d.erase(d.begin()+i);
      i--;
    }
    
    sort(d.begin(),d.end());
    
    //for(i=0;i<d.size();i++) cout << d[i] << endl;
    
    d.erase(unique(d.begin(),d.end()),d.end());
    cout << d.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

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

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll div=1;
  while(a[0]%(div*2)==0) {
    div*=2;
  }
  ll temp=a[0]/2;
  for(ll i=1;i<n;i++) {
    if(a[i]%div||a[i]/div%2==0||temp>m) {
      cout << 0 << endl;
      return 0;
    }
    else {
      ll d=gcd(temp,a[i]/2);
      temp=temp*a[i]/2/d;
    }
  }
  cout << (m/temp+1)/2 << endl;
}

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

int main(){
    string S;  cin >> S;
    bool ans = true;

    if(S[0]!='A') ans = false;

    int buf = 0;
    int cntC = 0;
    int len = S.length();
    if(ans){
        for(int i = 2; i <= len - 2; i++){
            if(S[i]=='C'){
                buf = i;
                cntC++;
            }
        }
        
    }
    if(cntC != 1) ans = false;

    if(ans){
        for(int i=1; i < len; i++){
            if(i==buf) continue;
            if(S[i] < 'a' || 'z' < S[i]) ans = false;
        }
    }

    if(ans) cout << "AC" << endl;
    else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=5005;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int f[MAXN][MAXN],g[MAXN][MAXN],n;char ch[MAXN];
int main()
{
	n=read();scanf("%s",ch+1);int len=strlen(ch+1);
	f[n][len]=1;int ans=0;
	for(int i=n;i>=1;i--)for(int j=1;j<=n;j++)if(f[i][j])
	{
		if(j!=0)ad(f[i-1][j+1],2LL*f[i][j]%mod);//backspace
		ad(f[i-1][j-1],f[i][j]);
	}
	g[0][0]=1;
	for(int i=0;i<n;i++)for(int j=0;j<=i;j++)if(g[i][j])
	{
		ad(g[i+1][max(j-1,0)],g[i][j]);
		ad(g[i+1][j+1],2LL*g[i][j]%mod);
	}
	for(int i=0;i<=n;i++)if(f[i][0])
		ad(ans,1LL*g[i][0]*f[i][0]%mod);
	pr2(ans);
	return 0;
}



Measured memory_bytes: 193408
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 200005;
int n,k;
int a[N],f[N];
int check(int lim){
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += max(0ll,a[i]-(lim/f[i]));
    }
    return ans;
}
main(){
    scanf("%lld%lld",&n,&k);
    for (int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
    }
    for (int i = 0; i < n; i++){
        scanf("%lld",&f[i]);
    }
    sort(a,a+n);
    sort(f,f+n,greater<int>());
    int lo = 0, hi = 1e12;
    while (lo + 1 < hi){
        int mid = (lo+hi)/2;
        if (check(mid) <= k){
            hi = mid;
        }
        else lo = mid;
    }
    if (lo+1 == hi){
        if (check(lo) <= k) hi = lo;
        else lo = hi;
    }
    printf("%lld ",lo);

}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vec vector<int>
using namespace std;

const ll INF = 1e18;
int n, m, s;
vec a, b, c, d, u, v;
vector<vec> edge;
vector<vector<ll>> dp;
vector<vector<bool>> vis;

int oth(int x, int e) {
	if (u[e] == x) return v[e];
	return u[e];
}

int main() {
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	cin >> n >> m >> s;
	a = vec(m);
	b = vec(m);
	c = vec(n);
	d = vec(n);
	u = vec(m);
	v = vec(m);
	edge = vector<vec>(n); 
	for (int i=0; i<m; i++) {
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		--u[i]; --v[i];
		edge[u[i]].push_back(i);
		edge[v[i]].push_back(i);
	}
	for (int i=0; i<n; i++) cin >> c[i] >> d[i];
	
	int MXS = n*50 + 2;
	int MX = MXS - 1;
	dp = vector<vector<ll>>(n, vector<ll>(MXS, INF));
	vis = vector<vector<bool>>(n, vector<bool>(MXS));
	dp[0][min(MX, s)] = 0;
	priority_queue<pair<ll,pii>, vector<pair<ll,pii>>, greater<pair<ll,pii>>> pq;
	pq.push({0, {0, min(MX, s)}});
	while (!pq.empty()) {
		int id = pq.top().second.first;
		int co = pq.top().second.second;
		pq.pop();
		if (vis[id][co]) continue;
		vis[id][co] = true;
		for (int e : edge[id]) {
			int idx = oth(id, e);
			// reach all city
			if (co == MX) {
				if (dp[idx][co] > dp[id][co]+b[e]) {
					dp[idx][co] = dp[id][co] + b[e];
					pq.push({dp[idx][co], {idx, co}});
				}
				continue;
			}
			
			if (co>=a[e] && dp[idx][co-a[e]] > dp[id][co]+b[e]) {
				dp[idx][co-a[e]] = dp[id][co] + b[e];
				pq.push({dp[idx][co-a[e]], {idx, co-a[e]}});
			}
			int coin = co + c[id];
			coin = min(MX, coin);
			if (dp[id][coin] > dp[id][co]+d[id]) {
				dp[id][coin] = dp[id][co] + d[id];
				pq.push({dp[id][coin], {id, coin}});
			}
		}
	}
	vector<ll> ans(n, INF);
	for (int i=1; i<n; i++) {
		for (int j=0; j<MXS; j++) {
			ans[i] = min(ans[i], dp[i][j]);
		}
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 6244
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#define inf 1000000000000000000

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define pair(A, B) make_pair(A, B)

using namespace std;

typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> pii;

void perform() {
  ll b[200001] = {0};
  ll d[200001] = {0};
  int n; cin >> n;
  ll arr[n];
  ll totalDP = 0;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    b[t]++; arr[i] = t;
    totalDP -= d[t];
    d[t] = (b[t] * (b[t] - 1))/2;
    totalDP += d[t];
  }

  for (int i = 0; i < n; i++) {
    ll ans = totalDP;
    if (totalDP && b[arr[i]] - 1 > 0) {
      ans -= d[arr[i]];
      ans += ((b[arr[i]] - 1) * (b[arr[i]] - 2)) / 2;
    }
    cout << ans << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1; //cin >> t;
  while (t--) {perform();}
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {

  long  N,K;

  std::cin >> N;
  std::cin >> K;
  
  if(2*K-1<=N){
    cout <<"YES" <<endl;
  }else{
    cout <<"NO" <<endl;
  }
  return 0;
   
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import math

class Point_Class:
    def __init__(self, x, y):
        self.x  =   x
        self.y  =   y

    def printPoint(self):
        print "%f %f" %(self.x, self.y)

def koch(n, p1, p2):
    if n == 0:
        return
    sin60 = math.sin(math.radians(60))
    cos60 = math.cos(math.radians(60))
    s = Point_Class((2*p1.x+p2.x)/3, (2*p1.y+p2.y)/3)
    t = Point_Class((p1.x+2*p2.x)/3, (p1.y+2*p2.y)/3)
    u = Point_Class((t.x-s.x)*cos60-(t.y-s.y)*sin60+s.x, (t.x-s.x)*sin60+(t.y-s.y)*cos60+s.y)
    koch(n-1, p1, s)
    s.printPoint()
    koch(n-1, s, u)
    u.printPoint()
    koch(n-1, u, t)
    t.printPoint()
    koch(n-1, t, p2)

n = int(raw_input())
p1 = Point_Class(0.0, 0.0)
p2 = Point_Class(100.0, 0.0)
p1.printPoint()
koch(n, p1, p2)
p2.printPoint()

Measured memory_bytes: 6656
n,k = gets.to_s.split.map{|t|t.to_i}

ary = Array.new(n) do
  a, b = gets.to_s.split
  a, b = a.to_i, b.to_i
end

sz = 0
ary.sort.each do |(a,b)|
  
  sz += b
  if k <= sz
    puts a
    exit
  end
end

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0 || vis[x] > (num+1))
      dfs2(x, curr, num+1);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  string s;
  cin>>s;
  if(s[0] == s[2]) puts("Yes");
  else puts("No");
  return 0;
}


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

int n, m, q;
int a[50], b[50], c[50], d[50];
int A[10];
int ans;

void dfs(int depth, int pre) {
    if (depth == n) {
        int sum = 0;
        for (int i = 0; i < q; i++) {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
                sum += d[i];
            }
        }
        ans = max(sum, ans);
        return;
    }

    for (int i = pre; i <= m; i++) {
        A[depth] = i;
        dfs(depth + 1, i);
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(0, 1);

    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 vector<int> v(n);
 forn cin>>v[i];
 ll ans=1e10;
 for(int i=1;i<=100;i++)
 {
           ll cur=0;
           for(auto x: v)
           {
                     cur+=(ll) (x-i)*(x-i);
           }
           ans=min(ans,cur);
 }
 cout<<ans;
 
 
 
 
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;
 
int32_t main(){
    vaibhavv06;
	int n,W; cin>>n>>W;
    int w[n],v[n];
    // int dp[W+1]={0};
    
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    int sum=0;
    for(int i=0;i<n;i++) sum+=v[i];
    int dp[sum+1]={0};
    for(int i=1;i<=sum;i++) dp[i]=INT_MAX;
    
    // for(int i=0;i<n;i++){
    //     for(int j=W-w[i]; j>=0; j--){
    //         dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
    //     }
    // }
    // int ans=0;
    // for(int i=0;i<=W;i++) ans= max(ans,dp[i]);
    for(int i=0;i<n;i++){
        for(int j=sum-v[i];j>=0;j--){
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
        }
    }
    int ans=0;
    for(int i=0;i<=sum;i++){
        if(dp[i]<=W){
            ans=max(ans,i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long k = sc.nextLong();

        int[] a = new int[n + 1];
        int[] count = new int[n + 1];
        Arrays.fill(count, Integer.MAX_VALUE);

        for(int i = 1; i <= n; i++){
            a[i] = sc.nextInt();
        }

        int current = 1;
        int cnt = 0;

        while(count[current] == Integer.MAX_VALUE){
            count[current] = cnt;
            current = a[current];
            cnt++;
            k--;
            if(k == 0){
                System.out.println(current);
                return;
            }
        }

        Arrays.fill(count, Integer.MAX_VALUE);
        cnt = 0;

        while(count[current] == Integer.MAX_VALUE){
            count[current] = cnt;
            current = a[current];
            cnt++;
            k--;
            if(k == 0){
                System.out.println(current);
                return;
            }
        }

        k %= cnt;

        while(true){
            if(k == 0){
                System.out.println(current);
                return;
            }
            current = a[current];
            k--;
        }

    }

}

Measured memory_bytes: 61284