akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  map<string, int> m;
  int q; cin >> q;
  int command;
  string key;
  int x;
  rep_i(i, q){
    cin >> command;
    if(command == 0){
      cin >> key >> x;
      auto it = m.find(key);
      if(it == m.end()){
        m.insert(make_pair(key, x));
      }else{
        m[key] = x;
      }
    }else if(command == 1){
      cin >> key;
      say(m.at(key));
    }
  }
}
  


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  n;
	cin >>n;
	VI a(n), b(n);
	rep(i, n) cin >>a[i] >>b[i];
	sort(all(a)); sort(all(b));
	
	int ans = b[n/2] - a[n/2] + 1 + (n&1? 0: (b[n/2-1] - a[n/2-1]));
	cout<<  ans << "\n";

	return 0;
}


Measured memory_bytes: 4776
N, M = map(int,input().split())

L = 1
R = N

for m in range(M):
    L_, R_ = map(int,input().split())
    if L < L_:
        L = L_
    if R_ < R:
        R = R_

if R < L:
    print(0)
else:
    print(R-L+1)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
 
//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}
 
ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}
 
 
int main(){
    int n;
    double a=1,c=1,m=0;
    cin>>n;
    vector<double> p(n);
    rep(i,n){
        cin>>p[i];
    }
    rep(i,n){
        c*=p[i];
        rep(j,n){
            if(i==j) continue;
            a*=p[j];
        }
        m+=a;
        a=1;
    }
    cout<<setprecision(10)<<(c/m)<<endl;
    return 0;
 
}

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

int main() {
  string A, B;
  cin >> A >> B;
  int cnt = 0;
  for (int i = 0; i < A.size(); ++i) {
    cnt += A[i] != B[i];
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					System.out.print("#");
				}
				System.out.print("\n");
			}

System.out.print("\n");
		}
	}
}


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

public class Main {

    public static void main(String[] arg) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer strToke;
        String line;
        String revLine;

        // ab = gcd * lcm
        while ((line = in.readLine()) != null) {
            revLine = "";
            for (int i = line.length() - 1; i >= 0; i--) {
                revLine = revLine + line.charAt(i);
            }
            System.out.println(revLine);
        }
    }
}

Measured memory_bytes: 16868
n = int(input())
a = list(map(int, input().split()))

a = list(enumerate(a))
a.sort(key=lambda x: x[1])

# dp[left + right][left]
dp = [[] for _ in range(n+1)]
dp[0].append(0)

for i in range(1, n+1): # i = left + right
    ind, act = a.pop(-1)

    # all right
    dp[i].append(dp[i-1][0] + act * (n - i - ind))

    # middle
    for j in range(1, i): # j = left
        ar = dp[i-1][j] + act * (n - i + j - ind) # rightに追加
        al = dp[i-1][j-1] + act * (ind - j + 1) # leftに追加
        dp[i].append(max([ar, al]))

    # all left
    dp[i].append(dp[i-1][i-1] + act * (ind - i + 1))

print(max(dp[n]))

Measured memory_bytes: 85528
x, y = map(int, input().split())

a = (x+y) // 3
n = (2*x-y) // 3
m = a - n

mod = 10**9 + 7

def nCr(n, r, mod):
  r = min(r, n-r)
  numer = denom = 1
  for i in range(1, r+1):
    numer = numer * (n+1-i) % mod
    denom = denom * i % mod
  return numer * pow(denom, mod-2, mod) % mod

if n<0 or m<0 or (x+y)%3!=0:
  print(0)
  exit()
  
print(nCr(a, n, mod))

Measured memory_bytes: 3064
N = int(input())
H = list(map(int,input().split()))
x = 0
lis = []
for i in range(0,len(H)-1) :
    if H[i] - H[i+1] >=0:
        x += 1
    else:
        lis.append(x)
        x =0
lis.append(x)
print(max(lis))
                
  


Measured memory_bytes: 14252
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
///////////////////////
const int N = 1e6; 
const int mod_ = MOD;

ll fact[N+1];

void set_fact() {
    fact[0] = 1;
    rep(i,N) fact[i+1] = ((((ll)i+1) % mod_) * fact[i]) % mod_;
}

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

// n! mod_ p 
ll mod_fact(ll n, ll p, ll &e) {
    e = 0;
    if (!n) return 1;
    ll res = mod_fact(n/p, p, e);
    e += n/p;

    if ((n/p)%2) 
        return res * (p - fact[n%p]) %p;
    else
        return res * fact[n%p] % p;
}

// nCk mod_ p ; O(log_p n)
ll mod_comb(ll n, ll k, ll p) {
    if (n<0 || k<0 || n<k) return 0;
    ll e1, e2, e3;
    ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n-k, p, e3);
    if (e1 > e2+e3) return 0;
    return a1 * mod_inv(a2*a3%p, p) % p;
}

// nHk mod_ p ;
ll mod_h_comb(ll n, ll k, ll p) {
    return mod_comb(n+k-1, k, p);
}
///////////////////////

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

    set_fact();

    ll n, K; cin >> n >> K;
    chmin(K, n - 1);

    ll res = 0LL;
    rep(i, K + 1){
        ll cur = mod_comb(n, i, MOD);
        cur = MUL(cur, fact[i + (n - i - 1)]);
        cur = DIV(cur, fact[i]);
        cur = DIV(cur, fact[n - i - 1]);

        res = ADD(res, cur);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8064
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n, ans = 0;
  cin >> n;
  VLL A(n);
  INPUT(A);

  SORTR(A, LL);
  int ct = 1, idx = 0;
  REP(int, i, n-1)
  {
    ans += A[idx];
    ct++;
    if (ct >= 2)
    {
      ct = 0;
      idx++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4784
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int x;
    
    if(b<10){
        x=b+10*a;
    }else if(b<100){
        x=b+100*a;
    }else{
        x=b+1000*a;
    }
    int i;
    for(i=1;i<400;i++){
        if(x==i*i){
            printf("Yes");
            return 0;
        }
    }

    printf("No");


    return 0;
}

Measured memory_bytes: 128
k = int(input())

ls = []

def dfs(n):
    if len(n) >= 12:
        return
    ls.append(int(n))
    lastNum = int(n[-1])
    for i in range(max(0, lastNum-1), min(lastNum + 2, 10)):
        dfs(n + str(i))

dfs("1")
dfs("2")
dfs("3")
dfs("4")
dfs("5")
dfs("6")
dfs("7")
dfs("8")
dfs("9")

ls = list(ls)
ls = sorted(ls)
print(ls[k-1])



Measured memory_bytes: 32312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << "ABC"<<in() << "\n";
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    long long N, K;
    cin >> N >> K;
    N %= K;
    if (K - N < N) {
        cout << K - N;
    } else {
        cout << N;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

class Main {


	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		int week = readNumber(reader);
		BigDecimal debt = BigDecimal.valueOf(100000);
		for (int i = 0; i < week; i++) {
			// 5%の利子を追加し、1000円未満は切り捨て
			debt = debt.multiply(BigDecimal.valueOf(1.05)).setScale(-3, BigDecimal.ROUND_UP);
		}
		System.out.println(debt.toPlainString());

	}

	/**
	 * ストリームから1行読み込んで、数値として返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return 数値
	 */
	private static int readNumber(BufferedReader reader) {
		int result = 0;
		try {
			String line = reader.readLine();
			result = Integer.parseInt(line);
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return result;
	}
}

Measured memory_bytes: 16984
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long ans=0;
        int []a=new int[n-1];
        int []b=new int[n];
        b[0]=Integer.MAX_VALUE;
        for(int i=0;i<n-1;i++){
            a[i]=sc.nextInt();
            b[i+1]=a[i];
            ans+=Math.min(b[i],a[i]);
        }
        ans+=b[n-1];
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define w(x) int x;cin>>x;while(x--)
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vi vector<int>
#define ff first
#define ss second
#define fr(a,b) for(int i=a;i<=b;i++)
#define inf 1e18
#define mod 1000000007
int main()
{
    ll n;
    cin>>n;
    ll a[n+1];
    ll pre[n+1];
    for(int i=0;i<n;i++){
    cin>>a[i];
    pre[i]=a[i];
    }
    for(int i=n-2;i>=0;i--)
    {
        pre[i]=pre[i]+pre[i+1];
        pre[i]=pre[i]%mod;
    }
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        ans=(ans%mod+(pre[i]%mod*a[i-1]%mod)%mod)%mod;
    }
    cout<<ans<<"\n";
    return 0;
    
}


Measured memory_bytes: 6740
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main(){
	int n, k;
	cin >> n >> k;
	int a[n];
	FOR0(i,n) cin>>a[i];
	bool dp[100001];
	memset(dp, false, sizeof(dp));
	FOR0(i,k+1){
		FOR0(j,n){
			if (a[j]<=i){
				if (!dp[i-a[j]]) dp[i] = true;
			}
		}
	}	

	if(dp[k]) cout<<"First\n";
	else cout << "Second\n";
}

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

int main() {
  int in;
  stack<int> t;

  while (cin >> in) {
    if (in != 0) {
      t.push(in);
    }
    else {
      cout << t.top() << endl;
      t.pop();
    }
  }
}

Measured memory_bytes: 2988
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9
#define vint vector<int>

using namespace std;
typedef long long  ll;

const long long M = 1e9+7;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 0;
    while(true){
        if(i%2 == 0){
            c = c - b;
            if(c <= 0){
                p("Yes");
                break;
            }
        } else {
            a = a - d;
            if(a <= 0){
                p("No");
                break;
            }
        }
        i++;
    }
}

Measured memory_bytes: 3104
#pragma GCC optimize("O3")
#include <stdio.h>
#include <functional>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
#define PB push_back
#define F first
#define S second
constexpr int kN = int(5E5 + 10), kBlk = 710;

int c[kN], cnt[kN], ans[kN];
pair<int, int> p[kN];
vector<int> v[kBlk];

int main() {
	int n, q, now = 0, lpos = 0, rpos = -1;
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
	for (int i = 1; i <= q; i++) scanf("%d%d", &p[i].F, &p[i].S);
	for (int i = 1; i <= q; i++) v[p[i].F / kBlk].PB(i);

	for (int i = 0; i < kBlk; i++) {
		sort(v[i].begin(), v[i].end(), [&](int a, int b){return p[a].S == p[b].S ? p[a].F < p[b].F : p[a].S < p[b].S;});
		//now = 0, lpos = kBlk * i, rpos = kBlk * i - 1;
		for (int j : v[i]) {
			while (rpos < p[j].S) if(cnt[c[++rpos]]++ == 0) now++;
			while (lpos > p[j].F) if (cnt[c[--lpos]]++ == 0) now++;
			while (lpos < p[j].F) if (--cnt[c[lpos++]] == 0) now--;
			while (rpos > p[j].S) if (--cnt[c[rpos--]] == 0) now--;
			ans[j] = now;
		}
	}
	for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    cin >> K;

    ll N = 1000000;
    vector<ll> seven(N);

    ll now = 7;
    REP(i, N){
        if(i == 0){
            seven[i] = 7 % K;
        }
        else{
            now = now*10;
            now = now % K;
            seven[i] = now;
        }
    }

    ll total = 0;
    REP(i, N){
        total += seven[i];
        total = total % K;
        if(total == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 11156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  ios_base :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, l;
  cin >> n >> l;
  vector<string> v(n);
  int i;
  for(i=0; i<n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  for(auto it = v.begin(); it!=v.end(); it++){
    cout << *it;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include <vector>
#include <map>
using namespace std;
int s[3][3];
int check()
{
    if(s[0][1] - s[0][0] != s[1][1] - s[1][0] || s[0][1] - s[0][0] != s[2][1] - s[2][0])return 0;
    if(s[0][2] - s[0][0] != s[1][2] - s[1][0] || s[0][2] - s[0][0] != s[2][2] - s[2][0])return 0;
    if(s[0][1] - s[0][2] != s[1][1] - s[1][2] || s[0][1] - s[0][2] != s[2][1] - s[2][2])return 0;
    if(s[0][0] - s[1][0] != s[0][1] - s[1][1] || s[0][0] - s[1][0] != s[0][2] - s[1][2])return 0;
    if(s[0][0] - s[2][0] != s[0][1] - s[2][1] || s[0][0] - s[2][0] != s[0][2] - s[2][2])return 0;
    if(s[2][0] - s[1][0] != s[2][1] - s[1][1] || s[2][0] - s[1][0] != s[2][2] - s[1][2])return 0;
    return 1;
}
int main()
{
    for(int i = 0;i < 3;i ++)
    {
        for(int j = 0;j < 3;j ++)
        {
            cin>>s[i][j];
        }
    }
    if(check())cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
S=input()
dp=[[0 for i in range(2)] for j in range(len(S))]
# dp[x]:x番目の文字に、dp[x][0]:1文字で来たときの最大分割数、dp[x][1]:2文字で来た時
dp[0][0]=1
dp[0][1]=-1
for i in range(1,len(S)):
  if S[i]==S[i-1]:
    dp[i][0]=dp[i-1][1]+1
  elif S[i]!=S[i-1]:
    dp[i][0]=max(dp[i-1][0],dp[i-1][1])+1
  if i-2>=0:
    dp[i][1]=max(dp[i-2][0],dp[i-2][1])+1
print(max(dp[-1][0],dp[-1][1]))

Measured memory_bytes: 39524
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int N;
    cin >> N;
    if(N % 2 == 0)
        cout << N / 2 - 1 << endl;
    else
        cout << N / 2 << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n) cin >> a[i];

    sort(a,a+n,greater<ll>());
    ll ans = a[0],roopcnt = 2,index = 1;
    while(roopcnt < n){
        if(roopcnt == n-1){
            ans += a[index];
        }
        else{
            ans += a[index] * 2;
            roopcnt++;
        }
        index++;
        roopcnt++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5124
#include<iostream>
#include<vector>

#define INF (1<<29)

using namespace std;

int main(void){
  int n,m;
  cin >> n >> m;
  vector<int>d(m),dp(n+1,INF);
  for(int i=0;i<m;i++)cin >> d[i];
  
  dp[0]=0;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      if(j+d[i]<=n)dp[j+d[i]]=min(dp[j+d[i]],dp[j]+1);

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

Measured memory_bytes: 1284
#include <iostream>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
int N,X,Y;
vector<int> A;

int nlen(int, int);

int main()
{
  int i,j;
  int ml;
  int len;

  cin >> N >> X >> Y;

  A.resize(N+1);
  for (i=1; i<N; i++) {
    for (j=i+1; j<=N; j++) {
      len = nlen(i, j);
//printf("nlen(%d, %d) = %d ", i, j, len);
      A[len] = A[len]+1;
//printf("/ A[%d] = %d\n", len, A[len]);
    }
  }
  for (i=1; i<N; i++) {
    printf("%d\n", A[i]);
  }

  return 0;
}
int nlen(int i, int j){
  if (i<=X) {
    if (j<= (X+Y)/2) return j-i;
    if (j<Y) return X-i+1+Y-j;
//    if (j>=Y) {}
    return j-i-(Y-X-1);
  }
  if (i<(X+Y)/2) {
    if (j<Y) return min(j-i, i-X+1+Y-j);
    return i-X+1+j-Y;
  }
//  if (i>=(X+Y)/2) {  }
  return j-i;
}
/*
  1=2=3=..=X=..=Y=..=N

  1=2=3=4=5=6=7
      +=======+
  */


Measured memory_bytes: 256
data = input()
num = int(input())

cnt = 0
for lop in range(len(data)):
    if int(data[lop]) == 1:
        cnt = cnt + 1
        if num == cnt:
            print(data[lop])
            break
    else :    
        cnt = cnt + (int(data[lop])*1000000000000000000)**5
        if cnt > num:
            print(data[lop])
            break

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int N, P;
vector<int> A;
int f() {
    int ret = 0;
    rep(S, 1 << N) {
        int s = 0;
        rep(i, N) if (S >> i & 1) s += A[i];
        if (P == s % 2) ret++;
    }
    return ret;
}
int main() {
    cin >> N >> P;
    A.resize(N);
    rep(i, N) cin >> A[i];
    int cnt[2] = {};
    rep(i, N) cnt[A[i] % 2]++;
    // cout << f() << endl;
    long long ans = 0;
    long long c;
    if (P == 0) {
        c = cnt[0];
        if(cnt[1]) c += cnt[1] - 1;
    } else {
        if (cnt[1] == 0) {
            cout << "0" << endl;
            return 0;
        }
        c = cnt[0];
        if(cnt[1]) c += cnt[1] - 1;
        // if (cnt[1] % 2 == 0) c--;
    }
    ans += 1LL << c;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      int a,b,c;
      cin>>a>>b>>c;
      if(a==100||b==100||c==100)cout<<'A'<<endl;
      else if(a+b>=180)cout<<'A'<<endl;
      else if(a+b+c>=240)cout<<'A'<<endl;
      else if(a+b+c>=210)cout<<'B'<<endl;
      else if(a+b+c>=150&&(a>=80||b>=80))cout<<'B'<<endl;
      else cout<<'C'<<endl;
    }
  }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    if(r < 1200){
        cout << "ABC" << endl;
    }
    else if(r < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
class Main{
    public static void main(String[] a){
		output();
    }
    
    private static void output() {
    	for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
    }
    
}

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

int main() {
  int N;
  cin >> N;
  int a,b,c,d;
  a = N / 1000;
  N = N - a * 1000;
  b = N / 100;
  N = N - b * 100;
  c = N / 10;
  d = N - c * 10;
  if ((a == b && b == c) || (b == c && c == d) ||(a == b && b == c && c == d)){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
N, X, M = map(int, input().split())
x = X
nums = []
isSearched = [False] * (M+1)
isSearchedNums = [-1] * (M+1)
n = 0
looped = 0
while True:
    x = (x*x) % M
    if isSearched[x]:
        looped = isSearchedNums[x]
        break
    isSearched[x] = True
    isSearchedNums[x] = n
    nums.append(x)
    n+=1
if (isSearched[0]):
    ans = X
    for i in range(min((N-1), len(nums))):
        ans += nums[i]

    print(ans)
else:
    ans = X
    al = 0
    d = len(nums) - looped
    for i in range(looped, len(nums)):
        al += nums[i]
    if N - 1 > len(nums):
        N -= len(nums)
        ans += sum(nums)
        ans += al * ((N-1) // d)
        for i in range(looped, ((N-1) % d) + looped):
            ans += nums[i]
    else:
        for i in range(N - 1):
            ans += nums[i]

    print(ans)



Measured memory_bytes: 13972
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

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

	printf("%d %d %lf\n", a/b, a%b, (double)a/b);



	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int64_t N, P;
    cin >> N >> P;

    vector<int64_t> v;
    map<int64_t, int64_t> m;
    int64_t i;

    if (N == 1) {
        // do nothing
    } else {
        for (i = 2; i * i <= P; i++) {
             while (P % i == 0) {
                m[i] += 1;
                v.push_back(i); 
                P /= i;
             }
        }
    }

    if (P != 1) {
        v.push_back(P);
        m[P] += 1;
    }

    int64_t ans = 1;
    for (auto p: m) {
        if (p.second < N) {
            continue;
        } else {
            ans *= static_cast<int64_t>(pow(p.first, (p.second / N)));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  /*
  int K,A,B; cin >> K >> A >> B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  */
  int X; cin >> X;
  int mon=100;
  int y=0;
  while(mon<X){
    mon=mon+mon/100;
    y++;
  }
  cout << y << endl;
  return 0;
}


Measured memory_bytes: 3652
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll K;
// string S = "";

int main() {
	scanf("%lld", &N);
	// cin >> S;
	scanf("%lld", &K);
	if(N >= 1 && N <= 9 && K >= 1 && K <= 9) {
		printf("%lld\n", N * K);
	}
	else {
		printf("-1\n");
	}

	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
N,M,Q = map(int,input().split())
m = [[0 for i in range(N+1)] for i in range(N+1)]
for i in range(M):
  l,r = map(int,input().split())
  m[l][r] += 1
for i in range(N+1):
  for j in range(N):
    m[i][j+1] += m[i][j]
for i in range(N):
  for j in range(N+1):
    m[i+1][j] += m[i][j]    

p = [0]
q = [0]
for i in range(Q):
  a,b = map(int,input().split())
  p.append(a)
  q.append(b)


for i in range(1,Q+1):
  print(m[q[i]][q[i]]+m[p[i]-1][p[i]-1]-m[q[i]][p[i]-1]-m[p[i]-1][q[i]])


Measured memory_bytes: 18420
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); 
int main() {
	ios;
	string s;
	cin>>s;
	int l=s.length();
	while(l--) cout<<"x";
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(LL, n);
	n--;
	LL s = 0, e = 26, d = 0;
	inc1(i, 100) {
		if(n < s + e) { d = i; break; }
		s += e;
		e *= 26;
	}
	n -= s;
	
	string ans;
	inc(i, d) {
		ans += 'a' + (n % 26);
		n /= 26;
	}
	reverse(ALL(ans));
	OUT(ans);
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
// #define a first
// #define b second

const int N = 100010;
int n, x;
vi arr(105);
int dp[N][2];


int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);	
    
    cin >> n >> x;
    forn(i, n)
        cin >> arr[i];
    dp[0][0] = 1;
    dp[0][1] = 0;

    rep(i, 1, x + 1)
        forn(j, 2){
            dp[i][j] = !j;
            forn(k, n){
                if(i - arr[k] >= 0){
                    if(dp[i - arr[k]][!j] == j){
                        dp[i][j] = j;
                        break;
                    }
                }
            }
        }

    if(dp[x][0] == 0)
        cout << "First\n";
    else cout << "Second\n";



    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int an1 = 0, an2 = 0, n = s.size();
    char ch1, ch2;
    for (int i = 0; i < n; ++i) {
        if (i & 1) {
            ch1 = '0';
            ch2 = '1';
        } else {
            ch1 = '1';
            ch2 = '0';
        }
        if (s[i] != ch1) an1++;
        if (s[i] != ch2) an2++;
    }
    cout << min(an1, an2) << endl;
    return 0;
}


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

struct point { int x; int y; ll h; };

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vector<point> points(N);
  point ph;
  rep(i, N) {
    int x, y; ll h;
    cin >> x >> y >> h;
    points[i] = {x, y, h};
    //最初のheight決める用の数
    if(h >= 1) {
      ph = {x, y, h};
    }
  }
  
  //100^2を全探索
  for(int x=0; x<=100; x++) {
    for(int y=0; y<=100; y++) {
      bool ng = false;
      ll hh = ph.h + (ll)abs(x - ph.x) + (ll)abs(y - ph.y);
      for(int i=0; i<N; i++) {
        ll chpos = max(hh - (ll)abs(x - points[i].x) - (ll)abs(y - points[i].y), 0LL);
        if(chpos != points[i].h) {
          ng = true;
          break;
        }
      }
      if(!ng) {
        cout << x << " " << y << " " << hh << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    let mut cnt = 0;
    loop {
        for i in 0..a.len() {
            if a[i] % 2 == 0 {
                a[i] = a[i] / 2;
            } else {
                println!("{}", cnt);
                return;
            }
        }
        cnt += 1;
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
       int ext = 0;
        if((n - 1) % (k - 1) != 0)
             ext = 1;
	cout <<  (n - 1) / (k - 1) + ext;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
int main(){
    //x+y=a
    //2x+4y=b
    int a,b;
    while (scanf("%d %d",&a,&b)!=EOF) {
        if (b<2*a)
            printf("No\n");
        else {
            if ((b-2*a)%2)
                printf("No\n");
            else
            {
                int y = (b-2*a)/2;
                int x = a-y;
                if (x>=0&&y>=0)
                    printf("Yes\n");
                else
                    printf("No\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3168
// 6/23 解き直し
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    // mint sum = 0;
    // ll xsum;

    // // rep(i, N) sum += A[i];
    // // sum = sum * (N - 1) / 2;

    // xsum = A[0] ^ A[1];
    // sum = xsum;

    // for (int i = 2; i < N; i++) {
    //     sum = xsum + A[i];
    //     xsum ^= A[i];
    // }

    // cout << sum << endl;

    ll ans = 0;

    rep(i, 60) {
        ll x = 0;
        rep(j, N) if (A[j]>>i&1) ++x;
        ll now = x * (N - x) % mod;
        rep(j, i) now = now * 2 % mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll H, W, N;
    cin >> H >> W >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> C;
    rep(i, N) rep(j, A[i]) C.pb(i + 1);

    rep(i, H){
        if(i % 2 == 0) for (ll j = 0; j < W; ++j) cout << C[i*W+j] << " ";
        else for (ll j = W - 1; j >= 0; --j) cout << C[i*W+j] << " ";
        print("");
    }

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t1,t2,tt1,tt2;
  int kt[n+1];
  int kkt[n];
  int j=1,count=-1;
  int jb[n+1];
  /*int siran;
  siran = n*(n-1)/2;
  cout << siran << endl;*/
  for(int i=0;i<=n;i++) kt[i] = 0;
  for(int i=0;i<n*(n-1)/2;i++){
    cin >> t1 >> t2 >> tt1 >> tt2;
    if(tt1>tt2) kt[t1] += 3;
    else if(tt2>tt1) kt[t2] += 3;
    else{
      kt[t1] += 1;
      kt[t2] += 1;
    }
  }
  //for(int i=1;i<=n;i++) cout << kt[i] << endl; 
  for(int i=1;i<=n;i++) kkt[i-1] = kt[i];
  sort(kkt,kkt+n,greater<int>());
  for(int i=0;i<n;i++){
    for(int g=1;g<=n;g++){
      if(kkt[i]==kt[g]){
	jb[g] = j;
	count++;
      }
    }
    j += (count+1);
    i += count; 
    count = -1;
  }
  for(int i=1;i<=n;i++) cout << jb[i] << endl;
  return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int N, T;
    cin >> N >> T;
    int ans = INF;
    for(int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if(T >= t){
            ans = min(ans, c);
        }
    }
    if(ans == INF){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def input_preprocessing():
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    return a, op, b

a = 0
op = ''
b = 0
dataset = []
while op != '?':
    a, op, b = input_preprocessing()
    dataset.append([a, op, b])

def calc(a, op, b):
    if op == '?': return
    elif op == '+': return print(a+b)
    elif op == '-': return print(a-b)
    elif op == '*': return print(a*b)
    elif op == '/': return print(a//b)
    return

for data in dataset:
    calc(data[0], data[1], data[2])


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y):x(x),y(y){}
  Point operator+(Point p) {return Point(x+p.x,y+p.y);}
  Point operator-(Point p) {return Point(x-p.x,y-p.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}
  
};
typedef Point Vector;
typedef vector<Point> Polygon;
struct Segment{
  Point p1,p2;
  Segment(){}
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};

typedef Segment Line;

double norm(Vector a){
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
  return sqrt(norm(a));
}

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

double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1) < 0.0) return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2) < 0.0) return abs(p-s.p2);
  return getDistanceLP(s,p);
}



signed main(){
  int n,m,x,y;
  cin>>n>>m;
  n++;
  Polygon p(n);
  for(int i=0;i<n;i++) cin>>p[i].x>>p[i].y;
  bool used[n];
  memset(used,0,sizeof(used));
  used[0]=1;
  double dist[n];
  for(int j=0;j<n;j++)
    dist[j]=abs(p[j]-p[0]);
  double ans=0;
  for(int i=0;i<m;i++){
    int tmp=-1;
    for(int j=0;j<n;j++){
      if(used[j]) continue;
      if(tmp<0||dist[j]<dist[tmp]) tmp=j;
    }
    int par=0;
    for(int j=0;j<n;j++){
      if(!used[j]) continue;
      if(abs(p[j]-p[tmp])<abs(p[par]-p[tmp])) par=j;
    }
    //cout<<tmp<<" "<<par<<endl;
    used[tmp]=1;
    ans+=abs(p[par]-p[tmp]);
    Segment s=Segment(p[par],p[tmp]);
    for(int j=0;j<n;j++){
      if(used[j]) continue;
      dist[j]=min(dist[j],getDistanceSP(s,p[j]));
    }
  }
  printf("%.12f\n",ans);
  return 0;
}

Measured memory_bytes: 3340
l = []
num = []

for i in range(5):
    menu = int(input())
    if menu%10 != 0:
        num.append(menu%10)
        menu = (menu//10+1)*10
    l.append(menu)

ans = sum(l)

if num:
    ans -= 10-min(num)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main () {
    int N;
    cin >> N;
    vector <float> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());

    for (int i = 0; i < N-1; i++) v[i+1] = (v[i]+v[i+1]) / 2;
    cout << v[N-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		String s = sc.next();
		int k  = sc.nextInt();
		
		LinkedList<String> res = new LinkedList<String>();
		res.add(Character.valueOf((char)('z'+1))+"");
		res.add(Character.valueOf((char)('z'+1))+"");
		res.add(Character.valueOf((char)('z'+1))+"");
		res.add(Character.valueOf((char)('z'+1))+"");
		res.add(Character.valueOf((char)('z'+1))+"");

		for(int i = 0 ; i < s.length(); i++){
			
			for(int j = i; j < i+5 && j < s.length(); j++){
				
				String str = s.substring(i, j+1);
				
				int p = Collections.binarySearch(res, str);
					
				if(p >= 0 ){
					continue;
				}
				
				int ins = -p-1;
				res.add(ins,str);
				res.removeLast();
			}
		}
		
		System.out.println(res.get(k-1));
	}
}


Measured memory_bytes: 26700