akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int N;
vi now, target;

bool dfs(int d, int maxDepth) {
    if (d == maxDepth) {
        if (now == target) return true;
        else return false;
    }
    int exist = 0;
    for (int i = 0; i < N; i++) {
        int tmp = (10+target[i]-now[i])%10;
        exist |= 1<<tmp;
    }
    if (__builtin_popcount(exist)+d > maxDepth+1) return false;
    for (int i = 0; i < N; i++) if (now[i] != target[i]) {
        int diff = (10+target[i]-now[i])%10;
        for (int j = i; j < N; j++) {
            for (int k = i; k <= j; k++) {
                now[k] = (now[k]+diff)%10;
            }
            if (dfs(d+1, maxDepth)) return true;
            for (int k = i; k <= j; k++) {
                now[k] = (now[k]+10-diff)%10;
            }
        }
        break;
    }
    for (int i = N-1; i >= 0; i--) if (now[i] != target[i]) {
        int diff = (10+target[i]-now[i])%10;
        for (int j = 0; j <= i; j++) {
            for (int k = j; k <= i; k++) {
                now[k] = (now[k]+diff)%10;
            }
            if (dfs(d+1, maxDepth)) return true;
            for (int k = j; k <= i; k++) {
                now[k] = (now[k]+10-diff)%10;
            }
        }
        break;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (cin >> N) {
        if (N==0) break;
        now.clear(); target.clear();
        now.resize(N); target.resize(N);
        string s, t;
        cin >> s >> t;
        for (int i = 0; i < N; i++) {
            now[i] = (s[i]-'0');
            target[i] = (t[i]-'0');
        }
        int ans = N;
        for (int i = 0; i < ans; i++) {
            if (dfs(0, i)) {
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

int main() {
    int ans, N, i;
    string S, ss;
    cin >> N >> S;
    for (i = 0; i < S.length();i++){
        if((int)S[i] + N < 91){
            S[i] = S[i] + N;
        } else {
            S[i] = S[i] + N - 26;
        }
    }
    cout << S << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007


typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}

typedef pair<ll,ll> pll;


int main() {
  ll k=gll();
  int n=50;
  vll a(50,49);
  ll inc=k/n;
  for(int i=0;i<n;i++){
    a[i]+=inc;
  }
  ll r=k%n;
  for(int i=0;i<n;i++){
    if(i<r){
      a[i]+=n+1;
    }
    a[i]-=r;
  }
  cout<<n<<endl;
  for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
  cout<<endl;



  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll h(n);
    REP(i, n) cin >> h[i];
    REP(i, n - 1){
        if(h[i + 1] - h[i] < -1){
            cout << "No" << endl;
            return 0;
        }
        if(h[i + 1] - h[i] == -1 && i && h[i] == h[i - 1]){
            cout << "No" << endl;
            return 0;
        }
        if(i && h[i] > h[i - 1]) h[i]--;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
#B
D = int(input())
c = [0] + list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0] * 27
manzoku = [0] * 27
for i in range(1, D+1):
    t = int(input())
    manzoku[t] += s[i-1][t-1]
    last[t] = i
    for j in range(1, 27):
        manzoku[j] -= c[j] * (i - last[j])
            
    result = 0
    for k in range(27):
        result += manzoku[k]
    print(result)


Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    string s = "No";
    if (B == C && A != B) s = "Yes";
    if (A == C && B != A) s = "Yes";
    if (A == B && C != B) s = "Yes";

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
ll direction[8][2]={{1,0},{0,1},{0,-1},{-1,0},{-1,1},{-1,-1},{1,-1},{1,1}};
bool valid(ll a,ll b){
    if(a>=1&&a<=n&&b>=1&&b<=m)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    ll x=0;
    cin>>n>>m;
    ll c=n,d=m;
    n=min(c,d);
    m=max(c,d);
    if(n==1&&m==1)cout<<1<<endl;
    else if(n==1)cout<<m-2<<endl;
    else cout<<(ll)((ll)(n*m)-(ll)(2ll*n)-(ll)(2ll*m)+4ll)<<endl;
}


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

int main() {
  int N,M,X; 
  cin>>N>>M>>X;
  vector<int> A(M);
  rep(i,M) cin>>A[i];
  
  int a;
  rep(i,M){
    if(A[i]>X){
      a=i;
      break;
    }
  }
  cout<<min(a,M-a)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll a,b,c;
int main()
{
	cin>>a>>b>>c;
	if((b*10+c)%4) puts("NO");
	else puts("YES");
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 100 * 1000 + 9;
const int MOD = 1e9 + 7;

int n, q;
vector<pair<int, pair<int, int> > > g[maxN];

struct segTree {
	ll sum, cnt;
	int l, r;
	segTree *lCh, *rCh;
}; 

segTree *head[maxN];

segTree *getNode(int l, int r){
	segTree *ans = new segTree;
	ans->l = l, ans->r = r;
	ans->lCh = ans->rCh = NULL;
	ans->sum = ans->cnt = 0;

	return ans;
}

void buildTree0(segTree *id, int l, int r){
	int mid = (l + r) >> 1;
	
	if(l == r){
		return;
	}

	id->lCh = getNode(l, mid);
	id->rCh = getNode(mid + 1, r);

	buildTree0(id->lCh, l, mid);
	buildTree0(id->rCh, mid + 1, r);
}

segTree *upd(segTree *id, int idx, int val){
	int l = id->l, r = id->r, mid = (l + r) >> 1;
	segTree *nw = getNode(l, r);
	nw->lCh = id->lCh;
	nw->rCh = id->rCh;
	nw->sum = id->sum;
	nw->cnt = id->cnt;

	if(idx == l && idx == r){
		nw->sum += val;
		nw->cnt++;
		return nw;
	}

	if(idx <= mid){
		nw->lCh = upd(id->lCh, idx, val);
	} else {
		nw->rCh = upd(id->rCh, idx, val);
	}

	return nw;
}

bool visited[maxN];
int jump[maxN][20], tIn[maxN], tOut[maxN], dfsTime;
ll dist[maxN];

void dfs(int u){
	tIn[u] = ++dfsTime;
	visited[u] = true;

	for(int i = 1; i < 20; i++){
		jump[u][i] = jump[jump[u][i - 1]][i - 1];
	}

	for(int i = 0, L = g[u].size(); i < L; i++){
		int v = g[u][i].first;
		int c = g[u][i].second.first;
		int d = g[u][i].second.second;
		if(visited[v]){
			continue;
		}
		
		head[v] = upd(head[u], c, d);
		jump[v][0] = u;
		dist[v] = dist[u] + (ll)d;
		dfs(v);
	}

	tOut[u] = dfsTime;
}

pair<ll, ll> query(segTree *id, int idx){
	int l = id->l, r = id->r, mid = (l + r) >> 1;
	//cerr << l << ' '  << r << '\n';
	if(l == idx && r == idx){
		return make_pair(id->sum, id->cnt);
	}

	if(idx <= mid){
		return query(id->lCh, idx);
	} else {
		return query(id->rCh, idx);
	}
}

bool isAnc(int u, int v){
	return tIn[u] <= tIn[v] && tOut[u] >= tOut[v];
}

int lca(int u, int v){
	if(isAnc(u, v)){
		return u;
	}

	if(isAnc(v, u)){
		return v;
	}

	for(int i = 19; i >= 0; i--){
		if(!isAnc(jump[u][i], v)){
			u = jump[u][i];
		}
	}

	return jump[u][0];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> q;
	for(int i = 0; i < n - 1; i++){
		int u, v, c, d;  cin >> u >> v >> c >> d;
		g[u].push_back(make_pair(v, make_pair(c, d)));
		g[v].push_back(make_pair(u, make_pair(c, d)));
	}
	
	head[1] = getNode(1, n);
	buildTree0(head[1], 1, n);
	
	jump[1][0] = 1;
	dfs(1);
	
	while(q--){
		ll x, y, u, v;
		cin >> x >> y >> u >> v;
		ll a = lca(u, v);
		//cerr << "lca = " << a << '\n';
		pair<ll, ll> tou = query(head[u], x);	
		pair<ll, ll> tov = query(head[v], x);
		pair<ll, ll> toa = query(head[a], x);


		ll cnt = tou.second + tov.second - 2 * toa.second;
		ll tot = tou.first + tov.first - 2 * toa.first;
		ll du = dist[u] + dist[v] - 2 * dist[a];
		
		ll ans = du - tot + cnt * y;
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 115328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AMealDelivery {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int x, a, b;
	    in >> x >> a >> b;
	    out << (abs(x-a) < abs(x-b) ? "A" : "B") << endl;
	}
};


int main() {
	AMealDelivery solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(void) {
    int n;
    scanf("%d", &n);
    if (n%2 == 1) {
        printf("No\n");
        return 0;
    }

    char str[n+1];
    //fgets(str, n/2+1, stdin);
    scanf("%s", str);

    char former[n/2+1];
    char latter[n/2+1];

    for (int i = 0; i < n/2; i++) {
        former[i] = str[i];
    }
    former[n/2] = '\0';
    for (int i = 0; i < n/2; i++) {
        latter[i] = str[i + n/2];
    }
    latter[n/2] = '\0';

    if (strcmp(former, latter) == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a= readLine()!!.split(" ").map{ it.toLong()}

    val x0=a.count{(it and 1L)==1L}
    val x1=a.count{(it and 3L)==2L}
    val x2=a.count{(it and 3L)==0L}

    if (x2>=x0 || x2==x0-1 && x1==0){
        println("Yes")
    }else{
        println("No")
    }

}

Measured memory_bytes: 54016
def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    d = sorted(a, reverse=True)
    for i in range(n):    
        if d[0] == a[i]:
            print(d[1])
        else:
            print(d[0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 14176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

ll a, b, c, d, n;
map<ll, ll> mp;

ll dfs(ll x) {
	if (mp.find(x) != mp.end()) {
		return mp[x];
	}
	ll ret = linf;
	if ((long double)d * (long double)x < ret) {
		ret = d * x;
	}
	ret = min(ret, dfs(x / 2) + a + d * (x % 2));
	if (x % 2 != 0)ret = min(ret, dfs(x / 2 + 1) + a + d * (2 - x % 2));
	ret = min(ret, dfs(x / 3) + b + d * (x % 3));
	if (x % 3 != 0)ret = min(ret, dfs(x / 3 + 1) + b + d * (3 - x % 3));
	ret = min(ret, dfs(x / 5) + c + d * (x % 5));
	if (x % 5 != 0)ret = min(ret, dfs(x / 5 + 1) + c + d * (5 - x % 5));
	return mp[x] = ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> a >> b >> c >> d;
		mp.clear();
		mp[0] = 0;
		mp[1] = d;
		cout << dfs(n) << endl;
	}
	return 0;
}


Measured memory_bytes: 4444
#include <iostream>
#include <string>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if((a>=b&&b>=c)||(a>=c&&c>=b)){
    cout<<a*10+b+c<<endl;
}
else if((b>=c&&c>=a)||(b>=a&&a>=c)){
    cout<<b*10+a+c<<endl;
}
else{
    cout<<c*10+b+a<<endl;
}
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				sc.close();
				break;
			}

			boolean[][] sche = new boolean[n][31];
			for (int i = 0; i < n; i++) {
				int days = sc.nextInt();
				for (int j = 0; j < days; j++) {
					int d = sc.nextInt();
					sche[i][d] = true;
				}
			}

			HashSet<Integer>[][] dp = new HashSet[n][31];
			adjust: for (int day = 1; day < dp[0].length; day++) {
				for (int child = 0; child < dp.length; child++) {
					if (sche[child][day]) {
						if (day == 1) {
							// 1日目ならとりあえず新しく作る
							dp[child][day] = new HashSet<Integer>();
							dp[child][day].add(child);
						} else {
							for (int past = day - 1; past >= 1; past--) {
								// 前に地図をゲットしてたら引き継ぐ
								if (sche[child][past]) {
									dp[child][day] = new HashSet<Integer>(
											dp[child][past]);
									break;
								}

								// 前にゲットしてなかったら新しく作る
								if (past == 1) {
									dp[child][day] = new HashSet<Integer>();
									dp[child][day].add(child);
								}
							}
						}
					}
				}

				for (int child = 0; child < dp.length; child++) {
					if (sche[child][day]) {
						for (int person = 0; person < sche.length; person++) {
							// 集まれる人から地図をもらう
							if (sche[person][day]) {
								for (int map : dp[person][day]) {
									dp[child][day].add(map);
								}
							}
						}
						if (dp[child][day].size() == n) {
							System.out.println(day);
							break adjust;
						}
					}
				}
				if (day == dp[0].length - 1) {
					System.out.println(-1);
				}
			}

		}
	}
}

Measured memory_bytes: 73240
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if ((n == 1 && m > 1) || (m == 1 && n > 1)) {
		ans = max(n, m);
		ans -= 2;
	}
	else if (n == 1 && m == 1) {
		ans = 1;
	}
	else
	{
		ans = (n - 2) * (m - 2);
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 3600
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int r = sc.nextInt();
    int s = sc.nextInt();
    int p = sc.nextInt();
    String t = sc.next();
    int ans = 0;
    String[] te = new String[n];
    for(int i = 0; i < n; i++) {
      if(t.charAt(i) == 'r') {
        if((i >= k) && (te[i - k].equals("p"))) {
          if((i + k) >= n) {
            te[i] = "s";
          } else {
            if(t.charAt(i + k) == 'r') {
              te[i] = "s";
            } else if(t.charAt(i + k) == 's') {
              te[i] = "s";
            } else {
              te[i] = "r";
            }
          }
        } else {
          ans += p;
          te[i] = "p";
        }
      } else if(t.charAt(i) == 's') {
        if((i >= k) && (te[i - k].equals("r"))) {
          if((i + k) >= n) {
            te[i] = "s";
          } else {
            if(t.charAt(i + k) == 'r') {
              te[i] = "s";
            } else if(t.charAt(i + k) == 's') {
              te[i] = "s";
            } else {
              te[i] = "p";
            }
          }
        } else {
          ans += r;
          te[i] = "r";
        }        
      } else {
        if((i >= k) && (te[i - k].equals("s"))) {
          if((i + k) >= n) {
            te[i] = "r";
          } else {
            if(t.charAt(i + k) == 'r') {
              te[i] = "r";
            } else if(t.charAt(i + k) == 's') {
              te[i] = "p";
            } else {
              te[i] = "r";
            }
          }
        } else {
          ans += s;
          te[i] = "s";
        }        
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 27684
//(|||.()(||||||)
 //.(|||.()(||||||)
      #include<bits/stdc++.h>
    #define FiO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

    //using ll = long long;

    using namespace std;
    int main()
    {
        int m,n;
        cin>>m>>n;
        n =2*n;
        int d= m-n;
        if(d>=0){
            cout<<d<<endl;
        }
        else {
            cout<<0<<endl;
        }

    }


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

using namespace std;

set<int> S;

int main() {
	int k , ans = 1, now = 7;
	scanf("%d",&k);
	now %= k;
	while (now != 0) {
		if (S.count(now) > 0) break;
		S.insert(now);
		now = (now * 10 + 7) % k;
		ans ++;
	}
	if (now == 0)
		printf("%d\n",ans);
	else 
		printf("-1\n");
	return 0;
}


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

using namespace std;

typedef long long ll;

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

    int x;
    for(int i=1; i<=5; i++){
        cin >> x;
        if(!x) cout << i;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int>a(n);
	int sum=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	sort(all(a));
	int th=ceil(sum/float(4*m));
	cout<<(int(a.end()-lower_bound(all(a),th))<m?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
import sys

INF = sys.maxsize
D, G = map(int, input().split())

class P:
  def __init__(self, index, number, bonus):
    self.index = index
    self.number = number
    self.bonus = bonus
    
  @property
  def score(self):
    return (self.index + 1) * 100
   
  @property
  def complete_score(self):
    return self.score * self.number + self.bonus
  
  # score 獲得するのに必要な解答数
  def cost_of(self, score):
    if score > self.complete_score:
      return INF
    if score == 0:
      return 0
    if score < self.score:
      return 1
    return min(score // self.score, self.number)
  
problems = []
for i in range(D):
  p, c = map(int, input().split())
  problems.append(P(i, p, c))
  
min_number_of_solved = INF

for m in range(1 << D):
  total = 0
  number_of_solved = 0
  uncompleted = set()
  
  for i, p in enumerate(problems):
    if 1 << i & m:  # 完答
      total += p.complete_score
      number_of_solved += p.number
    else:
      uncompleted.add(p)

  # 他の問題を解かなくても条件を満たしている
  if total >= G:
    min_number_of_solved = min(
      min_number_of_solved, 
      number_of_solved
    )
  # 残りの必要点数を最小コストで獲得できる問題を中途半端に解く
  else:
    # 不足する点を最小コストで獲得できる問題を探す
    m = min(uncompleted, key=lambda x: x.cost_of(G - total))
        
    min_number_of_solved = min(
      min_number_of_solved, 
      number_of_solved + m.cost_of(G - total)
    )
                   
print(min_number_of_solved)
    

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

int main() {
  string str;
  cin >> str;
  int w; cin >> w;
  int I = 0;
  for(auto x : str) {
    if(I % w == 0) cout << x;
    I++;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
li = []
while True:
    li.append(input().split())
    if li[-1][1] == '?':
        break
for s in li:
    if s[1] == '+':
        print(int(s[0]) + int(s[2]))
    elif s[1] == '-':
        print(int(s[0]) - int(s[2]))
    elif s[1] == '*':
        print(int(s[0]) * int(s[2]))
    elif s[1] == '/':
        print(int(s[0]) // int(s[2]))
        


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n%2==0)
	{
		cout<<n/2<<endl;
		return 0;
	}
	else
	{
		cout<<n/2+1<<endl;
		return 0;
	}
	
} 

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

ll N;
vll A;

bool C(ll x) // 公約数をxとできるか
{
    int count = 0;
    REP(i, N)
    {
        if(A[i] % x != 0)
        {
            if(count == 0) count++;
            else return false;
        }
    }
    return true;
}

void solve()
{
    int N, K; cin >> N >> K;
    double ans = 0;
    REP1(i, N)
    {
        double t = 1.0 / N;
        int n = i;
        while(n < K)
        {
            n *= 2;
            t /= 2;
        }
        ans += t;
    }
    cout << ans << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void solve()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    rep(i,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n][4];
    dp[0][1]=a[0];
    dp[0][2]=b[0];
    dp[0][3]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);   


    }
    //cout<<dp[2][2]<<endl;
    //n=1;
    cout<<max(max(dp[n-1][1],dp[n-1][2]),dp[n-1][3]);


}
int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    solve();
    return 0;
}

Measured memory_bytes: 6388
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int x[N], w[N], ans[N], n, m, t;
long long mi;
int main() {
	scanf("%d%d%d", &n, &m, &t);
	for(int i=1; i<=n; i++) { scanf("%d%d", &x[i], &w[i]); if(w[i]==2) w[i]=-1; }
	int to=0;for(int i=1; i<=n; i++) {to=x[i]+t*w[i]; if(to>0) (mi+=to/m)%=n; if(to<0) (mi+=(to+1)/m-1)%=n; ans[i]=(to%m+m)%m;}
	sort(ans+1, ans+n+1), mi=(mi+n)%n;
	for(int i=mi+1; i<=n; i++) printf("%d\n", ans[i]); for(int i=1; i<=mi; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const char tab = '\t';
const char space = ' ';
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  ll n = s.size();

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    for (ll j = 1; j <= n - i; j++) {
      ll m = stoll(s.substr(i, j));
      ll x = j + 1;
      if (i == 0) x--;
      if (j == n - i) x--;
      ans += m * pow(2, n - 1 - x);
    }
  }
  cout << ans << endl;
}

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

int main(){
	int n; cin >> n; int l[n]; for(int i=0; i<n; i++) cin >> l[i];
	sort(l, l+n); int an = 0;
	for(int i=1; i<n-1; i++) {
		for(int j=i+1; j<n; j++) {
			int df = l[j] - l[i];
			auto it = upper_bound(l, l+n, df);
			int ds = distance(it, l+i);
			if (ds > 0) an += ds;
			//cout << ds << " ";
		}
	}
	cout << an << endl;
}

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

int main(){ 
  int N, R, I;
  cin >> N >> R;
  
  if (N >= 10) I = R;
  else I = R + 100 * (10 - N);
  
  cout << I << endl;
}


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

using namespace std;

template <typename T>
class BinaryIndexedTree {
 private:
  std::vector<T> data;

 public:
  BinaryIndexedTree(int sz) : data(sz + 1, 0) {}

  T sum(int idx) const {
    T res = 0;
    for (int i = idx + 1; i > 0; i -= i & -i) res += data[i];
    return res;
  }

  void add(int idx, T x) {
    for (int i = idx + 1; i < (int)data.size(); i += i & -i) data[i] += x;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<BinaryIndexedTree<int>> bit(26, BinaryIndexedTree<int>(N));
  for (int i = 0; i < N; i++) {
    bit[S[i] - 'a'].add(i, 1);
  }
  for (int i = 0; i < Q; i++) {
    int q;
    cin >> q;
    if (q == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      bit[S[i] - 'a'].add(i, -1);
      bit[c - 'a'].add(i, 1);
      S[i] = c;
    } else if (q == 2) {
      int l, r;
      cin >> l >> r;
      l--, r--;
      int res = 0;
      for (int i = 0; i < 26; i++) {
        if (bit[i].sum(r) - bit[i].sum(l - 1) > 0) res++;
      }
      cout << res << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 53660
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

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

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[i] + l[j]) {
                    count++;
                }
            }
        }
    }

    std::cout << count << std::endl;
}


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

class Main
{
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

	public static void main (String[] args)
	{
		FastReader reader = new FastReader();
		int a = reader.nextInt();
		int b = reader.nextInt();
		int x = reader.nextInt();

		if (a<=x && x<a+b)
			System.out.println ("YES");
		else
			System.out.println ("NO");
	}
}


Measured memory_bytes: 20948
def main():
    n = int(input())
    a = list(map(int,input().split()))
    res = 0
    for i in range(n):
        minj = i
        for j in range(i+1,n):
            if a[j] < a[minj]:
                minj = j
        if minj != i:res+=1
        a[i],a[minj] = a[minj],a[i]
    print (' '.join(map(str,a)))
    print (res)

if __name__ == '__main__':
    main()




Measured memory_bytes: 5600
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 1000000;

int n;
int ans = 0;
pair<int,int> m[20][20];
int a[20];
int b[20];
// 1を正直者とする
void cal(int k=0){
    if(k<n){
        b[k]=1;
        cal(k+1);
        b[k]=0;
        cal(k+1);
    }
    else if(k==n){
        bool key=true;
        int check[20];
        rep(i,n){
            if(b[i]==1)check[i]=1;
            else check[i]=INF;
        }
        rep(i,n){
            if(b[i]){
                rep(j,a[i]){
                    if(check[m[i][j].first]==INF)check[m[i][j].first]=m[i][j].second;
                    else if(check[m[i][j].first]!=m[i][j].second)key=false;
                }
            }
        }
        rep(i,n){
            if(check[i]!=INF&&check[i]!=b[i])key=false;
        }
        if(key){
            int cnt=0;
            rep(i,n){
                if(b[i])cnt++;
            }
            ans=max(ans,cnt);
        }
    }
    return;
}

int main(){
    
    cin >> n;
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            cin >> m[i][j].first>>m[i][j].second;
            m[i][j].first--;
        }
    }
    
    cal();
    
    cout << ans<<endl;
    
    return 0;
}


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

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> broken(m);
    for (ll i = 0; i < m; ++i) cin >> broken.at(i);
    vector<ll> dp(n + 1, -1);
    for (ll j : broken) dp.at(j) = 0;
    if (dp.at(1) != 0) dp.at(1) = 1;
    dp.at(0) = 1;
    for (ll k = 2; k < n + 1; ++k) if (dp.at(k) == -1) dp.at(k) = (dp.at(k - 2) + dp.at(k - 1)) % 1000000007;
    cout << dp.at(n) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
	int a, b, c, d, i;
	cin >> a >> b >> c >> d;
	i = 0;
	while (i < 5) {
		c = c - b;
		if (c < 1) {
			cout << "Yes";
			break;
		}
		a = a - d;
		if (a < 1) {
			cout << "No";
			break;
		}
	}
	return 0;
}

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

bool is_pal(string x){
  string t = x;
  reverse(t.begin(), t.end());
  return x == t;
}

int main(){
  string s;
  cin >> s;
  
  bool ans = true;
  if (!is_pal(s)) ans = false;
  if (!is_pal(s.substr(0, s.size() / 2))) ans = false;
  
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  

}



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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    int l = s.size();

    bool iseasy = true;
    for (int i = 0; i < l; i++)
    {
        if (s[i] == 'D' || s[i] == 'U')
            continue;
        if (i % 2 == 1 && s[i] == 'R')
        {
            iseasy = false;
            break;
        }
        if (i % 2 == 0 && s[i] == 'L')
        {
            iseasy = false;
            break;
        }
    }

    string ans;
    if (iseasy)
        ans = "Yes";
    else
        ans = "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int a = 0, b = 0, tmp;

	REP(i, 4) {
		cin >> tmp;
		a += tmp;
	}

	REP(i, 4) {
		cin >> tmp;
		b += tmp;
	}

	cout << ((a>b) ? a : b) << endl;

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
}



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

int main() {
    int x, y;
    cin >> x >> y;
    int n = min(x,y);
    int m = max(x,y);
    if (n == 1) {
        if (m == 1) {
            cout << 1 << endl;
            return 0;
        }
        cout << m-2 << endl;
        return 0;
    }
    cout << (ll)(m-2) * (n-2) << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt();
		int B = scn.nextInt();
		int ans = 0;
		if(A >B) {
			ans += A;
			A--;
		}else {
			ans += B;
			B--;
		}
		ans += Math.max(A, B);
		System.out.println(ans);
	}

}


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

int main()
{
  int N;
  cin >> N;
  
  int K;
  cin >> K;
  
  int ans = 0;
  int x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x <= K / 2) {
      ans += x * 2;
    } else {
      ans += 2 * (K - x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int K,t[25],tot,cnt,s[10005];
int64 L[10005],p[25],b[25];
int S(int64 x) {
    int res = 0;
    while(x) {res += x % 10;x /= 10;}
    return res;
}


int64 f(int64 x) {
    tot = 0;cnt = 0;int64 h = x;
    while(h) {t[++tot] = h % 10;h /= 10;}
    int64 num = 0;
    for(int i = tot ; i >= 1 ; --i) {
	for(int j = t[i] ; j <= 9 ; ++j) {
	    int64 tmp = num + j * b[i - 1] + p[i - 1];
	    if(tmp >= x) L[++cnt] = tmp;
	}
	num = num + t[i] * b[i - 1];
    }
    
    for(int i = 1 ; i <= cnt ; ++i) s[i] = S(L[i]);
    int r = 1;
    for(int i = 2 ; i <= cnt ; ++i) {
	int64 h = L[i] * s[r] - L[r] * s[i];
	if(h < 0) r = i;
	else if(h == 0 && L[i] < L[r]) r = i; 
    }
    return L[r];
}
void Solve() {
    read(K);
    int64 N = 1;
    p[1] = 9;
    for(int i = 2 ; i <= 16 ; ++i) p[i] = p[i - 1] * 10 + 9;
    b[0] = 1;
    for(int i = 1 ; i <= 16 ; ++i) b[i] = b[i - 1] * 10;
    while(K--) {
	out(N);enter;
	N = f(N + 1);
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int N;
    string s, t;

    cin >> N;
    cin >> s >> t;
    int i, j;
    int h = 0;

    for (i = 0; i < N;i++)
    {
        for (j = 0; j < N - i; j++)
        {
            if(s[i + j] != t[j])
            {
                break;
            }
            h = max(h, j + 1);
        }
    }

    cout <<  2 * N - h << endl;

    return 0;
}


Measured memory_bytes: 256
function main(input) {
    const input_array = input.split('\n');

//    const A = parseInt(args[0], 10),
//          B = parseInt(args[1], 10),
//          C = parseInt(args[2], 10),
//          X = parseInt(args[3], 10);

    const coins_count = input_array.slice(0,3);
    const desired_sum = parseInt(input_array.slice(-1), 10);
    const A = parseInt(input_array[0], 10),
          B = parseInt(input_array[1], 10),
          C = parseInt(input_array[2], 10),
          X = parseInt(input_array[3], 10);

    var count = 0;

    for (var a = 0; a <= A; ++a) {
        for (var b = 0; b <= B; ++b) {
            for (var c = 0; c <= C; ++c) {
                var sum = (a * 500) + (b * 100) + (c * 50);
                if (sum === X) ++count;
            }
        }
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

int main() {
	int h, w;
	cin >> h >> w;

	vector<bool> row(h), column(w);

	string a[h];
	for (int i = 0; i < h; i++) {
		cin >> a[i];
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = 1;
				break;
			}
		}
	}

	for (int j = 0; j < w; j++) {
		for (int i = 0; i < h; i++) {
			if (a[i][j] == '#') {
				column[j] = 1;
				break;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (row[i] && column[j])
				cout << a[i][j];
		}
		if (row[i])
			cout << endl;
	}
}


Measured memory_bytes: 256
<?php
/*
    Problem URL : http://abc056.contest.atcoder.jp/tasks/abc056_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d %d %d", $W, $a, $b);

$al = $a;
$ar = $a + $W;
$bl = $b;
$br = $b + $W;

if ($al <= $bl && $bl <= $ar) {
    echo "0\n";
    exit;
}
if ($al <= $br && $br <= $ar) {
    echo "0\n";
    exit;
}
$mv = PHP_INT_MAX;
if ($ar < $bl) {
    $mv = min($mv, abs($ar - $bl));
}
if ($al > $br) {
    $mv = min($mv, abs($al - $br));
}

echo $mv . PHP_EOL;


Measured memory_bytes: 4604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            
            while((line = stdReader.readLine()) != null) {
                String[] input = line.split(" ", 0);
                long a = Long.parseLong(input[0]);
                long b = Long.parseLong(input[1]);
                
                long d = a / b;
                long r = a % b;
                double f = (double)a / (double)b;
                String after = String.format("%.5f", f);
                System.out.println(d + " " + r + " " + after);
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

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

int main(void){
  string str;
  int cup[3] = {1, 0, 0};
  while(cin >> str){
    int t1 = str[0] - 'A', t2 = str[2] - 'A';
    swap(cup[t1], cup[t2]);
  }
  char ans = (cup[0] == 1) ? 'A' : (cup[1] == 1) ? 'B' : 'C';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1172
import java.util.Scanner;

/*import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
*/

public class Main {

	public static void main(String[] args)/* throws IOException*/ {
		Scanner sc = new Scanner(System.in);
		//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		/*
				int a = Integer.parseInt(br.readLine());//数字
				String op = br.readLine();//演算子
				int b = Integer.parseInt(br.readLine());//数字
		

		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();

		//		for(int i =0;;i++)
		switch (op) {
		case "+":
			System.out.println(a + b);
			break;
		case "-":
			System.out.println(a - b);
			break;
		case "*":
			System.out.println(a * b);
			break;
		case "/":
			System.out.println(a / b);
			break;
		case "?":
			break;
		
		}
		}
		}
		
		*/while (true) {
			
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if (op.equals("?")) {
				break;
			}else if (op.equals("+")) {
				System.out.println(a + b);
			
			} else if (op.equals("-")) {
				System.out.println(a - b);
			} else if (op.equals("*")) {
				System.out.println(a * b);
			} else if (op.equals("/")) {
				System.out.println(a / b);
			 
			}
		}
	}
}


Measured memory_bytes: 26224
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int ans = 1;
  rep(i, N) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << '\n';
      return 0;
    }
  }

  rep(i, N) {
    if (1000000000000000000ll / ans < A[i]) {
      cout << -1 << '\n';
      return 0;
    }
    ans *= A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4052
h, w = map(int, input().split())
if h ==1 or w ==1:
  print(1)
elif h % 2 == 0:
  print(int(h*w//2))
elif w % 2 == 0:
  print(int(h//2 *w + w//2))
else:
  print(int(h//2 *w + w//2 + 1))

Measured memory_bytes: 3060