akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, n = mi()

    x = min(b - 1, n)
    print(math.floor(a * x / b) - a * math.floor(x / b))



if __name__ == "__main__":
    main()


Measured memory_bytes: 9220
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }


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

    int temp = ceil((double)T/1000);
    
    cout << temp*1000-T;

  return 0;
}


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

const int N = 100;

void print(int n, int A[]) {
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertion_sort(int n, int A[]) {
  int i, j, v;
  
  for (i = 0; i < n; i++) {
    v = A[i];
    
    for (j = i-1; j >= 0; j--) {
      if (A[j] > v) {
        A[j+1] = A[j];
      } else {
        break;
      }
    }
    A[j+1] = v;
    
    print(n, A);
  }
}

int main() {
  int n;
  int A[N];    

  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];

  insertion_sort(n, A);

  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
using namespace std;
int n,a,b;
vector<int> v[100001];
int F[100001],S[100001];

void dfs(int *D,int node,int num){
    D[node]=num;
    for(int i=0;i<v[node].size();i++){
        if(D[v[node][i]]==-1)dfs(D,v[node][i],num+1);
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=1;i<=n;i++)F[i]=-1,S[i]=-1;
    dfs(F,1,0);
    dfs(S,n,0);
    int f=0,s=0;
    for(int i=1;i<=n;i++){
        if(F[i]>S[i])s++;
        else f++;
    }
    cout<<(f>s?"Fennec":"Snuke");
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define lli long long int
#define pb push_back
#define MAX 1e16

using namespace std;

int main(){
    lli X,Y,Z,i,j,k,ans;
    ans = 0;

    cin>>X>>Y>>Z;


    i = Z;

    while(i<=(X-Y-Z)){
        ans++;
        i += Y+Z;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
#define fr(i,a,b) for(int i=a;i<b;i++)
using namespace std;
void solve()
{
    /*int n, m, i, j, k, l;
    cin>>n;
    int a[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    int cnt=0;
    for(i=0; i<n; i++)
    {
        int x=a[i];
        bool ok=true;
        for(j=0; j<n; j++)
        {
            if(i==j)
                ;
            else
            {
                if(x%a[j]==0)
                {
                    ok=false;
                    break;
                }
            }
        }
        if(ok==true)
            cnt++;
    }
    cout<<cnt<<endl;*/

    int n,y,cnt=0;
    cin>>n;
    int ar[1000006],used[1000007]={0},br[1000007]={0};
    fr(i,0,n){cin>>ar[i];br[ar[i]]++;}

    for(int i=1;i<=1000000;i++){

        if(br[i]){
            if(br[i]>1){used[i]=1;}
            for(int j=i+i;j<=1000000;j+=i){
                used[j]=1;
            }
        }
    }

    fr(i,0,n){
    if(used[ar[i]]==0)++cnt;
    }
    cout<<cnt<<endl;
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 12224
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

ll c[10][10];
void WarshallFloyd(ll n){
    rep(k,0,n){
        rep(i,0,n){
            if(i==k) continue;
            rep(j,0,n){
                c[i][j] = min2(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
}


int main(void){
    // char ;
    ll h,w,ans=0;
    scanf("%lld%lld",&h,&w);
    ll a[h][w];
    // ll magic[10][10];
    rep(i,0,10){
        rep(j,0,10){
            scanf("%lld",&c[i][j]);
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            scanf("%lld",&a[i][j]);
        }
    }
    WarshallFloyd(10);
    // rep(i,0,10){
    //     rep(j,0,10) printf("%lld ",c[i][j]);
    //     PN;
    // }
    rep(i,0,h){
        rep(j,0,w){
            if(a[i][j]==-1) continue;
            ans+=c[a[i][j]][1];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main () {
    int n;
    cin >> n;
    int a[n];
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    
    for (int i = n; i > 1; --i)
        cout << a[i] << " ";
    cout << a[1] << "\n";    
}


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

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

	int N, K, X, Y;

	cin >> N >> K >> X >> Y;
  
	cout << min( K*X+(N-K)*Y, N * X) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
const ll mod=1e9+7;
ll factorial[100002];
ll power(ll a, ll b){            
    ll x = 1, y = a;
    while (b > 0){
        if (b%2){
            x = (x*y)%mod;
        }
        y = (y*y)%mod;
        b /= 2;
    }
    return x%mod;
}   
ll modular_inverse(ll n){                
    return power(n, mod-2);
}
ll nCr(ll n, ll k){
    ll temp= ((factorial[n])*(modular_inverse(factorial[k])))%mod;
    return (temp*modular_inverse(factorial[n-k]))%mod;
}
int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	factorial[0]=1;
    for (int i = 1; i < 100002; ++i)        
    {
        factorial[i] = ((ll)i*factorial[i-1])%mod;
    }
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans=0;
	for (int i = 0; i < n; ++i)
	{
		if(i<k-1) continue;
		ll curr= nCr(i,k-1);
		ans = (ans + curr*a[i])%mod;
	}
	for (int i = 0; i < n; ++i)
	{
		if(n-1-i<k-1) continue;
		ll curr = nCr(n-1-i,k-1);
		ans = (ans - curr*a[i])%mod;
	}
	ans = (ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
using namespace std;

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

    if(A==B && B==C && C==A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
a=input()
l=len(a)
a=int(a)
if a==100000:
  print(90909)
elif 99999>=a>=10000:
  print(909+a-9999)
elif 9999>=a>=1000:
  print(909)
elif 999>=a>=100:
  print(9+a-99)
elif 99>=a>=10:
  print(9)
else:
  print(a)


Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static bool[] vd;
        static List<long>[] g;
        static long strt;
        static Stack<long> nodes;
        static List<long> ans;
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            g = new int[N].Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < M; ++i) 
            {
                var ab = Sarray();
                g[ab[0] - 1].Add(ab[1] - 1);
            }
            ans = new long[N + 1].ToList();
            for (var i = 0; i < N; ++i)
            {
                vd = new bool[N];
                strt = i;
                nodes = new Stack<long>();
                nodes.Push(i);
                dfs(i);
            }
            if (ans.Count == N + 1)
                WriteLine(-1);
            else
            {
                WriteLine(ans.Count);
                for (var i = 0; i < ans.Count; ++i)
                    WriteLine(ans[i] + 1);
            }
        }
        static void dfs(long n)
        {
            foreach (var v in g[n])
            {
                if (v == strt)
                {
                    if (nodes.Count < ans.Count)
                        ans = nodes.ToList();
                }
                if (!vd[v])
                {
                    vd[v] = true;
                    nodes.Push(v);
                    dfs(v);
                    nodes.Pop();
                }
            }
        }
    }
}

Measured memory_bytes: 31824
N, M, X, Y = map(int, input().split())
*x, = map(int, input().split())
*y, = map(int, input().split())

def check(Z):
    if not X < Z <= Y:
        return 0

    for e in x:
        if not e < Z:
            return 0

    for e in y:
        if not Z <= e:
            return 0
    return 1

for Z in range(-100, 101):
    if check(Z):
        print('No War')
        break
else:
    print('War')


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var n = (double)nk[0];
            var k = (double)nk[1];

            double ans = 0;

            for (int i = 1; i <= n; i++)
            {
                if (i < k)
                {
                    var x = Ceiling(Log(k / i, 2));
                    var y = 1 / (Pow(2, x) * n);
                    ans += y;
                }
                else
                {
                    ans += 1/n;
                }
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1LL<<31;

int main(){
    ll n;
    cin >> n;
    ll sum=0;
    vector<ll> a(n+2);
    rep(i,n){
        cin >> a[i+1];
    }
    for(ll i=1;i<=n+1;i++){
        sum+=abs(a[i]-a[i-1]);
    }
    for(ll i=1;i<=n;i++){
        if(a[i-1]<=a[i] && a[i]<=a[i+1]){
            cout << sum << endl;
            continue;
        }
        if(a[i-1]<=a[i+1] && a[i+1]<=a[i]){
            cout << sum-2*(a[i]-a[i+1]) << endl;
            continue;
        }
        if(a[i+1]<=a[i-1] && a[i-1]<=a[i]){
            cout << sum-2*(a[i]-a[i-1]) << endl;
            continue;
        }
        if(a[i+1]<=a[i] && a[i]<=a[i-1]){
            cout << sum << endl;
            continue;
        }
        if(a[i]<=a[i+1] && a[i+1]<=a[i-1]){
            cout << sum-2*(a[i+1]-a[i]) << endl;
            continue;
        }
        if(a[i]<=a[i-1] && a[i-1]<=a[i+1]){
            cout << sum-2*(a[i-1]-a[i]) << endl;
            continue;
        }
    }
} 

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

const int N = 505;
int in[N][N];
int D[N][N];
vector< int> v[3];
vector< int> cost[3];


int chk(vector< int> vec, int color) {
    int rv = 0;
    for(int &x: vec) {
        rv += D[x][color];
    }
    return rv;
}

int main() {
    int n, c;
    scanf("%d %d", &n, &c);
    for (int i = 1; i <= c; ++i) for (int j = 1; j <= c; ++j) scanf("%d", &D[i][j]);
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) {
        int x; scanf("%d", &x);
        v[(i + j) % 3].emplace_back(x);
    }


    for(int i = 1; i <= c; ++i) {
        cost[0].emplace_back(chk(v[0], i));
        cost[1].emplace_back(chk(v[1], i));
        cost[2].emplace_back(chk(v[2], i));
    }

    int res = 1e9;
    for(int i = 0; i < c; ++i) {
        for(int j = 0; j < c; ++j) if(i != j) {
            for(int k = 0; k < c; ++k) if(i != k and j != k) {
                res = min(res, cost[0][i] + cost[1][j] + cost[2][k]);
            }
        }
    }

    printf("%d\n", res);
}

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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var dg = new Dictionary<string, List<string>>();
            var dm = new Dictionary<string, List<string>>();
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var grp = new string[n];
            var buf = new string[n];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(':');
                grp[i] = line[0];
                dg[line[0]] = new List<string>();
                dm[line[0]] = new List<string>();
                buf[i] = line[1];
            }
            for (int i = 0; i < n; i++)
            {
                string[] s = buf[i].Split(',', '.');
                foreach (var x in s)
                    if (x.Length > 0)
                        if (grp.Contains(x)) dg[grp[i]].Add(x);
                        else dm[grp[i]].Add(x);
            }
            var res = solve(dg, dm, grp[0]);
            Console.WriteLine(res);
        }
    }
    public static int solve(Dictionary<string, List<string>> dg, Dictionary<string, List<string>> dm, string g)
    {
        var hsm = new HashSet<string>();
        var hsa = new HashSet<string>();
        var q = new Queue<string>();
        foreach (var x in dg[g])
        {
            q.Enqueue(x);
            hsm.Add(x);
        }
        foreach (var x in dm[g])
            hsa.Add(x);
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            foreach (var x in dg[w])
                if (hsm.Add(x)) q.Enqueue(x);
            foreach (var x in dm[w]) hsa.Add(x);
        }
        return hsa.Count();
    }
}


Measured memory_bytes: 12708
from sys import stdin, setrecursionlimit


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    n = len(s)

    dp = [0] * 13
    if s[0] == '?':
        for i in range(10):
            dp[i % 13] += 1
    else:
        dp[int(s[0]) % 13] += 1

    for i in range(1, n):
        tmp_dp = [0] * 13
        if s[i] == '?':
            for j in range(13):
                for k in range(10):
                    index = (10 * j + k) % 13
                    tmp_dp[index] += dp[j]
                    tmp_dp[index] %= mod
        else:
            for j in range(13):
                index = (10 * j + int(s[i])) % 13
                tmp_dp[index] += dp[j]
                tmp_dp[index] %= mod
        dp = tmp_dp

    print(dp[5] % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

using namespace std;

int main()
{
    int a, k;
    string s;
    cin >> a >> s >> k;
    k--;
    for (int i = 0; i < a; i++)
    {
        if (s[i] != s[k])
        {
            s[i] = '*';
        }
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 2*1e13;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s;
    bool ans = true;
    if(s[2]!=s[3])ans = false;
    if(s[4]!=s[5])ans = false;
    Yes(ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
inline void work(int n, int d, int arr[][605])
{
	int blk = 1; 
	while (!(d & 3))
	{
		d >>= 2; 
		blk <<= 1; 
	}
	if (d & 1)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
				arr[i][j] = (i / blk & 1) ^ (j / blk & 1);
		}
	}
	else
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
				arr[i][j] = i / blk & 1;
		}
	}
}
int arr1[605][605], arr2[605][605], app[5]; 
int main()
{
	// freopen("AGC025-D.in", "r", stdin); 
	int n, d1, d2; 
	scanf("%d%d%d", &n, &d1, &d2);
	work(n << 1, d1, arr1); 
	work(n << 1, d2, arr2); 
	for (int i = 0; i < n << 1; i++)
	{
		for (int j = 0; j < n << 1; j++)
			app[arr1[i][j] << 1 | arr2[i][j]]++; 
	}
	for (int i = 0; i < 4; i++)
	{
		if (app[i] < n * n)
			continue;
		int cnt = n * n; 
		for (int x = 0; x < n << 1; x++)
		{
			for (int y = 0; y < n << 1; y++)
			{
				if ((arr1[x][y] << 1 | arr2[x][y]) == i && cnt)
				{
					printf("%d %d\n", x, y);
					cnt--;
				}
			}
		}
		break; 
	}
	return 0; 
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	ans=modpow(10,n,M);
	ans-=modpow(9,n,M)*2;
	ans+=modpow(8,n,M);
	while(ans<0){
		ans+=M;
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <stdlib.h>
#include <stack>

using namespace std;
int a[100001];
int b[100001];
int c[100001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int cntx = 0; int cnty = 0;
	int x = 0;
	int y = 0;
	for (int i = 1; i <= n; i += 2) {
		b[a[i]] += 1;
		if (cntx < b[a[i]]) {
			cntx = b[a[i]];
			x = a[i];
		}
	}
	for (int i = 2; i <= n; i += 2) {
		c[a[i]] += 1;
		if (cnty < c[a[i]]) {
			cnty = c[a[i]];
			y = a[i];
		}
	}
	if (x == y) {
		sort(b, b + n);
		sort(c, c + n);
		if (b[n - 2] < c[n - 2]) {
			cout << n - (c[n - 2] + cntx);
		}
		else {
			cout << n - (b[n - 2] + cnty);
		}
	}
	else {
		cout << n - (cntx + cnty) << '\n';
	}
}




Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

//DP用
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;
}

const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    int h[n];
    long long dp[n];
    for(int i = 0; i < n; i++) {
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i > 1) {
            chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B<C+D){
    cout<<"Right"<<endl;
  }
  if(A+B>C+D){
    cout<<"Left"<<endl;
  }
  if(A+B==C+D){
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

int main(void) {
  int N, K; cin >> N >> K;
  int count[200000] = {};

  for (int i = 0; i < N; i++) {
    int tmp; cin >> tmp;
    count[tmp - 1]++;
  }

  ll ans = 0;
  sort(count, count + N, std::greater<int>());
  for (int i = K; i < N; i++) {
    ans += count[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    lint a, b, c, x, y;
    scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
    lint ans = INF;
    rep(i, MAX)if(i%2 == 0){
        lint j = max(0LL, a * (x - i/2));
        lint k = max(0LL, b * (y - i/2));
        chmin(ans, c*i + j + k);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(;;){
			int q=sc.nextInt();
			if(q==-1)
				break;
			double x=q/2;
			while(abs(x*x*x-q)>=0.00001*q){
				x-=(x*x*x-q)/(3*x*x);
			}
//			println(x+"");
			println(String.format("%.6f", x));
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    vector<bool>dp(1001001,true);
    ll pre=0;
    for (int i = 0; i < n; ++i) {
        if(pre==a[i])continue;
        if(dp[a[i]]){
            for (ll j =a[i]*2; j <1001001; j+=a[i]) {
                dp[j]=false;
            }
        }
        pre=a[i];
    }
    for (int i = 0; i < n - 1; ++i) {
        if(a[i]==a[i+1]){
            dp[a[i]]=false;
        }
    }
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        if(dp[a[i]])ans++;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e6+10;
struct w
{
    int x, y;
} w[100];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d %d",&w[i].x,&w[i].y);
    }
    double z=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            z=z+sqrt((w[i].x-w[j].x)*(w[i].x-w[j].x)+(w[i].y-w[j].y)*(w[i].y-w[j].y));
        }
    }
    printf("%.10f\n",2.0*z/n);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
//各人が迎えたターン数を表す変数i,j,kを用意する
//現在の先頭のカードをXとする
  string sa,sb,sc;
  cin >> sa >> sb >> sc;
  char X = sa[0];
  int i = 1;
  int j = 0;
  int k = 0;
  while(1){
    if(i == sa.size() +1){
      cout << "A" << endl;
      break;
    }
    else if(j == sb.size() + 1){
      cout << "B" << endl;
      break;
    }
    else if(k == sc.size() +1){
      cout << "C" << endl;
      break;
    }
    if(X == 'a'){
      X = sa[i];
      i++;
    }
    else if(X == 'b'){
      X = sb[j];
      j++;
    }
    else if(X == 'c'){
      X = sc[k];
      k++;
    }
   }
 }


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//const ll MOD  = 998244353;
//vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
//vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

const ll N_ = (1 << 18);
ll seg[2*N_-1];
//Range Minimum Query
void update(ll k, ll x){
  k += N_-1;
  seg[k] = x;
  while(k > 0){
    k = (k-1)/2;
    seg[k] = min(seg[2*k+1], seg[2*k+2]);
  }
}

ll query(ll x, ll y, ll k, ll left, ll right){
  if(right <= x || y <= left) return INFL;
  if(x <= left && right <= y) return seg[k];
  ll mid = (left + right) / 2;
  ll l = query(x, y, 2*k+1, left, mid);
  ll r = query(x, y, 2*k+2, mid, right);
  return min(l, r);
}

ll N, K, Q;
vector<ll> A;

int main(void){
  cin >> N >> K >> Q;
  A.resize(N);
  rep(i, N) cin >> A[i];
  rep(i, N) update(i, A[i]);
  ll ans = INFL;
  rep(i, N){
    vector<pair<ll, ll>> can;
    rep(j, N){
      ll k = j + K;
      if(query(j, k, 0, 0, N_) >= A[i]){
        while(query(j, k+1, 0, 0, N_) >= A[i]) k++;
        can.pb({j, k});
        j = k-1;
      }
    }

    ll cnt = 0;
    rep(j, can.size()) cnt += (can[j].s - can[j].f) - K + 1;

    if(cnt < Q) continue;
    vector<ll> xs[can.size()];
    rep(j, can.size()) for(ll k = can[j].f; k < can[j].s; k++) xs[j].pb(A[k]);
    rep(j, can.size()) sort(xs[j].begin(), xs[j].end());
    vector<ll> canGet;
    rep(j, can.size()) rep(k, xs[j].size() - K + 1) canGet.pb(xs[j][k]);
    sort(canGet.begin(), canGet.end());
    ans = min(ans, canGet[Q-1] - A[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2432
s = input()
n = len(s)
if s == ''.join(list(reversed(s))) and s[:(n-1)//2] == ''.join(list(reversed(s[:(n-1)//2]))) and s[(n+3)//2-1:] == ''.join(list(reversed(s[(n+3)//2-1:]))):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<stdio.h>
int common(int n,int m){
    int l=n*m;
    while(n!=m){
        if(n>m){
        n-=m;
        }else{
            m-=n;
        }
        }
        return l/n;
}
int main(void){
    int i,n,a[10],x;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    x=common(a[0],a[1]);
    for(i=2;i<n;i++)
    {
        x=common(x,a[i]);
    }
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 596
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


## input
N,C = map(int, input().split())
Cn = [[0 for j in range(10**5+1)] for i in range(C)]
An = [0 for j in range(10**5+1)]
for i in range(N):
  s,t,c = map(int, input().split())
  if Cn[c-1][s] == -1:
    An[s] += 1
  else:
    An[s-1] += 1
  if Cn[c-1][t] == 1:
    An[t-1] -= 1
  else:
    An[t] -= 1    

  Cn[c-1][s] += 1
  Cn[c-1][t] -= 1

for i in range(1,10**5+1):
  An[i] += An[i-1]

print(max(An))

Measured memory_bytes: 27444
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    string s; cin >> s;
    if(s.size() == 1) cout << 0;
    else {
        string s1, s2;
        int c1 = 0, c2 = 0;
        For(i, 0, s.size()) {
            if(i % 2 == 0) {
                s1 += '0';
                s2 += '1';
            }
            else {
                s1 += '1';
                s2 += '0';
            }
        }
        For(i, 0, s.size()) {
            if(s[i] != s1[i]) c1++;
            else if (s[i] != s2[i]) c2++;
        }
        cout << min(c1, c2);

    }

    
    
    
    return 0;
}

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

#define fi first
#define se second
#define SZ(x) (int)x.size()
#define ll long long
#define pb push_back
#define pq priority_queue
#define pii pair<int,int>
#define mod 998244353
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i,a,b) for (int i=a;i<(b);i++)

const int maxn=2e5+10;

int n;
int a[maxn];
int sum=0;

int main(){
	std::ios::sync_with_stdio(false);
	cin>>n;
	rep(i,0,n) cin>>a[i],sum^=a[i];
	rep(i,0,n) cout<<(a[i]^sum)<<" ";
 	return 0; 
}


Measured memory_bytes: 4344
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		long K = sc.nextLong();
		int Q = sc.nextInt();
		int[] ansers = new int[N+1];
		for (int i = 1; i <= Q; i++) {
			ansers[sc.nextInt()]++;
		}
		for (int i = 1; i <= N; i++) {
			String ans = "Yes";
			if (K - Q + ansers[i] <= 0) {
				ans = "No";
			}
			System.out.println(ans);
		}
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 40620
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;

template<class T>void read(T &x){
    T s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}

void solve(){
	
}	
int main(){
	// debug;
	int s,w;
	read(s,w);
	if(s<=w) puts("unsafe");
	else puts("safe");
	
	return 0;
}


Measured memory_bytes: 3628
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;



int main(){
 
    int N;
    int Y;
    cin>>N>>Y;
    Y/=1000;
    
    REP(i,N+1){
        REP(j,N+1){
            int k=N-i-j;
            if(k<0){continue;}

            if(i+5*j+10*k==Y){
                cout<<k<<" "<<j<<" "<<i<<endl;
                return 0;
            }
            // REP(k,N+1){
            //     if(i+j+k>N){continue;}
            //     if(i+5*j+10*k==Y){
            //         cout<<i<<" "<<j<<" "<<k<<endl;
            //         return 0;
            //     }
            // }
        }
    }
    cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ld h,a;
    cin>>h>>a;
    
    cout<<ceil(h/a)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long N, W;
	cin >>N >>W;
	vector<pair<long long, long long>> arr(N);
	long long totalValue = 0LL;
	for(long long i = 0LL; i < N; i++){
		cin >>arr[i].first >>arr[i].second;
		totalValue += arr[i].second;
	}
	// dp[i] = minimum total weight with value exactly i
	vector<long long> dp(totalValue + 1LL, INF);
	dp[0] = 0LL;
	for(long long i = 0LL; i < N; i++) {
		for(long long v = totalValue - arr[i].second; v >= 0LL; v--) {
			dp[v + arr[i].second] = min(dp[v + arr[i].second], dp[v] + arr[i].first);
		}
	}
	long long ans = 0LL;
	for(long long i = 0LL; i <= totalValue; i++) {
		if(dp[i] <= W) {
			ans = max(ans, i);
		}
	}
	cout <<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
 
using namespace std;
 
typedef vector<int> vi;
 
int n;
 
int f(vi a, int n, int idx)
{
	vi kesu;
 
	for (int i = idx + 1; i < n; ++i) {
		if (a[i] != a[idx]) break;
		kesu.push_back(i);
	}
	for (int i = idx - 1; i >= 0; --i) {
		if (a[i] != a[idx]) break;
		kesu.push_back(i);
	}
 
	if (kesu.size() < 3) return n;
 
    while (kesu.size()) {
		a[kesu.back()] = 0;
		kesu.pop_back();
	}
	a[idx] = 0;
 
	vi b;
 
	int nextidx = -1;
 
	for (int i = 0; i < n; ++i) {
		if (a[i]) {
			b.push_back(a[i]);
			if (nextidx == -1 && i >= 1 && a[i - 1] == 0) {
				nextidx = b.size() - 1;
			}
		} else {
			if (nextidx == -1) {
                if (b.size()) {
					nextidx = i - 1;
				}
			}
		}
	}
 
   return f(b, b.size(), nextidx); 
}
 
int calc(vi a, int n, int idx)
{
	vi b = a;
	if (idx >= 3 && a[idx - 1] == a[idx - 2] && a[idx - 2] == a[idx - 3]) {
		b[idx] = b[idx - 1];
	} else if (idx <= n - 4 && a[idx + 1] == a[idx + 2] && a[idx + 2] == a[idx + 3]) {
		b[idx] = b[idx + 1];
	} else if (idx >= 2 && idx <= n - 2 && a[idx - 1] == a[idx - 2] && a[idx - 1] == a[idx + 1]) {
		b[idx] = b[idx - 1];
	} else if (idx >= 1 && idx <= n - 3 && a[idx - 1] == a[idx + 1] && a[idx - 1] == a[idx + 2]) {
		b[idx] = b[idx - 1];
	} else {
		return n;
	}
 
	return f(b, b.size(), idx);
}
 
int main()
{
	while (scanf("%d", &n), n) {
		vi arr;
 
		for (int i = 0; i < n; ++i) {
			int a; scanf("%d", &a);
			arr.push_back(a);
		}
 
		int mi = 10001;
 
		for (int i = 0; i < n; ++i) {
			mi = min(mi, calc(arr, arr.size(), i));
		}
 
		printf("%d\n", mi);
	}
}

Measured memory_bytes: 37624
N = int(input())
song = [0] * N
time = [0] * N
for i in range(N):
    song[i], time[i] = map(str, input().split())
time = [int (t) for t in time]
X = input()
res = 0
Sleep = song.index(X)
Played = time[Sleep+1::]
for time in Played:
    res = res + time
print(res)


Measured memory_bytes: 3064
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
  int n, d, x[11][11], c = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int k = i; k < n; k++) {
      if (i == k) {
        continue;
      }
      double naka = 0;
      for (int j = 0; j < d; j++) {
        naka += pow(abs(x[i][j] - x[k][j]), 2.0);
      }
      double dis = sqrt(naka);
      if (dis == floor(dis)) {
        c++;
      }
    }
  }
  cout << c << endl;
}

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

int main(){
    int N;
    int a[110];
    cin >> N;

    for(int i = 0; i < N; i ++){
        cin >> a[i];
    }

    sort(a, a + N, greater<int>());
    int A = 0;
    int B = 0;

    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            A += a[i];
        }
        else{
            B += a[i];
        }
    }

    cout << A - B << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    int a, b, c; cin >> a >> b >> c;
    cout << (a+b>=c?"Yes":"No");
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256