akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bitdig(int x){return 32 - __builtin_clz(x);}
int bitdig(ll x){return 64 - __builtin_clzll(x);}
int bitffs(int x){return __builtin_ffs(x);}
int bitffs(ll x){return __builtin_ffsll(x);}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	vl a(m,0);
	rep(i,m){
		int t; cin>>t;
		rep(j,t){
			int p;cin>>p;
			a[i]|=1<<(p-1);
		}
	}
	vl p(m);
	cin>>p;

	rep(s,1<<n){
		int cnt=0;
		rep(i,m){
			if(popcnt(s&a[i])%2==p[i]) cnt++;
		}
		if(cnt==m)ans++;
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
# solution
import io

n, m = map(int, input().split())
array = []

for i in range(n-1, -1, -1):
    qwe = list(input())
    if qwe!=["."]*m:
        array.append(qwe)

for j in range(m-1, -1, -1):
    cnt = 0
    for k in range(len(array)):
        if array[k][j]==".":
            cnt += 1
    if cnt ==len(array):
        for k in range(len(array)):
            array[k].pop(j)

for i in range(len(array)):
    print("".join(array[i]))

Measured memory_bytes: 3188
from sys import stdin

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

def sum_num(num):
    sum = 0
    for i in range(len(num)):
        sum += int(num[i])
    return sum

N = int(stdin.readline().rstrip())

x = N

for i in range(N+1):
    cc = 0
    t = i
    while(t > 0):
        cc += t % 6
        t //= 6
    t = N - i
    while(t > 0):
        cc += t % 9
        t //= 9
    if x > cc:
        x = cc

print(x)


Measured memory_bytes: 3064
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			double weight = stdIn.nextDouble();
			if(weight <= 48.0)
			{
				System.out.println("light fly");
			}
			else if(weight <= 51.0)
			{
				System.out.println("fly");
			}
			else if(weight <= 54.0)
			{
				System.out.println("bantam");
			}
			else if(weight <= 57.0)
			{
				System.out.println("feather");
			}
			else if(weight <= 60.0)
			{
				System.out.println("light");
			}
			else if(weight <= 64.0)
			{
				System.out.println("light welter");
			}
			else if(weight <= 69.0)
			{
				System.out.println("welter");
			}
			else if(weight <= 75.0)
			{
				System.out.println("light middle");
			}
			else if(weight <= 81.0)
			{
				System.out.println("middle");
			}
			else if(weight <= 91.0)
			{
				System.out.println("light heavy");
			}
			else
			{
				System.out.println("heavy");
			}
		}
	}
}

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

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(105, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    p[a] = 1;
  }
  for (int i = 0; i <= 100; i++) {
    if (p[x - i] == 0) {
      cout << x - i << endl;
      return 0;
    }
    if (p[x + i] == 0) {
      cout << x + i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3624
/*
 #pragma GCC target ("avx2")
 #pragma GCC optimize ("Ofast")
 #pragma GCC optimize ("unroll-loops")
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#define F first
#define S second
#define pb push_back
using namespace std;
const long long N = 2e5 + 10;
char a[105][105];
int dp[105][105];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n , m;
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=103;i++){
        dp[0][i]=dp[i][0]=10000000;
    }
    dp[1][1]=(a[1][1]=='#');
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i==1&&j==1)continue;
            if(a[i][j]=='.'){
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
                continue;
            }
            
            int k1=dp[i-1][j];
            k1+=(a[i-1][j]=='.');
            
            int k2=dp[i][j-1];
            k2+=(a[i][j-1]=='.');
            
            dp[i][j]=min(k1,k2);

        }
    }
    cout<<dp[n][m];
    return 0;
}


Measured memory_bytes: 256
function StoneMonument(input) {
    input = input.split("\n");
    tmp = input[0].split(" ");
    var a = parseInt(tmp[0], 10);
    var b = parseInt(tmp[1], 10);
    console.log((b-a)*(b-a+1)/2-b);
}
StoneMonument(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define PI 3.141592653589793
int main()
{
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double t = abs((360.0L*h/12.0L + 0.50L*m) - (6.0L*m));
    long double ans = b * b + a * a - 2 * a * b * cos(t*PI/ 180.0L);
    cout << fixed << setprecision(20) << 1.0*sqrt(ans) << endl;
}

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

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
d = list(map(int,input().split()))
d.sort()
#print(d)
c = [0] * N 
i = 0
tmp = d[0]
count = 1
 
for j in range(1,N):
    if tmp == d[j]:
        #print("yes",j)
        count += 1
    else:
        #print("no",j)
        tmp = d[j]   
        c[i] = count
        count = 1
        i += 1
#print(c)
 
hantei = 0
hantei1 = 0

for j in range(N):
    hantei += c[j]
    if len(d) / 2 == hantei:
        hantei1 = 1
        break
    elif len(d) / 2 < hantei:
        #hantei1 = 0
        break
 
if hantei1 == 1:
    print(d[len(d)//2] - d[len(d)//2-1])
else:
    print(0)

Measured memory_bytes: 14396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
        Scanner sc= new Scanner(System.in);
        n=sc.nextInt();
        k=0;
      for(i=1;i<=9;i++)
      {
          if(n%i==0)
          {
              if(n/i<10)
              {
                  k=1;
                  break;
              }
          }

      }
      if(k==1)
      {
          System.out.println("Yes");
      }
      else
      {
          System.out.println("No");
      }

    }
}


Measured memory_bytes: 35836
#include <iostream>
#include <string>
#include <cstdio>
#include <unordered_map>
#include <vector>
#define task ""
using namespace std;
using ll = long long;
using ld = long double;

const int N = 5e3 + 2;
const ll mod = 1e9 + 7, base = 311;
int n;
ll has[N], Pow[N];
string s;

void Prepare(){
	Pow[0] = 1;
	for(int i = 1; i <= n; ++i){
		Pow[i] = (Pow[i - 1] * base) % mod;
		has[i] = (has[i - 1] * base + (ll)(s[i] - 'a' + 1) ) % mod;
	}
}

void Read(){
	cin >> n >> s;
	s = " " + s;
}

ll cal(int l, int r){
	return (has[r] - has[l - 1] * Pow[r - l + 1] + mod * mod) % mod;
}

bool found(int i, vector<int> &a){
	int l = 0, m, h = a.size() - 1;
	while(l <= h){
		m = (l + h) >> 1;
		if(a[m] < i) l = m + 1;
		else h = m - 1;
	}
	return (l < a.size());
}

bool check(int m){
	unordered_map<ll, vector<int> > cnt;
	for(int i = 1; i <= n - m + 1; ++i){
		cnt[cal(i, i + m - 1)].push_back(i);
	}
	for(auto a : cnt){
		auto &b = a.second;
		for(auto i : b){
			if(found(i + m, b))
				return true;
		}
	}
	return false;
}

void Solve(){
	int l = 1, m, h = n;
	while(l <= h){
		m = (l + h) >> 1;
		if(check(m)) l = m + 1;
		else h = m - 1;
	}
	cout << h;
}

main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen(task".INP", "r", stdin);
//	freopen(task".OUT", "w", stdout);
	Read();
	Prepare();
	Solve();
}


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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            bool result = a.Contains("7");
            if (result == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 25880
def main():
    s,t = input().split()
    a,b = map(int,input().split())
    U = input()
    res = {
        s:a,
        t:b
    }
    res[U] -=1
    print("{0} {1}".format(res[s], res[t]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c,ans; cin>>a>>b>>c; a-=c;
	ans=(a)/(b+c);
	cout<<ans;
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int h, w, b[605][605], c[605][605], d[605][605];
long long ans;
char s[305];
int main(){
	scanf("%d %d", &h, &w);
	rep(i,h){
		scanf("\n%s", s);
		rep(j,w) if(s[j] == '#') b[i+j][i-j+w] = 1;
	}
	rep(i,h+w) rep(j,h+w){
		c[i][j+1] = c[i][j] + b[i][j];
		d[i+1][j] = d[i][j] + b[i][j];
	}
	rep(i,h+w) rep(j,h+w) if(b[i][j]) rep(k,h+w){
		if(j+k < h+w && b[i][j+k]) ans += (i >= k ? c[i-k][j+k] - c[i-k][j] : 0) + (i+k < h+w ? c[i+k][j+k] - c[i+k][j] : 0);
		if(i+k < h+w && b[i+k][j]) ans += (j >= k ? d[i+k+1][j-k] - d[i][j-k] : 0) + (j+k < h+w ? d[i+k][j+k] - d[i+1][j+k] : 0);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	map<char,bool>t;
	t.insert(make_pair<char,bool>('A',1));
	t.insert(make_pair<char,bool>('B',0));
	t.insert(make_pair<char,bool>('C',0));
	t['A']=1;
	char a,b;
	while(scanf("%1s,%1s",&a,&b)!=EOF){
	swap(t[a],t[b]);
	}
	map<char,bool>::iterator it=t.begin();
	for(;it!=t.end();it++)if((*it).second==1)cout<<(*it).first<<endl;
	return 0;
}

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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const ll M = (ll)1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }
const ll MAX = 2000007LL;

ll fact[MAX], inv[MAX], finv[MAX];

void precal() {

	fact[0] = fact[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll i = 2; i < MAX; ++i) {
		fact[i] = fact[i - 1] * i % M;
		inv[i] = M - inv[M % i] * (M / i) % M;
		finv[i] = finv[i - 1] * inv[i] % M;
	}
}

ll comb(ll n, ll r) {

	if(n < r) return 0;
	if(n < 0 || r < 0) return 0;

	return fact[n] * ((finv[r] * finv[n - r]) % M) % M;
}

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	precal();
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = 0;
	ans += comb(r1 + c1, r1);
	for(ll i = r1 + 1; i <= r2; ++i) {
		ans += comb(i + c2, i);
		ans %= M;
	}

	for(ll i = c1 + 1; i <= c2; ++i) {
		ans += comb(r2 + i, i);
		ans %= M;
	}

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

Measured memory_bytes: 50492
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    q, mod = divmod(N, K)
    print(min(mod, abs(K-mod)))


if __name__ == '__main__':
    main()


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

char s[1005][1005];
int cnt[1005][1005];

int INF = 1001001001;

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

vector<vector<P> > X(1000000);

void umeru(int h, int w, int d){
    cnt[h][w] = d;
    X[d].push_back(make_pair(h, w));
    rep(i, 4){
        int hn = h+dy[i];
        if(hn < 0 || hn >= H)continue;
        int wn = w+dx[i];
        if(wn < 0 || wn >= W)continue;
        if(s[hn][wn] == '.' && cnt[hn][wn] == INF){
            umeru(hn, wn, d);
        }
    }
    return;
}

void warp(int d){
    int ss = X[d].size();
    rep(k, ss){
        int h = X[d][k].first;
        int w = X[d][k].second;
        for (int i = -2; i <= 2; i++){
            int hn = h + i;
            if(hn < 0 || hn >= H)continue;
            for (int j = -2; j <= 2; j++){
                int wn = w + j;
                if(wn < 0 || wn >= W)continue;
                if(s[hn][wn] == '.' && cnt[hn][wn] == INF){
                    umeru(hn, wn, d+1);
                }
            }
        }
    }
    return;
}

int main() {
    cin >> H >> W;
    int ch, cw; cin >> ch >> cw;
    ch--; cw--;
    int dh, dw; cin >> dh >> dw;
    dh--; dw--;
    rep(i, H){
        rep(j, W){
            cin >> s[i][j];
        }
    }

    rep(i, H){
        rep(j, W){
            if(s[i][j] == '#'){
                cnt[i][j] = -1;
            } else {
                cnt[i][j] = INF;
            }
        }
    }

    umeru(ch, cw, 0);

    /*rep(i, H){
        rep(j, W){
            cout << i << " " << j << " " << cnt[i][j] << endl;
        }
    }*/

    int cnt2 = 0;
    while(1){
        warp(cnt2);
        if(cnt[dh][dw] != INF){
            break;
        }
        if(X[cnt2+1].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        cnt2++;
    }

    /*rep(i, H){
        rep(j, W){
            cout << i << " " << j << " " << cnt[i][j] << endl;
        }
    }*/

    cout << cnt[dh][dw] << endl;


    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    rep(i,a+1)rep(j,b+1)rep(k,c+1){
        if(500*i+100*j+50*k==x)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int n;
	cin >> n;

	int a[n], b[n];
	FOR(i, n){
		cin >> a[i];
		b[i] = a[i];
	}

	sort(a, a+n);

	int count = 0;
	FOR(i, n){
		if(a[i] != b[i]){
			count++;
		}
	}

	if(count <= 2){
		cout << "YES";
	} else {
		cout << "NO";
	}

    return 0;
}


Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template <typename T>
    debugger &operator,(const T &v)
    {
        cerr << v << " ";
        return *this;
    }
} dbg;
double calc(LL i)
{
    LL t = i, s = 0;
    while (t > 0) {
        s += t % 10;
        t /= 10;
    }
    return double(i) / s;
}
void solve2(long long K)
{
    stack<LL> x;
    double mn = 1 / double(0);
    for (int i = K + 100000; i >= 1; --i) {
        if (i <= K && calc(i) <= mn) {
            x.push(i);
        }
        mn = min(mn, calc(i));
    }
    while (!x.empty()) {
        cout << x.top() << endl;
        x.pop();
    }
}
LL mi[20];
void solve(long long K)
{
    int cnt = 0;
    mi[0] = 1;
    for (int i = 1; i <= 15; ++i) {
        mi[i] = mi[i - 1] * 10;
    }
    for (int i = 1; i <= 9; ++i) {
        if (calc(i) <= calc(i + 1)) {
            cout << i << endl;
            ++cnt;
            if (cnt >= K) {
                return;
            }
        }
    }
    for (int i = 1; i <= 9; ++i) {
        cout << i << 9 << endl;
        ++cnt;
        if (cnt >= K) {
            return;
        }
    }
    for (int i = 1; i <= 9; ++i) {
        cout << i << 99 << endl;
        ++cnt;
        if (cnt >= K) {
            return;
        }
    }
    vector<LL> x;
	for(int j=1000; j<1000000; ++j) {
		x.push_back(j);
	}
    for (int i = 7; i <= 17; ++i) {
        for (int j = 100001; j <= 1000000; ++j) {
            LL now = j * mi[i-6] - 1;
            x.push_back(now);
			//debug(now);
        }
    }
    double mn = 1/double(0);
	stack<LL> s;
    for (int i = x.size() - 1; i >= 0; --i) {
        LL now = x[i];
        if (calc(now) <= mn) {
			s.push(now);
			//debug(now,calc(now));
			mn=calc(now);
        }
    }
	while(!s.empty() && cnt<K) {
		if (s.top()>1000000000000000LL) return;
		cout<<s.top()<<endl;
		s.pop();
		++cnt;
	}
}

int main()
{
#ifdef WAAUTOMATON
    // freopen("in.txt","r",stdin);
#endif
    long long K;
    scanf("%lld", &K);
    solve(K);
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define INF 1000000000000
typedef long long ll;

int main() {
	int n;
	ll sum = 0;
	cin >> n;
	REP(i, n) {
		if ((i+1) % 3 != 0 && (i+1) % 5 != 0) {
			sum += i + 1;
		}
	}
	cout << sum;
}

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

int pow(int x, int y) {
    if (y == 0) return 0;
    int X = 1;
    for (int i = 0; i < y; i++) {
        X *= x;
    }
    return X;
}

int main() {
  int A, B;
  cin >> A >> B;
  int C = B;
  int cnt = 0;
  while (C >= 1) {
    C /= 10;
    cnt++;
  }
  int z = A * pow(10, cnt) + B;
  for (int i = 0; i <= 400; i++) {
    if (i * i == z) {
      cout << "Yes" << endl;
      break;
    }
    if (i == 400) {
      cout << "No" << endl;
    }
  }
}
  

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

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

    int* a = new int[n];

    for (int i = 0; i < n; ++i) {
        int t, c=0;
        cin >> t;
        while (t % 2 == 0) {
            t /= 2;
            c++;
        }
        a[i] = c;
    }
    cout << *min_element(a, a + n);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,q,p;
    scanf("%d",&n);
    int a[n],b[n];
    p=0,q=n-1;
    for(i=0;i<n;i++)
    {
        scanf(" %d",&a[i]);
    }
    for(i=q;i>=0;i--)
    {
        if(n%2)
        {
            if(i%2==0)
                b[p++]=a[i];
            else b[q--]=a[i];}
        else { if(i%2)
            b[p++]=a[i];
            else b[q--]=a[i];
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%d ",b[i]);
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  ll h, w;
  cin >> h >> w;
  ll s = h * w;
  if (h % 3 == 0 || w % 3 == 0) cout << 0 <<endl;
  else {
    ll h1 = h / 3;
    ll h2 = h / 3 + 1;
    ll w1 = w / 3;
    ll w2 = w / 3 + 1;
    
    ll h1sa = 0;
    ll h1s1 = h1 * w;
    ll h1s2, h1s3;
    ll H1 = h-h1;
    if (H1%2==0 || w%2==0) {
      h1s2 = H1*w/2;
      h1s3 = h1s2;
    }
    else {
      ll m = min(H1, w);
      ll M = max(H1, w);
      h1s2 = (M/2)*m;
      h1s3 = (M/2+1)*m;
    }
    ll MMh1 = max(h1s1, max(h1s2, h1s3));
    ll mmh1 = min(h1s1, min(h1s2, h1s3));
    h1sa = MMh1 - mmh1;
    if (mmh1 == 0) h1sa = s;
    
    ll h2sa = 0;
    ll h2s1 = h2 * w;
    ll h2s2, h2s3;
    ll H2 = h-h2;
    if (H2%2==0 || w%2==0) {
      h2s2 = H2*w/2;
      h2s3 = h2s2;
    }
    else {
      ll m = min(H2, w);
      ll M = max(H2, w);
      h2s2 = (M/2)*m;
      h2s3 = (M/2+1)*m;
    }
    ll MMh2 = max(h2s1, max(h2s2, h2s3));
    ll mmh2 = min(h2s1, min(h2s2, h2s3));
    h2sa = MMh2 - mmh2;
    if (mmh2 == 0) h2sa = s;
    
    ll w1sa = 0;
    ll w1s1 = h * w1;
    ll w1s2, w1s3;
    ll W1 = w-w1;
    if (W1%2==0 || h%2==0) {
      w1s2 = W1*h/2;
      w1s3 = w1s2;
    }
    else {
      ll m = min(W1, h);
      ll M = max(W1, h);
      w1s2 = (M/2)*m;
      w1s3 = (M/2+1)*m;
    }
    ll MMw1 = max(w1s1, max(w1s2, w1s3));
    ll mmw1 = min(w1s1, min(w1s2, w1s3));
    w1sa = MMw1 - mmw1;
    if (mmw1 == 0) w1sa = s;
    
    ll w2sa = 0;
    ll w2s1 = h * w2;
    ll w2s2, w2s3;
    ll W2 = w-w2;
    if (W2%2==0 || h%2==0) {
      w2s2 = W2*h/2;
      w2s3 = w2s2;
    }
    else {
      ll m = min(W2, h);
      ll M = max(W2, h);
      w2s2 = (M/2)*m;
      w2s3 = (M/2+1)*m;
    }
    ll MMw2 = max(w2s1, max(w2s2, w2s3));
    ll mmw2 = min(w2s1, min(w2s2, w2s3));
    w2sa = MMw2 - mmw2;
    if (mmw2 == 0) w2sa = s;
    
    cout << min(h1sa, min(h2sa, min(w1sa, w2sa))) <<endl;
  }
}

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

int main() {
  ll N;
  cin >> N;
  ll q = N;
  map<ll,ll> mp;
  while (1) {
    ll R = sqrt(q);
    bool b = false;
    for (ll i = 2; i <= R; i++) {
      if (q % i == 0) {
        b = true;
        q /= i;
        mp[i] += 1;
        break;
      }
    }
    if (!b) {
      if (q > 1) mp[q] += 1;
      break;
    }
  }
  vector<ll> v(41);
  for (int i = 0; i < 41; i++) {
    v[i] = i*(i+1)/2;
  }
  
  int count = 0;
  for (auto m : mp) {
    for (int i = 1; i < 41; i++) {
      if (v[i] > m.second) {
        count += i-1;
        break;
      }
    }
  }
    cout << count << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='1'){
                ans++;
            }
        }else{
            if(s[i]=='0'){
                ans++;
            }
        }
    }
    int ans2 = 0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='0'){
                ans2++;
            }
        }else{
            if(s[i]=='1'){
                ans2++;
            }
        }
    }
    cout << min(ans,ans2) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cctype>
#include<cmath>
using namespace std;
class stack{
public:
	stack();
	stack(int s);
	stack(const stack& r);
	int get(int index){return a[index];}
	void push(int n);
	int isEmpty();
	int isFull();
	int pop();
	~stack(){delete []a;}
protected:
	int *a;
	int size;
	int top;
};
int getnum(const string& str)
{
    int s=0,len=str.length();
    for(int i=0;i<len;i++)
        s+=((str[i]-'0')*pow(10,len-1-i));
    return s;
}
int main()
{
	stack v;
	string ch;
	while(cin>>ch)
	{
		if(isdigit(ch[0]))
		{
			int temp=getnum(ch);
			v.push(temp);
		}
		else
		{
			int t1=v.pop();
			int t2=v.pop();
			switch(ch[0])
			{
				case '+':
					v.push(t2+t1);
					break;
				case '-':
					v.push(t2-t1);
					break;
				case '*':
					v.push(t2*t1);
					break;
			}
		}
	}
	cout<<v.pop()<<endl;
	return 0;
}

stack::stack()
{
	top=0;
	size=250;
	a=new int[size];
}

stack::stack(int s)
{
	top=0;
	size=s;
	a=new int[s];
}

stack::stack(const stack& r)
{
	size=r.size;
	a=new int[size];
	top=r.top;
}

void stack::push(int n)
{
	a[top]=n;
	top++;
}

int stack::isEmpty()
{
	if(top==0)
		return 1;
	return 0;
}

int stack::isFull()
{
	if(top==size)
		return 1;
	return 0;
}

int stack::pop()
{
	top--;
	return a[top];
}




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

int main(){
    int n;
    cin >> n;
    int x[n];
    int y[n];
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int j = 0; j < n; j++) cin >> y[j];
    double p1 = 1;
    double p2 = 2;
    double p3 = 3;
    double d1, d2, d3, d4;
    double e1 = 0.0;
    double e2 = 0.0;
    double e3 = 0.0;
    double a = 0.0;
    for(int l = 0; l < n; l++){
        e1 += pow(fabs(1.0*(x[l] - y[l])), p1);
        e2 += pow(fabs(1.0*(x[l] - y[l])), p2);
        e3 += pow(fabs(1.0*(x[l] - y[l])), p3);
        if(a < fabs(1.0*(x[l] - y[l]))) a = fabs(1.0*(x[l] - y[l]));
    }
    d1 = pow(e1, 1/p1);
    d2 = pow(e2, 1/p2);
    d3 = pow(e3, 1/p3);
    d4 = a;
    printf("%lf\n", d1);
    printf("%lf\n", d2);
    printf("%lf\n", d3);
    printf("%lf\n", d4);
}


Measured memory_bytes: 3312
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
K = int(input())
ans = ""


def dist_to_a(c):
    return 26-(26+ord(c)-ord('a')) % 26


for s in S[:-1]:
    to_a = dist_to_a(s)
    if s != "a" and to_a <= K:
        K -= to_a
        ans += "a"
    else:
        ans += s

ans += chr(ord('a')+(ord(S[-1])-ord('a')+(K % 26)) % 26)
print(ans)


Measured memory_bytes: 3444
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

a,b = map(int,input().split())
print(a*b)

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

using namespace std;
typedef long long ll;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    ll ans = 0;

    unordered_map<string, ll> counter;
    for (int i = 0; i < N; i++) {
        string buf; cin >> buf;
        sort(buf.begin(), buf.end());
        if (counter.find(buf) == counter.end())
            counter[buf] = 1;
        else
            counter[buf]++;
    }

    for (auto kv : counter) {
        if (kv.second > 1) {
            ll v = kv.second * (kv.second - 1) / 2;
            ans += v;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 10660
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int b[] = new int[n-1];
    int ans = 0;
    
    for (int i=0; i<n-1; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    
    ans += b[0] + b[n-2];
    
    for (int i=1; i<n-1; i++) {
      ans += Math.min(b[i], b[i-1]);
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[200000], dp[3005][3101], b[200000];
string s, s1;
ll f(ll n, ll m)
{
    if(n==0||m==0)
        return 0;
    if(s[n-1]==s1[m-1]) f(n-1,m-1);
    else if(dp[n-1][m]>dp[n][m-1]) f(n-1,m);
    else f(n,m-1);
    if(s[n-1]==s1[m-1]) cout<<s[n-1];
    return 0;
}
int main()
{
    IO;

    ll j, n, m, k, m1, m2, a1, a2, l, t, cnt=0, mn, h=0, mod=1e7+7, ans=0; int tc=0; ll i;
    //cin>>t;
   // while(t--){
        tc++;
        cin>>s>>s1; n = s.size(); m = s1.size();
        for(i = 1; i<=n; i++)
            for(j=1; j<=m; j++) {
                if(s[i-1]==s1[j-1]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        //cout<<"Case "<<tc<<": "<<dp[n]<<endl;
        j =  f(n,m); cout<<endl;
   // }
    return 0;
}


Measured memory_bytes: 74880
#include <vector>
#include <cstring>
#include <iostream>
using namespace std;
int n, a[10000]; bool p[10000], prime[10000];
int main() {
	for(int i = 2; i < 10000; i++) prime[i] = true;
	for(int i = 2; i * i < 10000; i++) {
		if(!prime[i]) continue;
		for(int j = i * i; j < 10000; j += i) prime[j] = false;
	}
	while(scanf("%d", &n), n) {
		if(p[n] && n % 4 == 3) {
			for(int i = 0; i < n / 2; i++) printf("%d\n", (n - 3) / 2);
			continue;
		}
		vector<int> v;
		for(int i = 0; i < n; i++) a[i] = 0, p[i] = 0;
		for(int i = 1; i < n; i++) p[i * i % n] = true;
		for(int i = 0; i < n; i++) {
			if(p[i]) v.push_back(i);
		}
		for(int i = 0; i < v.size(); i++) {
			for(int j = i + 1; j < v.size(); j++) {
				int r = v[j] - v[i];
				if(r < 0) r += n;
				if(r > n / 2) r = n - r;
				a[r - 1]++;
			}
		}
		for(int i = 0; i < n / 2; i++) printf("%d\n", a[i] * 2);
	}
}

Measured memory_bytes: 3340
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n,t;
    cin>>n>>t;
    vector<int> imos(t+1,0);
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        imos[l]++;
        imos[r]--;
    }
    for(int i=1;i<=t;i++) imos[i]+=imos[i-1];
    int ans=0;
    for(int i=0;i<=t;i++){
        if(imos[i]>ans) ans=imos[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3112
N = int(input())

ts = [0]*N
ms = [0]*N
for i in range(N):
  t_i, m_i = input().split()
  m_i = int(m_i)
    
  ts[i] = t_i
  ms[i] = m_i
    
X = input()

ind = ts.index(X)
ind_m = ms[ind]
ans = sum(ms[ind:]) - ind_m

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<list>
#include<cstdio>

using namespace std;

int main()
{
	list<int> L;
	int n, k;
	cin >> n;
	char com[20];
	for (int i = 0; i < n; i++)
	{
		scanf("%s", com);
		if (com[0] == 'i') 
		{
			scanf("%d", &k);	
			L.push_front(k);
		}
		else if (com[6] == 'F')
				L.pop_front();
		else if (com[6] == 'L')
				L.pop_back();
		else
		{
			scanf("%d", &k);
			for (list<int>::iterator it = L.begin(); it != L.end(); it++)
			{
				if (*it == k)
				{
					L.erase(it);
					break;
				}
			}
		}
	}
	int i = 0;
	for (list<int>::iterator it = L.begin(); it != L.end(); it++)
	{
		if (i++)         
			printf(" ");
		printf("%d", *it);
	}
	cout << endl;
}



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

using namespace std;

#define N 100
#define MAX 10000

int c[256];
int occ[MAX + 1];
char mat[N + 1][N + 1];

int main(){
	int one, two, four, n, m, i, j;
	char k;

	scanf("%d%d%*[\r\n]", &n, &m);

	for (i = 1; i <= n; i++){
		for (j = 1; j <= m; j++){
			scanf("%c", mat[i] + j);
			c[(int)mat[i][j]]++;
		}

		scanf("%*[\r\n]");
	}

	if (n % 2 and m % 2){
		one = 1;
		two = n + m - 2;
	}
	else if (n % 2){
		one = 0;
		two = m;
	}
	else if (m % 2){
		one = 0;
		two = n;
	}
	else{
		one = 0;
		two = 0;
	}

	four = n * m - two - one;

	one /= 1;
	two /= 2;
	four /= 4;

	for (k = 'a'; k <= 'z'; k++){
		while (four and c[(int)k] / 4){
			four--;
			c[(int)k] -= 4;
		}

		while (two and c[(int)k] / 2){
			two--;
			c[(int)k] -= 2;
		}

		if (c[(int)k]){
			one--;
			c[(int)k]--;
		}
	}

	if (!one and !two and !four){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

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


int main()
{
  vector<int> v(3,0);
  cin >> v[0] >> v[1] >> v[2];
  set<int> s(all(v));
  cout << s.size() << endl;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int H, N, A;
    cin >> H >> N;
    rep(i, N) {
        cin >> A;
        H -= A;
    }
    if (H > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<queue>
#include<functional>
#define loop(n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define REP(i,n) FOR(i,0,n)
#define INF 9999999999999
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
typedef long long ll;
using namespace std;
priority_queue<int, vector<int>, greater<int>> small;//chiisai
priority_queue<ll>large;//ookii

ll pointleft[100000] = { 0 }, pointright[100000] = { 0 }, n;
vector < vector<ll>> route(100000);
ll megurasuright(ll num, ll chiten) {
	if (pointright[chiten]<num) {
		return 0;
	}
	else { pointright[chiten] = num; }
	REP(i, route[chiten].size()) {
		megurasuright(num + 1, route[chiten][i]);
	}
	return 0;
}

ll megurasu(ll num, ll chiten) {
	if (pointleft[chiten]<num) {
		return 0;
	}
	else { pointleft[chiten] = num; }

	REP(i, route[chiten].size()) {
		megurasu(num + 1, route[chiten][i]);
	}
	return 0;
}

int main()
{

	cin >> n;	fill(pointleft, pointleft + n, 114514);
	fill(pointright, pointright + n, 114514);
	REP(i, n - 1) {
		ll a, b; cin >> a >> b; a--; b--;
		route[a].push_back(b);
		route[b].push_back(a);
	}
	megurasu(1, 0);
	megurasuright(1, n - 1);
	ll fenec = 0, snuke = 0, middle = 0;
	REP(i, n) {
		if (pointleft[i] > pointright[i]) {
			snuke++;
		}
		else if (pointleft[i] <= pointright[i]) {
			fenec++;
		}
		
	}
	if (fenec > (snuke)) {
		cout << "Fennec" << endl;
	}
	if (fenec <= (snuke)) {
		cout << "Snuke" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 11904
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int, input().split())
unionfind = UnionFind(N + 1)
for _ in range(M):
    x, y, z = map(int, input().split())
    unionfind.union(x, y)
print(len([p for p in unionfind.parents if p < 0]) - 1)

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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  bool s=false;
  for(int i=a;i<=b;i++) {
    if(i%k==0) {
      cout << "OK" << endl;
      s=true;
      break;
    }
    else {
    }
  }
  if(s==false) cout << "NG" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int R;
  cin >> R;
  if(R<1200) cout << "ABC" << endl;
  else if(1200 <= R && R < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        final int MOD = 1000000007;
        long power = 1;
        for (int i = 1; i <= n; i++) {
            power *= i;
            power %= MOD;
        }
        long result = power;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 20692
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define dd double
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // {
       double D,T,S,a;
       cin>>D>>T>>S;
       a=D/S;
       if(a<=T)
      cout<<"Yes";
      else
      cout<<"No";
    return 0;
  }

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

int A, B, C;
int K;
int sum;

int main() 
{
	ios::sync_with_stdio(false);
	cin >> A >> B >> C >> K;
	while(A--) 
	{
		K--;
		sum += 1;
		if(!K) 
		{
			cout << sum;
			return 0;
		}
	}
	while(B--) 
	{
		K--;
		if(!K) 
		{
			cout << sum;
			return 0;
		}
	}
	while(C--) 
	{
		K--;
		sum -= 1;
		if(!K) 
		{
			cout << sum;
			return 0;
		}
	}
	return 0;
}

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

const ll INF = 1LL << 60;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N + 2);
    rep(i, N) cin >> A[i + 1];

    ll total = 0;
    for (int i = 1; i < N + 2; i++) {
        total += abs(A[i] - A[i - 1]);
    }

    for (int i = 1; i <= N; i++) {
        ll connect = abs(A[i - 1] - A[i + 1]);
        ll minus = abs(A[i] - A[i - 1]) + abs(A[i] - A[i + 1]);

        cout << total + connect - minus << endl;
    }
    // cout << total << endl;
}

Measured memory_bytes: 2048
#include<map>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	string a[110];
	string b[110];
	int n;
	int ans=0;

	map<string,int> mp1,mp2;

	cin>>n;
	for(int i=0;i<n;i++){
        cin>>a[i];
        mp1[a[i]]++;
	}
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>b[i];
        mp2[b[i]]++;
    }

    for(int i=0;i<n;i++){
        ans=max( ( mp1[ a[i] ]-mp2[a[i]] ),ans);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long A[100002];
 int main(void) {
    int N;
   	(void)scanf("%d",&N);
   	if(2 > N || N > 100000){
   		return 1;
   	}

 int	 i;
 for(i=0;i<N;i++){
   (void)scanf("%lld",&A[i]);
 }
   int zero=0;
   int x;
   for(x=0;x<N;x++)if(A[x]==0)zero++;
     if(zero>0){
    			printf("0\n");
    			return 0;
      }

  long long sum=1;
  int j;
  	for(j=0;j<N;j++){
    	if(A[j] <= 1000000000000000000/sum){
    		sum *= A[j];
    	}else{
    		printf("-1\n");
    		return 0;
    	 }
   	}
    	printf("%lld",sum);
    	return 0;
 }



Measured memory_bytes: 2512
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*b==15) {
			System.out.println("*");
		}else if(a+b==15){
			System.out.println("+");
		}else {
			System.out.println("x");
		}


		sc.close();
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  int ans = 0;
  vector<int> v;
  v.push_back(0);
  for(int i = 0; ; i++){
    v[0]++;
    for(int j = 0; j < v.size(); j++){
      if(v[j] == 3){
        v[j] = 0;
        if(j + 1 >= v.size()) v.push_back(0);
        else v[j + 1]++;
      }
      else break;
    }
    //for(int i = v.size() - 1; i >= 0; i--) cout << v[i]; cout << endl;
    vector<int> cnt(3, 0);
    for(int i = 0; i < v.size(); i++){
      cnt[v[i]]++;
    }
    unsigned long long int sum = 0, ten = 1, x;
    for(int i = 0; i < v.size(); i++){
      if(v[i] == 0) x = 3;
      else if(v[i] == 1) x = 5;
      else x = 7;
      sum += x * ten;
      ten *= 10;
    }
    //cout << sum << endl;
    if(sum > n) break;
    if(cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0) ans++;
    /*for(int i = 0; i < cnt.size(); i++){
      cout << "i:" << i << " " << cnt[i] << " ";
    }
    cout << endl;*/
  }
  cout << ans << endl;
  return;
}

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


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

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_set<string> S;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S.insert(s);
  }

  if (S.size() == 3) {
    cout << "Three";
  } else {
    cout << "Four";
  }

  return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int cost[333][333];

int dp[333][333];

int H,W;
int calc(string S,string T){
    fill_n(*dp,333*333,1001001001);
    memset(cost,0,sizeof(cost));

    for(int d=0;d<H;d++){
        int c=0;
        int cc=0;
        for(int i=H-1;i>=d;i--){
            if(S[i-d]==T[i])c++;
            cost[i-d][i]=c;
            if(S[i]==T[i-d])cc++;
            cost[i][i-d]=cc;
        }
    }

    dp[0][0]=0;
    for(int i=0;i<=H;i++){
        for(int j=0;j<=H;j++){
            if(i!=H)chmin(dp[i+1][j],dp[i][j]+cost[i][j]);
            if(j!=H)chmin(dp[i][j+1],dp[i][j]+cost[i][j]);
        }
    }
    return dp[H][H];
}

signed main(){
    cin>>H>>W;
    vector<string>vec(H);
    rep(i,H)cin>>vec[i];

    int ans=0;
    for(int i=0;i<W-1;i++){
        string S,T;
        for(int j=H-1;j>=0;j--){
            S+=vec[j][i];
            T+=vec[j][i+1];
        }
        ans+=calc(S,T);
    }

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


Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
  long long n;
  cin>>n;
  long long m=n;
  long long now=2;
  vector<pair<long long,long long> > a;
  vector<long long> c;
  for(long long i=1;i*i<=n;i++){
  	if(n%i==0){
  		if(i!=1){
  			c.push_back(i);
  		}
  		c.push_back(n/i);
  	}
  }
  sort(c.begin(),c.end());
  int ab=0;
  while(m>1&&ab<c.size()){
  	if(m%c[ab]==0){
  		long long cnt=0;
  		while(m>1&&m%c[ab]==0){
  			m/=c[ab];
  			cnt++;
  		}
  		a.push_back(make_pair(c[ab],cnt));
  	}
  	ab++;
//  	cout<<ab<<" "<<m<<endl;
  }
  long long d[100000]={};
  for(int i=1;i<100000;i++){
  	d[i]=d[i-1]+i;
  }
  long long ans=0;
  for(int i=0;i<a.size();i++){
  	long long hoge=a[i].second;
  	long long id=upper_bound(d,d+100000,hoge)-d;
  	id--;
  	ans+=id;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4416