akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
int a[100010];
int n,cnt1,cnt2;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		cnt1 += a[i];
		if (i % 2)cnt2 += a[i];
	}
	int b = cnt1 - cnt2 * 2;
	cout << b << ' ';
	rep(i, n - 1) {
		cout << a[i] * 2 - b<<' ';
		b = a[i] * 2 - b;
	}
	cout << endl;
}

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

int main(){
  int N; cin >> N;
  vector<int> E(N+1,1);
  E[0]=0;
  E[1]=0;
  for(int i=0;i*i<=N;i++){
    if(E[i]==1){
      for(int j=2*i;j<=N;j+=i){
        E[j]=0;
      }
    }
  }
  vector<int> P={};
  for(int i=0;i<=N;i++){
    if(E[i]==1){
      P.push_back(i);
    }
  }
  vector<int> Q(P.size(),0);
  for(int i=2;i<=N;i++){
    int M=i;
    // prime factorization
    for(int j=0;j<P.size();j++){
      while(M%P[j]==0){
        Q[j] ++;
        M /= P[j];
      }
      if(M==1){
        break;
      }
    }
  }
  ll ans = 1;
  for(int j=0;j<P.size();j++){
    ans = (ans*(Q[j]+1))%1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
bool f[20010];
int main()
{
	int n=read();f[0]=1;
	for(int i=1;i<=n;i++){
		int x=read();
		for(int j=10000;j>=0;j--)f[j+x]|=f[j];
	}
	int ans=0;
	for(int i=10000;i>=0;i--)if(i%10!=0&&f[i]){ans=i;break;}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

#define iof freopen("input.txt","r", stdin) ;freopen("output.txt","w", stdout) ;
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define mod 1000000007
#define vec vector<long long>
#define pb push_back
#define ll  long long
#define f(b) for(int i=0;i<b;i++)
#define f2(b) for(int j=0;j<b;j++)
#define f3(b) for(int k=0;k<b;k++)
#define endl '\n'
#define pi pair<int,int>
#define INF 1000000000000000001

long long pow(long long x, long long y){ if (y == 0) return 1; else if (y % 2 == 0) return pow(x, y / 2) * pow(x, y / 2);else return x * pow(x, y / 2) * pow(x, y / 2);}
long long dig(long long n) {return floor(log10(n) + 1);}

int main()
{
	io
	#define int long long
    //int t; cin>>t; while(t--)
    {
        double a,b,c,x;

        cin>>a>>b>>c;

        x = ceil(a/b);

        int zx;

        zx = c * x;

        cout<<zx;
    }
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,m;
    cin>>n>>m;
    map<ll,ll> mp;
    REP(i,m){
        ll a,b;
        cin>>a>>b;
        mp[a]++;
        mp[b]++;
    }

    bool flag=true;
    for(auto i:mp){
        if(i.second%2) flag=false;
    }
    cout<<(flag?"YES":"NO")<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    char S[11], T[11], U[11];
    int A,B;
    scanf("%s",S);
    scanf("%s",T);
    scanf("%d %d",&A,&B);
    scanf("%s",U);
    if(strcmp(S,U) == 0)
        printf("%d %d\n",A-1,B);
    else
        printf("%d %d\n",A,B-1);
}


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

const int maxn = 2001;

typedef vector<int> vi;
typedef long long ll;

int main(){

    int n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    queue < pair<int,int> > q;
    int mat[n][m];
    memset(mat,0,sizeof(mat));
    int dist[n][m];
    memset(dist,-1,sizeof(dist));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]=='#'){
                q.push(make_pair(i,j));
                dist[i][j] = 0;
            }
        }
    }
    int r[4] = {0,0,-1,1};
    int c[4] = {1,-1,0,0};
    int ans;
    while(!q.empty()){
        pair<int,int> val = q.front();
        q.pop();
        if(mat[val.first][val.second]!=0) continue;
        mat[val.first][val.second] = 1;
        ans = dist[val.first][val.second];
        for(int i=0;i<4;i++){
            int nx = val.first+r[i];
            int ny = val.second+c[i];
            if(nx>=0&&nx<n&&ny>=0&&ny<m){
                if(dist[nx][ny]==-1){
                    dist[nx][ny] = dist[val.first][val.second]+1;
                    q.push(make_pair(nx,ny));
                }
            }
        }

    }
    cout<<ans;
    return 0;
}

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

using namespace std;

const int N = 1024;

long long a[N];
bool live[N];
bool used[N];

int bit[N];
int get(int x) {
  ++x;
  int r = 0;
  for (; x; x -= x & -x)
    r += bit[x];
  return r;
}
void upd(int x, int v) {
  ++x;
  for (; x < N; x += x&-x)
    bit[x] += v;
}
set<int> st;
void rem(int id) {
  st.erase(id);
  upd(id, -1);
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%lld", a+i);
  long long sum1 = 0, ma1 = -1e18, sum2 = 0, ma2 = -1e18;
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      if (a[i] > 0)
        sum1 += a[i];
      ma1 = max(ma1, a[i]);
    }
    else {
      if (a[i] > 0)
        sum2 += a[i];
      ma2 = max(ma2, a[i]);
    }
  }
  fill(live, live+n, 1);
  if (ma1 < 0) sum1 = ma1;
  if (ma2 < 0) sum2 = ma2;
  if (sum1 > sum2) {
    if (ma1 < 0) {
      for (int i = 0; i < n; ++i)
        if (a[i] == ma1) {
          used[i] = 1;
          break;
        }
    }
    else {
      for (int i = 1; i < n; i += 2)
        if (a[i] >= 0)
          used[i] = 1;
    }
  }
  else {
    if (ma2 < 0) {
      for (int i = 0; i < n; ++i)
        if (a[i] == ma2) {
          used[i] = 1;
          break;
        }
    }
    else {
      for (int i = 0; i < n; i += 2)
        if (a[i] >= 0)
          used[i] = 1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    if (used[i]) ans += a[i];
  for (int i = 0; i < n; ++i) {
    upd(i, 1);
    st.insert(i);
  }
  printf("%lld\n", ans);
  vector<int> op;
  while (st.size() > 1) {
    for (auto it = st.begin(); it != st.end(); ++it) {
      if (used[*it]) continue;
      auto nx = it;
      ++nx;
      bool del = 0;
      if (it == st.begin() || nx == st.end()) {
        del = 1;
      }
      else {
        auto pr = it; --pr;
        if (used[*pr] == used[*nx])
          del = 1;
      }
      if (del) {
        op.push_back(get(*it));
        if (nx != st.end()) {
          used[*it] = used[*nx];
          rem(*nx);
        }
        if (it != st.begin()) {
          auto pr = it; --pr;
          used[*it] = used[*pr];
          rem(*pr);
        }
        break;
      }
    }
  }
  printf("%d\n", op.size());
  for (int x : op)
    printf("%d\n", x);
  return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
double iPow(     // n乗の計算をする関数
    double base  // (base) の (power) 乗の近似値を求める
    ,
    int power  // べきは整数
) {
    double buff = 1;
    do {
        if (power & 1) buff *= base;
        power >>= 1;
        base *= base;
    } while (power);
    return buff;
}
double calcNthRoot(  // n乗根の計算をする関数
    double base      // (base) の (1/order) 乗の近似値を求める
    ,
    int order  //
    ,
    double PREC  // 収束の精度
) {
    double root = base, rootPrev;
    do {
        rootPrev = root;
        root = ((order - 1) * root) / order +
               base / (order * iPow(root, order - 1));
    } while ((rootPrev - root) / root > PREC);
    return root;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll x;
    cin >> x;
    rep3(i, -1e3, 1e3) {
        ll k = pow(i, 5);
        k += x;
        ll f = calcNthRoot(k, 5, 0);
        if (abs((pow(f, 5) - k)) ==0) {
            cout << (ll)f << " " << i << endl;
            return 0;
        }
    }
}


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

int main(int argc, char const *argv[]) {
    int N, min=0, max=0, sum=0;
    cin >> N;
    vector<int> weight(N);
    for (int i=0; i<N; i++) {
        cin >> weight.at(i);
        sum += weight.at(i); 
    }
    int diff = sum;

    for (int i=0; i<N; i++) {
        min += weight.at(i);
        max =  sum - min;
        if (abs(max - min) < diff) {
            diff = abs(max-min);
        }
    }

    cout << diff << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> data(120);

    int maximum = 0;
    int minimum = 1000000000;

    for(int i = 0 ; i < N ; ++i){
        cin >> data.at(i);
        maximum = max(data.at(i),maximum);
        minimum = min(data.at(i),minimum);
    }

    cout << maximum - minimum << endl;

}

Measured memory_bytes: 256
main = do
    n <- readLn
    putStr (show n ++ ": ")
    putStrLn $ unwords.map show.primeFactorize $ n
primeFactorize :: Integer -> [Integer]
primeFactorize n = pf n primes

pf :: Integer -> [Integer] -> [Integer]
pf n (x:xs)
  | x > n = []
  | isPrime n = [n]
  | modnx == 0 = x : pf divnx (x:xs)
  | otherwise = pf n xs
  where (divnx, modnx) = divMod n x

primes :: [Integer]
primes = 2 : filter isPrime [3,5..]

isPrime :: Integer -> Bool
isPrime n = all (/= 0).map (mod n).takeWhile (<= sqrtn) $ primes
    where sqrtn = floor.sqrt.fromIntegral $ n

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

bool v[100005];

vector<ll>xx[100005];

void check(ll ind)
{
    if(v[ind]==1) return;
    v[ind]=1;

    for (auto &it: xx[ind])
        if (!v[it]) check(it) ;
}

int main()
{
    ll a,c,d,e,n,m,i,j,k=0;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>a>>c;
        xx[a].push_back(c);
        xx[c].push_back(a);
    }

    for(j=1; j<=n; j++)
    {
        if(v[j]==0)
        {
            k++;
            check(j);
        }
    }
    cout<<k-1<<endl;
}


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

int main() {
    ll A ;
    cin >> A ;
    ll B =1e18;
    for(ll i=1;i*i<=A;++i){
        if(A%i!=0)continue;
        ll j = A/i;
        B =min(B,i+j-2);
    }
 cout << B << endl;

    return 0;    
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement, groupby
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

n, k = Is()
s = S()
A = []  # group count of 1, 0 (1, 0, 1, 0, ... , 1)
if s[0] == "0":
    A.append(0)
for key, value in groupby(s):
    A.append(len(list(value)))
if s[-1] == "0":
    A.append(0)
# print(A)
ans = 0
w = 2*k+1
tmp = sum(A[:w])
ans = max(ans, tmp)
for i in range(w+1, len(A)+1, 2):
    tmp -= A[i-1-w] + A[i-w]
    tmp += A[i-1] + A[i]
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 70124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else 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;
using ll = long long;
typedef std::pair<int,int> ipair;

int main()
{
    float r;
    cin >> r;
    float len;
    const double PI = acos(-1);
    len = 2*r*PI;
    
    cout << len << endl;

    return 0;
}

Measured memory_bytes: 3772
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int n;
string s;


string find_str = "Hoshino";	// 検索対象の文字列
string rep_str = "Hoshina";

int main(){
    
        
    while(cin>>n){
        cin.ignore();
        for(int i=0; i<n; i++){
            getline(cin, s);
            int f;
            while((f=s.find("Hoshino"))!=-1){
                s.replace(f, find_str.length(), rep_str);
            }
            cout<<s<<endl;

        }
        
    }
    
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);
#define N 110
#define M 210
ll n,m;
ll a[M],b[M],d[M];
ll hu[M],op[M];

struct edge{
  ll to,cost;  
};
edge edges(ll to,ll cost){
    edge gen;gen.to=to,gen.cost=cost;
    return gen;
}
ll solve(){
    vector<edge> g[N];
    for(int i=0;i<m;i++){
	if(op[i]==1){
	    g[b[i]].push_back(edges(a[i],-d[i]));
	}
	if(op[i]==0){
	    g[b[i]].push_back(edges(a[i],0));
	    g[a[i]].push_back(edges(b[i],d[i]));
	}
    }
    ll t[N]; for(int i=1;i<=n;i++)t[i]=1e17; t[1]=0;
    ll befma=1e17;
    for(int u=0;u<=M;u++){
	for(int i=1;i<=n;i++){
	    for(edge e:g[i]){
		chmin(t[e.to],t[i]+e.cost);
	    }
	}
	ll curma=-1e17;
	for(int i=2;i<=n;i++)curma=max(curma,t[i]);
	if(u==M&&befma!=curma)return -1;
	befma=curma;
    }
    for(int i=1;i<=n;i++)if(t[i]<0)return -1;
    return befma;
}
int main(){
    cin>>n>>m;
    ll huc=0;
    for(int i=0;i<m;i++){
	string s;cin>>s;
	int ph=0; ll cur=0;
	for(int j=0;j<s.size();j++){
	    if(ph==0){
		if(not('0'<=s[j]&&s[j]<='9')){
		    a[i]=cur;
		    ph++;
		}
		cur*=10;
		cur+=s[j]-'0';
	    }
	    if(ph==1){
		if(s[j]=='*')hu[i]=1,j++;
		else{
		    if(s[j]=='<')hu[i]=0;
		    if(s[j]=='>')hu[i]=2;
		    j+=2;
		}
		ph++; cur=0;
	    }
	    if(ph==2){
		if(not('0'<=s[j]&&s[j]<='9')){
		    b[i]=cur;
		    ph++;
		}
		cur*=10;
		cur+=s[j]-'0';
	    }
	    if(ph==3){
		op[i]=(s[j]=='+');
		ph++,j++; cur=0;
	    }
	    if(ph==4){
		cur*=10;
		cur+=s[j]-'0';
	    }
	}
	d[i]=cur;
	if(hu[i]==2){
	    swap(a[i],b[i]);
	    hu[i]=0;
	}
	if(hu[i]==1)huc++;
    }
    /*
    for(int i=0;i<m;i++){
	cout<<i<<":"<<a[i]<<" "<<b[i]<<" "<<d[i]<<" "<<hu[i]<<" "<<op[i]<<endl;
    }*/
    ll ans=0; bool exi=0,negative=1;
    for(int i=0;i<(1<<huc);i++){
	
	for(int j=0,p=0;j<m;j++){
	    if(hu[j]==0)continue;
	    if(i&(1<<p))swap(a[j],b[j]);
	    p++;
	}
	ll res=solve(); //cout<<"---"<<res<<endl;
	if(res>1e16)exi=1;
	else if(res>=0){
	    negative=0;
	    chmax(ans,res);
	}
	for(int j=0,p=0;j<m;j++){
	    if(hu[j]==0)continue;
	    if(i&(1<<p))swap(a[j],b[j]);
	    p++;
	}
    }
    if(negative)cout<<-1<<endl;
    else if(exi)cout<<"inf"<<endl;
    else cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int n;
  ll a[200000];
  cin>>n;
  for (int i(0);i<n;i++) cin>>a[i];
  if (n%2==0){
    int x(n-1);
    while (x>=1){
      cout << a[x]<<" ";
      x-=2;
    }
    x=0;
    while (x<=n-1){
      cout << a[x]<<" ";
      x+=2;
    }
  }else{
    int x(n-1);
    while (x>=0){
      cout << a[x]<<" ";
      x-=2;
    }
    x=1;
    while (x<=n-1){
      cout << a[x]<<" ";
      x+=2;
    }
  }
  cout << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

int K, N;

int main() {
    cin >> K >> N;
    vector<int> a(N+1);
    rep(i,N) cin >> a[i];
    a[N] = a[0] + K;
    int diff = 0;
    rep(i,N) chmax(diff, a[i+1] - a[i]);
    cout << K - diff << endl;
}

Measured memory_bytes: 4028
# bit 全探索
# https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

if __name__ == '__main__':
    s = input()
    # s = '125'
    d = len(s) - 1

    ans = 0
    for bit in range(1 << d):
        sum_i = 0
        prev_pos = 0
        for i in range(d):
            if bit & (1 << i) != 0:
                sum_i += int(s[prev_pos:i + 1])
                prev_pos = i + 1

        ans += sum_i + int(s[prev_pos:d + 1])

    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define vl vector
#define ll long long
#define fast std::ios::sync_with_stdio(false)
using namespace std;

bool check(ll a,ll b)
{
    if(a==0 && b==0) return false;
    return true;
}

int main()
{
    fast;
    ll a,b,k;
    cin>>k>>a>>b;
    for(ll i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
    
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

int i,j;
void solve(void);

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

  return 0;
}
//
void solve()
{
	string s; cin>>s;
	int a,b,c,d;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';

bool pos1=0,pos2=0;
	if(c*10+d<=12 && c*10+d>=1)
		pos1=1;
	if(a*10+b<=12 && a*10+b>=1)
		pos2=1;

	if(pos1==1 && pos2==0)
		cout<<"\nYYMM";
	else if(pos1==0 && pos2==1 )
		cout<<"\nMMYY";
	else if(pos1==1 && pos2==1)
		cout<<"\nAMBIGUOUS";
	else cout<<"\nNA";
}

Measured memory_bytes: 256
using System;

class Program
{
    public static void Main()
    {
        int time = int.Parse(Console.ReadLine());
        int h = time / 3600;
        int m = (time % 3600) / 60;
        int s = (time　% 3600) % 60;
        Console.WriteLine("{0}:{1}:{2}",h,m,s);
    }
}


Measured memory_bytes: 17948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main()
{
  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(all(t), greater<int>());
  cout << ((s < t) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n; cin >> n;
	std::vector<pair<ll,ll>> AB;

	for (int i = 0; i < n; ++i)
	{
		ll a,b; cin >> a >> b;
		AB.push_back(make_pair(b,a));
	}
	sort(AB.begin(), AB.end());

	ll TimeLimit = 0;
	ll TimeNow = 0;
	bool isTask = true;

	for (int i = 0; i < n; ++i)
	{
		TimeLimit = AB[i].first;
		TimeNow += AB[i].second;
		if(TimeNow > TimeLimit) {
			isTask = false;
		}
	}

	if(isTask) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 6384
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll h,w;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    vector<ll> flag(9);
    rep(i,n){
        if(v[i]<400) flag[0]++;
        else if(v[i]<800) flag[1]++;
        else if(v[i]<1200) flag[2]++;
        else if(v[i]<1600)flag[3]++;
        else if(v[i]<2000)flag[4]++;
        else if(v[i]<2400)flag[5]++;
        else if(v[i]<2800)flag[6]++;
        else if(v[i]<3200)flag[7]++;
        else flag[8]++;
    }
    ll colors=0;
    rep(i,8) if(flag[i]!=0) colors++;
    ll bu=colors;
    if(flag[8]!=0&&colors==0) colors++;
    cout<<colors<<" ";
    bu+=flag[8];
    //if(bu>=9) cout<<9<<endl;
    cout<<bu<<endl;



    //cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::{input,fastout};
use std::cmp::{max, min};
#[fastout]
fn main(){
    input!{
        n: usize,
        a: [i64;n]
    }
    let mut b: Vec<_> = a.into_iter().enumerate().collect();
    b.sort_by_key(|p| p.1);
    let diff = |a:usize, b:usize| -> i64 {
        (max(a, b) - min(a, b)) as i64
    };
    let mut dp = vec![0];
    while let Some((k, a)) = b.pop() {
        let len = dp.len();
        let mut next = vec![0; len + 1];
        for (i, v) in dp.into_iter().enumerate() {
            next[i] = max(next[i], v + a * diff(k, n - (len - i)));
            next[i+1] = max(next[i + 1], v + a * diff(k, i));
        }
        dp = next;
    }
    let ans = dp.into_iter().max().unwrap();
    println!("{}", ans);
}

Measured memory_bytes: 2308
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
using namespace std;
int main()
{
	int a, b, c, d, e,f,g,h, i, j, k, l, m, n, o, p, q, r,s,t,u;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> f;
	cin >> g;
	cin >> h;
	cin >> i;
	cin >> j;
	cin >> k;
	cin >> l;
	cin >> m;
	cin >> n;
	cin >> o;
	cin >> p;
	cin >> q;
	cin >> r;
	f += 60;
	e += 60;
	f = f - c;
	if (f > 59){ f -= 60; }
	else{ e -= 1; }
	e = e - b;
	if (e > 59){ e -= 60; }
	else{ d -= 1; }
	d = d - a;
	l += 60;
	k += 60;
	l = l - i;
	if (l > 59){ l -= 60; }
	else{ k -= 1; }
	k = k - h;
	if (k > 59){ k -= 60; }
	else{ j -= 1; }
	j = j - g;
	r += 60;
	q += 60;
	r = r - o;
	if (r > 59){ r -= 60; }
	else{ q -= 1; }
	q = q - n;
	if (q > 59){ q -= 60; }
	else{ p -= 1; }
	p = p - m;
	cout << d << " " << e << " " << f << endl;
	cout << j << " " << k << " " << l << endl;
	cout << p << " " << q << " " << r << endl;
	
	return 0;
}

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

int main() {
  int A, B;
  string S, T, U;

  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if (U == S) {
    cout << A - 1 << " " << B;
  }
  else {
    cout << A << " " << B - 1;
  }

  return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    char a[20]={0};
    int i;
    scanf("%s",a);
    for(i=19;i>=0;i--){
        if(a[i] != 0){
            printf("%c",a[i]);
    }
}
    printf("\n");
    return 0;
}

Measured memory_bytes: 932
#include<stdio.h>
#define NUM 100

int main(void)
{
  int num[NUM];
  int N,i;
  double sum=0.0;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&num[i]);
  }
  
  for(i=0;i<N;i++){
    sum += 1.0/num[i];
  }
  
  printf("%f",1/sum);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define M 500000
#define MM 2000000000

int L[M/2+2],R[M/2+2];
int cou;

void merge(int A[],int l,int r){
	int m=(l+r)/2;
	int n1=m-l;
	int n2=r-m;
	for(int i=0;i<n1;i++) L[i]=A[l+i];
	for(int i=0;i<n2;i++) R[i]=A[m+i];
	L[n1]=R[n2]=MM;
	int i=0,j=0;
	for(int k=l;k<r;k++){
		cou++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}
		else A[k]=R[j++];
	}
}

void sort(int A[],int l,int r){
	if(l+1<r){
		int m=(l+r)/2;
		sort(A,l,m);
		sort(A,m,r);
		merge(A,l,r);
	}
}
int main(){
	int A[M],n,i,j;
	cou=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	sort(A,0,n);
	printf("%d",A[0]);
	for(i=1;i<n;i++) printf(" %d",A[i]);
	printf("\n%d\n",cou);
} 


Measured memory_bytes: 6620
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll a[maxn];
ll b[maxn];
struct node{
	int x,y;
	int dir;
}p[maxn]; 
bool cm1(node x1,node x2){
	if((x1.x-x1.y)==(x2.x-x2.y)) return x1.x<x2.x;
	else return (x1.x-x1.y)<(x2.x-x2.y);
}
bool cm2(node x1,node x2){
	if((x1.x+x1.y)==(x2.x+x2.y)) return x1.x<x2.x;
	else return (x1.x+x1.y)<(x2.x+x2.y);
}
bool cmp1(node x1,node x2){
	if(x1.x!=x2.x){
		return x1.x<x2.x;
	}else {
		return x1.y>x2.y;
	}
}
bool cmp2(node x1,node x2){
	if(x1.y!=x2.y){
		return x1.y>x2.y;
	}else {
		return x1.x<x2.x;
	}
}
int main() {
	int n;
	cin>>n;
	map<char,int> mp;
	mp['U'] = 1;
	mp['R'] = 2;
	mp['D'] = 3;
	mp['L'] = 4; 
	map<pair<int,int> ,int> mpp1;
	map<pair<int,int> ,int> mpp2;
	map<pair<int,int> ,int> mpp3;
	map<pair<int,int> ,int> mpp4;
	for(int i=1;i<=n;i++){
		char c;
		cin>>p[i].x>>p[i].y>>c;
		p[i].dir = mp[c];
	}
	sort(p+1,p+1+n,cm1);
	int flag = 0;
	int ans = INF;
	for(int i=1;i<=n;i++){
		int dxy = p[i].x-p[i].y;
		if(p[i].dir==4&&mpp1[{dxy,1}]){
			flag = 1;
			ans = min(ans,abs(p[mpp1[{dxy,1}]].x-p[i].x)*10);
		//	break;
		}
		if(p[i].dir==3&&mpp1[{dxy,2}]){
			flag = 1;
			ans = min(ans,abs(p[mpp1[{dxy,2}]].x-p[i].x)*10);
		//	break;
		}
		mpp1[{p[i].x-p[i].y,p[i].dir}] = i;
	}
	
	sort(p+1,p+1+n,cm2); 
	for(int i=1;i<=n;i++){
		int dxy = p[i].x+p[i].y;
		if(p[i].dir==4&&mpp2[{dxy,3}]){
			flag = 1;
			ans = min(ans,abs(p[mpp2[{dxy,3}]].y-p[i].y)*10); 
		//	break;
		}
		if(p[i].dir==1&&mpp2[{dxy,2}]){
			flag = 1;
			ans = min(ans,abs(p[mpp2[{dxy,2}]].y-p[i].y)*10);
		//	break;
		}
		mpp2[{dxy,p[i].dir}] = i;
	}
//	if(flag){
//		cout<<abs(ans)*10<<endl;
//		return 0;
//	}
	sort(p+1,p+1+n,cmp1);
	for(int i=1;i<=n;i++){
		if(p[i].dir==1&&mpp3[{p[i].x,3}]){
			flag = 1;
			ans = min(ans,abs(p[mpp3[{p[i].x,3}]].y-p[i].y)*5);
		//	break;
		}
		mpp3[{p[i].x,p[i].dir}] = i;
	}
//	if(flag){
//		cout<<abs(ans)*5<<endl;
//		return 0;
//	}
	sort(p+1,p+1+n,cmp2);
	for(int i=1;i<=n;i++){
		if(p[i].dir==4&&mpp4[{p[i].y,2}]){
			flag = 1;
			ans = min(ans,abs(p[mpp4[{p[i].y,2}]].x-p[i].x)*5);
		//	break;
			
		}
		mpp4[{p[i].y,p[i].dir}] = i;
	}
	if(flag){
		cout<<ans<<endl;
		return 0;
	}
	cout<<"SAFE\n";
    return 0;
}

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

int g[16][16] = {};

int main(void){
    int n;
    cin >> n;
    rep(i,n) rep(j,n) g[i][j] = -1;
    rep(i,n){
        int m;
        cin >> m;
        rep(j,m){
            int x,y;
            cin >> x >> y;
            g[i][x-1] = y;
        }
    }
    int res = 0;
    rep(mask, 1<<n){
        auto check = [&](){
            rep(i,n){
                if (!(bit(i) & mask)) continue;
                rep(j,n){
                    if(g[i][j] == 1){
                        if (!(bit(j) & mask)) {
                            return false;
                        }
                    }
                    if(g[i][j] == 0){
                        if ((bit(j) & mask)) {
                            return false;
                        }
                    }
                }
            }
            return true;
        };
        if(check()){
            res = max(res, __builtin_popcount (mask));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
l = []
x.sort()
for i in range(m-1):
    l.append(x[i+1]-x[i])
ans = x[m-1] - x[0]
l.sort(reverse=True)
for i in range(min(n-1,m-1)):
    ans -= l[i]
print(max(ans,0))

Measured memory_bytes: 13968
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <map>

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

long long 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;
        //そのまま計算すると負の値になるので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;
}

//UnionFind木
struct UnionFind{
   vector<long long int> par; //par[i] : iの親の番号
   vector<long long int> rnk; //root[i] : iの木のサイズ

   //コンストラクタ
   UnionFind(long long int n): par(n), rnk(n){
       //木の初期化
       for(long long int i = 0; i < n; i++){
           par[i] = i;
           rnk[i] = 1;
       }
   }

   //データxが属する木の根を再帰で取得
   long long int root(long long int x){
       if(par[x] == x){
           return x;
       }else{
           return par[x] = root(par[x]);
       }
   }

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       //併合するときにサイズを足し合わせる
       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
           rnk[ry] += rnk[rx];
       }else{
           par[ry] = rx;
           rnk[rx] += rnk[ry];
       }
   }

   //属している木のサイズを取得
   long long int size(long long int x){
       return rnk[root(x)];
   }
};


int main(){
    int n, m, k;
    cin >> n >> m >> k;

    vector<set<int> > out(n);
    UnionFind uf(n);

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;

        out[a-1].insert(b-1);
        out[b-1].insert(a-1);

        uf.unite(a-1, b-1);
    }

    for(int i = 0; i < k; i++){
        int c, d;
        cin >> c >> d;
        if(!uf.same(c-1, d-1)) continue;
        out[c-1].insert(d-1);
        out[d-1].insert(c-1);
    }

    for(int i = 0; i < n; i++){
        int ans = uf.size(i) - 1 - out[i].size();
        cout << ans << endl;
    }
}


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int mod = 998244353;
const int MAX = 4018;

int inv[MAX], f[MAX], fInv[MAX], pw2[MAX];

int add(int a, int b)
{
	return (a + b) % mod;
}

int mult(int a, int b)
{
	LL res = ((LL)a * b) % mod;
	if(res < 0)
		res += mod;
	return res;
}

int C(int n, int k)
{
	if(k > n)
		return 0;
	return mult(mult(f[n], fInv[k]), fInv[n - k]);
}

int H(int m, int r)
{
	if(r < 0)
		return 0;
	return C(m + r - 1, r);
}

int ans(int n, int k, int x)
{
	int cnt = 0;
	FOR(i, 1, k + 1)
		cnt += x - i > i && x - i <= k;
	int res = 0;
	if(x & 1)
	{
		FOR(i, 0, cnt + 1)
			res = add(res, mult(mult(H(k - 2 * cnt + i, n - i), pw2[i]), C(cnt, i)));
		return res;
	}
	FOR(i, 0, cnt + 1)
	{
		res = add(res, mult(mult(H(k - 2 * cnt + i - 1, n - i), pw2[i]), C(cnt, i)));
		res = add(res, mult(mult(H(k - 2 * cnt + i - 1, n - i - 1), pw2[i]), C(cnt, i)));
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	inv[1] = 1;
	FOR(i, 2, MAX)
		inv[i] = mult(-inv[mod % i], mod / i);
	f[0] = 1;
	fInv[0] = 1;
	pw2[0] = 1;
	FOR(i, 1, MAX)
	{
		f[i] = mult(f[i - 1], i);
		fInv[i] = mult(fInv[i - 1], inv[i]);
		pw2[i] = mult(pw2[i - 1], 2);
	}
	int k, n;
	cin >> k >> n;
	FOR(i, 2, 2 * k + 1)
		cout << ans(n, k, i) << endl;
	return 0;
}

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
            
        ll d, t, s;
        cin >> d >> t >> s;
        
        if((t * s) < d) {
                cout << "No" << endl;
        } else {
                cout << "Yes" << endl;
        }
       
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3544
#include <iostream>

using namespace std;

int main(void) {
	int a, b, c;
	int ans = 0;

	cin >> a >> b >> c;

	ans = a + b + c;
	if (ans == 17) {
		cout << "YES" << endl;

	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3508
//I_F_A
#include "bits/stdc++.h"
using namespace std;

int main(){

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

	string s;
	cin >> s;

	for(long long i=0;i<s.length();i++)
		if(s[i] == ',')
			s[i] = ' ';

	cout << s << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	if (d % 2 == 1) {
		cout << b - a << endl;
	}
	else {
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
int main() {
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    S = '#' + S + '#';
    if(C > D){
         bool snuke_can_over = false;
               for (int i = B; i <= D; i++) {
                   if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                       snuke_can_over = true;
                   }
               }
               if (!snuke_can_over) {
                   cout << "No" << endl;
                   return 0;
               }
    } else {
         auto can_reach = [&](int start, int end) {
               for (int i = start; i + 1 <= end; i++) {
                   if (S[i] == '#' && S[i + 1] == '#') return false;
               }
               return true;
           };
        
           if (!can_reach(A, C) || !can_reach(B, D)) {
               cout << "No" << endl;
               return 0;
           }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 772
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
#include <complex>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = acosl(-1.0);
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	ll ans = INT64_MIN;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		b[i]--;
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int st = 0;st < n; st++) {
		vector<int> used(n);
		vector<ll> path;
		int pos = st;
		ll temp = 0;
		while (!used[b[pos]]) {
			pos = b[pos];
			temp += a[pos];
			used[pos] = 1;
			path.push_back(pos);
		}
		temp = max(temp, 0LL); // one cycle profit
		ll pp = 0;
		for (int i = 0; i < min(k, (ll)path.size()); i++) {
			pp += a[path[i]];
			ans = max(ans, pp + (k - i - 1) / (ll)path.size() * temp);
		}
	}
	cout << ans;
}

Measured memory_bytes: 3872
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int f=0;
		for(int i=0;i<n-1;i++) {
			if(a[i]==a[i+1]) {
				f=1;
				break;
			}
		}
		if(f==0) {
			System.out.println("YES");

		}else {
			System.out.println("NO");
		}




	}

}


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

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] v = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] l = new int[n];
        for(int i = 0; i < n; i ++) l[i] = v[i] - c[i];
        Console.WriteLine(Math.Max(0, l.Where(x => x > 0).Sum()));
    }
}

Measured memory_bytes: 11348
# B - Frog 2
# https://atcoder.jp/contests/dp/tasks/dp_

(N, K) = gets.chomp.split.map(&:to_i)
H = gets.chomp.split.map(&:to_i)

@dp = Array.new(N+3) { 0 }
(0...N).each do |i|
  if i == 0
    @dp[i] = 0
    next
  else
    cost = []
    (1..K).each do |j|
      if i >= j
        cost << @dp[i-j] + (H[i-j] - H[i]).abs
      else
        break
      end
    end

    @dp[i] = cost.min
  end
end

puts @dp[N-1]


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

int main() {
    int query, flag = 0;
    deque<string> str;
    string input;
    cin >> input >> query;
    str.push_back(input);
    rep(i, query) {
        int t;
        cin >> t;
        if(t == 1) {
            flag = (flag + 1) % 2;
        } else {
            int f;
            string temp;
            cin >> f >> temp;
            f--;
            if(f ^ flag) str.push_back(temp);
            else str.push_front(temp);
        }
    }
    string ans = "";
    for(string s : str) {
        ans += s;
    }
    if(flag) reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 12128
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
char S[100010],T[100010];
signed main(){
	scanf("%lld%lld",&n,&m);
	scanf("%s%s",S,T);
	for (int i=0;i<n;i++)
		if (i*m%n==0){
			int j=1LL*i*m/n;
			if (j>=m) continue;
			if (S[i]!=T[j]) {puts("-1"); return 0;}
		}
	printf("%lld\n",1LL*n*m/__gcd(n,m));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

int dp[21000][256], c[64000], x[64000];

int sum_of_square(int d, int i) {
    int ret = (int)pow(abs(x[i]-d), 2);
    return ret;
}

int main(int argc, char const *argv[]) {
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0&&m == 0) break;
        REP(i,21000) REP(j,256) dp[i][j] = INF*2;
        REP(i,m) cin >> c[i];
        for (int i = 1; i <= n; ++i) cin >> x[i];
        dp[0][128] = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = 0; j < 256; ++j) {
                if (dp[i-1][j] == INF) continue;
                REP(k,m) {
                    int next = c[k]+j;
                    if (next < 0) {
                        next = 0;
                    }
                    else if (next > 255) {
                        next = 255;
                    }
                    dp[i][next] = min(dp[i][next], dp[i-1][j]+sum_of_square(next, i));
                }
            }
        }
        int ans = INF*2;
        REP(i,256) {
            ans = min(ans, dp[n][i]);
        }
        cout << ans << endl;
    }
    
    return 0;
}


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

using namespace std;

// #define multitest 1
#define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, k;
	cin >> n >> k;
	if (k == 1)
	{
		cout << 0;
	}
	else
		cout << n - k;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    int S;    cin>>S;
    cout<<S/3600<<":"<<(S%3600)/60<<":"<<(S%3600)%60<<endl;
}


Measured memory_bytes: 3108