akhauriyash/Code-Regression huggingface dataset:
def gcd(a,b):
  if b==0:
    return a
  else:
    a = a%b
    return gcd(b,a)
def lcm(a,b):
  return a*b//gcd(a,b)

a,b = map(int,input().split())
if b > a:
  t = a
  a = b
  b = t
print(lcm(a,b))

Measured memory_bytes: 3060
def greater(a,b):
    if len(a)>len(b):
        return a
    elif len(b)>len(a):
        return b
    for i in range(len(a)):
        if a[i]<b[i]:
            return b
        if b[i]<a[i]:
            return a
    return a

cost=[0,2,5,5,4,5,6,3,7,6]
n,m=map(int,input().split())
la=[int(a) for a in input().split()]
la.sort()
sa=[str(a) for a in la]
ca=[cost[a] for a in la]
max=[None for i in range(10010)]
for i in range(m):
    max[ca[i]]=sa[i]
for i in range(2,n):
    if max[i]==None:
        continue
    for j in range(m):
        if max[i][0]>sa[j]:
            k=max[i]+sa[j]
        else:
            k=sa[j]+max[i]
        if max[i+ca[j]]==None:
            max[i+ca[j]]=k
        else:
            max[i+ca[j]]=greater(max[i+ca[j]],k)
print(max[n])

Measured memory_bytes: 135688
a,b,c,d,e = map(int, input().split())

if a == 0:
  print(1)
  
if b == 0:
  print(2)
  
if c == 0:
  print(3)
  
if d == 0:
  print(4)
  
if e == 0:
  print(5)

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

struct SegTree
{
    int N;
    vector<int> seg;

    SegTree(int n)
    {
        N = 1;
        while (N < n) N<<=1;
        seg.assign(2*N-1,0);
    }

    void add(int k,int x)
    {
        k += N-1;

        seg[k] += x;

        while(k>0)
        {
            k = (k-1)/2;
            seg[k] = seg[k*2+1] + seg[k*2+2];
        }
    }

    int sum(int a,int b) { return sum(a,b,0,0,N); }

    int sum(int a,int b,int k,int l,int r)
    {
        if ( r <= a || b <= l ) return 0;
        if ( a <= l && r <= b ) return seg[k];

        return sum(a,b,k*2+1,l,(l+r)/2) + sum(a,b,k*2+2,(l+r)/2,r);
    }
};

int main()
{
    int N,Q;
    cin >> N >> Q;

    SegTree seg(N);

    for(int i=0; i<Q; i++)
    {
        int c,x,y;
        cin >> c >> x >> y;

        if(c)
        {
            cout << seg.sum(x-1,y) << endl;
        }
        else
        {
            seg.add(x-1,y);
        }
    }
}

Measured memory_bytes: 2060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
vector<pair<ll, ll>>prime_factorize(ll n) {
	vector<pair<ll, ll>>res;
	for (ll p = 2; p*p <= n; ++p) {
		if (n%p != 0)continue;
		int num = 0;
		while (n%p == 0) {
			++num;
			n /= p;
		}
		res.push_back(make_pair(p,num));
	}
	if (n != 1)res.push_back(make_pair(n, 1));
	return res;
}
const int MAX = 210000;
ll 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%INF;
		inv[i] =INF - inv[INF%i] * (INF / i)%INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}
//nCkを求める関数
ll 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] % INF) % INF;
}
int main() {
	int N, M;
	COMinit();
	cin >> N >> M;
	auto vec = prime_factorize(M);
	ll res = 1;
	for (auto pa : vec) {
		int num = pa.second;
		ll tmp = COM(num + N - 1, N - 1);
		res = (res*tmp) % INF;
	}
	cout << res << endl;
	return 0;
}



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

const int mod = 1'000'000'007;

int main(){
    int n ;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n ;i++) cin >> a.at(i);
    int x = 0;
    int ans = 0;
    for(int i = 0 ; i < n; i++){
        ans = (ans + (long long)a.at(i) * x) % mod;
        x = (x + a.at(i)) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
#pragma GCC diagnostic ignored "-Wunused-result"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 1502;
//const ll INF = (ll)1e18 + 41;
const int INF = (int)1e9 + 41;
const ll MD = (ll)1e9 + 7;
bool D = false;

int sum[N][N], a[N][N];
int max_depth[N][N];
short int r[2][N][N];
short int l[2][N][N];

void solve() {
    int n, m;
    cin >> n;
    m = n;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            a[i][j] = 0;
            max_depth[i][j] = i;
            sum[i][j] = 0;            
        }
    }

    for (int i = 0; i < 2; i++) {
    	for (int j = 0; j <= m; j++) {
    		for (int h = 0; h <= m; h++) {
    			r[i][j][h] = (short int)-1;
    			l[i][j][h] = (short int)N;
    		}
    	}
    }

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            if (s[j] == '#') a[i][j] = 0;
            else a[i][j] = s[j] - '0';
        }
    }
    ll ans = 0;

    for (int i = n - 1; i >= 0; i--) {
    	int my = i % 2;
    	int nx = (i + 1) % 2;

    	for (int j = 0; j <= m; j++) {
    		for (int h = i; h <= n; h++) {
    			l[my][j][h] = (short int)N;
    			r[my][j][h] = (short int)-1;
    		}
    	}

        for (int j = m - 1; j >= 0; j--) {
            if (a[i][j] == 0) {
                max_depth[i][j] = -1;
                continue;
            }

            short int *left = r[nx][j];
            short int *_left = l[nx][j];
            short int *rait = l[my][j + 1];
            short int *_rait = r[my][j + 1];
            short int *meL = l[my][j];
            short int *meR = r[my][j];

            meL[i] = (short int)j;
            meR[i] = max(meL[i], _rait[i]);
            for (int h = i + 1; h < n; h++) {
                meL[h] = min(_left[h], rait[h]);
                meR[h] = max(left[h], _rait[h]);
            }
            max_depth[i][j] = max(i, max(max_depth[i + 1][j], max_depth[i][j + 1]));

            int cur_sum = sum[i][j + 1] + sum[i + 1][j];
            int h = i;
            //cout << i << " " << j << endl;
            if (i == 1 && j == 0) {
                j = i * j;
            }
            while (h < n) {
                while (h < n && left[h] < rait[h]) h++;
                if (h >= n) continue;

                cur_sum -= sum[h][rait[h]];
                h = max_depth[h][rait[h]] + 2;
            }

            sum[i][j] = cur_sum + a[i][j];
            ans += a[i][j] * cur_sum;
        }
    }

    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tst = 1;
    //scanf("%d", &tst);
    //cin >> tst;
#ifdef MADE_BY_SERT
    //freopen("a.in", "r", stdin);
    D = true;
    tst = 4;
    while (tst--) {
        solve();
    }
#else
    while (tst--) solve();
#endif
}


Measured memory_bytes: 44288
def swap(a, b, row):
    row[a-1], row[b-1] = row[b-1], row[a-1]  

w = int(raw_input())
n = int(raw_input())

result = range(1, w+1)

for i in range(n):
    a, b = map(lambda x: int(x), raw_input().split(','))
    swap(a, b, result)

for x in result:
    print x

Measured memory_bytes: 6248
#include "bits/stdc++.h"
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)

using namespace std;

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


Measured memory_bytes: 768
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    string s;
    cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1];

    return 0;
}  

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

using namespace std;
typedef long long ll;

int main(){
  ll X;
  cin >> X;
  for(ll i=-200; i<200; i++){
    for(ll j=-200; j<200; j++){
      if(pow(i,5) - pow(j,5) == X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0; 
}

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


/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
int inf=100000000;

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};

int main(){
    int H,W;
    cin>>H>>W;
    int cnt=0;
    vector<vector<char>> s(H,vector<char> (W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>s.at(i).at(j);
            if(s.at(i).at(j)=='#'){
                cnt++;
            }
        }
    }//入力の完成

    queue<pair<int,int>> que;

    vector<vector<int>> d(H,vector<int> (W,inf));

    que.push(pair<int,int> (0,0));
    d.at(0).at(0)=0;

    while(que.size()>0){
        pair<int,int> p=que.front();
        que.pop();

        if(p.first==H-1 && p.second == W-1){
            break;
        }

        for(int i=0;i<4;i++){
            int ny = p.first + dy.at(i);
            int nx = p.second + dx.at(i);
            if(0<=nx && nx<W && 0<=ny && ny<H && s.at(ny).at(nx)!='#' && d.at(ny).at(nx)==inf){
                que.push(pair<int,int> (ny,nx));
                d.at(ny).at(nx)=d.at(p.first).at(p.second) + 1;
            }
        }
    }
    if(d.at(H-1).at(W-1)==inf){
        cout<<-1<<endl;
    }
    else{
        int tmp= d.at(H-1).at(W-1);
        int ans=H*W-cnt-tmp-1;
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 256
def resolve():
    """
    b: 2, 5
    a: 2, 2, 5


    b: 0, 153, 10, 10, 23
    a: 0, 0, 10, 10, 10, 23
    """
    n = int(input())
    b = [int(i) for i in input().split()]
    a = [b[0]]
    for i, v in enumerate(b):
        if i < len(b)-1:
            a.append(min(b[i], b[i + 1]))

    a.append(b[-1])
    print(sum(a))


resolve()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int N;
	string S;
	cin >> N;
	cin >> S;

	for(int i=0;i<S.length();i++){
		char target = S[i];
		int index=str_array.find(target);
		char modifyied = str_array[(index+N)%26];
		S[i]=modifyied;
	}

	cout << S;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read();
int n, m, k, len;
char s[1000006], t[1000006];
int a[2000006];
struct St {
    int type, p;
} st[2000006], tst[2000006];
int top, ttop;
int res[2000006];

void prt() {
    int len = st[1].p;
    while (!res[len]) len--;
    for (int i = len; i >= 0; --i) putchar('0' + res[i]);
    puts("");
}

int main() {
    scanf("%d%d%d%s%s", &n, &m, &k, s, t), len = max(n, m);
    reverse(s, s + n), reverse(t, t + m);
    for (int i = 0; i < len; ++i) a[i] = ((s[i] == '1') << 1) | (t[i] == '1');

    for (int i = len - 1; i >= 0; --i) {
        if (a[i] != 3) {
            if (a[i]) st[++top] = (St){a[i], i};
            continue;
        }
        int tmp = k - 1, tpos = i, x = 3;
        while (1) {
            if (x != 3 && tpos + 1 != st[top].p) {
                tst[++ttop] = (St){x, tpos + 1};
                break;
            }
            if (!top) {
                tst[++ttop] = (St){x, tpos + tmp + 1};
                break;
            }
            if (x == 3) {
                int step = st[top].p - tpos - 1;
                if (step > tmp) {
                    tst[++ttop] = (St){x, tpos + tmp + 1};
                    break;
                } else
                    tmp -= step;
            }
            tpos = st[top].p;
            if ((st[top].type ^ x) == 3) {
                --tmp, --top, x = 3;
            } else {
                int ttype = st[top].type ^ x;
                x = st[top--].type & x, tst[++ttop] = (St){ttype, tpos};
            }
        }
        while (ttop) st[++top] = tst[ttop--];
    }

    st[top + 1].p = -1;
    for (int i = 1; i <= top; ++i) {
        res[st[i].p] = st[i].type >> 1;
        if (res[st[i].p] == -23) {
            cerr << i << ' ' << st[i].p << ' ' << st[i].type << endl;
        }
        for (int j = st[i].p - 1; j > st[i + 1].p; --j) res[j] = 0;
    }
    prt();
    for (int i = 1; i <= top; ++i) {
        res[st[i].p] = st[i].type & 1;
        for (int j = st[i].p - 1; j > st[i + 1].p; --j) res[j] = 0;
    }
    prt();
    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n, m;
  cin >> n >> m;
  ll result = 1;
  for(i = m / n; i >= 1; i--){
    if(m % i == 0){
      result = i;
      break;
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())

if (A*B*C)%2 == 0:
    print(0)
else:
    m = max(A,B,C)
    print(abs(((A*B*C)//m) * (m//2) - ((A*B*C)//m) * (-(-m//2))))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double a,b,c,d,e,f;
    double x,y;
    while(cin>>a>>b>>c>>d>>e>>f){
        x=(b*f-c*e)/(b*d-a*e);
        y = (a*f-c*d)/(a*e-b*d);
        if(x == 0) x = 0.000;
        if(y == 0) y = 0.000;
        cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include "bits/stdc++.h"
using namespace std;
int main()
{
  int i,j,f=0;
  string s,c;
  cin>>s;
  c=s;
  reverse(c.begin(),c.end());
  for(i=0;i<s.size();i++)
  {
  	//cout<<s[i]<<"\\"<<s[s.size()-i-1]<<endl;
    if(s[i]!=s[s.size()-i-1])f++;
  }
  cout<<f/2<<endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    T = input()
    dp = [[0] * (len(S) + 1) for _ in range(len(T) + 1)]
    for j, t in enumerate(T, 1):
        for i, s in enumerate(S, 1):
            dp[j][i] = max(dp[j - 1][i], dp[j][i - 1], dp[j - 1][i - 1] + 1 if s == t else 0)
    i, j = len(S), len(T)
    R = ''
    while i > 0 and j > 0:
        n = dp[j][i]
        if dp[j - 1][i] == n:
            j -= 1
        elif dp[j][i - 1] == n:
            i -= 1
        elif dp[j - 1][i - 1] == n - 1:
            j -= 1
            i -= 1
            R += T[j]
        else:
            assert False
    return R[::-1]

print(main())


Measured memory_bytes: 144368
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int N;
vector<vector<pair<int,int>>> adj;
vector<int> out;

void Solve(int p, int c, int prev) {
  if (out[p] > 0) return;
  out[p] = c;
  for (auto a : adj[p]) {
    int q = a.first;
    int d = a.second;
    int cc = c;
    if (d % 2 == 1) cc ^= 2;
    Solve(q, cc, p);
  }
}

int main() {
  while (cin >> N) {
    adj.clear();
    adj.resize(N);
    out.clear();
    out.resize(N);
    for (int i = 0; i < N-1; ++i) {
      int u, v, w;
      cin >> u >> v >> w;
      --u; --v;
      adj[u].push_back(make_pair(v, w));
      adj[v].push_back(make_pair(u, w));
    }
    Solve(0, 1, -1);
    for (int i = 0; i < N; ++i) {
      cout << out[i]/2 << endl;
    }
  }
}


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

int n;
int h[100000];
//dp[i]: i번쨰부터 출발해서 도착할 때 까지 걸리는 최소 비용
int dp[100000];

int solve(int i){
	int& ret=dp[i];
	if(ret!=-1) return ret;
	if(i==n-1) return ret=0;
	if(i==n-2) return ret=abs(h[n-1]-h[i]);
	ret=1000000000;
	ret=min(ret,abs(h[i]-h[i+1])+solve(i+1));
	ret=min(ret,abs(h[i]-h[i+2])+solve(i+2));
	return ret;
}

int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		scanf("%d",h+i);
	}
	memset(dp, -1, sizeof(dp));
	cout<<solve(0);
	return 0;
}

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

int main(){
  char a,b,c,d,e,f;
  cin >> a >> b >> c;
  cin >> d >> e >> f;
  int count = 0;
  if (a == d){
    count++;
  }
  if (b == e){
    count++;
  }
  if (c == f){
    count++;
  }
  cout << count << endl;
}

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

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll N;
    cin>>N;
    ll curt, curx, cury;
    curt=curx=cury=0;
    rep(i,0,N){
        ll t,x,y;
        cin>>t>>x>>y;
        ll diff = abs(curx-x) + abs(cury-y);
        if (diff > (t-curt) || (diff-t+curt)%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
        curt = t;
        curx = x;
        cury = y;
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  ll A, B, C;
  cin >> A >> B >> C;
  for( int i=0; i<10000; i++ ){
    if( A % 2 == 1  || B % 2 == 1 || C % 2 == 1 ){
      cout << i << endl;
      return 0;
    }
    ll a = B/2 + C/2;
    ll b = C/2 + A/2;
    ll c = A/2 + B/2;
    A = a;
    B = b;
    C = c;
  }
  cout << -1 << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    int n;
    cin >> n;
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=i;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[20],W[100],s[10],X,Y;
   scanf("%d %d %d",&A,&B,&C);
   printf("%d",(A+B)*C/2);
    return 0;
}

Measured memory_bytes: 128
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        
        if (n == 1) {
            System.out.println("Hello World");
        }
        else {
            int a = Integer.parseInt(br.readLine());
            int b = Integer.parseInt(br.readLine());
            System.out.println(a+b);
        }
        
    
        
    }
}


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

long long d[2000], e[2000];
int	w[2000], h[2000], a[1501 * 1024], b[1502 * 1024], n, m;

int main(){

	while (cin >> n >> m, n){
		long k = 0, l = 0, count = 0, f = 0;
		for (int i = 1; i <= n; i++)
		{
			cin >> w[i];
			if (i==1)d[1] = w[i];
			else if (i > 1)d[i] = w[i] + d[i - 1];
		}
		for (int i = 1; i <= m; i++)
		{
			cin >> h[i];
			if (i==1)e[1] = h[i];
			else e[i] = h[i] + e[i - 1];
		}
		d[0] = 0; e[0] = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 0; j < i; j++){
				a[k] = d[i] - d[j]; k++;
			}
		for (int i = 1; i <= m; i++)
			for (int j = 0; j < i; j++){
				b[l] = e[i] - e[j]; l++;
			}
		sort(a, a + k);
		sort(b, b + l);

		for (int i = 0; i < k && f < l; i++)
			for (; f < l;){
				if (a[i] == b[f]){
					int q = f;
						do{
							count++; q++; if (q == l)break;
						} while (a[i] == b[q]);break;
				}
				if (a[i] < b[f])break;
				else f++;
			}
		cout << count << endl;
	}
}

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

int main(){
  int n;
  int m;
  const int MOD=1e9+7;
  cin>>n>>m;
  if(abs(n-m)>1){
    cout<<0<<endl;
  }
  else{
    long long int res1=1;
    for(int i=1;i<=n;i++){
      res1*=i;
      res1%=MOD;
    }
    long long int res2=1;
    for(int i=1;i<=m;i++){
      res2*=i;
      res2%=MOD;
    }
    auto res=res1*res2;
    if(abs(n-m)==0){
      res*=2;
    }
    res%=MOD;
    cout<<res<<endl;

  }

		 

  return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <stack>
#include <functional>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, a, b, c, h, w;
  scanf("%lld%lld%lld", &n, &a, &b);
  printf("%lld %lld", a < b ? a : b, n - a - b > 0 ? 0 : a + b - n);
  return 0;
}

Measured memory_bytes: 128
import math

X=int(input())
rt=int(math.sqrt(X))

def prime(A):
  pn=[2]
  for L in range(3,A+1,2):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)
  return pn

pm_list=prime(rt)


if X in pm_list:
  print(X)
else:
  get_pri=False
  N=X
  
  while get_pri==False:
    judge=True
    for i in pm_list:
    
      if N%i==0:
        judge=False
        continue
    if judge==True:
      get_pri=True
      print(N)
    N+=1

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll>v(n),dp(n);
	for(int i=0;i<n;i++) cin>>v.at(i);
	dp.at(0)=0;
	dp.at(1)=abs(v.at(0)-v.at(1));
	for(int i=2;i<n;i++){
		dp.at(i)=min(abs(v[i-1]-v[i])+dp[i-1],abs(v[i-2]-v[i])+dp[i-2]);
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;


int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy";
    }
    if (s == "Cloudy")
    {
        cout << "Rainy";
    }
    if (s == "Rainy")
    {
        cout << "Sunny";
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];
bool flag[2][110];

const ll A = 1010101;

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>c(A);
	
	rep(i, n) {
		cin >> a[i];
		c[a[i]]++;
	}
	bool flag = true;
	for (ll i = 2;i < A;++i) {
		ll cnt = 0;
		for (ll j = i;j < A;j += i) {
			cnt += c[j];
		}
		if (cnt > 1) {
			flag = false;
		}
	}
	if (flag) {
		puts("pairwise coprime");
		return 0;
	}
	ll g = 0;
	rep(i, n) {
		g = gcd(g, a[i]);
	}
	if (g == 1) {
		puts("setwise coprime");
		return 0;
	}
	puts("not coprime");
	return 0;
}


Measured memory_bytes: 19016
#include <cstdio>
#include <algorithm>
#include <cmath>
#define MAXN 305
#define MAXD 90010
using namespace std;
int sum[MAXD], ind[4][MAXD];
int main()
{
    int n, m, d, q;
    scanf("%d %d %d", &n,&m, &d);
    for(int i =0 ;i<n; ++i)
    {
        for(int j = 0, a; j<m; ++j)
        {
            scanf("%d", &a);
            ind[1][a] = i;
            ind[2][a] = j;
        }
    }

    for(int i = d; i<=n*m; ++i)
    {
        sum[i] = sum[i-d] + (abs(ind[1][i]-ind[1][i-d])+ abs(ind[2][i]-ind[2][i-d]));
    }

    scanf("%d", &q);

    while(q--)
    {
        scanf("%d %d", &n, &m);

        printf("%d\n", sum[m]-sum[n]);
    }
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<algorithm>
#define LL long long
#define PII pair<int,int>
#define pi acos(-1.0)
#define eps 1e-6
#define lowbit(x) x&(-x)
using namespace std;

const int maxn=50;
const double g=9.8;
int N,V,X,Y;
int L[maxn],B[maxn],R[maxn],T[maxn];

double cal(double vy,double t){
    return vy*t-g*t*t/2;
}

int cmp(double lb,double ub,double a){
    return a<lb+eps?-1:a>ub-eps?1:0;
}

bool check(double qx,double qy){
    double a=g*g/4,b=g*qy-V*V,c=qx*qx+qy*qy;
    double D=b*b-4*a*c;
    if(D<0 && D>-eps) D=0;
    if(D<0) return false;
    for(int d=-1;d<=1;d+=2){
        double t2=(-b+d*sqrt(D))/(2*a);
        if(t2<=0) continue;
        double t=sqrt(t2);
        double vx=qx/t,vy=(qy+g*t*t/2)/t;
        double yt=cal(vy,X/vx);
        if(yt<Y-eps) continue;
        bool ok=true;
        for(int i=0;i<N;i++){
            if(L[i]>=X) continue;
            if(X>=L[i] && X<=R[i] && Y<=T[i] && B[i]<=yt) ok=false;
            int yL=cmp(B[i],T[i],cal(vy,L[i]/vx));
            int yR=cmp(B[i],T[i],cal(vy,R[i]/vx));
            int xH=cmp(L[i],R[i],vx*(vy/g));
            int yH=cmp(B[i],T[i],cal(vy,vy/g));
            if(xH==0 && yH>=0 && yL<0) ok=false;
            if(yL*yR<=0) ok=false;
        }
        if(ok) return true;
    }
    return false;
}

void solve(){
    for(int i=0;i<N;i++){
        R[i]=min(X,R[i]);
    }
    bool ok=check(X,Y);
    for(int i=0;i<N;i++){
        ok|=check(L[i],T[i]);
        ok|=check(R[i],T[i]);
    }
    printf("%s\n",ok?"Yes":"No");
}

int main(void){
    scanf("%d %d %d %d",&N,&V,&X,&Y);
    for(int i=0;i<N;i++){
        scanf("%d %d %d %d",&L[i],&B[i],&R[i],&T[i]);
    }
    solve();
    return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a,b,c,k;
inline void read(ll &x)
{
	ll f=1;char c;
	for(x=0,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48); x*=f;
}
int main()
{
	read(a);read(b);read(c);read(k);
	if(k<=a)
	{
		printf("%lld\n",k);
		return 0;
	}
	if(k<=a+b)
	{
		printf("%lld\n",a);
		return 0;
	}
	printf("%lld\n",a-(k-a-b));
	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}


int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll>H(N);
	rep(N)
		cin >> H[i];
	vector<ll>C(N,1);
	vector<ll>A(M);
	vector<ll>B(M);
	rep(M) {
		cin >> A[i] >> B[i];
		A[i] -= 1;
		B[i] -= 1;
		if (H[A[i]] >= H[B[i]])
			C[B[i]] = 0;
	    if (H[A[i]] <= H[B[i]])
			C[A[i]] = 0;
	}
	ll ans = 0;
	rep(N) {
		ans += C[i];
	}
	cout << ans;
}

Measured memory_bytes: 6428
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for lr in range(min(n, k)+1):
    for l in range(lr+1):
        r = lr - l
        jewels = v[:l]+v[-r:] if r > 0 else v[:l]
        n_release = k - lr
        ans_cur = 0
        for j in sorted(jewels):
            if j < 0 and n_release > 0:
                n_release -= 1
            else:
                ans_cur += j
        ans = max(ans, ans_cur)
        
print(ans)


Measured memory_bytes: 3064
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#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 reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#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<P> v(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        v[i] = P(x, y);
    }
    sort(all(v));
    rep(i, n) cout << v[i].fi << " " << v[i].se << endl;
}



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

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

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

const int MAX_N = 110;
const int MAX_V = 100010;

int N;
ll W, weight[MAX_N], value[MAX_N];
ll dp[MAX_N][MAX_V];

int main() {
  IOS;
  constexpr char endl = '\n';

  int N, W;
  cin >> N >> W;
  rep(i, N) cin >> weight[i] >> value[i];

  rep(i, MAX_N) rep(j, MAX_V) dp[i][j] = INFL;
  dp[0][0] = 0;

  rep(i, N) rep(sum_v, MAX_V) {
    if (sum_v - value[i] >= 0)
      chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
    chmin(dp[i + 1][sum_v], dp[i][sum_v]);
  }

  ll res = 0;
  rep(sum_v, MAX_V) {
    if (dp[N][sum_v] <= W) res = max(res, (ll)sum_v);
  }

  cout << res << endl;
}

Measured memory_bytes: 86272
#include <iostream>
using namespace std;
int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (max(a, b) - min(a, b) <= d && max(b, c) - min(b, c) <= d || (max(a, c) - min(a, c) <= d)) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;

	return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    int a,score = 0;
    cin >> a;
  	int b[a],c[a],d[a-1];
	for(int i = 0 ; i < a ;i++){
      cin >> b[i];
    }
  	for(int i = 0 ; i < a ;i++){
      cin >> c[i];
    }
  	for(int i = 0 ; i < (a-1) ;i++){
      cin >> d[i];
    }
  	for(int i = 0 ; i < a ;i++){
      score += c[b[i] - 1];
        if((b[i -1] + 1) == b[i]){
          score += d[b[i -1] - 1];
        }
    }
    cout << score << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    int N;cin>>N;
    cout<<(N+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    double a, b, c, d, e, f;
    
    while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF){
        double y=0, x=0;
        y = (a*f-c*d)/(a*e-b*d);
        x = (c-b*y)/a;
        
        printf("%.3f %.3f\n", x, y);
        
    }
    
    return 0;
}



Measured memory_bytes: 2036
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
  int N, X, Y;
  cin >> N >> X >> Y;

  int dmin[N + 1][N + 1];
  int ans[N] = {};

  for(int i = 1; i < N; i++){
    for(int j = i; j < N + 1; j++){
      dmin[i][j] = min(abs(j - i), abs(X - i) + 1 + abs(Y - j));
      dmin[i][j] = min(dmin[i][j], abs(Y - i) + 1 + abs(X - j));
      ans[dmin[i][j]]++;
    }
  }

  for(int k = 1; k < N; k++){
    cout << ans[k] << endl;
  }

  return 0;
}

Measured memory_bytes: 15744
#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 0
    for d in range(40,-2,-1):# X, Kは高々40bit
        # dはXとKのbitが初めて一致しない桁（全探索している）
        if d != -1 and not (K & (1<<d)):# Kが0の桁はdの候補から外れる
            continue

        tmp = 0
        for e in range(40,-1,-1):# 上の桁から見ていく
            mask = 1<<e# e桁目の数字だけ
            num = 0
            # 配列Aのそれぞれのe桁目のbitの和
            for i in range(N):
                if A[i] & mask:
                    num += 1
            
            if e > d:
                if K & mask:# e桁目が1なので元が0の数だけ立ち上がる
                    tmp += mask*(N-num)
                else:
                    tmp += mask*num
            elif e == d:# K==1よりX==0, よって元が1の数だけ立ち上がる
                tmp += mask*num
            else:# Xが自由に選べるから立ち上がる数が大きくなるようにGreedyに取れる
                tmp += mask*max(num,N-num)
        ans = max(ans,tmp)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 86900
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
#define int ll

#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second

#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

#define MOD (ll)(1e9+7)
#define INF (1e18)
#define EPS (1e-6)

#ifdef LOCALMEOW
#define debug(...) do{\
	cerr << __PRETTY_FUNCTION__ << " - " << __LINE__ <<\
	" : ("#__VA_ARGS__ << ") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T> void _OUT(T x) { cerr << x << "\n"; }
template<typename T,typename...I>
void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); }
#else
#define debug(...)
#endif
void INIT(){ ios::sync_with_stdio(false); cin.tie(0); }


int32_t main(){
	//code...
	int n; cin >> n;
	vector<int> v(n), dp(n);
	for(auto &i:v) cin >> i;
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);
	For(i, 2, n - 1){
		dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]),
				    dp[i-2] + abs(v[i] - v[i-2]));
	}
	cout << dp[n-1]<<"\n";
	return 0;
}
























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

int dfs(int v, vector<string> const& g, vector<bool>& visited) {
    visited[v] = true;
    int res = 1;
    for(int i = 0; i < (int)g.size(); ++i) {
        if(g[v][i] == 'Y' && !visited[i]) {
            res += dfs(i, g, visited);
        }
    }
    return res;
}

int rec(int odd, int even, int unused, vector<vector<vector<int>>>& dp) {
    int& res = dp[odd][even][unused];
    if(res != -1) {
        return res;
    }

    if(odd + even == 2) { // base
        return res = unused;
    }
    if(odd > 0 && even > 0 && !rec(odd, even - 1, !unused, dp)) {
        return res = 1;
    }
    if(odd >= 2 && !rec(odd - 2, even + 1, unused, dp)) {
        return res = 1;
    }
    if(even >= 2 && !rec(odd, even - 1, !unused, dp)) {
        return res = 1;
    }
    return res = 0;
}

int main() {
    int N;
    cin >> N;
    vector<string> g(N);
    for(int i = 0; i < N; ++i) {
        cin >> g[i];
    }

    vector<bool> visited(N);
    int odd = 0, even = 0;
    int unused = 0;
    for(int i = 0; i < N; ++i) {
        if(!visited[i]) {
            int C = dfs(i, g, visited);
            unused += C * (C - 1) / 2;
            if(C & 1) {
                ++odd;
            } else {
                ++even;
            }
        }
        for(int j = i + 1; j < N; ++j) {
            unused -= (g[i][j] == 'Y');
        }
    }
    unused %= 2;

    vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(N + 1, vector<int>(2, -1)));
    if(rec(odd, even, unused, dp)) {
        cout << "Taro" << endl;
    } else {
        cout << "Hanako" << endl;
    }
}


Measured memory_bytes: 58772
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n;
    cin>>n;
    ll sum=0,i=1;
    while(sum<n){
        sum+=i;
        i++;
    }
    repi(j,1,i){
        if(j==sum-n) continue;
        cout<<j<<endl;
    }
}

Measured memory_bytes: 3596
//By : BebekJK
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 998244353
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

typedef long long ll;
typedef long long ld;
typedef pair<int , int> pii;
typedef pair<long long , long long> pll;

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
ll N , M , K;
ll fact[200005];
ll comb(ll a , ll b){
	ll temp = fact[a];
	temp*=pmod((fact[b]*fact[a-b])%MOD , MOD-2);
	return temp%MOD;
}
int main(){
//	BOOST();
	
	fact[0] = 1;

	cin>>N>>M>>K;
	for(int i=1;i<=N;i++)fact[i]=(fact[i-1]*i)%MOD;
	ll ans = 0;
	for(int i=0;i<=K;i++){
		ans = ans + (comb(N-1,i)*pmod(M-1,N-i-1))%MOD;
		ans%=MOD;
	}
	ans*=M;
	ans%=MOD;
	cout<<ans<<endl;
}





Measured memory_bytes: 5196
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
# print(N, A)

L = [0]*(N - 1)
R = [0]*(N - 1)
L[0] = A[0]
R[0] = A[-1]

for i in range(1, N - 1):
    L[i] = gcd(L[i - 1], A[i])
    R[i] = gcd(R[i - 1], A[-1 - i])

# print(L)
# print(R)

B = [R[-1]]
for i in range(N - 2):
    l = L[i]
    r = R[N - 3 - i]
    # print(l, r)
    B.append(gcd(l, r))
B.append(L[-1])

# print(B)
ans = max(B)
print(ans)


Measured memory_bytes: 90344
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int num=0;
    scanf("%d",&num);
    int x[num];
    int max,min;
    scanf(" %d",&x[0]);
    scanf(" %d",&x[1]);
    max=x[1]-x[0];
    if(x[1]<x[0]){
        min=x[1];
    }else{
        min=x[0];
    }
    
    for(int i=2;i<num;i++){
        scanf(" %d",&x[i]);
        
        if(x[i]>=min&&x[i]-min>max){
            max=x[i]-min;
        }
        if(x[i]<min){
            min=x[i];
        }

    }
    printf("%d\n",max);
}


Measured memory_bytes: 3460
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll K;
string S;

cin >> K >> S;

if(S.length() <= K) cout << S << endl;
else{

    for(ll i = 0;i < K;++i) cout << S[i];
    cout << "..." << endl;


}

return 0;

}

Measured memory_bytes: 3620
import math
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
N,M = map(int,input().split())
L = prime_factor(M)
L.append(0)
K = []
cur = L[0]
cnt = 0
for i in range(len(L)):
  if cur == L[i]:
    cnt += 1
  else:
    K.append(cnt)
    cnt = 1
    cur = L[i]
ans = 1
for i in range(len(K)):
  n = K[i]+N-1
  k = N-1
  cur = 1
  for i in range(k+1,n+1):
    cur *= i
  for j in range(1,n-k+1):
    cur = cur//j
  ans *= cur%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	string s,t;
	cin>>s>>t;
	cout<<t+s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	string s[3];
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}
	int i = 0;
	while (s[i].size() > 0) {
		int j = s[i][0] - 'a';
		s[i].erase(0, 1);
		i = j;
	}
	cout << (char) ('A'+i) << endl;
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, a;
    cin >> n >> a;
    if(n % 500 <= a){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,0,n) cin >> a[i];
  int ans = 0;
  rep(i,0,n) {
    int b;
    cin >> b;
    ans += b;
  }
  vector<int> c(n);
  rep(i,1,n) cin >> c[i];
  rep(i,0,n-1) {
    if (a[i+1]-a[i] == 1) {
      ans += c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
from fractions import gcd
A, B=map(int, input().split())
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

  # divisors.sort()
  return divisors

import math

def is_prime(n):
  if n == 1: return False

  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False

  return True
ans=0
for x in set(make_divisors(A))&set(make_divisors(B)):
  if is_prime(x):
    ans+=1

#print(set(make_divisors(A))&set(make_divisors(B)))
print(ans+1)

Measured memory_bytes: 7160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
using namespace std;

int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H')
	{
		cout << b << endl;
	}
	if (a == 'D')
	{
		if (b == 'H')
		{
			cout << 'D' << endl;
		}
		else
		{
			cout << 'H' << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    long long N,A,B,C,D;
    string S;
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    if (C < D){
        bool a_can_clear = true;
        bool b_can_clear = true;
        for (int i = A;i< C;i++){
            if (S[i] == '#' && S[i-1] == '#'){
                // cout << "cannotclear" << endl;
                a_can_clear = false;
            }
        }
        for (int i = B;i< D;i++){
            if (S[i] == '#' && S[i-1] == '#'){
                // cout << "cannotclear" << endl;
                b_can_clear = false;
            }
        }
        if (a_can_clear && b_can_clear){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        bool a_can_clear = true;
        bool b_can_clear = true;
        for (int i = A;i< C;i++){
            if (S[i] == '#' && S[i-1] == '#'){
                // cout << "cannotclear" << endl;
                a_can_clear = false;
            }
        }
        for (int i = B;i< D;i++){
            if (S[i] == '#' && S[i-1] == '#'){
                // cout << "cannotclear" << endl;
                b_can_clear = false;
            }
        }
        bool can_oikoshi = false;
        for (int i = B - 1;i< D;i++){
            if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.'){
                // cout << "oikoshi" << endl;
                can_oikoshi = true;
            }
        }

        if (a_can_clear && b_can_clear && can_oikoshi){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
  
  
      
int main(){
 

int i,j=0,n,kane;

scanf("%d",&n);

kane=100000;

for(i=0;i<n;i++){
	kane*=1.05;
	if(kane%1000>0){
		kane-=kane%1000;
		kane+=1000;
	}
}

printf("%d\n",kane);

    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll N,M;
int main(){
	cin>>N>>M;

	ll ans=0;
	if(2*N>M){
		ans=M/2;
	}else{
		ans=N+(M-2*N)/4;
	}








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


Measured memory_bytes: 256