akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  string T;
  cin>>T;
  int len=T.length();
  for( int i=0;i<len;i++){
    if(T[i]=='?'){T[i]='D';}

  }
  cout<<T<<endl;
}

Measured memory_bytes: 3724
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll D,T,S;
	scan(D>>T>>S);
	if(S*T>=D) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int ans,n,a,b,sum,tmp;
string s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	ans=n;
	tmp=n;
	while(n!=0)
    {
        tmp=n%10;
        sum+=tmp;
        n/=10;
    }
    if(ans%sum==0) cout<<"Yes"<<endl; else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int r, c, i, j;
	int array[101][101]={0};
	
	scanf("%d %d", &r, &c);
	
	for(i=0; i < r; i++){
		for(j=0; j < c; j++){
			scanf("%d", &array[i][j]);
		}
	}
	
	for(j=0; j < c; j++){
		for(i=0; i < r; i++){
			array[r][j] += array[i][j];
		}
	}
	
	for(i=0; i <= r; i++){
		for(j=0; j < c; j++){
			array[i][c] += array[i][j];
		}
	}
	
	for(i=0; i <= r; i++){
		for(j=0; j <= c; j++){
			printf("%d", array[i][j]);
			if(j != c) printf(" ");  
		}
		printf("\n");
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int n, sum = 0, idx;
  cin >> n;
  FOR(i, 1, n+1) {
    sum += i;
    if(sum >= n) {
      idx = i;
      break;
    }
  }
  VI ans;
  while(n) {
    if(n >= idx) {
      n -= idx;
      ans.push_back(idx);
    }
    idx--;
  }
  for(int i: ans) cout << i << endl;
  return 0;
}


Measured memory_bytes: 384
n = int(input())
t,a = map(int,input().split(' '))
H = list(map(int, input().split(' ')))
d_min = abs(a - (t - H[0]*0.006))
ans = 0
i = 1
while i < n:
    if abs(a - (t-H[i]*0.006)) < d_min:
        d_min = abs(a - (t-H[i]*0.006))
        ans = i
    i += 1
print(ans+1)

Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
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;
}
 
//-----------------------ここから-----------

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

    if(n % 2 == 0){
        cout << n / 2 - 1 << endl;
    } else {
        cout << n / 2 << endl;
    }

}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val h = sc.nextInt()
    val w = sc.nextInt()
    val map = Array(h) { Array(w) { '.' } }
    for (i in 0 until h) {
        val s = sc.nextLine()
        for (j in 0 until w) {
            map[i][j] = s[j]
        }
    }
    val dp = Array(h) { Array(w) { 0 } }
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (i == 0 && j == 0) continue
            val x = if (i == 0) Int.MAX_VALUE else (dp[i - 1][j] + if (map[i][j] != map[i - 1][j]) 1 else 0)
            val y = if (j == 0) Int.MAX_VALUE else (dp[i][j - 1] + if (map[i][j] != map[i][j - 1]) 1 else 0)
            dp[i][j] = Math.min(x, y)
        }
    }
    val start = map[0][0]
    val goal = map[h - 1][w - 1]
    val n = dp[h - 1][w - 1]
    if (start == '.' && goal == '.') {
        println(n / 2)
    } else if (start == '#' && goal == '#') {
        println(n / 2 + 1)
    } else {
        println((n + 1) / 2)
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31384
#include<stdio.h>
int N,M;
int a[50];
int l[50];
int r[50];
int ans=0;

void init();
int root(int x);
void unite(int x,int y);
int query(int x,int y);
int judge();

int main(){
	scanf("%d%d",&N,&M);
	
	int i;
	for(i=0;i<M;i++){
		scanf("%d%d",&l[i],&r[i]);
		l[i]--;
		r[i]--;
	}
	
	for(i=0;i<M;i++){
		init();
		
		int j;
		for(j=0;j<M;j++){
			if(j==i)continue;
			unite(l[j],r[j]);
		}
		
		if(judge()==0)ans++;
	}
	
	printf("%d\n",ans);
	return 0;
}

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

int root(int x){
	if(a[x]==x)return x;
	else return a[x]=root(a[x]);
}

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

int query(int x,int y){
	if(root(x)==root(y))return 1;
	return 0;
}

int judge(){
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(query(i,j)==0)return 0;
		}
	}
	return 1;
}

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

using namespace std;

#define ll long long

const ll mod  = 1e9 + 7;
const ll INF = 1e14;


void solve(){

    int n, a, b; cin >> n >> a >> b;
    if(((a+n-1) / n) * n <= b) cout << "OK";
    else cout << "NG";
}

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

    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();
    //}

	return 0;
}


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

int main()
{
  int i;
  char j;
  string s, ans;
  ans = "None";
  cin >> s;
  sort(s.begin(),s.end());
  for(j='a'; j <= 'z'; j++)
  {
    for(i=0; i<s.size(); i++)
    {
      if(j == s[i]) break ;
    }
    if(i == s.size() )
    {
      ans = j;
      break;
    }
  }
  cout << ans <<endl;
  return 0;
}


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

int main() {
	int x,n,ans,i,j;
	cin >> x >> n;
	if(n==0){
		cout << x << endl;
		return 0;
	}
	
	vector<int> p(n);
	for(i=0; i<n; i++){
		cin >> p[i];
	}
	
	for(j=0; j<=52; j++){
		ans=x-j;
		for(i=0; i<n && p[i]!=ans; i++){
		}
		if(i==n){
			cout << ans << endl;
			return 0;
		}
		ans=x+j;
		for(i=0; i<n && p[i]!=ans; i++){
		}
		if(i==n){
			cout << ans << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
while true
  n, k, m, r = gets.split.map(&:to_i)
  break if n == 0
  x, y = 1, n
  if m == 1
    mx, my = (1...n).reduce([1, 1]){ |b, i| [b[0] * i + b[1], b[1] * i] }
    x *= mx; y *= my
  end 
  g = x.gcd y
  x / g; y / g
  x, mod = x.divmod y
  print x.to_s + "."
  x = mod * 10
  r.times.reduce(x){ |t, _| t, mod = t.divmod y; print t; mod * 10 }
  puts
end

Measured memory_bytes: 90908
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m;
ll k;
string s;

int main() {
	cin >> n>>m;
	//	REP(i, n){
	//	}
	//	REP(i, n){
	//	}
	cin >> s;

	int ans = 0;

	cout << n+(m-n)*2;
	cout << endl;
}


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

int main() {
  int n, i, check = 1;
  cin >> n;
  
  vector<vector<long long>> a(n, vector<long long>(2));
  for(i = 0; i < n; i++){
    cin >> a.at(i).at(1) >> a.at(i).at(0);
  }
  
  sort(a.begin(), a.end());
  
  long long now = 0;
  
  for(i = 0; i < n; i++){
    now += a.at(i).at(1);
    if(now > a.at(i).at(0)){
      check = 0;
      break;
    }
  }
  
  if(check) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 13184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if ((i + j) % 2 == 0)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	}

}

Measured memory_bytes: 33048
#abc135d
s=raw_input()
mod=10**9+7
res=[0]*13
res[0]=1
for i in s:
 dp=[0]*13
 for j in range(13):
  dp[(j*10)%13]=res[j]%mod
 dp+=dp
 if i=='?':
  for k in range(13):
   res[k]=sum(dp[k+4:k+14])
 else:
  for k in range(13):
   res[k]=dp[k+13-int(i)]
print res[5]%mod


Measured memory_bytes: 2696
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let input: Vec<i32> = s.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();

    let A = input[0];let B = input[1];
    let mut ans=std::cmp::max(A+B,A-B);
    ans =std::cmp::max(ans, A*B);
    println!("{}",ans);
}


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

using namespace std;

class Vector{
	public:
	double x;
	double y;
	Vector():x(0),y(0){}
	Vector(double a,double b){
			x = a;
			y = b;
	}
	Vector(const Vector& other){
			x = other.x;
			y = other.y;
	}

	Vector& operator+=(Vector &other){
			x += other.x;
			y += other.y;
			return *this;
	}
	Vector& operator-=(Vector &other){
			x -= other.x;
			y -= other.y;
			return *this;
	}
	Vector& operator*=(double k){
			x *= k;
			y *= k;
			return *this;
	}
	Vector& operator/=(double k){
			return (*this) *= (1/k);
	}

	Vector operator+(Vector other){return Vector(*this)+=other;}
	Vector operator-(Vector other){return Vector(*this)-=other;}
	Vector operator*(double k){return Vector(*this)*=k;}
	Vector operator/(double k){return Vector(*this)/=k;}
};

double dot(Vector a,Vector b){
		return a.x * b.x + a.y * b.y;
}

double magnitude(Vector x){
		return dot(x,x);
}

double abs(Vector x){
		return sqrt(magnitude(x));
}

Vector normal(Vector x){
		return x / abs(x);
}

Vector invector(){
		double x;
		double y;
		cin >> x >> y;
		return Vector(x,y);
}

const double EPS = 1e-6;

long long bit(int x){
	return 1LL << x;
}

int func(){
	int n;
	cin >> n;
	vector<double> radius(n);
	vector<Vector> from(n);
	vector<Vector> to(n);
	for(int i=0;i<n;++i){
		cin >> radius[i];
		from[i] = invector();
		to[i] = invector();
	}

	auto is_cross = [&](int move,Vector target,int tp){
		Vector mv = to[move] - from[move];
		Vector mn = normal(mv);
		double mk = abs(mv);
		double dis = dot(mn,target-from[move]);
		if(dis<0){
				dis = 0;
		}else if(dis>mk){
				dis = mk;
		}
		Vector pos = target - mn * dis;
		return abs(pos-from[move]) <= radius[move] + radius[tp] + EPS;
	};

	function<int(int)> func =
	[&](int used){
		static vector<int> dp(bit(n),-1);
		int &it = dp[used];
		if(it>=0)return it;
		it = 0;
		for(int i=0;i<n;++i){
				if(bit(i)&used)continue;
				bool cross = false;
				for(int j=0;j<n;++j){
						if(i==j)continue;
						Vector pos = from[j];
						if(bit(j)&used)pos=to[j];
						if(is_cross(i,pos,j)){
								cross = true;
								break;
						}
				}
				if(cross)continue;
				it = max(it,1+func(used|bit(i)));
		}
		return it;
	};
	return func(0);
}

int main(){ 
		cout << func() << endl;
		return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int N, Z, W;
	cin >> N >> Z >> W;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	if(N>=2) cout << max(abs(A[N-1]-W), abs(A[N-1]-A[N-2])) << endl;
	else cout << abs(A[N-1]-W) << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n, x, y = map(int, sys.stdin.readline().split())
	x -= 1
	y -= 1
	ans = [0]*(n-1)
	for i in range(n):
		for j in range(i+1, n):
			log.print(i, j, ans)
			if i == j:
				continue
			if (i <= x and j <= x) or (y <= i and y <= j):
				ans[abs(i-j)-1] += 1
			elif (i <= x and y <= j):
				ans[x-i + j-y + 1 - 1] += 1
			elif (x < i < y and x < j < y):
				ans[min(abs(i-j), i-x + 1 + y-j)-1] += 1
			elif (i <= x and x < j < y):
				ans[min(abs(i-j), x-i + 1 + y-j)-1] += 1
			elif (x < i < y and y <= j):
				ans[min(abs(i-j), j-y + 1 + i-x)-1] += 1
	for i in range(len(ans)):
		print(ans[i])







main()

Measured memory_bytes: 44912
def main():
	ad = input()
	now = int(ad[0])
	q = []
	n = len(ad)
	q.append([0 , now , ad[0]])
	while len(q)!=0:
		#print(23)
		cur = q.pop(0)
		#print(cur[0] , cur[1] , cur[2])
		if cur[0] ==n-1:
			if cur[1]==7:
				print(cur[2]+'='+'7')
				break
				exit(0)
			continue
		#print(cur[1]+((int)(ad[cur[0]+1])) , cur[0])
		if cur[0]+1<n:
			q.append([cur[0]+1, cur[1]+((int)(ad[cur[0]+1])) , cur[2]+'+'+ad[cur[0]+1]])
			q.append([cur[0]+1, cur[1]-((int)(ad[cur[0]+1])) , cur[2]+'-'+ad[cur[0]+1]])
if __name__=="__main__":
	main()

Measured memory_bytes: 61996
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,m := input.Next2Ints()
  es := NewEdges(m)
  for i:=0;i<m;i++ {
    a,b,c := input.Next3Ints()
    es[i] = Edge{a-1,b-1,c}
  }
  q := input.NextInt()
  qs := NewQueries(q)
  for i:=0;i<q;i++ {
    s,t := input.Next2Ints()
    qs[i] = Query{s-1,t-1}
  }
  sort.Sort(es)
  uf := NewUnionFind(n)
  tr := NewGraph(n)
  tot := int64(0)
  for i:=0;i<m;i++ {
    if uf.Same(es[i].fm,es[i].to) { continue }
    uf.Unite(es[i].fm,es[i].to)
    tr.Add(es[i].fm,es[i].to,es[i].cost)
    tr.Add(es[i].to,es[i].fm,es[i].cost)
    tot += es[i].cost
  }
  maxcost := make([][]int64,n)
  for i:=0;i<n;i++ {
    tmp := make([]int64,n)
    var dfs func(int,int)
    dfs = func(v,p int) {
      for _,e := range tr[v] {
        if e.to == p { continue }
        tmp[e.to] = max(tmp[v],e.cost)
        dfs(e.to,v)
      }
    }
    dfs(i,-1)
    maxcost[i] = tmp
  }
  for i:=0;i<q;i++ { fmt.Println(tot-maxcost[qs[i].s][qs[i].t]) }
}

func max(n,m int64) int64 {
  if n > m { return n }
  return m
}

type UnionFind struct { par,rank []int }
func NewUnionFind(n int) UnionFind {
  par := make([]int,n)
  rank := make([]int,n)
  for i:=0;i<n;i++ { par[i] = i }
  return UnionFind{par,rank}
}
func(u UnionFind) Find(i int) int {
  if u.par[i] == i { return i }
  u.par[i] = u.Find(u.par[i])
  return u.par[i]
}
func(u UnionFind) Same(i,j int) bool { return u.Find(i) == u.Find(j) }
func(u UnionFind) Unite(i,j int) {
  i,j = u.Find(i),u.Find(j)
  if i == j { return }
  if u.rank[i] < u.rank[j] { u.par[i] = j;return }
  u.par[j] = i
  if u.rank[i] == u.rank[j] { u.rank[i]++ }
}

type Edge struct { fm,to int;cost int64 }
type Edges []Edge
func NewEdges(n int) Edges { return make([]Edge,n) }
func(e Edges) Len() int { return len(e) }
func(e Edges) Swap(i,j int) { e[i],e[j] = e[j],e[i] }
func(e Edges) Less(i,j int) bool { return e[i].cost < e[j].cost }
type Graph [][]Edge
func NewGraph(n int) Graph { return make([][]Edge,n) }
func(g Graph) AddEdge(fm int,e Edge) { g[fm] = append(g[fm],e) }
func(g Graph) Add(fm,to int,cost int64) { g.AddEdge(fm,Edge{fm,to,cost}) }

type Query struct { s,t int }
type Queries []Query
func NewQueries(q int) Queries { return make([]Query,q) }

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) Next2Ints() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(i *Input) Next3Ints() (int,int,int64) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.ParseInt(s[2],10,64)
  return x,y,z
}

Measured memory_bytes: 137752
n = int(input())
s = input()
MOD = 10**9+7

from collections import defaultdict
import string
d = defaultdict(int)
let = string.ascii_lowercase

for ele in s:
  d[ele] += 1

ans = 1
for i in range(26):
  if d[let[i]]>0:
    ans = (ans * (d[let[i]]+1))%MOD
print(ans-1)

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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[303][303];
    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){
        cin >> a[i][j];
        a[i][j]--;
    }
    int nth[303] {0};
    int deleted[303] {0};
    int ans = 1000;
    for(int count = 0; count < m; count++){
        int pop[303] {0};
        for(int i = 0; i < n; i++){
            while(deleted[a[i][nth[i]]]) nth[i]++;
            pop[a[i][nth[i]]]++;
        }
        int lar = 0;
        int larnum = -1;
        for(int i = 0; i < m; i++){
            if(pop[i] > lar){
                lar = pop[i];
                larnum = i;
            }
        }
        ans = min(ans, lar);
        deleted[larnum] = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
template<class T>
void printv(vector<T> vec) { for (T e : vec) cout << e << ' '; cout << endl; }




int main() {		
	int h, w, m, a, b;
	cin >> h >> w >> m;
	vector<int> row(h, 0), col(w, 0);
	//vector<vector<int> > target(h, vector<int>(w, 0));
#define pii pair<int, int>
	set<pii> target;
	rep(i, m) {
		cin >> a >> b;
		//target[--a][--b] = 1;
		target.insert(pii(--a, --b));
		row[a]++;
		col[b]++;
	}
	
	a = *max_element(row.begin(), row.end());
	b = *max_element(col.begin(), col.end());
	vector<int> r, c;
	rep(i, h) if (row[i] == a) r.push_back(i);
	rep(i, w) if (col[i] == b) c.push_back(i);
	for(int i : r) for(int j : c) {
		if (target.find(pii(i, j)) == target.end()) {
			cout << a + b << endl;
			return 0;
		}
	}

	cout << a + b - 1 << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 23796
from operator import mul
from functools import reduce
def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
def combinations_with_replacement_count(n, r):
    return combinations_count(n + r - 1, r)

s=int(input())
ans=0
for i in range(s//3):
  seqlen=s//3-i
  mv=s%3+3*i
  ans+=combinations_with_replacement_count(seqlen, mv)
ans%=(10**9+7)
print(ans)


Measured memory_bytes: 68132
import sys
si = sys.stdin.readline


def main():
    n = int(si())
    l = [int(e) for e in si().split()]
    tot = sum(l)
    mod, ans = 10**9+7, 0
    for i in range(n-1):
        h = l[i]
        tot -= h
        ans = (ans+(tot*h) % mod) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31408
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    double target = 1.0 * sum / N;

    int ret = 0;
    double diff = abs(a[0] - target);

    for (int i = 1; i < N; i++) {
        if (abs(a[i] - target) < diff) {
            diff = abs(a[i] - target);
            ret = i;
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
int gcd(int a, int b) { while (a) { b %= a; swap(a, b); } return b; }
bool solve(int n, vector<int> & a) {
    ll sum = whole(accumulate, a, 0ll);
    bool is_first = (sum - n) % 2;
    int even = whole(count_if, a, [&](int ai) { return ai % 2 == 0; });
    auto odd = whole(find_if,  a, [&](int ai) { return ai % 2 == 1; });
    if (not is_first and even == n-1 and *odd != 1) {
        -- (*odd);
        int d = a[0]; repeat (i,n) d = gcd(d, a[i]);
        repeat (i,n) a[i] /= d;
        return not solve(n, a);
    } else {
        return is_first;
    }
}
int main() {
    int n; cin >> n;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    cout << (solve(n, a) ? "First" : "Second") << endl;
    return 0;
}

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

namespace test
{

    class Program
    {
        static void Main(string[] args)
        {
            List<int> resultList = new List<int>();

            Dictionary<char, int> dict = new Dictionary<char, int>();
            dict.Add('I', 1);
            dict.Add('V', 5);
            dict.Add('X', 10);
            dict.Add('L', 50);
            dict.Add('C', 100);
            dict.Add('D', 500);
            dict.Add('M', 1000);

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                char[] cArray = input.ToCharArray();

                int sum = dict[cArray[cArray.Length-1]];
                for (int i = cArray.Length - 1; i > 0; i--)
                {
                    if (dict[cArray[i - 1]] >= dict[cArray[i]])
                    {
                        sum += dict[cArray[i - 1]];
                    }
                    else
                    {
                        sum -= dict[cArray[i - 1]];
                    }
                    
                }

                resultList.Add(sum);
            }

            foreach (int a in resultList)
            {
                Console.WriteLine(a);
            }


        }

        
    }
}

Measured memory_bytes: 6116
import numpy as np

n, m = map(int, input().split())
vote_lists = list(map(int, input().split()))

vote_arr = np.array(vote_lists)
total_vote = vote_arr.sum()
is_popular = total_vote / (4 * m)

answer_lists = []

for i in vote_lists:
  if i >= is_popular:
    answer_lists.append(i)

if len(answer_lists) >= m:
  print('Yes')
else:
  print('No')

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

int main() {
  string o, e, ans;
  int io, ie, oc = 0, ec = 0, i = 0, flag = 1;
  cin >> o >> e;

  io = o.size();
  ie = e.size();

  while(1) {
    if(io > oc && i % 2 == 0) {
      ans += o[oc];
      oc++;
    } else if(ie > ec) {
      ans += e[ec];
      ec++;
    }
    i++;
    if(i == (io + ie)) {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) {
    cin >> a[i];
    n -= a[i];
  }
  if (n < 0) n = -1;
  cout << n << '\n';
  return 0;
}

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

int main(){
    int k;cin>>k;
    int a,b;cin>>a>>b;
    if (a % k == 0 || b % k == 0){
        cout << "OK" << endl;
    } else {
        if (a / k - b / k == 0){
            cout << "NG" << endl;
        } else {
            cout << "OK" << endl;
        }
    }
}

Measured memory_bytes: 3624
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

one2n = sum([i for i in range(1, n+1)])

ok = True

if sum(a) % one2n > 0:
    ok = False
    
if ok:
    b = a + [a[0]]
    end = 0
    kire = sum(a) // one2n
    for idx in range(n):
        dif = b[idx+1] - b[idx]
        if (kire-dif) % n > 0:
            ok = False
            break
        
        elif (kire-dif)//n < 0:
            ok = False
            break
        
        end += (kire-dif) // n
        
    if end != kire:
        ok = False
        
print("YES") if ok else print("NO")

Measured memory_bytes: 15044
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}


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

	if(n%2)
		cout<<n*2;
	else
		cout<<n;
	

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,s;
  int maxm,mini,sum;
  
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    sum=0;
    maxm=0;
    mini=1000;
    for(int i=0;i < n;i++){
      scanf("%d",&s);
      sum=sum+s;
      if(maxm < s){
        maxm=s;
      }
      if(mini > s){
        mini=s;
      }
    }

    printf("%d\n", (sum-maxm-mini)/(n-2) );
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0,  1, 0, -1};

bool fie[401][401];

int main() {
    int N, n, d;
    while (cin >> N, N) {
        memset(fie, false, sizeof fie);
        vector<pair<int,int>> pos(201);
        fie[200][200] = true;
        pos[0] = make_pair(200, 200);
        int x, y, mx_x = 200, mx_y = 200, mn_x = 200, mn_y = 200;
        for (int i=1; i<N; ++i) {
            cin >> n >> d;
            x = pos[n].first + dx[d];
            y = pos[n].second + dy[d];
            fie[x][y] = true;
            pos[i] = make_pair(x, y);
            mx_x = max(mx_x, x);
            mx_y = max(mx_y, y);
            mn_x = min(mn_x, x);
            mn_y = min(mn_y, y);
        }
        cout << mx_x - mn_x + 1 << " " << mx_y - mn_y + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1360
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

    if(n == 3){
        cout << "2 5 63" << endl;
    }else{
        vector<ll> ans = {2,3,4,9};
        n -= 4;
        for(int k = 15; k <= 30000; k += 12){
            if(n > 1 && k+6 <= 30000){
                ans.push_back(k);
                ans.push_back(k+6);
                n -= 2;
            }else{
                break;
            }
        }
        for(int k = 8; k <= 30000; k += 6){
            if(n > 1 && k+2 <= 30000){
                ans.push_back(k);
                ans.push_back(k+2);
                n -= 2;
            }else{
                break;
            }
        }
        for(int k = 6; k <= 30000 && n > 0; k += 6){
            ans.push_back(k);
            n--;
        }
        for(int i = 0; i < ans.size(); i++){
            if(i > 0){
                cout << " ";
            }
            cout << ans[i];
        }
        cout << endl;
    }
    
    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,A,B=MAP()

print(min(N*A, B))


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

int main(){
    int N = 0, Height = 0, Width = 0;
    cin >> N >> Height >> Width;
    
    int array[N][2];
    
    for(int i=0; i<N; i++){
        for(int j=0; j<2; j++){
            cin >> array[i][j];
        }
    }
    
     int count = 0;
    
    for(int i=0; i<N; i++){
        if(array[i][0] >= Height && array[i][1] >= Width)
        count++;
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

penal = {}
ac = 0
wa = 0
for i in range(m):
    p, s = input().split()
    
    #初めて解く問題を辞書に追加
    if p not in penal:
        if s == 'AC':
            ac += 1
            penal[p] = -1
        elif s == 'WA':
            penal[p] = 1

    #２回目以降の挑戦
    elif p in penal:
        #すでにACしている時
        if penal[p] == -1:
            continue
        #まだACしていない時
        if s == 'WA':
            penal[p] += 1
        if s == 'AC':
            wa += penal[p]
            penal[p] = -1
            ac += 1

print(ac, wa)


Measured memory_bytes: 17112
import java.util.Scanner;
public class Main{
    int max;
    int min;
    int sa;
	
    public void solve(){
		Scanner sc =new Scanner(System.in);
		for(int i=0; i<7; i++){
		max=sc.nextInt();
		min=sc.nextInt();   
		sa=max-min;
		System.out.println(sa);
			 }
    }
       public static void main(String[] args){
      Main obj = new  Main(); 
      obj.solve();      
  }
}

Measured memory_bytes: 17368
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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;

ll N, M, S;

int main()
{
  std::cin >> N >> M;
  
  rep( i, M )
  {
    ll A;   
    std::cin >> A;
    S += A;
  }

  std::cout << (N-S>=0 ? N-S : -1) << std::endl;

  return 0;
}

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

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		map = Enumerable.Range(0, h[0] - 1).Select(i => read()).GroupBy(r => r[0]).ToDictionary(g => g.Key, g => g.Select(r => r[1]).ToArray());
		ops = Enumerable.Range(0, h[1]).Select(i => read()).GroupBy(r => r[0]).ToDictionary(g => g.Key, g => g.Sum(r => r[1]));

		c = new int[h[0]];
		FindPoints(1);
		Console.WriteLine(string.Join(" ", c));
	}

	static Dictionary<int, int[]> map;
	static Dictionary<int, int> ops;
	static int[] c;
	static int sum;

	static void FindPoints(int p)
	{
		if (ops.ContainsKey(p)) sum += ops[p];
		c[p - 1] = sum;
		if (map.ContainsKey(p)) foreach (var r in map[p]) FindPoints(r);
		if (ops.ContainsKey(p)) sum -= ops[p];
	}
}


Measured memory_bytes: 94712
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int x;  cin>>x;
    if(x>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3608
import bisect
n = int(input())
l = len(str(n))
ary = []
siti = ["3","5","7"]
def dfs (s,t):
  if len(s) == t:
    if s.count("3") > 0 and s.count("5") > 0 and s.count("7") > 0:
      ary.append(int(s))
    return
  for j in siti:
    dfs(s+j,t)
for i in range(3,l+1):
  dfs("",i)
print (bisect.bisect_right(ary,n))


Measured memory_bytes: 4084
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define eps 1e-15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

ll snuke(ll n) {
    ll ret = 0;
    while (n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

ll next(ll num) {
    ll min_v = num;
    ll min_snuke = snuke(num);

    for (int i = 0; (ll) round(pow(10, i)) < num;) {
        //下i桁目を変えていく
//        if ((num % (int) round(pow(10, i)) * 10) / (int) round(pow(10, i)) == 9) {
        if ((num / (ll) round(pow(10, i))) % 10 == 9) {
            i++;
        } else {
            num += (ll) round(pow(10, i));
        }

        if (num * min_snuke < min_v * snuke(num)) {
            min_v = num;
            min_snuke = snuke(num);
        }
    }

    return min_v;
}

void solve() {
    int K;
    cin >> K;

    ll cur = 1ll;
    while (K--) {
        cout << cur << endl;
        cur = next(cur + 1);
    }

}


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

    solve();


    return 0;
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        int[][] point = new int[n][d];
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(in.readLine());
            for (int j = 0; j < d; j++) {
                point[i][j] = Integer.parseInt(st.nextToken());
            }
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                double distance = 0;
                for (int k = 0; k < d; k++) {
                    int x = point[i][k] - point[j][k];
                    distance += x*x;
                }
                if (Math.sqrt(distance) == (int)Math.sqrt(distance)) {
                    res++;
                }
            }
        }
        System.out.println(res);
    }

}
/*

 */

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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
long long dp[100100];

int main() {
    int N, M; cin >> N >> M;
    vector<pair<long long, long long>> AB(N);
    
    for(int i = 0; i < N; i++) {
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB.begin(), AB.end());

    long long ans = 0;
    int i = 0;
    while (M > 0) {
        if(M >= AB[i].second) ans += AB[i].first * AB[i].second;
        else ans += AB[i].first * M;
        M -= AB[i].second;
        i++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[allow(dead_code)]
fn ext_gcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (g, x, y) = ext_gcd(b, a % b);
        (g, y, x - (a / b) * y)
    }
}
#[allow(dead_code)]
fn mod_inverse(n: u64, modulo: u64) -> u64 {
    let (_, inv, _) = ext_gcd(n as i64, modulo as i64);
    ((inv + modulo as i64) as u64 % modulo) % modulo
}
#[allow(dead_code)]
fn mod_factor(n: u64, modulo: u64) -> u64 {
    let mut fact = 1;
    for i in 1..=n {
        fact = fact * i % modulo;
    }
    fact
}
#[allow(dead_code)]
fn mod_combination(n: u64, r: u64, modulo: u64) -> u64 {
    if n < r {
        return 0;
    }
    let a1 = mod_factor(n, modulo);
    dbg!(a1);
    let a2 = mod_factor(r, modulo);
    let a3 = mod_factor(n - r, modulo);
    a1 * mod_inverse(a2 * a3 % modulo, modulo) % modulo
}

fn main() {
    input! {
        n: usize,
        c_: [u64; n],
    }
    let mut c = c_.clone();
    c.sort();
    c.reverse();

    let modulo = 1_000_000_007;

    // let mut pow4 = vec![1u64; n];
    // for i in 1..n {
    //     pow4[i] = pow4[i - 1] * 4 % modulo;
    // }

    // let mut dp = vec![0u64; n + 1];
    // for i in 0..n {
    //    dp[i + 1] = 4 * dp[i] % modulo + ((i as u64 + 2) * pow4[i] % modulo) * c[i] % modulo;
    // }
    // println!("{}", dp[n]);

    let mut ret = 0;
    for i in 0..n {
        ret = (ret + c[i] * (i as u64 + 2) % modulo) % modulo;
    }
    for _ in 0..n-1 {
        ret = ret * 4 % modulo;
    }
    println!("{}", ret)
}


Measured memory_bytes: 5764
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class ABC10000000{
        static void Main(){
            string[] nk = Console.ReadLine().Split();
            int n = int.Parse(nk[0]);
            int k = int.Parse(nk[1]);
            string[] vs = Console.ReadLine().Split();
            int[] v = new int[n];
            for(int i=0;i<n;i++){
                v[i] = int.Parse(vs[i]);
            }
            long ans = -1;
            for(int i=0;i<k+1 & i<n+1;i++){
                for(int j=0;j<k-i+1 & j<n-i+1;j++){
                    int[] temochi = new int[i+j];
                    long tans = 0;
                    for(int ii=0;ii<i;ii++){
                        temochi[ii] = v[ii];
                        tans += v[ii];
                    }
                    for(int jj=0;jj<j;jj++){
                        temochi[i+j-jj-1] = v[n-jj-1];
                        tans += v[n-jj-1];
                    }
                    Array.Sort(temochi);
                    for(int m=0;m<k-i-j & m<i+j;m++){
                        if(temochi[m]<0){
                            tans -= temochi[m];
                        }else{
                            break;
                        }
                    }
                    if(tans>ans){
                        ans = tans;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N;
	vector<llong> A;

	cin >> N;
	A.resize(N);
	for (auto &in: A) {
		cin >> in;
		++in;
	}

	vector<llong> exist(N+1, 0);
	exist[0] = 3;
	llong ans = 1;
	for (auto &many: A) {
		ans = (ans * exist[many-1]) % mod;
		++exist[many];
		--exist[many-1];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792