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


ll calc(int l, int r, int n){
    int ans=0;
    for(int i=1;i<=n;i++){
        int tmp=i;
        bool ch=true;
        if(i%10!=r)ch=false;
        while(tmp/10>0){
            tmp/=10;
        }
        if(tmp==l&&ch)ans++;
    }
    return ans;
}

int main(void) {

    itn n;
    cin>>n;

    ll ans=0;
    if(n<10){
        fin(n);
        return 0;
    }
    string s="";
    int tmp=n;
    while(tmp>0){
        s+=tmp%10+'0';
        tmp/=10;
    }
    reverse(all(s));
    for(int l=1;l<10;l++){
        for(int r=1;r<10;r++){
            // cout<<l<<" "<<r<<" "<<calc(l,r,n)<<endl;
            ans+=calc(l,r,n)*calc(r,l,n);
        }
    }
    fin(ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int n=0, i;
    long int x=0;

    scanf("%d", &n);

    for(i=1;i<=n;i++){
        if((i%3) != 0 && (i%5) != 0)
            x += i;

    }

    printf("%ld\n", x);

    return 0;
}

Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  if (n%m == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}

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

l = []

k = 0
g1 = 0
g2 = 0

if K % 2 == 1:
	for i in range(1,N+1):
		if i % K == 0:
			k += 1
		
else:
	for i in range(1,N+1):
		if i % K == 0:
			g1 += 1
		elif i % K == K / 2:
			g2 += 1

print(k**3 + g1**3 + g2**3)            

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    int ans = min(b,d) - max(a,c);
    if (ans >= 0) cout << ans << endl;
    else cout << 0 << endl;
}

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

#define H 500000

int h;

void maxHeapify(int *,int);
void buildMaxHeap(int *);

int main() {
    
    int i,A[H];
    
    scanf("%d",&h);
    
    for(i=1; i<=h; i++) scanf("%d",&A[i]);
    
    buildMaxHeap(A);
    
    for(i=1; i<=h; i++) printf(" %d",A[i]);
    printf("\n");
    
    return 0;
}


void maxHeapify(int *A,int i) {
    int l,r,largest,tmp;
    
    l = i*2;
    r = i*2+1;
    
    if(l<=h && A[l]>A[i]) largest = l;
    else largest = i;
    
    if(r<=h && A[r]>A[largest]) largest = r;
    
    if(largest!=i) {
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        
        maxHeapify(A,largest);
    }
}


void buildMaxHeap(int *A) {
    int i;
    
    for(i=h/2; i>0; i--) maxHeapify(A,i);
}

Measured memory_bytes: 2552
import numpy as np

N = int(input())
A = np.array(input().split(), np.int64)

Acum = np.zeros((N, N + 1), dtype=np.int64)
for i in range(N):
    Acum[i, i + 1:] = A[i:].cumsum()

dp = np.zeros((N, N + 1), dtype=np.int64)

for length in range(2, N + 1):
    for left in range(N - length + 1):
        right = left + length
        dp[left, right] = (dp[left, left + 1: right] + dp[left + 1: right, right]).min() + Acum[left, right]

print(dp[0, N])

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

int main(){
	

	int n;
	string s;
	cin >> n;
	n = n%10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon";
	else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
	else cout << "bon";
	return 0;
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll a, b;
    cin >> a >> b;
    if(b >= a) {
        cout << "unsafe" << endl;
        return 0;
    }
    else {
        cout << "safe" << endl;
    }
   return 0;
}



Measured memory_bytes: 3616
#include <stdio.h>
#define MAX 100009

void swap(int *,int *);
int partition(int,int);

int A[MAX];
int n;

int main(){
  int i;
  int q;

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

    q=partition(0,n-1);
    for(i=0;i<n;i++){
      if(i)printf(" ");
      if(i==q)printf("[");
      printf("%d",A[i]);
      if(i==q)printf("]");
      }
      printf("\n");

return 0;
}

int partition(int p,int r){
  int x;
  int i,j;
  int t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}

void swap(int *a,int *b){
  int v;
  v=*a;
  *a=*b;
  *b=v;
}

Measured memory_bytes: 988
import Data.Bool
import qualified Data.ByteString.Char8 as C
import Data.Maybe
import qualified Data.IntSet as S
import Data.Vector.Generic ((!))
import qualified Data.Vector.Unboxed as U

main = C.interact $ put . sol . get

get = U.unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.pack . (++ "POSSIBLE") . bool "" "IM"

sol v = S.null via
  where
  n = v!0
  m = v!1
  u = U.drop 2 v
  es = U.unfoldrN m split2 u
  split2 u = Just ((min (U.head v) (U.last v), max (U.head v) (U.last v)), w)
    where (v,w) = U.splitAt 2 u
  e1 = S.fromList . U.toList . U.map snd $ U.filter ((==1) . fst) es
  en = S.fromList . U.toList . U.map fst $ U.filter ((==n) . snd) es
  via = S.intersection e1 en

Measured memory_bytes: 19676
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
struct UnionFind{
    vector<int> parent;

    UnionFind(int n){
        parent.resize(n);
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int root(int node){
        if(parent[node] == node){
            return node;
        } else {
            return parent[node] = root(parent[node]);
        }
    }

    void unite(int x, int y){
        int rootx = root(x);
        int rooty = root(y);
        if(rootx == rooty) return;
        parent[rootx] = rooty;
    }

    bool isSame(int x, int y){
        return root(x) == root(y);
    }
};
int main(void){
    int n, k, l;
    cin >> n >> k >> l;

    UnionFind road(n);
    UnionFind rail(n);

    for(int i = 0; i < k; i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }

    for(int i = 0; i < l; i++){
        int r, s;
        cin >> r >> s;
        r--, s--;
        rail.unite(r, s);
    }

    
    map<pair<int,int>,int> mp;
    for(int i = 0; i < n; i++){
        pair<int,int> p = make_pair(road.root(i), rail.root(i));
        mp[p]++;
    }

    for(int i = 0; i < n; i++){
        pair<int,int> p = make_pair(road.root(i), rail.root(i));
        cout << mp[p] << " ";
    }

    cout << endl;

}

Measured memory_bytes: 13568
a, b, c, x, y = tuple(map(lambda i: int(i), input().split()))

# 個別買い
p1 = a * x + b * y

# セット＋残りを個別
p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x))

# セットのみ
p3 = c*(x+y) * 2
p4 = c*max(x, y)*2

print(min(p1, p2, p3, p4))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
stack<int> st;
int main()
{

    int n;cin>>n;
    int x;cin>>x;
    st.push(x);
    n=n-1;
    while(n--)
    {
        cin>>x;
        if(x<=st.top())
        {
            st.push(x);
        }
    }
    cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

//B

int main(void) {
	ll n, k;
	cin >> n >> k;
	vector<ll> h = vector<ll>(n);
	rep(i, 0, n)cin >> h[i];
	const ll INF = 1e10;
	vector<ll> dp = vector<ll>(n, INF);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	rep(i, 2, n) {
		for (ll j = i - 1; 0 <= j && (i - j) <= k; j--) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define        ll     long long int
using namespace std;
int main()
{
    string s;
    cin>>s;
    int x=s.size()-1;
    if(s[x]=='s'){
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<"s"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int H,W,h,w;cin>>H>>W>>h>>w;
  cout << (H-h) * (W-w) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;
   vector<int> v(n), c(n);
   for (int i = 0; i < n; ++i)
   {
      cin>>v[i];
   }

   for (int i = 0; i < n; ++i)
   {
      cin>>c[i];  
   }
      
   int ans = 0;
   for (int i = 0; i < (1LL<<n); ++i)
   {
      int vals = 0;
      for (int j = 0; j < n; ++j)
      {
         if (i&(1LL<<j)){
            vals += (v[j] - c[j]);
         }
      }
      smax(ans, vals);
   }

   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 256
N, M = map(int, input().split())
s = [tuple(map(int, input().split())) for i in range(N)]
check_points = [tuple(map(int, input().split())) for i in range(M)]

for a, b in s:
    ans_num = 0
    ans_dist = 1000000007
    for i in range(len(check_points)):
        x, y = check_points[i]
        dist = abs(a - x) + abs(b - y)
        if dist < ans_dist:
            ans_num = i + 1
            ans_dist = dist
    print(ans_num)
        

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

unordered_map<ll, ll> prime_factor(ll n) {
    unordered_map<ll, ll> primes;
    for (ll p = 2; p * p <= n; ++p) {
        while (n % p == 0) {
            primes[p]++;
            n /= p;
        }
    }
    if (n != 1) primes[n]++;
    return primes;
}

int main() {
    ll N, P; cin >> N >> P;
    auto primes = prime_factor(P);
    ll gcd = 1LL;
    for (const auto&[prime, power] : primes) gcd *= pow(prime, power/ N);
    cout << gcd << endl;
    return 0;
}


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

int main(void)
{
    int n;
    cin >> n;
    int ac=0,wa=0,tle=0,re=0;
    rep(i, n){
        string str;
        cin >> str;
        if(str=="AC"){
            ac++;
        }else if(str=="WA"){
            wa++;
        }else if(str=="TLE"){
            tle++;
        }else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n, i, j, h[100002], a[100002] =  {0};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n;
    for(i = 0; i < n; i++) {
    	cin >> h[i];
    }
    a[1] = abs(h[1] - h[0]);
    for(i = 2; i < n; i++) {
    	a[i] = min(a[i - 2] + abs(h[i] - h[i - 2]), a[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << a[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef long double ld;

const int N = 200006;

int n, k;
vector<int> a(N);

bool okay(int x) {

    int cuts = 0;

    for(int i = 1; i <= n; i++) {
        
        if (x >= a[i]) continue;

        cuts += (a[i] - 1) / x;

        //val * x = a[i]
    }

    return cuts <= k;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;

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

    int low = 1, high = 1e9 + 6, ans;

    while(low <= high) {

        int mid = (low + high) / 2;

        if (okay(mid)) {

            ans = mid;
            high = mid - 1;

        } else low = mid + 1;
    }

    cout << ans << '\n';

    return 0; 
}


Measured memory_bytes: 3876
import collections

number = int(input())

array = []

for i in range(number):
    array.append(input())

dic = collections.Counter(array).most_common()

max_dic = [dic[0][0]]

for i in range(len(dic) - 1):
    if dic[i + 1][1] == dic[0][1]:
        max_dic.append(dic[i + 1][0])
        
max_dic.sort()

for i in range(len(max_dic)):
    print(max_dic[i])

Measured memory_bytes: 45036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define R(a) a=sqrt(a)
#define POW(a,b) a=pow(a,b)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    FAST;
    ll n;
    ll ans=0;
    string s;
    cin>>n>>s;
    rep(i,n-2){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C'){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
    
}



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

using namespace std;

int main(){
 long long int a,b,c;
  cin >> a >> b ;
  
  c = a % b; 
  if(c > b/2){
  cout << b-c << endl;
}
  else{
    cout << c << endl;
  }
}


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

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

  int cnt = 0;
  int ans = 0;
  rep(i, S.size()) {
    if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
      cnt++;
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  for(int i = 0;i<s.size();i++){
    if(s[i] != t[i]) count++;
  }
  cout << count << endl;
    
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define LIMTIME 1900
using namespace std;

unsigned int xorshift() {
  static unsigned int nowx = 123456789, nowy = 362436069, nowz = 521288629,
                      noww = 88675123;
  unsigned int temp;
  temp = (nowx ^ (nowx << 11));
  nowx = nowy;
  nowy = nowz;
  nowz = noww;
  return (noww = (noww ^ (noww >> 19)) ^ (temp ^ (temp >> 8)));
}

long long d, score = -1;
const long long t = 26;
vector<long long> c, res;
vector<vector<long long>> s;
vector<set<int>> st;

void solve();
long long calc();
long long change(int day, int id, bool ch = false);

int main() {
  cin >> d;
  c.resize(t);
  res.resize(d);
  for (auto &p : c) cin >> p;
  s.resize(d, vector<long long>(t, 0));
  for (auto &v : s)
    for (auto &p : v) cin >> p;
  solve();
  calc();
  for (auto p : res) cout << p + 1 << endl;
  return 0;
}

void solve() {
  auto start = chrono::system_clock::now();
  auto nowt = chrono::system_clock::now();
  auto dur = nowt - start;
  auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  long long lim = 15000;
  vector<long long> memo(t, 0);
  for (int i = 0; i < d; ++i) {
    int id = 0;
    for (int j = 0; j < t; ++j)
      if (s[i][id] < s[i][j]) id = j;
    if (s[i][id] >= lim || i < t)
      res[i] = id;
    else {
      int cid = 0;
      for (int j = 0; j < t; ++j)
        if (memo[j] + c[j] > memo[cid] + c[cid]) cid = j;
      res[i] = cid;
    }
    for (int j = 0; j < t; ++j)
      if (j != res[i])
        memo[j] += c[j];
      else
        memo[j] = 0;
  }
  change(0, res[0], 1);
  while (msec < LIMTIME) {
    long long now = score, nowd = xorshift() % d, nowid = xorshift() % t,
              bf = 0;
    bf = res[nowd];
    if (now > change(nowd, nowid)) change(nowd, bf);
    nowt = chrono::system_clock::now();
    dur = nowt - start;
    msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  }
  cerr << calc() + (1000000) << endl;
}

long long calc() {
  long long sum = 0;
  vector<long long> memo(t, 0);
  for (int i = 0; i < d; ++i) {
    int num = res[i];
    sum += s[i][num];
    for (int j = 0; j < t; ++j)
      if (j != num)
        sum -= (memo[j] += c[j]);
      else
        memo[j] = 0;
  }
  return sum;
}

long long change(int day, int id, bool ch) {
  if (ch) {
    res[day] = id;
    score = calc();
    st.resize(t);
    for (int i = 0; i < t; ++i) st[i].insert(0), st[i].insert(d + 1);
    for (int i = 0; i < d; ++i) st[res[i]].insert(i + 1);
    return score;
  }
  int bf = res[day];
  score -= s[day][bf];
  score += s[day][id];
  st[bf].erase(day + 1);
  auto it = st[bf].upper_bound(day + 1);
  int righ = *it, lef;
  --it;
  lef = *it;
  score += ((righ - day - 1) * (righ - day - 2) +
            (day + 1 - lef) * (day - lef) - (righ - lef) * (righ - lef - 1)) *
           c[bf] / 2;
  it = st[id].upper_bound(day + 1);
  righ = *it;
  --it;
  lef = *it;
  score -= ((righ - day - 1) * (righ - day - 2) +
            (day + 1 - lef) * (day - lef) - (righ - lef) * (righ - lef - 1)) *
           c[id] / 2;
  res[day] = id;
  st[id].insert(day + 1);
  return score;
}


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

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

	if(a*b%2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
}

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

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	int ans = 0;

	cin >> n;

	vector<int>p(n);

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

	for (int i = 1; i < n - 1; i++) {
		if (((p[i - 1] > p[i]) && (p[i] > p[i + 1])) ||
			((p[i - 1] < p[i]) && (p[i] < p[i + 1]))) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

int main() {
    // 前処理
    COMinit();

    int n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n)cin >> a[i];

    ll ans = 0;

    sort(a, a+n, greater<ll>());

    rep(i,n){
        // i番目がmaxになる組み合わせ
        ll tmp = COM(n-i-1, k-1) * a[i] % MOD;
        ans += tmp;
        ans %= MOD;
    }

    sort(a,a+n);
    rep(i,n){
        // i番目がminになる組み合わせ
        ll tmp = COM(n-i-1, k-1) * a[i] % MOD;
        ans += MOD - tmp;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define N 55
using namespace std;
const int INF = 1e9;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef priority_queue<PP,vector<PP>,greater<PP> > PQ;
int n, fee[N], height[N],G[2][N][N];
int D[N][N][1<<10];

int Push(PQ &Q,int cost,int p1,int p2,int bit){
  if(D[p1][p2][bit] <= cost) return 0 ;
  D[p1][p2][bit] = cost;
  Q.push(PP(P(cost,p1),P(p2,bit)));
  return 1;
}

int dijkstra(){

  int idx[N];
  map<int,int> cnt;
  for(int i=0;i<n;i++) idx[i] = cnt[height[i]]++;

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<(1<<10);k++) D[i][j][k] = INF;
  PQ Q;
  Push(Q,0,0,0,1<<idx[0]);
  
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first.first;
    int p1 = t.first.second;
    int p2 = t.second.first;
    int bit = t.second.second;
    if(D[p1][p2][bit] < cost) continue;
    if(p1 == n-1 && p2 == n-1) return cost;
    
    for(int to=0;to<n;to++){
      int ncost = cost + G[0][p1][to] + fee[to];
      int nbit = bit;
      if(height[p1] == height[to] && bit>>idx[to]&1) ncost -= fee[to] ;
      if(height[p1] == height[to]) nbit |= 1<<idx[to];
      else nbit = 1<<idx[to];
      Push(Q,ncost,to,p2,nbit);
    }
    
    for(int to=0;to<n;to++){
      if(height[p1] < height[to]) continue;
      int ncost = cost + G[1][p2][to] + fee[to];
      if(height[p1] == height[to] && bit>>idx[to]&1) ncost -= fee[to];
      Push(Q,ncost,p1,to,bit);
    }
  }
  return -1;
}

signed main(){
  while(1){
  int m;
  cin>>n>>m;
  if(n == 0 && m == 0) return 0;
  memset(fee,0,sizeof(fee));
  memset(height,0,sizeof(height));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) G[0][i][j] = G[1][i][j] = INF;
  
  height[0] = 0;
  height[n-1] = 1000;
  for(int i=1;i<n-1;i++) cin>>fee[i]>>height[i];
  
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c; a--, b--;
    if(height[a] <= height[b]) Min(G[0][a][b],c);
    if(height[a] >= height[b]) Min(G[1][b][a],c);
  }
  cout<<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 31460
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#include <unordered_map>
 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 200005
#define inf 2000000000
#define MOD 1000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<pair<int, int>, int> tup;
 
ll gcd(ll a, ll b)
 {
     return b ? gcd(b, a % b) : a;
 }
 
inline void solve()
{
    ll a,b;
    cin >> a >> b;
    cout << a * b / gcd(a, b);
}
 
int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=200000;
const int MAXZ=200000;
const int MAXS=(MAXLEN+1)*4;
struct Z { int l,r,val; };

int len,nz;
Z z[MAXZ];

ll dp[MAXLEN];

ll sval[MAXS],slazy[MAXS];
void sapply(int x,ll BY) { sval[x]+=BY; slazy[x]+=BY; }
void spull(int x) { sval[x]=slazy[x]+max(sval[2*x+1],sval[2*x+2]); }
void spush(int x) { if(slazy[x]!=0) sapply(2*x+1,slazy[x]),sapply(2*x+2,slazy[x]),slazy[x]=0; }
void sinit(int x,int l,int r) {
	slazy[x]=0;
	if(l==r) {
		sval[x]=0;
	} else {
		int m=l+(r-l)/2;
		sinit(2*x+1,l,m); sinit(2*x+2,m+1,r);
		spull(x);
	}
}
void smod(int x,int l,int r,int L,int R,ll BY) {
	//if(x==0) printf("smod(%d,%d..%d,%d..%d,%lld)\n",x,l,r,L,R,BY);
	if(L<=l&&r<=R) {
		sapply(x,BY);
	} else {
		int m=l+(r-l)/2; spush(x);
		if(L<=m) smod(2*x+1,l,m,L,R,BY);
		if(m+1<=R) smod(2*x+2,m+1,r,L,R,BY);
		spull(x);
	}
}
ll sget(int x,int l,int r,int L,int R) {
	if(L<=l&&r<=R) {
		return sval[x];
	} else {
		int m=l+(r-l)/2; spush(x);
		ll ret=LLONG_MIN;
		if(L<=m) ret=max(ret,sget(2*x+1,l,m,L,R));
		if(m+1<=R) ret=max(ret,sget(2*x+2,m+1,r,L,R));
		spull(x);
		return ret;
	}
}

vector<int> startat[MAXLEN];
vector<int> endat[MAXLEN];

ll solve() {
	REP(i,len) startat[i].clear(),endat[i].clear();
	REP(i,nz) startat[z[i].l].PB(i),endat[z[i].r].PB(i);
	sinit(0,0,len);
	REP(i,len) {
		REPSZ(j,startat[i]) { int zi=startat[i][j]; smod(0,0,len,0,z[zi].l,+z[zi].val); }
		dp[i]=sget(0,0,len,0,i);
		//printf("dp[%d]=%lld\n",i,dp[i]);
		smod(0,0,len,i+1,i+1,dp[i]);
		REPSZ(j,endat[i]) { int zi=endat[i][j]; smod(0,0,len,0,z[zi].l,-z[zi].val); }
	}
	ll ret=0; REP(i,len) ret=max(ret,dp[i]); return ret;
}

void run() {
	scanf("%d%d",&len,&nz);
	REP(i,nz) scanf("%d%d%d",&z[i].l,&z[i].r,&z[i].val),--z[i].l,--z[i].r;
	printf("%lld\n",solve());

}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 38528
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if (a>b) {
        cout << "a > b" <<endl;
    }
    else if (a== b){
        cout << "a == b" << endl;
    }
    else{
        cout << "a < b" <<endl;
    }
    }
    
   


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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = n-1; i >= 0; --i){
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; ++i){
			if(i != 0) System.out.print(" ");
			System.out.print(a[i]);
		}
		System.out.println();
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	private boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24276
#include <stdio.h>

int main()
{
	int H, W;
	while(scanf("%d %d", &H, &W), (W || H))
	{
		for(int y = 0; y < H; ++y)
		{
			for(int x = 0; x < W; ++x)
			{
				putchar((x + y) % 2 ? '.' : '#');
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 4;


int main() {
	char s[20];
	
	scanf("%s", s);
	s[4] = 0;

	string ss(s);
	puts(ss == "YAKI" ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
import itertools
n,k=map(int,input().split())
D=list(map(int,input().split()))
N=set(i for i in range(10))
C=list(N-set(D))
ans=float("inf")
for a in list(itertools.product(C,repeat=len(str(n)))):
  m=int("".join(map(str,a)))
  if m>=n:
    ans=min(ans,m)
if ans==float("inf"):
  for a in list(itertools.product(C,repeat=len(str(n))+1)):
    m=int("".join(map(str,a)))
    if m>=n:
      ans=min(ans,m)
print(ans)

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

#define endl '\n'

using namespace std;

const int maxn = 2e3 + 3;

int n, x, y;
void read()
{
    cin >> n >> x >> y;
}

vector <int> adj[maxn];
int dist[maxn];
int cnt_dist[maxn];

void bfs(int start)
{
    memset(dist, -1, sizeof(dist));
    queue <int> q;
    dist[start] = 0;
    q.push(start);

    while (!q.empty())
    {
        int curr = q.front();
        q.pop();

        for (auto i: adj[curr])
            if (dist[i] == -1)
        {
            dist[i] = dist[curr] + 1;
            q.push(i);
        }
    }

    for (int i = 1; i <= n; i++)
        if (i != start)
        cnt_dist[dist[i]]++;
}

void solve()
{
    for (int i = 1; i <= n-1; i++)
    {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }

    adj[x].push_back(y);
    adj[y].push_back(x);

    for (int i = 1; i <= n; i++)
        bfs(i);

    for (int i = 1; i <= n-1; i++)
        cout << cnt_dist[i] / 2 << endl;
}

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

    read();
    solve();
}


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

using namespace std;

using ll = long long;

int main()
{
	char c;
	cin >> c;
	if (c == 'A')
	{
		cout << 'T' << endl;
	}
	else if (c == 'T')
	{
		cout << 'A' << endl;
	}
	else if (c == 'G')
	{
		cout << 'C' << endl;
	}
	else if (c == 'C')
	{
		cout << 'G' << endl;
	}
}

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

int main(){
  int N, K;
  cin >> N >> K;
  for(int i = 0;;i++){
    int64_t a = pow(K, i);
    if(N / a == 0){
      cout << i<<endl;
      break;
    }
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>
#include <numeric>

typedef long long Int; 
#pragma warning(disable : 4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

map<char, int> tile;

int main(){
	tile['I'] = 1;
	tile['V'] = 5;
	tile['X'] = 10;
	tile['L'] = 50;
	tile['C'] = 100;
	tile['D'] = 500;
	tile['M'] = 1000;

	string a;
	while (cin >> a){
		Int ans(0);

		char before = 'I';
		for (auto i = a.rbegin(); i != a.rend();++i){
			if (tile[before] > tile[*i]){
				ans -= tile[*i];
			}
			else{
				ans += tile[*i];
			}
			before = *i;
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val i = inputs.head.toInt
  println(solve(i))

  private def solve(i: Int): Long = {
    ((1 to i).foldLeft(1L){ (acc, v) => 
        acc * v % 1000000007
    }).toLong
  }
}

Measured memory_bytes: 56152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int bingo[3][3];
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 3; ++j){
      cin >> bingo[i][j];
    }
  }
  int n;
  cin >> n;
  for(int i = 0, temp; i < n; ++i){
    cin >> temp;
    for(int i = 0; i < 3; ++i){
      for(int j = 0; j < 3; ++j){
        if(bingo[i][j] == temp) bingo[i][j] = -1;
      }
    }
  }
  bool flag = false;
  for(int i = 0; i < 3; ++i){
    flag = false;
    for(int j = 0; j < 3; ++j){
      if(bingo[i][j] == -1) flag = true;
      else {
        flag = false;
        break;
      }
    }
    if(flag){
      cout << "Yes" << endl;
      return 0;
    }
  }
  for(int j = 0; j < 3; ++j){
    flag = false;
    for(int i = 0; i < 3; ++i){
      if(bingo[i][j] == -1) flag = true; 
      else {
        flag = false;
        break;
      }
    }
    if(flag){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(bingo[0][0] == - 1 && bingo[1][1] == -1 && bingo[2][2] == -1){
    cout << "Yes" << endl;
    return 0;
  }
  if(bingo[0][2] == - 1 && bingo[1][1] == -1 && bingo[2][0] == -1){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int judge(int,int,int,int X[][10]);
int main(void)
{
    int n,d;
    int X[10][10];

    int ans=0;
    int i,j;

    scanf("%d %d", &n,&d);
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            scanf("%d", &X[i][j]);
        }
    }

    for(i=0;i<(n-1);i++){
        for(j=i+1;j<n;j++){
            ans += judge(d,i,j,X);
        }
    }
    printf("%d\n",ans);
 
    return 0;
}
int judge(int d,int i,int j,int X[][10])
{
    int memo = 0;
    float me=0;

    int m;

    for(m=0;m<d;m++){
            memo += (X[i][m] - X[j][m]) * (X[i][m] - X[j][m]);
    }
    
    me = sqrt(memo);
        
    if(ceil(me) == floor(me)){
        return 1;
    }
    else{
        return 0;
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr int INF = 1 << 30;


char c;
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> c;
  cout << (char)(c + 1);
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int s = 0;
  for (int i = 1; i <= N; i++) {
    
    if (i < 10) {
      s++;
    }
    else if (99 < i && i < 1000) {
      s++;
    }
    else if (9999 < i && i < 100000) {
      s++;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long int gcd(long long int a,long long int b){
    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(){
    long long int kd;
    cin >> kd;
    long long int ans = 0;

    for(long long int i=1;i<=kd;i++){
        for(long long int j=1;j<=kd;j++){
            long long int gcda = gcd(i,j);
            for(long long int k=1;k<=kd;k++){
                ans += gcd(gcda,k);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int	main(int	argc,
		 char*	argv[])
{
  int	a	= 0;
  int	b	= 0;
  int	c	= 0;

  std::cin >> a >> b >> c;

  if((a < b) && (b < c)){
	  std::cout << "Yes\n";
  }
  else{
	  std::cout << "No\n";
  }
}



Measured memory_bytes: 3044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, ans=0;

  cin >> N;

  for(int i = N; i < 1000; i++){
    string str = to_string(i);
    if(str[0] == str[1] && str[1] == str[2]){
      ans = i;
      break;
    }
  }
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll a,b;
    cin>>a>>b;
    if(a==b)cout<<"a"<<" == "<<"b"<<endl;
    if(a<b)cout<<"a"<<" < "<<"b"<<endl;
    if(a>b)cout<<"a"<<" > "<<"b"<<endl;
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
using namespace	std;
int main(){

  long long k,a[50],sho,ama,ka;
  cin>>k;
  if(k==1){
    cout<<"3"<<endl<<"1 0 3"<<endl;
    return 0;
  }
  sho=k/50+50;
  ka=k%50;
  ama=sho-(ka+1);
  cout<<"50"<<endl;
  for(int i=0;i<ka;i++){
    cout<<sho;
    if(i||i!=49) cout<<" ";
}
  for(int i=0;i<50-ka;i++){
    if(i) cout<<" ";
    cout<<ama;
  }
  cout<<endl;
  return 0;

}



Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define pb push_back
#define F first
#define S second
#define lll long long
#define lld long double

#define data etokek

//#define int lll

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 2.5e5 + 32;
//const int M = 1e9 + 7;
const int mod = 998244353;
const int rx[4] = {-1, -1, 1, 1};
const int ry[4] = {-1, 1, -1, 1};
const lld eps = 1e-11;
const double pi = acos(-1.0);
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("mushrooms.in", "r", stdin);
//    freopen("mushrooms.out", "w", stdout);
#endif
    lld r;
    cin >> r;
    cout << fixed << setprecision(2) << 2.0 * pi * r;
    return 0;
}


Measured memory_bytes: 3796
n, m = map(int, input().split())
L = []
for i in range(n):
  L.append(list(map(int, input().split())))
L.sort(key=lambda x: x[0])
counter = 0
for pair in L:
  if m <= pair[1]:
    counter += pair[0] * m
    print(counter)
    break
  else:
    m -= pair[1]
    counter += pair[0] * pair[1]

Measured memory_bytes: 64472
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<int> depend[1'000 * 1'000];
bool isVisited[1'000 * 1'000];
bool isLocked[1'000 * 1'000];
int day[1'000 * 1'000];

void dfs(int node)
{
    day[node] = 0;
    isVisited[node] = true;

    isLocked[node] = true;
    for (const int d : depend[node]) {
        if (!isVisited[d]) {
            dfs(d);
        }
        if (isLocked[d]) {
            day[node] = -1;
            return;
        }

        day[node] = max(day[node], day[d] + 1);
    }
    isLocked[node] = false;
}

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

    rep(i, n)
    {
        int a;
        cin >> a;
        a--;
        rep(j, n - 2)
        {
            int b;
            cin >> b;
            b--;

            depend[min(i, (int64_t)b) * n + max(i, (int64_t)b)].push_back(min(i, (int64_t)a) * n + max(i, (int64_t)a));
            a = b;
        }
    }

    fill(isVisited, isVisited + (1'000 * 1'000), false);
    fill(isLocked, isLocked + (1'000 * 1'000), false);

    int result = 0;
    rep(i, n) rep(j, n)
    {
        if (i != j) {
            int game = min(i, j) * n + max(i, j);
            if (!isVisited[game]) {
                dfs(game);
            }

            if (day[game] == -1) {
                cout << -1 << endl;
                return 0;
            }
            result = max(result, day[game]);
        }
    }

    cout << result + 1 << endl;
    return 0;
}

Measured memory_bytes: 45184
program ABC087B;
var
    a,b,c,x,i,j,k,r: integer;
begin
    read(a);
    read(b);
    read(c);
    read(x);
    r:=0;
    for i:=0 to x div 500 do begin
        for j:=0 to (x-500*i) div 100 do begin              k:=x-500*i-100*j;
            if (k mod 50=0) and (c>=k div 50) and (a>=i) and (b>=j) then begin
                r:=r+1;
            end;
        end;
    end;
    writeln(r);
end.

Measured memory_bytes: 128
import re
def main():
  S = input()
  if 'keyence' in S:
    print('YES')
    return
  
  if re.match(r'^k[a-z]*eyence$', S) or re.match(r'^ke[a-z]*yence$', S) or re.match(r'^key[a-z]*ence$', S) or re.match(r'^keye[a-z]*nce$', S) or re.match(r'^keyen[a-z]*ce$', S) or re.match(r'^keyenc[a-z]*e$', S):
    print('YES')
  else:
    print('NO')
  return

if __name__ == '__main__':
  main()
  

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	double ans=0.0;
	rep(i,n){
		double work;
		cin>>work;
		ans+=1/work;
	}

	cout<<1/ans<<endl;
	return 0;
}


Measured memory_bytes: 256