akhauriyash/Code-Regression huggingface dataset:
tgtstr = list(raw_input())
n = int(raw_input())

for i in range(n):
    cmd_list = raw_input().split(" ")
    if cmd_list[0] == "replace":
        for idx in range(int(cmd_list[1]), int(cmd_list[2])+1):
            tgtstr[idx] = cmd_list[3][idx - int(cmd_list[1])]
    elif cmd_list[0] == "reverse":
        start = int(cmd_list[1])
        end = int(cmd_list[2])
        while True:
            
            tmp = str(tgtstr[start])
            tgtstr[start] = str(tgtstr[end])
            tgtstr[end] = tmp
            start += 1
            end -= 1
            if start >= end:
                break

    elif cmd_list[0] == "print":
        print "".join(tgtstr[int(cmd_list[1]):int(cmd_list[2])+1])

Measured memory_bytes: 4284
#include <iostream>
using namespace std;
#define LL long long

#include <algorithm>
#include <vector>
void _150() {
    LL n;
    cin >> n;

    // int p[8];
    // int q[8];
    int temp;
    vector<int> p, q;
    vector<int> perm_base;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        p.push_back(temp);
        perm_base.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        q.push_back(temp);
    }

    LL a, b, index;
    a = -1;
    b = -1;
    index = 0;
    do {
        if (perm_base == p) {
            a = index;
        }

        if (perm_base == q) {
            b = index;
        }

        if (a != -1 && b != -1) {
            break;
        }

        index++;
    } while (next_permutation(perm_base.begin(), perm_base.end()));

    cout << abs(a - b) << endl;
}

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



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    cout << n / 2 + n % 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    int d = a[n-1] - a[0];
    if (d >= 2) {
        puts("No");
        return 0;
    }
    if (d == 0) {
        if (a[0] == n-1 || 2 * a[0] <= n) {
            puts("Yes");
        } else {
            puts("No");
        }
    } else {
        int p = lower_bound(all(a), a[0]+1) - a.begin();
        int q = n - p;
        int v = a[n-1];
        int mx = p + q/2;
        if (p+1 <= v && v <= mx) puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 3704
#include<stdio.h>
int main (void)
{
    int a,tate=0,yoko=0,i,j;
    while(1){
        scanf("%d %d",&tate,&yoko);
        if(tate==0&&yoko==0)
        {
            break;
        }
        for(i=0;i<tate;i++)
        {
            for(j=0;j<yoko;j++)
         {
             if(i==0||i==tate-1)
              printf("#");
            else if(j==0||j==yoko-1)
              printf("#");
              else
              {
                  printf(".");
              }
              
            
         }

            printf("\n");
        }
        printf("\n");
    }

    return 0;
    
}


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


int main(){
    ll x;   cin >> x;
    ll needs = (x%100)/5+min((x%100)%5, 1LL);

    int ans=1;
    if(x/100<needs) ans = 0;
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
import numpy as np
#======================================================#
MOD=10**9+7
def main():
    n = II()
    aa = np.array(MII(), dtype='uint64')
    ans = 0
    for i in range(60):
        cnt1 = (aa&1).sum()
        ans += (cnt1*(n-cnt1))%MOD*(2**i)%MOD
        aa >>= 1
    print(int(ans%MOD))

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int K, X;
  CIN(K >> X);

  int r = K * 500;
  if (X <= r) {
    COUT("Yes");
  } else {

    COUT("No");
  }

  return 0;
}


Measured memory_bytes: 384
while line = gets
  n, m = line.chomp.split.map(&:to_i)
  break if n == 0 && m == 0

  a = [*1..n]
  index = m - 1

  while a.size > 1
    a.delete_at(index)
    index = (index + m - 1) % a.size
  end

  puts a.first
end

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

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

    if (n == 0) ans = "0";
    while (n != 0) {
        int s = abs(n % 2);
        ans = to_string(s) + ans;
        n -= s;
        n /= -2;
    }

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

Measured memory_bytes: 256
N=int(input())
LV=list(map(int,input().split()))
LC=list(map(int,input().split()))
Lbenefit=[]
ans=0

for i in range(N):
    Lbenefit.append(LV[i]-LC[i])
Lbenefit.sort(reverse=True)

for b in Lbenefit:
    if b>=0:
        ans+=b
    else:
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>
#include <fstream>


int main() {
	int n, a, b; std::cin >> n >> a >> b;
	std::cout << std::min(a * n, b) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>

using namespace std;

int N;
int A, B, C;
int min_mp;

int calc(vector<int> s, int l[]) {
  // 0 -> Aの材料
  // 1 -> Bの材料
  // 2 -> Cの材料
  // 3 -> 使わない

  int mp = 0;
  int la = 0;
  int lb = 0;
  int lc = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 0) {
      if (la != 0) {
        mp += 10;
      }
      la += l[i];
    }
    else if (s[i] == 1) {
      if (lb != 0) {
        mp += 10;
      }
      lb += l[i];
    }
    else if (s[i] == 2) {
      if (lc != 0) {
        mp += 10;
      }
      lc += l[i];
    }
  }

  // A, B, Cに少なくとも一本は割り当てる必要がある
  if (la == 0 || lb == 0 || lc == 0) {
    return INT_MAX;
  }

  // A
  mp += abs(la - A);
  // B
  mp += abs(lb - B);
  // C
  mp += abs(lc - C);

  return mp;
}

void dfs(int depth, vector<int> s, int l[]) {
  if (depth == N) {
    min_mp = min(min_mp, calc(s, l));
    return;
  }

  for (int i = 0; i < 4; i++) {
    s[depth] = i;
    dfs(depth + 1, s, l);
  }
}

int main() {
  cin >> N >> A >> B >> C;

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

  vector<int> state(N);
  min_mp = INT_MAX;

  dfs(0, state, l);

  cout << min_mp << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline, to_string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap, pair
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow, sin
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd, accumlate
#include <deque>	//deque
#include <random>	//randam_device

using namespace std;

int main() {

	int a, p;
	cin >> a >> p;

	int ans = (a * 3 + p) / 2;

	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b, c; cin >> a >> b >> c;
    if (a == b && b == c) cout << "No\n";
    else if (a == b || b == c || a == c) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }




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

    if(n%2==1) {
        cout << "No" << endl;
        return 0;
    }
    else{
      FOR(i,0,n/2-1){
        if(s[i]!=s[i+n/2]){
            cout << "No" << endl;
            return 0;
        }
      }
    }

    cout << "Yes" << endl;
}



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

vector<int> graph[200005];
vector<int> d(200005,-1);
int n, m;

int main() {
    cin >> n >> m;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<int> que;
    que.push(0);
    d[0] = 0;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        
        for (int u : graph[v]) {
            if (d[u] != -1) continue;
            d[u] = v;
            que.push(u);
        }
    }
    bool flag = true;
    rep(i,n) {
        if (d[i] == -1) {
            flag = false;
            break;
        }
    }
    if (flag) {
        printf("%s\n","Yes");
        for (int i = 1; i < n; ++i) {
            printf("%d\n",d[i]+1);
        }
    } else {
        printf("%s\n","No");
    }
    return 0;
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=1e3+100,inf=1e18,LOG=23,mod=1e9 + 7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int n, have[1010][1010], uk[maxn], a[maxn][maxn], ans, res;

vector <pii> edge, nw;

main()
{
	cin >> n;
	forn(1, i, n)
	{
		forn(1, j, n - 1)
		{
			cin >> a[i][j];
		}
		uk[i] = 1;
		have[i][a[i][1]] = 1;
		if(have[a[i][1]][i] == 1)
		{
			edge.pb(mp(a[i][1], i));
		}
	}
	if(!edge.size())
	{
		cout << -1;
		return 0;
	}
	while(edge.size())
	{
//		cout << "NOW\n";
		FOR(0, i, edge.size())
		{
			int l = edge[i].f;
			int r = edge[i].s;
			res++;
//			cout << l << " " << r << endl;
			have[l][r] = 0;
			have[r][l] = 0;
			uk[l]++;
			uk[r]++;
			have[l][a[l][uk[l]]] = 1;
			if(have[a[l][uk[l]]][l])
			{
				nw.pb(mp(a[l][uk[l]], l));
			}
			have[r][a[r][uk[r]]] = 1;
			if(have[a[r][uk[r]]][r])
			{
				nw.pb(mp(a[r][uk[r]], r));
			}
		}
/*		forn(1, i, n)
		{
			forn(1, j, n)
			{
				cout << have[i][j] << " ";
			}
			cout << endl;
		}*/
		edge = nw;
		nw.clear();
		ans++;
	}
	if(res != n * (n - 1) / 2)
	{
		cout << -1;
	}
	else
	cout << ans;
}

Measured memory_bytes: 17664
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

const int mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  if(N%2) {
    for(int i = 2; i < N; i += 2) {
      if(A[i] != A[i-1] || A[i] != i) {
        cout << 0 << endl;
        return 0;
      }
    }
  } else {
    for(int i = 1; i < N; i += 2) {
      if(A[i] != A[i-1] || A[i] != i) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  ll ans = 1;
  rep(i, N/2)
    ans = ans*2%mod;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
int main()
{
    long n;
    std::cin>>n;
    long double check=1;
    long double a;
    long long ans=1;
    for(int i=0;i<n;i++){
        std::cin>>a;
        ans*=a;
        check*=a;
    } 
    if(check>1000000000000000000){
        std::cout<<"-1"<<std::endl;
    }
    else{
        std::cout<<ans<<std::endl;
    }
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<vector<ll>> a(n, vector<ll>(n));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  int ok = 1;
  for (int i = 0; i < n; i++){
    if (a[i][i] != 0)
      ok = 0;
    for (int j = i + 1; j < n; j++){
      if (a[i][j] != a[j][i])
        ok = 0;
    }
  }

  ll res = 0;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      int tok = 1;
      for (int k = 0; k < n; k++){
        if (k != i && k != j && a[i][j] == a[i][k] + a[k][j])
          tok = 0;
        else if (a[i][j] > a[i][k] + a[k][j])
          ok = 0;
      }
      if (tok){
        res += a[i][j];
      }
    }
  }

  if (ok){
    cout << res << endl;
  }
  else {
    cout << -1 << endl;
  }

  return 0;
}


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

int a, b;
long long dp[101][2], ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> a >> b;
	dp[1][0] = 0;
	dp[1][1] = 1;
	dp[b][1] = 1;
	for(int i=2; i<=a; ++i){
		dp[i][0] += dp[i-1][1];
		dp[i][1] += dp[i-1][0] + (i-b >= 1 ? dp[i-b][0] : 0);
	}
//	for(int i=1; i<=a; ++i)
//		cout << dp[i][0] << " " << dp[i][1] << "\n";
	for(int i=1; i<=a; ++i) ans += dp[i][1];
	cout << ans << "\n";
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<iomanip> 
#include<cmath>
using namespace std;
int main()
{
	int a, b, c;
	while (cin >> a >> b >> c)
	{
		if ((a + b) >= c) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL Q;
LL L[100000],R[100000];

vector<LL> ans;

bool is_prime(LL x){
	if(x==1) return false;
	if(x==2) return true;
	for(int i=2;i*i<=x;i++){
		if(x%i==0) return false;
	}
	return true;
}

void solve(){
	//1~iまでの数のうち、2017に似た数値の個数をaccum[i]とおく
	//ただしaccum[0] = 0と決める
	vector<LL> accum(100001,0);
	for(int i=1;i<=100000;i++){
		accum[i] = accum[i-1] + (is_prime(i)&&is_prime((i+1)/2));
	}
	for(int i=0;i<Q;i++){
		ans.push_back(accum[R[i]]-accum[L[i]-1]);
	}
}
 
int main(){
    cin >> Q;
    for(int i=0;i<Q;i++) cin >> L[i] >> R[i];
 
    solve();

    for(int i=0;i<Q;i++) cout << ans[i] << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define remove pop
#define all(x) x.begin(), x.end()

int values[MAXN];

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> values[i];
	}

	sort(values, values + n);


	ll answer = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int a = values[i];
			int b = values[j];

			//binary search

			int start = j + 1;
			int end = n - 1;

			while (start <= end) {
				int mid = (start + end) / 2;

				if (values[mid] >= a + b) {
					end = mid - 1;
				} else {
					start = mid + 1;
				}
			}

			int got = max(0, end - j);

			answer += got;
		}
	}

	cout << answer << endl;
}

//GCD GCD GCD USE GCD IN MATH


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
char c[yuzu|10];
int main(){
scanf("%s",c+1);
int i,n=strlen(c+1),llx=n;
for (i=1;i<n;++i) if (c[i]^c[i+1]) llx=min(llx,max(i,n-i));
write(llx);
}

Measured memory_bytes: 384
/**
*    author:  musasi
*    created: 27.04.2020 09:43:47
**/

#include <bits/stdc++.h>

using namespace std;
#define rep2(x,from,to) for(long long (x)=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
#define ASSERT(expr...) assert((expr))
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 (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<ll,P > PP;
typedef pair<ll,PP > PPP;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
map<string, int> mp;
signed main() {
   cin.tie(0);
   
   ios_base::sync_with_stdio(false);
   string s;
   int n;cin>>n;
   int ans=0;
   rep(i,n)
   {
       cin>>s;
       mp[s]++;
       if(mp[s]==1)ans++;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 19192
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/21
// =====================================================
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<vi> vvi;

#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) { return b ? "true" : "false"; }
str ts(vector<bool> v) { str res; F0R(i,sz(v)) res += char('0'+v[i]); return res; }
template<size_t SZ> str ts(bitset<SZ> b) { str res; F0R(i,SZ) res += char('0'+b[i]); return res; }

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

const ll MOD = 1e9+7; // 998244353;
const int MX = 3e5+5;

void solve() {
    int N, X, T;
    cin >> N >> X >> T;
    cout << ((N-1)/X+1) * T << endl;

}


int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 3648
# 最大公約数を求める
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

n=int(input())
a_array=[int(a) for a in input().split()]

# 累積GCDの計算(A1, A2, ... Ai-1の最大公約数)
left_gcd=[a_array[0]] # 
a=a_array[0] # 最初のループはgcd(a_array[0], a_array[1])になる
for i in range(1, n-1):
    a=gcd(a,a_array[i])
    left_gcd.append(a)

# 累積GCDの計算(Ai, Ai+1, ... ANの最大公約数)
right_gcd=[a_array[-1]]
b=a_array[-1] # 最初のループはgcd(a_array[-1], a_array[-2])になる
for i in range(n-2,0,-1):
    b=gcd(b,a_array[i])
    right_gcd.append(b)

# i番目の数値以外の最大公約数を格納
ans_gcd=[right_gcd[n-2],left_gcd[n-2]]

for i in range(n-2):
    ans_gcd.append(gcd(left_gcd[i],right_gcd[n-i-3]))

print(max(ans_gcd))


Measured memory_bytes: 14076
import random
import numpy as np
import sys
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
    temp = list(map(int, input().split()))
    s.append(temp)
s = np.array(s)
c = np.array(c)
#print(s)
#with open('output.txt', 'w') as f:
'''dice = list(range(26))
w = list(map(lambda x: x*x, c))
samples = random.choices(dice, k=d, weights=w)
for one in samples:
    print(one+1, file=f)'''
def p(text):
    print(text)

with open('output.txt', 'w') as f:
    for i in range(d):
        if max(s[i])>17000:
            if random.random()>0.2:
                #増やす
                p(s[i].argmax()+1)
            else:
                #ランダム
                p(int(random.random()*26+1))
        else:
            #減少を抑える
            dice = list(range(26))
            w = c**3
            samples = random.choices(dice, k=1, weights=w)
            for one in samples:
                p(one+1)
            #print(c.argmax()+1, file=f)

Measured memory_bytes: 27388
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <complex>
#include <functional>
#include <bitset>
#include <map>
#include <random>
#include <memory>
#include <map>
#include <valarray>
#include <iomanip>
#include <queue>

#include <cassert>
#include <ctime>
#include <cmath>
#include <cstdlib>

using namespace std;

const int inf = (int)1e9 + 7;

int main ()
{
    //freopen ("input.txt", "r", stdin);

    ios_base::sync_with_stdio (false);
    cin.tie (nullptr);

    int n;

    cin >> n;

    unordered_map<int, int> cand;

    cand.reserve (n);

    for (int i = 0; i < n; i++)
    {
        int t;

        cin >> t;

        cand[t]++;
    }

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int t;

        cin >> t;

        if (cand[t]-- == 0)
        {
            cout << "NO" << endl;

            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
using namespace std;
int main(){
  int n;
  int primes[2];
  int pizaKarori;
  int toppings[100];
  int masterK;
  int masterP;
  cin >> n;
  cin >> primes[0] ;
  cin >> primes[1] ;
  cin >> pizaKarori;
  masterK=pizaKarori;
  masterP=primes[0];
  for(int i=0;i<n;i++){
    cin >> toppings[i];
  }
  for(int j=0;j<n+1;j++){
 for(int i=0;i<n-1;i++){
      if(toppings[i]<toppings[i+1]){
	int c;
	c=toppings[i];
	toppings[i]=toppings[i+1];
	toppings[i+1]=c;
      }
 
 }
      }

  for(int i=0;i<n;i++){
    if(masterK/masterP <= (masterK+toppings[i])/(masterP+primes[1])){
      masterK+=toppings[i];
      masterP+=primes[1];

    }
  }
  cout << masterK / masterP <<endl;
  return 0;
}

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

struct card{char suit; int value;};
struct card C1[40];
struct card C2[40];

void buble_sort(card A[], int N)
{
	for(int i = N-1; i >= 0; i--)
	{
		for(int j = 1; j <= i; j++)
		{
			if(A[j].value < A[j-1].value)
				swap(A[j], A[j-1]);
		}
	}
}

void selection_sort(card A[], int N)
{
	int min;
	for(int i = 0; i < N; i++)
	{
		min = i;
		for(int j = i+1; j < N; j++)
		{
			if(A[j].value < A[min].value)
				min = j;
		}
		swap(A[i], A[min]);
	}
}

void print(card A[], int N)
{
	for(int i = 0; i < N; i++)
	{
		if(i)
			cout << " "; 
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool istable(card A[], card B[], int N)
{
	for(int i = 0; i < N; i++)
	{
		if(A[i].suit != B[i].suit)
			return false;
	}
	return true;
}

int main ()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> C1[i].suit >> C1[i].value;
		C2[i].suit = C1[i].suit;
		C2[i].value = C1[i].value;
	}
	buble_sort(C1, n);
	print(C1, n);
	cout << "Stable" << endl;
	selection_sort(C2, n);
	print(C2, n);
	if(istable(C1, C2, n))
		cout << "Stable" << endl;
	else 
		cout << "Not stable" << endl;
	return 0;
}


Measured memory_bytes: 3108
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;



use std::ops::{ Add, Sub , Div , Mul };




fn main() {

    input! { 
       n: usize,
       a: [usize;n],
       b: [i32;n],
       c: [i32;(n-1)],
    }

    
    let mut ans =b[a[0]-1];
    
    for i in 1..n{
        ans += b[a[i]-1];
        if(a[i-1]-1 +1 == a[i]-1){
            ans += c[a[i-1]-1];
            
        }

    }
    
    println!("{}",ans);


}


Measured memory_bytes: 4352
import java.util.*;

public class Main  {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a = new long[3 * N];
		for (int i = 0; i < 3 * N; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		long sum = 0;
		for (int i = N; i < 3 * N; i += 2) {
			sum += a[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 97744
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) cout << "infinity\n";
    else {
        if (t1 * a1 <= t1 * b1 && t2 * a2 <= t2 * b2) cout << 0 << '\n';
        else if (t1 * a1 >= t1 * b1 && t2 * a2 >= t2 * b2) cout << 0 << '\n';
        else if (t1 * a1 + t2 * a2 <= t1 * b1 + t2 * b2) {
            if (t1 * a1 < t1 * b1) cout << 0 << '\n';
            else {  // t1 * a1 > t1 * b1
                ll diff = t1 * b1 + t2 * b2 - t1 * a1 - t2 * a2;
                ll pred = t1 * a1 - t1 * b1;
                ll ans = pred / diff;
                if (2 * t1 * a1 + t2 * a2 >= 2 * t1 * b1 + t2 * b2) ans *= 2;
                if (pred % diff != 0) ans++;
                cout << ans << '\n';
            }
        } else {  // t1 * a1 + t2 * a2 >= t1 * b1 + t2 * b2
            if (t1 * a1 > t1 * b1) cout << 0 << '\n';
            else { // t1 * a1 < t1 * b1
                ll diff = t1 * a1 + t2 * a2 - t1 * b1 - t2 * b2;
                ll pred = t1 * b1 - t1 * a1;
                ll ans = pred / diff;
                if (2 * t1 * b1 + t2 * b2 >= 2 * t1 * a1 + t2 * a2) ans *= 2;
                if (pred % diff != 0) ans++;
                cout << ans << '\n';
            }
        }
    } 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }

int main(){
    ll n, t;
    cin >> n >> t;
    ll dp[n + 1][t][2];
    memset(dp, 0x00, sizeof(dp));
    for(ll i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        for(ll j = 0; j < t; j++){
            dp[i + 1][j][0] = dp[i][j][0];
            dp[i + 1][j][1] = max(dp[i][j][1], dp[i][j][0] + b);
            if(j >= a) chmax(dp[i + 1][j][0], dp[i][j - a][0] + b);
            if(j >= a) chmax(dp[i + 1][j][1], dp[i][j - a][1] + b);
        }
    }
    cout << max(dp[n][t - 1][0], dp[n][t - 1][1]) << endl;
}


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

int main() {
  string S;
  cin >> S;
    if(S.substr(S.size()-7,7)=="keyence") cout << "YES" << endl;
    else if(S.substr(0,1)=="k" && S.substr(S.size()-6,6)=="eyence") cout << "YES" << endl;
    else if(S.substr(0,2)=="ke" && S.substr(S.size()-5,5)=="yence") cout << "YES" << endl;
    else if(S.substr(0,3)=="key" && S.substr(S.size()-4,4)=="ence") cout << "YES" << endl;
    else if(S.substr(0,4)=="keye" && S.substr(S.size()-3,3)=="nce") cout << "YES" << endl;
    else if(S.substr(0,5)=="keyen" && S.substr(S.size()-2,2)=="ce") cout << "YES" << endl;
    else if(S.substr(0,6)=="keyenc" && S.substr(S.size()-1,1)=="e") cout << "YES" << endl;
    else if(S.substr(0,7)=="keyence") cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
using namespace std;
int main() {
    int a,b,c,k,cnt = 0;
    cin >> a >> b >> c >> k;
    while(a>=b) {
        cnt++;
        b *= 2;
    }
    while(b>=c) {
        cnt++;
        c *= 2;
    }
    cout << (cnt <= k ? "Yes" : "No");
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



void smain() {
    int n, p;
    cin >> n >> p;

    vl dp(2, 0);
    dp[0] = 1;
    fori (_, n) {
        int cur;
        cin >> cur;
        cur &= 1;
        vl old = dp;
        fori (z, 2) {
            dp[z] += old[z ^ cur];
        }
    }
    cout << dp[p];
}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	std::string str;
	cin >> str;
	cout << (str[0] == str[1] && str[1] == str[2] ? "No" : "Yes") << endl;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll K;
  cin >> K;
  if (K % 2 == 0) {
    PRINT(-1);
    return 0;
  }
  ll seven = 7;
  ll ans = 1;
  set<ll> se;
  se.insert(seven);
  while(!(seven % K == 0)) {
    seven *= 10;
    seven += 7;
    seven %= K;
    if (se.find(seven) != se.end()) {
      PRINT(-1);
      return 0;
    }
    se.insert(seven);
    ans++;
  }
  PRINT(ans);
  return 0;
} 


Measured memory_bytes: 50496
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll arr[n+1];
    for(ll i=1;i<=n;++i)
        cin>>arr[i];
    int ans[n+1];
    ans[1]=0;
    ans[2]=abs(arr[2]-arr[1]);
    for(ll i=3;i<=n;++i)
    {
        ans[i]=min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<ans[n];
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 100000;
ll mod = INF;

ll fac[maxn+1];
ll rfac[maxn+1];

//最小二乗法
ll pow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll a=pow(x,y/2);
        return (a*a)%mod;
    }else{
        ll a=pow(x,(y-1)/2);
        return a*a%mod*x%mod;
    }
}


int main(){
    ll ans=0;
    ll n;
    ll k;
    ll a[maxn+1];

    cin >> n>>k;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }

    sort(a+1,a+n+1);
    
    fac[0]=fac[1]=rfac[0]=rfac[1]=1;

    for(ll i=1;i<=maxn;i++){
        fac[i]=fac[i-1]*i%mod;
    }

    //逆元を求める
    rfac[maxn]=pow(fac[maxn],mod-2);
    
    for(ll i=maxn;i>=1;i--){
        rfac[i-1]=rfac[i]*i%mod;
    }
    
    if(k==1){
        ans=0;
    }else{
        for(int i=1;i<=n;i++){
            if(i<=n-k+1){
                // p= n-iCk-1
                ll p=fac[n-i]*rfac[k-1]%mod*rfac[n-i-k+1]%mod;
                p=p*a[i]%mod;
                ans-=p;
                while(ans<0)ans+=mod;
            }
            if(k<=i){
                // p= i-1Ck-1
                ll p=fac[i-1]*rfac[k-1]%mod*rfac[i-k]%mod;
                p=p*a[i]%mod;
                ans=(ans+p)%mod;
            }
        }
    }

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

Measured memory_bytes: 5952
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[3];
        for (int i = 0; i < 3; i++) {
            array[i] = sc.nextInt();
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (array[i] < array[j]) {
                    int a = array[i];
                    array[i] = array[j];
                    array[j] = a;
                }
            }
        }
        int a = array[0];
        int b = array[1];
        int c = array[2];
        int ans = 0;
        while (true) {
            if (a == b && b == c) {
                System.out.println(ans);
                break;
            } else if (a < b && b < c) {
                a++;
                b++;
                ans++;
            } else if (b == c) {
                if (a < b) {
                    a = a + 2;
                    ans++;
                } else {
                    b++;
                    c++;
                    ans++;
                }
            } else if (a == c) {
                if (b < a) {
                    b = b + 2;
                    ans++;
                } else {
                    a++;
                    c++;
                    ans++;
                }
            } else if (a == b) {
                if (c < a) {
                    c = c + 2;
                    ans++;
                } else {
                    a++;
                    b++;
                    ans++;
                }
            } else if (b < a && c < a) {
                b++;
                c++;
                ans++;
            } else if (a < b && c < b) {
                a++;
                b++;
                ans++;
            }
        }
        
    }
}


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

using namespace std;

const int INFTY = 0x3f3f3f3f;
const int MAXN = 100010;

int n,k;
int a[MAXN];

int solve(int a,int b)
{
    if(a<0&&b<0)return -a;
    if(a<0&&b>=0)return min(-a+b-a,b+b-a);
    if(a>=0)return b;
}

int main()
{
    std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=INFTY;
    for(int i=0;i<=n-k;i++)
        ans=min(ans,solve(a[i],a[i+k-1]));
    cout<<ans;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

const int MAX = 510000;
const int MOD = 1000000007;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int n,d,x ;
    cin >> n >> d >> x ;
    int a ;
    int ans = n + x ;
    for (int i = 0; i < n; i++)
    {
        cin >> a ;
        ans += (d-1)/a ;
    }
        
    cout << ans << endl ;
}

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

#include <iostream>
#include <fstream>

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

class APassword {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        out << n *n*n << endl;
	}
};


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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

typedef long long ll;

const ll INF = 1e9+7;

using namespace std;

int main(){
  int k,s;
  cin>>k>>s;
  int ans = 0;
  k++;
  rep(x,k){
  	rep(y,k){
      int tmp = s - (x + y);
      if(tmp > s || tmp < 0)break;
      if(tmp < k)ans++;
    }
  }
  print(ans)
  return 0;
}


Measured memory_bytes: 256