akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))

//毎回変える場所
#define N_MAX 200


//問題文のとおり
long long N, A, B, C, D;

int main() {
	//入力
	cin >> N >> A >> B >> C >> D;
	N--;

	long AB = abs(B - A);
	long esp = abs(D - C);
	long  CNum = 0;
	long  DNum = 0;

	//最近点を探す
	long temp = AB;
	while (abs(temp - C*(CNum + 1))<abs(temp - C*CNum))CNum++;
	while (abs(temp - D*(DNum + 1))<abs(temp - D*DNum))DNum++;



	//Cばかりでスタートの場合
	long  near;
	long  rest;
	FOR(i, -1, 2) {
		near = abs(temp - C*(CNum + i));
		rest = N - (CNum + i);

		if (rest % 2 == 0 && near <= esp*long (rest / 2)) {
			cout << "YES" << endl;
			goto end;
		}
	}
	//Dばかりでスタートの場合
	FOR(i, -1, 2) {
		near = abs(temp - D*(DNum + i));
		rest = N - (DNum + i);

		if (rest % 2 == 0 && near <= esp*long (rest / 2)) {
			cout << "YES" << endl;
			goto end;
		}
	}
	cout << "NO" << endl;
end:;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int D[10000], C = 0;

    while (true)
    {
        cin >> D[C];

        if (D[C] == 0) { goto Exit; }

        C++;
    }

    Exit:;

    for (int i = 0; i < C; i++)
    {
        cout << "Case " << i + 1 << ": " << D[i] << endl;
    }

    return 0;
}


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

int r, k;
long long L, R;

int main () {
	scanf("%lld%lld", &L, &R);
	if (L == R) return puts("1"), 0;
	for (r = 60; ~r; --r) {
		if ((L >> r & 1) != (R >> r & 1)) break;
		if (L >> r & 1) L ^= 1ll << r, R ^= 1ll << r;
	}
	for (k = r - 1; ~k; --k) if (R >> k & 1) break;
	printf("%lld\n", (2ll << r) - L - max(0ll, L - (1ll << k + 1)));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

    ll mod0 = 0, mod1 = 0;

    for (int i = 1; i <= n; i++)
    {
        if (i % k == 0)
            mod0++;

        else if (k % 2 == 0 && i % k == k / 2)
            mod1++;
    }

    cout << mod0 * mod0 * mod0 + mod1 * mod1 * mod1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename T> T gcd(T a, T b){a = abs(a); b = abs(b); if(a<b) swap(a,b); while(b>0){a %= b; swap(a,b);} return a;}
template <typename T> T lcm(T a, T b){return (1LL * a * b) / gcd(a,b);}
template <typename T, typename U> P<T,U> operator+(const P<T,U> &a, const P<T,U> &b){return {a.first + b.first, a.second + b.second};}
template <typename T, typename U> P<T,U> operator-(const P<T,U> &a, const P<T,U> &b){return {a.first - b.first, a.second - b.second};}

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

  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));

  vector<int> k(n);
  REP(i,n) k[i] = (i%2?-1:1)*(i==0||i==n-1?1:2);
  sort(ALL(k));

  LLI sum1 = 0;
  REP(i,n) sum1 += k[i] * a[i];

  REP(i,n) k[i] = (i%2?1:-1)*(i==0||i==n-1?1:2);
  sort(ALL(k));

  LLI sum2 = 0;
  REP(i,n) sum2 += k[i] * a[i];

  cout << max(sum1,sum2) << endl;
  
  return 0;
}


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

string getResult(const int taxPrice){
  for(int i = (int) (taxPrice / 1.08); ; i++){
    int compPrice = (int) (i * 1.08);
    if(compPrice == taxPrice) return to_string(i);
    if(compPrice > taxPrice) break;
  }
  return ":(";
}

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

  string result = getResult(N);
  cout << result;
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>

using namespace std;

int main()
{
	int a,b,c;
	int i;
	int counter=0;
	cin>>a>>b>>c;
	
	for(i=a;i<=b;i++)
	{
		if(c%i==0)
			counter++;
	}
	
	cout<<counter<<endl;
}



Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();

        //変数の割り当て
        int P = int.Parse(s.Split(' ')[0]);
        int Q = int.Parse(s.Split(' ')[1]);
        int R = int.Parse(s.Split(' ')[2]);

        //それぞれの二つの輪をとり、その中の宰相を求める
        Console.WriteLine(Math.Min(P + Q, Math.Min(P + R, Q + R)));

    }
}

Measured memory_bytes: 11092
// Problem : A - Frog 1
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(long long int i=0;i<n;i++)
#define FORR(i,n) for(long long int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<long long int>
#define slli set<long long int>
#define mlli map<long long int,long long int>
#define lli long long int 
#define test lli tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define MOD 1000000007
using namespace std;
lli n,arr[1000000],dp[1000000];
void solve(){
	// lli n;
	set(dp,0);
	cin>>n;
	rep(i,1,n+1)cin>>arr[i];
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	rep(i,3,n+1){
		dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
	}
	cout<<dp[n];
		
}


int32_t main() {
    	solve();
    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

const int MAX_V = 10000;
const int MAX_E = 100000;
vector<deque<int> > G(MAX_E);
vector<int> L;  // トポロジカルソートした結果を蓄積する空リスト.
deque<int> S;   // 入力辺を持たないすべてのノードの集合.
map<int, int> inCount;

// 各頂点から, トポロジカルソート を行い, 頂点の並び順を保存.
void topologicalSort(){
    
    // 1. キュー S が 空になるまで, ループ.
    while(!S.empty()){

        // 2. S からノード n を削除.
        int n = S.front();
        S.pop_front();
        
        // 3. L に n を追加.
        L.push_back(n);

        while(!G[n].empty()){
            // 4. 辺 e (n -> m)をグラフから削除.
            int m = G[n].front();
            G[n].pop_front();
            inCount[m]--;
            // printf("n=%d m=%d\n", n, m);
            // 5. m がその他の入力辺を持っていなければ, m を S に追加.
            if(inCount[m] == 0) S.push_back(m);
        }
    }
    
    // 6. グラフに辺が残っている場合は, 閉路があり DAG でないので中断.
    // 本問では, 考慮しなくて良さそう.
    
    return;
}

int main(){
    
    // 1. 入力情報.
    int V, E;
    scanf("%d %d", &V, &E);
    for(int i = 0; i < E; i++){
        int s, t;
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        inCount[t]++; // 各頂点への入力辺の本数を保存.
    }
    
    // 2. 辺の数が, 0本の場合, 頂点を S に追加.
    // -> 入力情報に, 必ずしも, 頂点情報が与えらるとは, 限らないので注意.
    for(int i = 0; i < V; i++) if(inCount[i] == 0) S.push_back(i);
    
    // 3. トポロジカルソートを行う.
    topologicalSort();
    
    // 4. 出力 ～ 後処理.
    for(int i = 0; i < L.size(); i++) printf("%d\n", L[i]);
    return 0;

}



Measured memory_bytes: 70676
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <cstdlib>
#include <set>
#include <map>
using namespace std;
int main()
{
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long kk=n/(a+b);
	long long sy=n-kk*(a+b);
	kk*=a;
	if(sy>=a) sy=a;
	printf("%lld",kk+sy);
	return 0;
	
}

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

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

    map<int, int> arr;

    for (int i = 1; i <= n; i++)
    {
        arr[i] = 0;
    }

    for (int i = 1; i <= m; i++)
    {
        int a, b;
        cin >> a >> b;
        arr[a] += 1;
        arr[b] += 1;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << arr[i] << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define Pi acos(-1.0)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=3e5+5;
int n,m;
struct node
{
    int x,y;
}a[N];
int cnt,q[N],len;
double ans;
bool flag;
bool cmp(node a,node b)
{
    return a.x<b.x;
}
int main()
{
    int x1,y1,y2,x2;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    if (x2<x1)swap(x1,x2),swap(y1,y2);
    if (y1>y2)y1=-y1,y2=-y2,flag=1;
    scanf("%d",&n);
    fo(i,1,n)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if (flag)y=-y;
        if (x>=x1&&x<=x2&&y>=y1&&y<=y2)a[++cnt]=(node){x,y};
    }
    sort(a+1,a+1+cnt,cmp);
    fo(i,1,cnt)
    {
        int l=1,r=len,ans=0;
        while (l<=r)
        {
            int mid=(l+r)>>1;
            if (a[i].y>q[mid])l=mid+1,ans=mid;
            else r=mid-1;
        }
        if (ans==len)q[++len]=a[i].y;
        else q[ans+1]=min(q[ans+1],a[i].y);
    }
    ans=(x2-x1+y2-y1)*100.0;
    if (x1==x2||y1==y2)
    {
        if (cnt)ans+=10.0*Pi-20.0;
    }
    else
    {
        ans-=(20-5.0*Pi)*len;
        if (len==min(x2-x1,y2-y1)+1)ans+=5*Pi;
    }
    printf("%.13lf\n",ans);
    return 0;
 } 

Measured memory_bytes: 2560
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe
"""
import numpy as np

def temp(height, t): 
    return t - 0.006 * height
   
def temp_to_height(a, t):
    return (t - a) / 0.006

def main():
    n = int(input())
    t, a = map(int, input().split())
    goal_height = temp_to_height(a, t)

    heights = list(map(int, input().split()))
    # print('heights: ', heights)
    # print('goal height: ', goal_height)


    best_index = -1
    best_diff = np.inf

    for i, h in enumerate(heights):
        diff = abs(h - goal_height)
        if diff < best_diff:
            best_diff = diff
            best_index = i
    best_number = best_index + 1

    print(best_number)
    
    

main()


Measured memory_bytes: 12500
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n;
char wcz[nax];

void tak()
{
	printf("Yes\n");
	exit(0);
}

void nie()
{
	printf("No\n");
	exit(0);
}

int czy(int a, int b, int c, int d)
{
	if (a==c && b==d)
		return 1;
	if (a>c || b>d)
		return 0;
	int kto=0;
	if (a==c)
		kto=1;
	if (a+1==b && wcz[a+2]=='#')
		kto=1;
	if (a+2==b && wcz[a+1]=='#')
		kto=1;
	if (!kto)
	{
		if (wcz[a+1]=='.' && b!=a+1)
			return czy(a+1, b, c, d);
		if (wcz[a+2]=='.' && b!=a+2)
			return czy(a+2, b, c, d);
		return 0;
	}
	else
	{
		if (wcz[b+1]=='.' && a!=b+1)
			return czy(a, b+1, c, d);
		if (wcz[b+2]=='.' && a!=b+2)
			return czy(a, b+2, c, d);
		return 0;
	}
}

int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	scanf("%s", wcz+1);
	wcz[n+1]=wcz[n+2]='#';
	if (czy(a, b, c, d) || czy(b, a, d, c))
		tak();
	else
		nie();
	return 0;
}


Measured memory_bytes: 384
/*
god taekyu
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n,k;
int A[100005], dp[100005];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>A[i];

    for(int i=2;i<=n;i++) {
        dp[i] = 2e9;
        for(int j=i-1;j>=1 && j>=i-k;j--) {
            dp[i] = min(dp[i] , dp[j] + abs(A[i] - A[j]));
        }
    }
    cout<<dp[n];
    return 0;
}

/*
god taekyu
*/


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin>>p[i];

  int min = p[0];
  int cnt = 1;
  for(int i=1;i<n;i++){
    if(p[i] < min){
      cnt++;
      min = p[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    int p[n];
    int cnt = 0;
    for(int i=0; i<n; i++) {
        cin >> p[i];
        if(p[i] != i+1){
            cnt++;
        }
    }
    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


// 700以上
// 100p 3 c=500
// 200p 5 c=800

// 2000以上
// 100p 3 c=500
// 200p 5 c=800

// 400以上
// 100p 3 c=500
// 200p 5 c=800

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d, g;
    cin >> d >> g;
    VI p(d), c(d);
    REP(i, d) cin >> p[i] >> c[i];

    int ans = 10000;
    REP(com_bit, (int)pow(2, d)) {
        int p_cnt = 0;
        int score = 0;
        REP(i, d)if(((com_bit >> i) & 1) == 1) {
            p_cnt += p[i];
            score += p[i] * (i + 1) * 100 + c[i];
        }
        FORR(i, d - 1, 0)if(((com_bit >> i) & 1) == 0) {
            if(score >= g) break;
            int p_add = min((g - score) / ((i + 1) * 100), p[i]);
            p_cnt += p_add;
            score += p_add * (i + 1) * 100;
        }

        ans = min(ans, p_cnt);
    }

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

template<typename T>
T ceil(T a, T b){
    return (a+b-1) / b;
}

int main(){
    ll n; cin >> n;
    vector<ll> c(n-1), s(n-1), f(n-1);
    rep(i,n-1)cin >> c[i] >> s[i] >> f[i];
    rep(i,n){
        ll time = 0;
        ll pos = i;
        while(pos < n-1){
            time = max(s[pos], ceil(time,f[pos]) * f[pos]);
            time += c[pos];
            pos++;
        }
        cout << time << "\n";
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections
import itertools


def solve(N: int, S: str):
    dp = [[0 for _ in range(N)] for _ in range(N)]

    for i in range(N):
        if S[i] == S[-1]:
            dp[i][N-1] = 1

    res = 0
    for i in range(N-2,-1,-1):
        for j in range(N-2,i,-1):
            if S[i] == S[j]:
                dp[i][j] = dp[i+1][j+1] + 1
                l = dp[i][j]
                if j >= i+l:
                    res = max(res,l)

    print(res)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 246280
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P x){
  if(head == (tail)%LEN){
    printf("1\n");
    exit(1);
  }
  Q[tail]=x;
  if(tail == LEN)tail = 0; 
  else tail++;

}

P dequeue(){
  P x;
  if(head == tail){
    printf("2");
    exit(2);
  }
  x = Q[head];
  if(head == LEN)head = 0;
  else head++;
  return x;

}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail++;
  }

  c = 0;
  while(c!=tail){
    if(Q[c].t-q <= 0){
      elaps += Q[c].t;
      printf("%s %d\n",Q[c].name,elaps);
      dequeue();
    }else{
      Q[c].t = Q[c].t - q;
      enqueue(Q[c]);
      dequeue();
      elaps += q;
    }
    if(c==LEN)c=0;
    else c++;
  }

  

  

  
  return 0;
}



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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> 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";
    cout << '\n';
    return 0;
}



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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
			
			Console.WriteLine(firstLine[0] <= firstLine[1] ? "unsafe" : "safe");
		}
	}
}


Measured memory_bytes: 19052
#include <bits/stdc++.h>
 
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned int        uint;

 

int main()
{
	ull N;
	uint K, h, Coas = 0;
	cin >> N >> K;
	for(ull i = 0; i < N; i++) {
	    cin >> h;
	    if(K <= h)Coas++;
	}
	cout << Coas << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int a = 0, b = 0;
	int in;
	int ans = 1;
	for(int i=0;i<10;i++){
		cin>> in;
		if(b < in){
			b = in;
		}else if(a < in){
			a = in;
		}else{
			ans = 0;
			for(int j=i+1;j<10;j++){
				cin>> in;
			}
			break;
		}
		if(a > b) swap(a,b);
	}
	string str = ans ? "YES" : "NO";
	cout<< str << endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

 

Measured memory_bytes: 1192
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var isProduct = false

func main() {
	nextReader = newScanner()

	k, n := nextInt(), nextInt()
	a := nextInts(n)

	td := 0
	md := 0

	sort.Ints(a)

	if a[n-1] == k {
		a = append([]int{0}, a[0:n-1]...)
	}

	// fmt.Println(a)

	for i := 0; i < n; i++ {

		var s int
		if i == n-1 {
			s = k + a[0]
		} else {
			s = a[i+1]
		}

		d := s - a[i]

		if d > md {
			md = d
		}

		td += d
		// fmt.Println(i, a[i], d, td)
	}

	fmt.Println(td - md)

}

/* --------------------------------------------------------------------------
 *  std.io
 * ------------------------------------------------------------------------- */
var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 3840
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.rbegin(), A.rend());
    long long a = 0, b = 0;
    for (int i = 1; i < N; i++) {
        if (A[i-1] == A[i]) {
            if (a == 0) a = A[i];
            else if (b == 0) b = A[i];
            else break;
            i++;
        }
    }
    cout << a * b << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3900
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int Twice1 = (A+(A-1));
		int Twice2 = (B+(B-1));
		int Both = A+B;
		
		int[]Array = new int[3];
		Array[0] = Twice1;
		Array[1] = Twice2;
		Array[2] = Both;
		
		Arrays.sort(Array);
		System.out.println(Array[2]);
	}

}


Measured memory_bytes: 35776
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
 
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");
 
T lread(T = long)()
{
    return readln.chomp.to!T();
}
 
T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}
 
void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a,b,c;
    scan(a,b,c);
    if(a == b)
    {
        writeln(c);
    }
    if(b == c)
    {
        writeln(a);
    }
    if(c == a)
    {
        writeln(b);
    }
}

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

string s, w[4] = { "Sunny","Cloudy","Rainy","Sunny" };

int main()
{
	cin >> s;
	for (size_t i = 0; i < 3; i++)
	{
		if (s == w[i])
		{
			cout << w[i + 1];
			break;
		}
	}
}

Measured memory_bytes: 760
//#include <bits/stdc++.h>
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iterator>
#include <tuple>
#include <utility>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
using namespace std;

#define V             vector
#define PQ            priority_queue

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

#define mod           (1e9+7)

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) {
    while (b) b^=a^=b^=a%=b;
    return a;
}

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

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll a,b;
    cin>>a>>b; cout<<lcm(a,b)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<vector>
#include<map>
#include<iomanip>
using namespace std;
#define fr first
#define sc second
typedef pair<int,int> P;
int main(){
  int X,Y,Z,N,E,A;
  while(cin >> X >> Y >> Z , X){
    int jump[X];
    P ivent[Y+1];
    for(int i = 0 ; i <= Y ; i++ ) ivent[i] = P( 0 , 0 );
    double dp[51][5001]={{}};
    dp[0][0] = 1.0;

    for(int i = 0 ; i < X ; i++ ){
      cin >> jump[i];
    }
    for(int i = 0 ; i < Z ; i++ ){
      cin >> N >> E >> A;
      switch(E){
      case 1: ivent[N].fr = A; break;
      case 2: ivent[N].sc = A; break;
      case 3: ivent[N].sc = -A; break;
      }
    }
    for(int i = 0 , limit = 0 ; i < Y ; i++ , limit += 100 ){
      for(int j = 0 ; j <= limit ; j++ ){
        if(dp[i][j]){
          for(int k = 0 , p_mas , p_money ; k < X ; k++ ){
            p_mas = min( i + jump[k] , Y );
            p_money = max(0,ivent[p_mas].sc + j );
            p_mas = min( p_mas + ivent[p_mas].fr , Y );

            dp[p_mas][p_money] += dp[i][j] / X;
          }
        }
      }
    }
    double ans = 0.0;
    for(int i = 0 ; i < 5001 ; i++ ){
      ans += dp[Y][i] * i;
    }
    cout << (int)ans << endl;
  }
}

Measured memory_bytes: 3156
use proconio::input;
use std::cmp::Ordering;

fn main() {
    input! {
        n: usize,
        r: usize,
    }

    solve(n, r);
}

fn solve(n: usize, r: usize) {
    match n.cmp(&10) {
        Ordering::Equal => println!("{}", r),
        Ordering::Greater => println!("{}", r),
        _ => println!("{}", r + 100 * (10 - n)),
    }
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll X, Y; cin >> X >> Y;
  if (Y % 2 == 0 && Y >= X * 2 && Y <= 4 * X)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll table[30005][10];

ll r(ll n, ll k) {
  if (k == 3) {
    return 1;
  }
  ll sum = 0;

  for (ll i = 0; i < 10; i++) {
    ll next_n = table[n][i];
    if (next_n != -1) {
      sum += r(next_n, k + 1);
    }
  }

  return sum;
}

int main() {
  ll N;
  scanf("%lld", &N);
  string s;
  cin >> s;

  fill(table[0], table[30004], -1);

  for (ll i = N - 1; i >= 0; i--) {
    for (ll j = 0; j < 10; j++) {
      table[i][j] = table[i + 1][j];
    }
    ll ch = s[i] - '0';

    table[i][ch] = i + 1;
  }

  cout << r(0, 0) << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std; 
//解説AC
int main() {
  string s;
  cin >>s;
  int n=s.size();
  vector<long long>a(n);
  a[0]=1;
  if(s[0]==s[1]&&s[1]==s[2]){
    a[1]=1;
    a[2]=2;
  }else if(s[0]==s[1]&&s[1]!=s[2]){
    a[1]=1;
    a[2]=2;
  }else if(s[1]==s[2]&&s[0]!=s[1]){
    a[1]=2;
    a[2]=2;
  }else{
    a[1]=2;
    a[2]=3;
  }
  for(int i=3;i<n;i++){
    if(s[i]==s[i-1]){
      a[i]=a[i-3]+2;
    }else{
      a[i]=a[i-1]+1;
    }
  }
  /*for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }*/
  //cout<<n<<endl;
  cout<<a[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll>
#define INF 1123456789012
using namespace std;
 
 
 
int main(){
	ll n, m; cin >> n >> m;
	vl root(n);
	rep(i, m){
		ll a, b; cin >> a >> b;
		root[a - 1]++;
		root[b - 1]++;
	}rep(i, n) cout << root[i] << endl;
	return 0;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
result=[]
result_2=[]
for bit in range(1 << n):
  book_add=[0 for _ in range(m+1)]
  for i in range(n):
    if (bit >> i) & 1:
      book_add=[x+y for x,y in zip(book_add,a[i])]
  temporary_list=[]
  for j in range(1,m+1):
    if book_add[j]>=x:
      temporary_list.append(book_add[j])
  if len(temporary_list)==m:
    result.append(book_add)
if len(result)==0:
   print(-1)
else:
  for k in range(len(result)):
    result_2.append(result[k][0])
  print(min(result_2))      

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

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int const MAX_V = 100000;
void stronglyConnectedComponents(Graph const & g, int cmp[MAX_V]){
    int n = g.size();
    Graph rg(n);
    rep(i,n) for(auto & e : g[i]) rg[e.dst].eb(e.dst, e.src, e.weight);
    static int added[MAX_V], visited[MAX_V], ord[MAX_V], S[MAX_V];
    rep(i,n) added[i] = visited[i] = cmp[i] = 0;
    int sz = 0;
    rep(i,n){
        if(visited[i]) continue;
        int s = 0;
        S[s++] = i;
        while(s){
            int v = S[s-1];
            visited[v] = true;
            bool pushed = false;
            for(auto & e : g[v]){
                int dst = e.dst;
                if(!visited[dst]){
                    S[s++] = dst;
                    pushed = true;
                }
            }
            if(!pushed){
                int t = S[s-1];
                if(!added[t]){
                    added[t] = true;
                    ord[sz++] = t;
                }
                s--;
            }
        }
    }
    rep(i,n) visited[i] = 0;
    int k = 0;
    rep(i,n){
        int u = ord[n-i-1];
        if(visited[u]) continue;
        int s = 0;
        S[s++] = u;
        while(s){
            int v = S[--s];
            visited[v] = true;
            cmp[v] = k;
            for(auto & e : rg[v]){
                int d = e.dst;
                if(!visited[d]) S[s++] = d;
            }
        }
        k++;
    }
}

int main(){
    int n,m;
    scanf("%d%d", &n,&m);
    Graph g(n);
    rep(i,m){
        int a,b;
        scanf("%d%d", &a,&b);
        g[a].eb(a,b,0);
    }
    int c[MAX_V];
    stronglyConnectedComponents(g,c);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        scanf("%d%d", &a,&b);
        printf("%d\n", c[a]==c[b]);
    }
}

Measured memory_bytes: 2416
n, T = gets.chomp.split(' ').map(&:to_i)
c = []
t = []
min = nil
for i in 0...n do
  c[i], t[i] = gets.chomp.split(' ').map(&:to_i)
  min = c[i] if t[i] <= T && (min.nil? || c[i] < min)
end

puts 'TLE' if min.nil?
puts min unless min.nil?

Measured memory_bytes: 1788
from fractions import gcd
A,B,C,D,E,F = map(int,input().split())
# d = b/(a+b)を最大化したい
# 条件1: 100*b <= a*E
# 条件2: a + b <= F
# 条件3: a % (100*gcd(A,B)) == 0
# 条件4: b % gcd(C,D) == 0
# (100A)i + (100B)j = a となる非負整数i,jが存在する => 条件3
# (C)k + (D)l = b となる非負整数k,lが存在する => 条件4
# d <= d'  <=>  b/(a+b) <= b'/(a'+b')  <=>  (a'+b')b <= (a+b)b'
a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 100*A; ans_b = 0
candidate = []
# 必要条件で絞り込み
for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E):
            continue
        candidate.append([a,b])
# 十分性の確認
for a, b in candidate:
    cnt = 0
    nA = (100*A) // a_d; nB = (100*B) // a_d; na = a // a_d
    # nAi + nBj = a を満たす非負整数i,jの存在を判定
    # nAi <= na  <=>  i <= na / nA
    for i in range(-(-na // nA)+1):
        # j = (a-Ai) / B, jは整数
        if (na-nA*i) % nB == 0:
            cnt += 1
            break
    nC = C // b_d; nD = D // b_d; nb = b // b_d
    # nCk + nDl = nb を満たす非負整数k,lの存在を判定
    # nCk <= nb  <=>  k <= nb / nC
    for k in range(-(-nb//nC)+1):
        # l = (nb-nCk) / nD, lは整数
        if (nb-nC*k) % nD == 0:
            cnt += 1
            break
    if cnt == 2 and (a+b)*ans_b <= (ans_a+ans_b)*b:
        ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)

Measured memory_bytes: 6780
// AtCoder Beginners Selection
// ABC168A - Therefore

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;


int main()
{
	int N,digit1;

    cin >> N;

	// 制約確認
	if (N < 1 || 999 < N)  {
        cout << "Nは条件を満たしていません!\n";
        return 0;
    }

	digit1 = N % 10;;
	if (digit1 == 3) {
		cout << "bon" << endl;
	} else if (digit1 == 0 || digit1 == 1 || digit1 == 6 || digit1 ==8) {
		cout << "pon" << endl;
	} else { 
		cout << "hon" << endl;
	}
}



Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            boolean[] composite = new boolean[1_000_000 + 1];
            int X = in.nextInt();

            for (int p = 2; p * p < 1_000_000 + 1; p++)
            {
                if (!composite[p])
                {
                    for (int i = p * 2; i < 1_000_000 + 1; i += p)
                    {
                        composite[i] = true;
                    }
                }
            }
            for (int i = X; i <= 1_000_000; i++)
            {
                if (!composite[i])
                {
                    out.print(i);
                    return;
                }
            }
        }

    }
}



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

int main(){
    int N, M, a, b;
    cin >> N >> M;
    int i1[200001] = {}, iN[200001] = {};
    for(int i=0;i<M;i++){
        cin >> a >> b;
        if(a == 1)
            i1[b] = 1;
        if(b == N)
            iN[a] = 1;
    }
    for(int i=2;i<N;i++){
        if(i1[i] == 1 && iN[i] == 1){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a,b,c;
		Scanner sc=new Scanner(System.in);

		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();

		if(a>b && b<c && a>c) {
			System.out.println("Yes");
		}
		else if(a<b && b>c && a<c) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

		sc.close();
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a%3 == 0 || b%3 == 0) {
			System.out.println("Possible");
		}
		else if((a+b)%3 == 0) {
			System.out.println("Possible");
		}
		else {
			System.out.println("Impossible");
		}
	}
}

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

int N;

bool f(int x) {
  int keta = 0;
  while (x) {
    keta ++;
    x /= 10;
  }
  return keta % 2 == 1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  int ans = 0;

  for (int i = 1; i <= N; i++) {
    if (f(i)) {
      ans ++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________

n, m, k = map(int, input().split())
a = [0]+list(accumulate(map(int, input().split())))
b = [0]+list(accumulate(map(int, input().split())))
ans = [0]
for i in range(n+1):
    c = bisect_right(b, k-a[i])-1
    if c!=-1: ans.append(c+i)
print(max(ans))

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n,m;
    cin >> n >> m;
    string ans;
    string nm;
    if(n >= m) {
        nm = to_string(m);
        rep(i,n) {
            ans += nm;
        }
    } else {
        nm = to_string(n);
        rep(i,m) {
            ans += nm;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int A, B, M;
    scan(A, B, M);

    auto a = readln.split.to!(int[]);
    auto b = readln.split.to!(int[]);
    
    int ans = a.reduce!min + b.reduce!min;

    foreach (i ; 0 .. M) {
        int xi, yi, ci;
        scan(xi, yi, ci);
        xi--, yi--;
        chmin(ans, a[xi] + b[yi] - ci);
    }

    assert(ans >= 0);

    writeln(ans);
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}





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

int main()
{
  int n, m;
  cin >> n >> m;
  int a[n][m], b[m], out[n];

  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < m; j++)
    {
      a[i][j] = 0;
      cin >> a[i][j];
    }
  }
    
  for(int i = 0; i < n; i++)
  {
    out[i] = 0;
  }

  for(int j = 0; j < m; j++)
  {
    b[j] = 0;
    cin >> b[j];
  }
    
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < m; j++)
    {
      out[i] += a[i][j] * b[j];
    }
    cout << out[i] << endl;
  }
    
  return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
int main(void)
{
	int f,m,r;
	do{
		scanf("%d %d %d",&f,&m,&r);
		if(f!=-1||m!=-1||r!=-1)
		{
		if(f==-1||m==-1)printf("F\n");
		else if((f+m)>=80)printf("A\n");
		else if((f+m)<80&&(f+m)>=65)printf("B\n");
		else if((f+m)<65&&(f+m)>=50)printf("C\n");
		else if((f+m)<50&&(f+m)>=30&&r<50)printf("D\n");
		else if((f+m)<50&&(f+m)>=30&&r>=50)printf("C\n");
		else if((f+m)<30)printf("F\n");
		}
	}while(f!=-1||m!=-1||r!=-1);
return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int x = N;
        for (int i=0; i < N + 1; i++) {
            int count = 0;
            int t = i;
            while (t > 0) {
                count += t % 9;
                t = t / 9;
            }
            t = N - i;
            while (t > 0) {
                count += t % 6;
                t = t / 6;
            }
            if (x > count) x = count;
        }
        
        System.out.println(x);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <stack>

int main() {
    std :: ios_base :: sync_with_stdio(false);

    int64_t n;
    std :: cin >> n;
    int64_t ans = -1;
    int64_t seven = 7;

    for(int i = 1 ; i <= n ; i++) {
        if(seven % n == 0) {
            ans = i;
            break;
        }

        seven = ((seven * 10) + 7) % n;
    }

    std :: cout << ans << '\n';
}


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

using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    double ans=0;
    for(int i=0;i<n;i++){
        long long score= (long long)i+1LL;
        double tmp=1.0/n;
        while(score<k){
            tmp/=2.0;
            score*=2LL;
        }
        ans+=tmp;
    }
    cout << setprecision(16)<< ans << endl;
    return 0;
}

Measured memory_bytes: 256
h,w = [int(_) for _ in input().split()]
board = [ list(input())  for _ in range(h)]

goodx = [False] * h
goody = [False] * w

for i in range(h):
  for j in range(w):
#    print("i={}\tj={}\tboard={}".format(i,j,board[i][j]))
    if board[i][j] == '#':
      goodx[i] = True
      goody[j] = True

for i in range(h):
  if goodx[i]:
    for j in range(w):
      if goody[j]:
        print(board[i][j], end='')
    print("")

Measured memory_bytes: 4596
import java.util.*;
 
public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int[] a = new int[N+1];
        a[0] = 0;
        int price = 0;
        
        for(int i = 1; i < N+1 ; i++){
          a[i] = sc.nextInt();
          price += Math.abs(a[i]-a[i-1]);
        }
        price += Math.abs(0-a[N]);
      
        int h = price;
        for(int i = 1; i+1 < N+1; i++){
          price = h;
          int tmp1 = Math.abs(a[i]-a[i-1]);
          int tmp2 = Math.abs(a[i+1]-a[i]);
          int tmp3 = Math.abs(a[i+1]-a[i-1]);
          price = price -tmp1-tmp2+tmp3;
         
          System.out.println(price);
        }
          
        int last = 0;
        for(int i = 1; i < N; i++){
          last += Math.abs(a[i]-a[i-1]);
        }
        last += Math.abs(0-a[N-1]);
        System.out.println(last);
	}
}

Measured memory_bytes: 60136
from collections import deque
h,w=map(int,input().split())
maplis=[input() for i in range(h)]

que=deque([(0,0,1)])
used={(0,0)}
bcount =sum(s.count("#") for s in maplis)


def check(x,y,c):
    if x<0 or x>w-1 or y<0 or y>h-1:
        return
    if maplis[y][x]=="#":
        return
    if  (x,y) in used:
        return
    que.append((x,y,c+1))
    used.add((x,y))

f=-1
while que:
    x,y,c=que.popleft()
    if x==w-1 and y==h-1:
        f=c
        break
    check(x-1,y,c)
    check(x+1,y,c)
    check(x,y-1,c)
    check(x,y+1,c)
print(f if f==-1 else(h*w-f-bcount))


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX_N 101
#define INF 100000000
using namespace std;

int m[MAX_N][MAX_N];
int d[MAX_N];
int color[MAX_N];

void dijkstra(int s, int n) {
  for (int i = 0; i < n; i++) {
    d[i] = INF;
    color[i] = WHITE;
  }

  d[s] = 0;
  color[s] = GRAY;

  while (true) {
    int mincost = INF;
    int u = -1;
    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
	mincost = d[i];
	u = i;
      }
    }
    
    if (mincost == INF) break;
    
    color[u] = BLACK;
    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && m[u][v] != INF) {
	if (d[u] + m[u][v] < d[v]) {
	  d[v] = d[u] + m[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
}

void init(int n) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      m[i][j] = INF;
    }
  }
}

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

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

  dijkstra(0, n);

  for (int i = 0; i < n; i++) {
    cout << i << " " << d[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3080