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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int n;
  cin>>n;

  map<int,int> mp;

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

  //for (auto ite = mp.begin();ite != mp.end();ite++) cout<<ite->first<<' '<<ite->second<<endl;
  //cout<<"---"<<endl;

  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    if(!mp[a]){
      cout<<"NO"<<endl;
      return 0;
    }
    mp[a]--;
    //for (auto ite = mp.begin();ite != mp.end();ite++) cout<<ite->first<<' '<<ite->second<<endl;
    //cout<<"---"<<endl;
  }
  cout<<"YES"<<endl;
  return 0;  

}


Measured memory_bytes: 9600
n = int(input())
if n % 2:
    print(0)
else:
    i, k = 0, [1]
    while n > 10*5**i:
        k.append(5*k[i] + 1)
        i += 1  
    ans, r = 0, n
    while i:
        q, r = divmod(r, 10*5**i)
        ans += q*k[i]
        i -= 1
    print(ans + r//10)

Measured memory_bytes: 3060
n=int(input())
ans=0
def divisor(n):
    d0=[]
    d1=[]
    for i in range(1,int(n**.5)+1):
        x,y=divmod(n,i)
        if y==0:
            d0.append(i)
            d1.append(x)
    if d1[-1]==d0[-1]:
        d1=d1[:-1]
    return d0+d1[::-1]
d=divisor(n)
for i in d:
    if i>2 and n//i<i-1:
        ans+=i-1
print(ans)

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

using namespace std;
typedef long long ll;
#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> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
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;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

int main(){
    int x, n;
    cin >> x >> n;

    vi a;

    rep(i,n){
        int tmp;
        cin >> tmp;

        a.emplace_back(tmp);
    }

    sort(a.begin(), a.end());

    int ans = x;
    int i = 0;
    while(true){
        int l = x - i;
        int r = x + i;

        bool fl = binary_search(a.begin(), a.end(), l);
        bool fr = binary_search(a.begin(), a.end(), r);

        if(!fl){
            cout << l << endl;
            break;
        } 

        if(!fr){
            cout << r << endl;
            break;
        }
        i++;
    }
}


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

int main() {
  int N, count = 0, i;
  bool isGood = false;
  cin >> N;
  vector<int> a(N);
  for (i =0; i<N; i++) {
    cin >> a[i];
    a[i] --;
  }
  i = 0;
  for(int j=0; j < N; j++){
    if(a[i] == 1){
      cout << count + 1 << endl;
      isGood = true;
      break;
    }
    else if(a[i] == 0){
      cout << -1 << endl;
      isGood = true;
      break;
    }
    else {
      count ++;
      i = a[i];
    }
  }
  if (!isGood) cout << -1 << endl;
  
}

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

ll a[N], b[N];

void solve() {
	vector<pair<ll, int>> c, d;
	int n;
	cin >> n;
	ll ans = 0, sa = 0, sb = 0;
	ll cur = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		sa += a[i];
		sb += b[i];

		cur += min(a[i], b[i]);
		c.push_back(make_pair(min(a[i], b[i]), i));
		d.push_back(make_pair(a[i] + b[i] - min(a[i], b[i]), i));
	}
	ans = min(sa, sb);

	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());

	sort(d.begin(), d.end());

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (c[i].second == d[j].second) continue;
			ans = min(ans, cur - c[i].first + d[j].first);
		}
	}

	for (int i = 0; i < n; i++) {
		if (c[i].first <= d[i].first) break;
		cur -= c[i].first;
		cur += d[i].first;
		ans = min(ans, cur);
	}

	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
	D = true;	
	tst = 4;
	while (tst--) {
		solve();
	}
#else
	while (tst--) solve();
#endif
}


Measured memory_bytes: 8420
#include <iostream>
#include<string.h>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<set>
#include<vector>
#define ll long long
using namespace std;
int main()
{
    int n,tmp,ret=0,ans=0;
    vector<int>v;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tmp);
        if(tmp==i)
            ret++;
            else if(ret&&tmp!=i)
            {
                v.push_back(ret);
                ret=0;
            }
        if(tmp==n)
            v.push_back(ret);

    }
    for(int i=0;i<v.size();i++)
    {
        ans+=(v[i]+1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
/*
 *  Lang    : C++
 *  Author  : little_angel
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3648
int main(void) {
    int H[100], W[100];
    int n, i, l, ret, nak, ire;
    for ( n = 0; ; n++ ) {
        scanf("%d %d", &H[n], &W[n]);
        if ( H[n] == 0 && W[n] == 0 )   break;
    }
    for ( l = 0; l < n; l++ ) {
        for ( i = 0; i < W[l]; i++ ) {
            printf("#");
        }
        printf("\n");
        for ( ret = 0; ret < H[l] - 2; ret++ ) {
            printf("#");
            for ( nak = 0; nak < W[l] - 2; nak++ ) {
                printf(".");
            }
            printf("#\n");
        }
        for ( ire = 0; ire < W[l]; ire++ ) {
            printf("#");
        }
        printf("\n");
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2052
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var x = Read();
            var n = x / 100;
            Console.WriteLine(n * 100 <= x && x <= n * 100 + 5 * n ? 1 : 0);


            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 11092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int read = rint();
        WriteLine(read*read);

    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 13140
def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  c = [0] * (max(a) + 3)
  for x in a:
    x += 1
    c[x-1] += 1
    c[x] += 1
    c[x+1] += 1
  ans = max(c)

  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 13964
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 053 ABC/ARC a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  int x;
  cin >> x;
  cout << (x < 1200 ? "ABC" : "ARC") << endl;
  return 0;
}



Measured memory_bytes: 256
//
// Created by munaiyi on 2020/3/20.
//
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
long long fac[maxn], inv[maxn];

void init() {
    inv[0] = inv[1] = 1;
    fac[0] = fac[1] = 1;
    for (int i = 2; i < maxn; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    }
    for (int i = 2; i < maxn; i++) {
        inv[i] = inv[i - 1] * inv[i] % mod;
    }
}

long long C(int a, int b) {
    if (a < 0 || b < 0 || b > a) return 0;
    return fac[a] * inv[b] % mod * inv[a - b] % mod;
}

int a[maxn];

int main() {
    init();
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
    }
    sort(a, a + n);
    long long ans = 0;
    for (int i = 0; i <= n - k; i++) {
        ans = (ans - C(n - i - 1, k - 1) * a[i]) % mod;
    }
    for (int i = n - 1; i >= k - 1; i--) {
        ans = (ans + C(i, k - 1) * a[i]) % mod;
    }
    ans = (ans % mod + mod) % mod;
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    int cnt_e=0;
    int cnt_o=0;
    int cnt_4=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]%4==0){
            cnt_4++;
        }else if(a[i]%2!=0){
            cnt_o++;
        }else{
            cnt_e++;
        }
    }
    if(cnt_e==0){
        if(cnt_o-1<=cnt_4){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(cnt_o==0&&cnt_4==0){
        cout << "Yes" << endl;
    }else{
        if(cnt_o<=cnt_4){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int r;
	while(scanf("%d", &r)==1)
	{
		printf("%.6f\n", 2.0*PI*r);
	}
	return 0;
}


Measured memory_bytes: 1748
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

int A[maxn];

vector<int> G[maxn],G2[maxn];

int vi[maxn];

priority_queue<PII> Q;

int deg[maxn];

bool cmp(int x,int y){
	return A[x]<A[y];
}

void addedge(int u,int v){
	deg[v]++;
	G2[u].PB(v);
}

void dfs(int u){
	vi[u]=1;
	for(auto v:G[u])if(!vi[v]){
		addedge(u,v);
		dfs(v);
	}
}

void Work(){
	REP(i,1,n)if(!vi[i])dfs(i);
	REP(i,1,n)if(!deg[i])Q.push(MP(A[i],i));
	while(!Q.empty()){
		int u=Q.top().se;Q.pop();
		printf("%d ",A[u]);
		for(auto v:G2[u])if(!--deg[v])Q.push(MP(A[v],v));
	}
}

void Init(){
	read(n);
	REP(i,1,n)read(A[i]);
	sort(A+1,A+n+1);
	REP(i,1,n)REP(j,1,n)if(i!=j&&__gcd(A[i],A[j])!=1)G[i].PB(j);
	REP(i,1,n)sort(G[i].begin(),G[i].end(),cmp);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 20608
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

bool f[8][8];
int ans = 0;
int n;
void solve( int now , vector<bool> c , int cnt ){
	
	if( cnt == 0 ){
		ans++;
		ret;
	}
	
	rep(i,0,n){
		if( !c[i] && f[now][i] ){
			vector<bool> tmp = c;
			tmp[i] = 1;
			solve( i , tmp , cnt-1 );
		}
	}


}

int main(){
	int m;
	cin >> n >> m;
	rep(i,0,m){
		int a,b;
		cin >> a >> b;
		a--; b--;
		f[a][b] = 1;
		f[b][a] = 1;
	}
	
	vector<bool> c(n,0);
	c[0] = 1;
	solve( 0 , c , n-1);

	cout << ans << endl;

	ret 0;
}

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


int main(){
  int N, M;
  string s[101], t[101];

  cin >> N;
  for (int i = 0; i < N; i++) cin >> s[i];

  cin >> M;
  for (int i = 0; i < M; i++) cin >> t[i];

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int temp = 0;
    for (int j = i; j < N; j++) {
      if (s[i] == s[j]) {
        temp++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (s[i] == t[j]) {
        temp--;
      }
    }
    if (temp >= ans) {
      ans = temp;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
program christmas_eve
  implicit none
  integer              :: n, k, m, sub, i
  integer, allocatable :: h(:)
  read(*,*) n, k
  allocate(h(n))
  m = 1000000001
  do i = 1, n
     read(*,*) h(i)
  end do
  call merge_sort(n,h)
  do i = 1, n-k+1
     sub = h(i+k-1) - h(i)
     if (sub < m) m = sub
  end do
  deallocate(h)
  write(*,'(i0)') m
  stop
contains
  subroutine merge_sort(n,c)
    implicit none
    integer, intent(in)    :: n
    integer, intent(inout) :: c(n)
    integer                :: number, length, i, ubound
    number = n
    length = 1
    do while (number .gt. 1)
       do i = 1, number/2
          ubound = min(2*i*length,n)
          call merge(c(2*(i-1)*length+1:(2*i-1)*length),c((2*i-1)*length+1:ubound))
       end do
       length = 2*length
       number = (number+1)/2
    end do
    return
  end subroutine merge_sort

  subroutine merge(c1,c2)
    implicit none
    integer, intent(inout) :: c1(:), c2(:)
    integer                :: c(size(c1)+size(c2))
    integer                :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1)
    n2 = size(c2)
    do while (i1 .le. n1 .and. i2 .le. n2)
       if (c1(i1) .lt. c2(i2)) then
          c(i1+i2-1) = c1(i1)
          i1 = i1+1
       else
          c(i1+i2-1) = c2(i2)
          i2 = i2+1
       end if
    end do
    if (i1 .le. n1) then
       c(i1+i2-1:n1+n2) = c1(i1:n1)
    else if (i2 .le. n2) then
       c(i1+i2-1:n1+n2) = c2(i2:n2)
    end if
    c1 = c(1:n1)
    c2 = c(n1+1:n1+n2)
    return
  end subroutine merge

  subroutine swap(a,b)
    implicit none
    integer, intent(inout) :: a, b
    integer                :: c
    c = a
    a = b
    b = c
    return
  end subroutine swap
end program christmas_eve

Measured memory_bytes: 1276
n = int(input())
a = [0 for i in range(n)]
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        xx, yy = map(int,input().split())
        x[i].append(xx)
        y[i].append(yy)
ans = 0
for i in range(2**n):
    ok = True
    for j in range(n):
        if ((1 << j) & i):
            for k in range(a[j]):
                if y[j][k] == 0:
                    if (1 << (x[j][k] - 1)) & i:
                        ok = False
                else:
                    if not((1 << (x[j][k] - 1)) & i):
                        ok = False
    if ok:
        cnt = bin(i).count('1')
        ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
n=int(input());a=list(map(int,input().split()));print(2*n-1)
if min(a)+max(a)>0:
    s=a.index(max(a))
    for i in range(n):print(s+1,i+1)
    for i in range(1,n):print(i,i+1)
else:
    s=a.index(min(a))
    for i in range(n):print(s+1,i+1)
    for i in range(n,1,-1):print(i,i-1)

Measured memory_bytes: 3064
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;




int main() {
  int a;
  cin>>a;
  vector<int> vec(a);
  int ans=0;
  rep(i,a){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  rep(i,a){
    rep(j,i){
      int ab=vec.at(i)+vec.at(j);
      int r=lower_bound(vec.begin(),vec.end(),ab)-vec.begin();
      int l=i+1;
      ans+=r-l;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
   unsigned long n,t,a[10000],sum,i,curr,prv;
   scanf("%lu%lu\n",&n,&t);
    scanf("%lu",&prv);
       sum=0;
       
   for(i=1;i<n;i++)
   {
       scanf("%lu",&curr);
       if(abs(curr-prv)<=t)
       {
           sum+=abs(curr-prv);
       }else{
           if(abs(curr-prv)>t)
           {
               sum+=t;
           }
       }
       prv=curr;
   }
   printf("%lu",(n==1)?t:sum+t);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){

  int n;
  int x[100];
  int y;

  double sum1=0,sum2=0,sum3=0,sumi=0;

  cin >> n;

  for(int i=0; i<n; i++)
    cin >> x[i];

  for(int i=0; i<n; i++){
    cin >> y;
    sum1 += abs(x[i]-y);
    sum2 += (x[i]-y)*(x[i]-y);
    sum3 += abs( (x[i]-y)*(x[i]-y)*(x[i]-y) );

    if(sumi < abs(x[i]-y))
      sumi = abs(x[i]-y);

  }

  printf("%.8lf\n%.8lf\n",sum1, sqrt(sum2) );
  printf("%.8lf\n%.8lf\n", pow(sum3,1.0/3.0), sumi);

  return 0;

}

Measured memory_bytes: 1232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPCvirtual6
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int val = ReadInt();
            WriteLine(val / 3);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

const int MAX=1000000007;

int main() {
  int n;
  while(cin >> n && n) {
    string t[n];
    for(int i=0; i<n; i++) cin >> t[i];
    int a[n][n];
    set<int> se;
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	if(i==j)continue;
	for(int k=0; k<t[i].size(); k++) {
	  string x=t[i].substr(k);
	  if(x.size()>t[j].size()) {
	    x=x.substr(0,t[j].size());
	    if(x==t[j]) {
	      se.insert(j);
	      break;
	    }
	  }
	}
      }
    }
    vector<string> s;
    for(int i=0; i<n; i++) if(!se.count(i)) s.push_back(t[i]);
    n=s.size();
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	if(i==j) a[i][j]=0;
	bool ck=true;
	for(int k=0; k<s[i].size(); k++) {
	  string x=s[i].substr(k);
	  string y=s[j].substr(0,min(s[j].size(),s[i].size()-k));
	  if(x==y) {
	    a[i][j]=k+s[j].size()-s[i].size();
	    ck=false;
	    break;
	  }
	}
	if(ck) a[i][j]=s[j].size();
      }
    }
    int dp[(1<<n)][n];
    fill(dp[0],dp[(1<<n)],MAX);
    for(int i=0; i<n; i++) dp[(1<<i)][i]=s[i].size();
    for(int t=0; t<(1<<n); t++) {
      for(int i=0; i<n; i++) {
	for(int j=0; j<n; j++) dp[t|(1<<j)][j]=min(dp[t|(1<<j)][j],dp[t][i]+a[i][j]);
      }
    }
    int ans=MAX;
    for(int i=0; i<n; i++) ans=min(ans,dp[(1<<n)-1][i]);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2112
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i,n,a[222222];
	cin >>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(&a[1],&a[n+1]);
	for(i=1;i<=n-1;i++){
		if (a[i] == a[i+1]){
			cout<<"NO"<<endl;
			return 0;
		}
	}	
	cout<<"YES"<<endl;
	return 0;
}


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

vector<pair<ll, ll>> prime_factor(ll n) {
    vector<pair<ll, ll>> ret;
    for (ll i = 2; i * i <= n; i++) {
        ll tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        ret.push_back(make_pair(i, tmp));
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}

int main() {
  ll N;
  cin >> N;

  vector<pair<ll, ll>> primeList = prime_factor(N);
  ll ans = 0;
  for (auto &x : primeList)
  {
    ll i = 1;
    while (x.second >= i)
    {
      x.second -= i;
      i++;
      ans++;
    }  
  }
  cout << ans << endl;
  return 0;
}


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

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = Integer.parseInt(sc.nextLine());
    
    Map<String, Integer> map = new HashMap<>();
    for(int i=0;i<n;i++){
      String result = sc.nextLine();
      map.put(result, map.getOrDefault(result,0)+1);
    }
    
    for(String item:new String[]{"AC","WA","TLE","RE"}){
      System.out.println(item + " x " + map.getOrDefault(item,0));
    }
  }
}


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

using namespace std;

#define PI (3.14159265358979323846)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MS multiset
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

const db eps = 0.00001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 750555;
const int M = 1125;

void solve() {
    int x;
    cin >> x;
    
    if (x >= 30) cout << "Yes"; else
        cout << "No";


}

int main() {
    ios_base::sync_with_stdio(false);

#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**7)

s = input()
t = input()

n = len(s)
m = len(t)

dp = [[0]*(m+1) for _ in range(n+1)]

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i][j] + 1, dp[i][j+1], dp[i+1][j])
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

ans = ""

def LCS(i=n,j=m):
    global ans
    if (i, j) == (0,0):
        return
    tmp = dp[i][j]
    if s[i-1] == t[j-1]:
        if i-1 >= 0 and j-1 >=0 and tmp == dp[i-1][j-1] + 1:
            ans = s[i-1] + ans
            LCS(i-1, j-1)
        elif i-1 >= 0 and tmp == dp[i-1][j]:
            LCS(i-1, j)
        elif j-1 >= 0 and tmp == dp[i][j-1]:
            LCS(i, j-1)
    else:
        if i-1 >= 0 and tmp == dp[i-1][j]:
            LCS(i-1, j)
        elif j-1 >= 0 and tmp == dp[i][j-1]:
            LCS(i, j-1)

LCS()
print(ans)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  string s;
  cin >> s;
  for(int i = 0; i < 3; ++i)
  {
    if (s[i] == '1') cout<< '9';
    if (s[i] == '9') cout<< '1';
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

#define max 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int i,h,A[max+1];

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=h)printf("left key = %d, ",A[left(i)]);
    if(right(i)<=h)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,K;
    cin >> N >> K;
    int h[114514];
    for (int i=0;i<N;i++){
        cin >> h[i];
    }
    sort(h,h+N);
    int ans=1145141919;
    for (int i=0;i<N-K+1;i++){
        if (ans>h[i+K-1]-h[i]){
            ans=h[i+K-1]-h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a; cin >> a;
	string s; cin >> s;
	if(a >= 3200) cout << s << endl;
	else cout << "red" << endl;
} 

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	vector<bool> vec;
	vec.resize(n, false);

	rep(i, k){
		int d;
		cin >> d;

		rep(j, d){
			int x;
			cin >> x;
			
			vec[x - 1] = true;
		}
	}

	int ans = 0;

	rep(i, n){
		if(!vec[i]) ans++;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long 
		#define ld long double
		#define MOD 1000000007
		#define mod9 1000000009
		#define mod 1000003
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second   	
		bool isPrime(ll n) 
		{ 
			// Corner case 
			if (n <= 1) 
				return false; 
			
			// Check from 2 to n-1 
			for (ll i = 2; i*i <= n; i++) 
				if (n % i == 0) 
					return false; 
			
			return true; 
		}
		long long binpow(long long a, long long b) {
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = (res%mod) * (a%mod);
				a = (a%mod) * (a%mod);
				b >>= 1;
			}
			return res%mod;
		}

		bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
		{
			return (a.se<b.se);
		}
		ll lcm(ll a,ll b)
		{
			return(a*b)/__gcd(a,b);
		}
		vector<ll>s[2005];
		void SieveOfEratosthenes() 
		{  
			ll n=2005;
			bool prime[1000005]; 
			memset(prime, true, sizeof(prime)); 
			// s[0]=1;
			// s[1]=1;
			for (int p=2; p*p<=n; p++) 
			{ 
				s[p].pb(1);
				if (prime[p] == true) 
				{   
					for (int i=p+p; i<=n; i += p) {
						prime[i] = false; 
						s[i].pb(p);
						}
				} 
			} 
			// for(ll i=2;i<10005;i++)
			// {
			// 	if(prime[i])
			// 	{
			// 		// s.pb(i);
			// 	}
			// }
		} 
		void eea(ll a, ll b, ll & x, ll & y) {
		if (a == 0) {
			x = 0;
			y = 1;
			return ;
		}
		ll x1, y1;
		eea(b % a, a, x1, y1);
		x = y1 - (b / a) * x1;
		y = x1;
		return ;
	}
	ll modinverse(ll a,ll m)
	{
		ll x, y;
		eea(a, m, x, y);
		if (__gcd(a,m) != 1) {
		return -1;
		}
	else {
		x = (x % m + m) % m;
		cout << x << endl;
		return x;
	}
	}
		ll fact[1000007]={0};
		ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
		y=y>>1;x=(1ll*x*x)%MOD;} return res;}
		void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
		ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
		ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
			ll C(ll n, ll k) {
    ll res = 1;
    for (ll i = 1; i <= k; ++i)
        res = ((res) * (n - k + i) / i)%MOD;
    return (ll)(res + 0.01)%MOD;
}
				
		int main()
		{
			fast
			ll n,k;
			cin>>n>>k;
			cout<<min(n%k,k-(n%k))<<"\n";
			}

 

Measured memory_bytes: 256
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = id
printer = unlines . (:[])

solver ss 
  | isMonth ai && isMonth bi = "AMBIGUOUS"
  | isMonth ai = "MMYY"
  | isMonth bi = "YYMM"
  | otherwise = "NA"
  where
    (a,b) = splitAt 2 ss
    ai = int a
    bi = int b

isMonth a = 1 <= a && a <= 12


Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;

int main()
{
    ll N, K;
    ll h;
    vector<ll> H;
    cin >> N >> K;
    for (ll i = 0; i < N; i++) {
        cin >> h;
        H.push_back(h);
    }

    sort(H.begin(), H.end());
    if (K >= N) {
        cout << 0 << endl;
    }
    else {
        ll sum = 0;
        for (ll i = 0; i < N - K; i++) {
            sum += H[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }


int main()
{
    char c;
    bool x=1;
    while(cin>>c){
        if(x)cout<<c;
        x=!x;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
str = gets.chomp;
list = str.split(" ")
hash = {}
list.each do |s|
    hash[s] = 0
end
list.each do |s|
    hash[s] += 1
end
h = hash.sort {|(k1, v1), (k2, v2)| v2 <=> v1 }
print h[0][0]
print " "
l = hash.sort {|(k1, v1), (k2, v2)| k2.size <=> k1.size }
puts l[0][0]


Measured memory_bytes: 6844
import java.util.Scanner;

public class Main{
        public static void main(final String[] args){
            final Scanner sc = new Scanner(System.in);
            while(true){
                int height = sc.nextInt();
                int wideth = sc.nextInt();
                if(height + wideth == 0){
                    break;
                }
                for(int i = 0; i < height; i++){
                    for(int j = 0; j < wideth; j++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }
            sc.close();
        }
         

}


Measured memory_bytes: 63880
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, x = map(int, input().split())
a = readints()
b = sorted(a)
cnt = 0
for i in range(len(b)):
    if b[i] <= x:
        x -= b[i]
        cnt += 1
if cnt == n and x > 0:
    cnt -= 1
print(cnt)


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

const int N = 2005;
const int mod = 1e9 + 7;

void add(int &x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
}

void sub(int &x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
}

int n, m;
int dp[N][N];
int a[N], b[N];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    scanf("%d", a + i);
  for (int i = 1; i <= m; i++)
    scanf("%d", b + i);

  for (int i = 0; i <= m; i++)
    dp[0][i] = 1;

  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= m; j++) {
      add(dp[i][j], dp[i][j - 1]);
      add(dp[i][j], dp[i - 1][j]);
      sub(dp[i][j], dp[i - 1][j - 1]);
      if (a[i] == b[j])
        add(dp[i][j], dp[i - 1][j - 1]);
    }
  }
  
  printf("%d\n", dp[n][m]);
  return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll d[301][301];
ll V;
ll ans;
bool use[500][500];
 
void warshall_floyd(){
  rep(k,V){
    rep(i,V){
      rep(j,V)if(d[i][j]!=min(d[i][j],d[i][k]+d[k][j])){
        cout << -1 << endl;
        return;
      }else{
        if(i!=j && i!=k && j!=k && d[i][j]==d[i][k]+d[k][j]){
          use[i][j]=false;
        }
      }
    }
  }
  rep(i,V)REP(j,i,V)if(use[i][j])ans+=d[i][j];
  cout << ans << endl;
}

int main(){
  cin >> V;
  rep(i,V)rep(j,V)if(i!=j)use[i][j]=true;
  rep(i,V){
    rep(j,V)cin >> d[i][j];
  }
  warshall_floyd();
return 0;}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define hell 100000000
using namespace std;

int main()
{
  IOS
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=(b-a+1);
  ll x=a/c;
  if(a%c)
  	x++;
  ll y=(b/c);
  ll val=(y-x+1);
  x=a/d;
  if(a%d)
  	x++;
  y=(b/d);
  val=val+(y-x+1);
  ll l=(c*d)/__gcd(c,d);
  x=a/l;
  if(a%l)
  	x++;
  y=(b/l);
  val=val-(y-x+1);
  ans=ans-val;
  cout<<ans;
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll N,K;
 
ll check(ll x){
  ll num=x;
  ll cnt=x+1;  
  for(int i=0;i<N-1;i++){
    cnt-=num/K;
    if(num==0)break;
    if(num%K==0)num--;
    num=num-1-num/K;    
  }
  if(cnt>=N)return 1;
  return 0;
}
 
ll solve(){
  ll L=0,R=1000000000000000000LL,M;
  while(L<R){
    M=(L+R)/2LL;
   
    
    if(check(M)){
      R=M;
    }else{
      L=M+1;
    }
  }
  return L;
}
 
int main(){
  cin>>N>>K;
  for(int i=2;i<=10;i++){
    //  cout<<i << ' ' << check(i) << endl;
  }
  
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
x = 0

for i in range(N):
    x = B[i]
    if A[i] >= B[i]:
        A[i] = A[i] - B[i]
        B[i] = 0
    else:
        if A[i + 1] >= B[i] - A[i]:
            A[i + 1] = A[i + 1] + A[i] - B[i]
            A[i] = 0
            B[i] = 0
        else:
            B[i] = B[i] - A[i] - A[i + 1]
            A[i] = 0
            A[i + 1] = 0
    y = x - B[i]
    ans += y

print(ans)

Measured memory_bytes: 18396
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 7;
using namespace std;
char s[maxn];
int l[maxn], r[maxn];
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    int n, k, c;
    scanf("%d%d%d%s", &n, &k, &c, s + 1);
    for(int i = 1, m = 0, next = 0; i <= n && m < k; i++){
        if(i > next && s[i] != 'x'){
            l[m++] = i;
            next = i + c;
        }
    }
    for(int i = n, m = k - 1, next = n + 1; i >= 1 && m >= 0; i--){
        if(i < next && s[i] != 'x'){
            r[m--] = i;
            next = i - c;
        }
    }
    for(int i = 0; i < k; i++){
        // printf("%d %d\n", l[i], r[i]);
        if(l[i] == r[i] && l[i] != 0) printf("%d\n", l[i]);
    }
    return 0;
}    

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;
using ll = long long;

int main()
{
	int r, D, x;
	cin >> r >> D >> x;
	for (int i = 0; i < 10; i++)
	{
		x = r * x - D;
		cout << x << endl;
	}
	return 0;
}


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

int main(){
    int n, ans = -2e9, min_r = 2e9; cin >> n;

    for (int i = 0; i < n; i++)
    {
        int r; cin >> r;
        ans = max(ans, r - min_r);
        min_r = min(min_r, r);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main(void){
  int x, n;
  cin >> x >> n;
  int p[100];
  for(int i = 0; i < n; i++)
    cin >> p[i];
  int dist = -1;
  int is_pos;
  while(true){
    dist++;
    
    for(is_pos = 0; is_pos < 2; is_pos++){
      bool b = false;
      for(int i = 0; i < n; i++)
	if(p[i] == x + (2 * is_pos - 1) * dist)
	  b = true;
      if(b == false)
	goto END;
    }
  }
 END:
  cout << (is_pos ? x + dist : x - dist)  << endl;
  
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <ctype.h>

#define MAX 1024

char *tolowerstr(char *s){
    int i;
    
    for(i = 0; s[i] != '\0'; ++i){
        s[i] = tolower(s[i]);
    }
    
    return s;
}

int main(){
    char w[MAX], t[MAX];
    int c = 0;
    
    scanf("%s", w);
    tolowerstr(w);
    
    while(scanf("%s", t), strcmp(t, "END_OF_TEXT") != 0){
        if(strcmp(w, tolowerstr(t)) == 0){
            ++c;
        }
    }
    
    printf("%d\n", c);
    
    return 0;
}


Measured memory_bytes: 2112
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

long long int gcd(long long int x, long long int y){
  if(x < y) swap(x,y);
  while(y){
    x %= y;
    swap(x,y);
  }
  return x;
}

int main(){
  long long int n, m;
  cin >> n >> m;
  vector<long long int> A(n);
  vector<double> P(n);
  for(int i = 0; i < n; ++i) cin >> A[i];
  for(int i = 0; i < n; ++i){
    cin >> P[i];
    P[i] /= 100.0;
  }
  double ans = 0;
  vector<long long int> LCM;
  vector<double> P_;
  vector<int> C;
  LCM.push_back(1);
  P_.push_back(1.0);
  C.push_back(0);
  for(int i = 0; i < n; ++i){
    long long int s = LCM.size();
    for(long long int j = 0; j < s; ++j){
      if(LCM[j]/gcd(LCM[j],A[i]) > m/A[i]) continue;
      long long int t = LCM[j]/gcd(LCM[j],A[i])*A[i];
      if(t > m) continue;
      double p = P_[j]*P[i];
      int c = C[j] + 1;
      if(c%2) ans += m/t*p;
      else ans -= m/t*p;
      LCM.push_back(t);
      P_.push_back(p);
      C.push_back(c);
      //cout << t << " " << p << " " << c << endl;
    }
  }
  printf("%.12f\n",ans);
  return 0;
}



Measured memory_bytes: 27508
#include<cstdio>
char a[105],b[105],c[105];

int main(){
    int n;
    scanf("%d%s%s%s",&n,a+1,b+1,c+1);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(a[i]==b[i] && b[i]==c[i]) continue;
        else if(a[i]==b[i] || a[i]==c[i] || b[i]==c[i]) ans++;
        else ans += 2;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1732
#include <cstdio>
#include <cstring>

#define MAXN 107

int onlyOneLetters(char *s)
{
    int winFlag=1,i;
    for (i=1;s[i];i++)
    {
        if(s[i]!=s[0])
        {
            winFlag=0;
            break;
        }
    }
    if(winFlag==1)
        return 1;
    else
        return 0;

}

int groupThem(char *s)
{
    char curr=s[0];
    int sum,count,i;
    sum=0;
    count=1;
    for(i=1;s[i];i++)
    {
        if(curr==s[i])
            count+=1;
        else
        {
            sum+=(count/2);
            count=1;
            curr=s[i];
        }
    }
    sum+=(count/2);
    return sum;
}


int main(void)
{
    char s[MAXN],ds[2*MAXN];
    int N,delta,monoswapTimes;
    long long K;
    scanf("%s",s);
    scanf("%lld",&K);

    N=strlen(s);
    if(onlyOneLetters(s))
    {
        printf("%lld\n",(N*K)/2);
    }
    else
    {
        strcpy(ds,s);
        strcpy(ds+N,s);
        
        monoswapTimes=groupThem(s);
        delta = groupThem(ds)-2*monoswapTimes;
        printf("%lld\n",(K-1)*delta+K*monoswapTimes);
    }
    return 0;
}





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

int X;

int main(){
	cin>>X;
	int k=0;
	for(int i=1;;i++){
		k+=X;
		k%=360;
		if(!k){
			cout<<i<<endl;
			return 0;
		}
	}
}


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

int main() {
    int n;
    cin >> n;
    int64_t power = 1;
    int mult = 1;
    rep(i,n) {
        power *= mult % MOD;
        power %= MOD;
        mult++;
    }
    cout << power << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] str = stdIn.nextLine().split(" ");
		Deque<Integer> stack = new LinkedList<Integer>();

		for (int i=0; i<str.length; i++) {
			char c = str[i].charAt(0);
			if(c>='0' && c<='9'){
				stack.add(Integer.parseInt(str[i]));
			}else {
				int x = stack.pollLast();
				int y = stack.pollLast();
				switch(c){
					case '+':stack.add(x+y); break;
					case '-':stack.add(y-x); break;
					case '*':stack.add(x*y); break;
				}
			}
		}

		System.out.println(stack.poll());
	}
}

Measured memory_bytes: 17264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(ALL(l));
    int ans = 0;

    for(int i = n-1; i >= 2; i--){
        for(int j = i-1; j >= 0; j--){
            if(l[i] - l[j] >= l[j-1]) break;
            int k = upper_bound(ALL(l), (l[i] - l[j])) - l.begin();
            ans += j-k;
            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256