akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    string s; cin >> s;
    int n = s.size();

    // map<char, int> mp;
    // map<char, int>::iterator itr;
    // int maxfreq = 1;
    // for(int i=0; i<n; i++){
    //     if(mp.find(s[i]) == mp.end()){
    //         mp.insert(make_pair(s[i], 1));
    //     }
    //     else{
    //         mp[s[i]]++;
    //         if(mp[s[i]] > maxfreq){
    //             maxfreq = mp[s[i]];
    //         }
    //     }
    // }

    // vector<char> v;
    // for(itr = mp.begin(); itr != mp.end(); itr++){
    //     pair<char, int> p = *itr;
    //     if(p.second == maxfreq){
    //         v.push_back(p.first);
    //     }
    // }

    // for(itr = mp.begin(); itr != mp.end(); itr++){
    //     pair<char, int> p = *itr;
    //     cout << p.first << " " << p.second << endl;
    // }

    set<char> setchar;
    set<char>::iterator itr;
    for(int i=0; i<n; i++){
        setchar.insert(s[i]);
    }
    
    int cnttemp;
    int maxtemp;
    int ans = 10000;
    for(itr = setchar.begin(); itr != setchar.end(); itr++){
        char c = *itr;
        cnttemp = 0;
        maxtemp = 0;
        for(int j=0; j<n; j++){
            if(s[j] != c){
                cnttemp++;
                if(maxtemp < cnttemp){
                    maxtemp = cnttemp;
                }
            }
            else{
                cnttemp = 0;
            }
        }
        if(ans > maxtemp){
            ans = maxtemp;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class SegmentTree():
    def __init__(self,param,default,func):
        if isinstance(param,list):
            n=len(param)
        else:
            n=param
        self.d=default
        self.leaf=1<<(n-1).bit_length()
        if isinstance(param,list):
            self.tree=[default]*(self.leaf-1)+param+[default]*(self.leaf-n)
            for i in range(self.leaf-2,-1,-1):
                self.tree[i]=func(self.tree[i*2+1],self.tree[i*2+2])
        else:
            self.tree=[default]*(self.leaf*2-1)
        self.f=func
    def find(self,i):
        return self.tree[i+self.leaf-1]
    def merge(self,a,b):
        return self.f(a,b)
    def get_top(self):
        return self.tree[0]
    def query(self,a,b):
        T=self.tree
        l,r=a+self.leaf-1,b+self.leaf-1
        res=self.d
        while l<r:
            if not l%2:
                res=self.merge(res,T[l])
                l+=1
            if not r%2:
                r-=1
                res=self.merge(res,T[r])
            l>>=1; r>>=1
        return res

def main():
    inf=10**7
    n,k=map(int,input().split())
    P=list(map(int,input().split()))
    segmax=SegmentTree(P,0,max)
    segmin=SegmentTree(P,inf,min)
    ans=n-k+1
    for i in range(n-k):
        if segmin.query(i,i+k)==P[i] and segmax.query(i,i+k)<P[i+k]:
            ans-=1
    tmp=1
    cnt=0
    for i in range(n-1):
        if P[i]>P[i+1]:
            if tmp>=k:
                cnt+=1
            tmp=1
        else:
            tmp+=1
    if tmp>=k:
        cnt+=1
    ans-=max(0,cnt-1)
    print(ans)
    
if __name__=='__main__':
    main()

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

using namespace std;

const int mod = 1e9 + 7;

int inverse(int a, int md = mod) {
  return a == 1 ? a : (long long)(md - md / a) * inverse(md % a, md) % md;
}

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n + 1);
  long long d = 1;
  for (int i = 1; i <= n; i++) {
    d = d * i % mod;
    a[i] = (a[i - 1] + inverse(i)) % mod;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long v;
    cin >> v;
    ans += (a[n - i + 1] - a[1] + a[i] + mod) * v % mod * d % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int i,j;

    cin >> N;
    int ans = 0;
    for(i=1;i<=N;i+=2){
        int count = 0;
        for(j=1;j<=i;j++){
            if(i%j == 0){
                count++;
            }
        }
        if(count == 8){
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

bool is_prime(int n){
    bool ans = true;
    int r = 2;
    while(r * r <= n){
        if(n % r == 0){
            ans = false;
            break;
        }
        r++;
    }
    return ans;
}

signed main(){

    int N = 100000;
    vector<int> count(N, 0);
    FOR(i, 1, N + 1){
        count[i] = count[i - 1];
        if(i >= 3 && i % 2 == 1){
            if(is_prime(i) && is_prime((i + 1) / 2)) count[i]++;
        }
    }

    int Q;
    cin >> Q;
    int l, r;
    REP(i, Q){
        cin >> l >> r;
        cout << count[r] - count[l - 1];
        if(i != Q - 1) cout << endl;
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int now = n-1;
    int alice = 0, bob = 0;
    while (now >= 0) {
        alice += a.at(now);
        now--;
        if (now < 0) break;
        bob += a.at(now);
        now--;
    }
    cout << alice - bob << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()

ss = s.split(" ")

N = int(ss[0])
A = int(ss[1])
B = int(ss[2])


ans = 0
div = N //( A + B ) # A > 0
ans = div * A
# ans += min( N % (A + B) , A)
mod = N % ( A + B )


if mod > A :
  ans += A
else :
  ans += mod

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int submitted[30]={0};
	int num,i;
	char buf[4];

	for(i=0;i<28;i++)
	{
		fgets(buf,4,stdin);
		sscanf(buf,"%d",&num);
		submitted[num-1]=1;
	}
	for(num=0;num<30;num++)
	{
		if(submitted[num]==0)
		{
			printf("%d\n",num+1);
		}
	}
	return 0;
}

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

int main() {
 int n;
 cin >> n;
 vector<vector<int>> a(n,vector<int>(2));
  rep(i,n)rep(j,2) cin >> a.at(i).at(j);
 vector<int> b(n);
 rep(i,n) b.at(i) = i;
double sum = 0;
int cnt = 0;
 do{
   rep(i,n-1){
     int dx = a.at(b.at(i)).at(0)-a.at(b.at(i+1)).at(0);
     int dy = a.at(b.at(i)).at(1)-a.at(b.at(i+1)).at(1);
     sum += pow(dx*dx+dy*dy,0.5);
   }
     cnt++;
 }while(next_permutation(b.begin(),b.end()));
 double ans = sum/cnt;
 printf("%.10f\n",ans);
}

Measured memory_bytes: 4196
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=1010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int qwq=1e18;
signed main()
{
    int n;
    n=read();
    for(ri int i=1;i*i<=n;i++)
    {
        if(n%i) continue;
        int x=i, y=n/i;
        int res,cnt; res=cnt=0;
        while(x) x/=10, cnt++;
        res=max(res,cnt), cnt=0;
        while(y) y/=10, cnt++;
        res=max(res,cnt);
        qwq=min(qwq,res);
    }
    printf("%lld\n",qwq);
    return 0;
}

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

int main() {
  int A[5];
  cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
  sort(A, A + 5, greater<int>());
  for (int i = 0; i < 5; ++i)
    if (i == 4)
      cout << A[i] << endl;
    else
      cout << A[i] << ' ';
}


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

#define ll long long int

int main() {
    ll n, w;
    cin>>n>>w;
    vector<ll> weights(n), values(n);
    for(int i=0; i<n; i++)
        cin>>weights[i]>>values[i];
    vector<vector<ll>> dp(n+1, vector<ll> (w+1, 0));
    for(int i=0; i<n; i++)
        for(int j=0; j<=w; j++)
            if(j >= weights[i])
                dp[i+1][j] = max(dp[i][j], dp[i][j-weights[i]] + values[i]);
            else
                dp[i+1][j] = dp[i][j];
    cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 80256
/*input
3242
*/	
#include <bits/stdc++.h>
using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;

#define FOR(i, l, r) for( i = l; i <= r; ++i)
#define FORD(i, l, r) for(int i = l; i >= r; --i)
#define REP(i, r) for(int i = 0; i < int(r); ++i)
#define REPD(i, r) for(int i = int(r)-1; i >= 0; --i)
#define fi first
#define se second
#define sz size
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;

const int Nmax = 1e6 + 10;
const ll inf = 1e9;
const db _eps = 1e-5;

int a[5];
int e[5];

bool check() {
	int sum = a[1];
	int i;
	FOR(i, 1, 3) {
		if (e[i] == 1) sum += a[i+1];
			else sum -= a[i+1];
	}
	if (sum == 7) {
		cout << a[1] << (e[1] == 1 ? '+' : '-')
		     << a[2] << (e[2] == 1 ? '+' : '-')
		     << a[3] << (e[3] == 1 ? '+' : '-') << a[4] << "=7";
		return true;
	}
	return false;
}

int main() {
	int b;
	cin >> b;
	int cnt = 1;
	while (b != 0) {
		a[cnt] = b%10;
		b /= 10;
		cnt++;
	}
	reverse(a + 1, a + 5);
	FOR(e[1], 1, 2) FOR(e[2], 1, 2) FOR(e[3], 1, 2) if (check()) return 0;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, m, ans;
string a;
set<string>s;
map<string,int>c;

int main(){
    ios::sync_with_stdio(0);
    s.clear();
    c.clear();
    cin >> n;
    forn(i,n){
        cin >> a;
        c[a]++;
    }
    cin >> m;
    forn(i,m){
        cin >> a;
        c[a]--;
    }
    ans = 0;
    for(map<string,int>::iterator it = c.begin(); it != c.end(); it++){
        ans = max(ans,it->second);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647
int main()
{
    ll n, q;
    cin >> n;
    string s;
    //意外と二分探索は強かったりする。
    //累積和を考える問題でも、mapを用いる必要はない。それだと計算量が死んでしまうから。
    //
    cin >> s;
    cin >> q;
    //vector<ll> Q(q);
    vector<set<ll>> data(26); //順序づけされた値を,重複を排除してその順番を保持したまま格納する・
    rep(i, n)
    {
        data[s[i] - 'a'].insert(i);
    }

    rep(i, q) //間の文字が何種類あるかを答える。
    {
        int a = 0;
        cin >> a;
        if (a == 1)
        {
            ll b;
            char c;
            cin >> b >> c;
            b--;
            if (s[b] != c)
            {
                data[s[b] - 'a'].erase(b); //s[b] = c;
                data[c - 'a'].insert(b);
                s[b] = c;
            }
        }
        else
        {
            ll r, l;
            cin >> r >> l;
            r--;
            l--;
            ll ans = 0;
            rep(i, 26)
            {
                auto u = data[i].lower_bound(r);
                if (u != data[i].end() && *u <= l)
                {
                    ans += 1;
                }

                //lower_bound(v.begin(), v.end(), 3)-v.begin();探したい値3
                //探したい値3
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	ll h,a;
	cin>>h>>a;
	ll mov = 0;
	while(1){
		if(h <= 0)break;
		mov++;
		h-=a;
	}	
	cout<<mov<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323

ll n,a[3],b[3],gain[3],pain[3];
ll dp[5005*5005];


void solve()
{
       cin>>n>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
       rep(i,0,3) gain[i]=b[i]-a[i];
       rep(i,0,3) pain[i]=a[i]-b[i];
       for(ll i=0; i<=n; i++)
       {
              for(ll j=0; j<3; j++)
              {
                     if(a[j] <= i) dp[i] = max(dp[i-a[j]]+gain[j], dp[i]);
              }
       }
       ll tot=n+dp[n];
       memset(dp, 0, sizeof dp);
       for(ll i=0; i<=tot; i++)
       {
              for(ll j=0; j<3; j++)
              {
                     if(b[j] <= i) dp[i] = max(dp[i-b[j]]+pain[j], dp[i]);
              }
       }
       ll ans=tot+dp[tot];
       cout<<ans;
}


int main() {
	ll T = 1;
       //pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


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

string S;
int year;
int month;
bool can = true;

int main () {
    cin >> S;
    year = stoi(S.substr(0,4));
    month = stoi(S.substr(5,7));
    if (year > 2019) can = false;
    else if (year == 2019 && month > 4) can = false;
    
    if (can) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;
}

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

#define max_n 100

using namespace std;

int n,cap[max_n][max_n];
bool vis[max_n];

bool dfs(int i, int t){
  if(i==t)return true;
  vis[i]=true;
  for(int j=0;j<n;j++){
    if(!vis[j] && cap[i][j]>0 && dfs(j,t)){
      cap[i][j]--;
      cap[j][i]++;
      return true;
    }
  }
  return false;
}

int max_flow(int s, int t){
  for(int flow=0;;flow++){
    fill(vis,vis+n,false);
    if(!dfs(s,t))return flow;
  }
}

int main(void){

  int m;
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    int u,v,c;
    cin >> u >> v >> c;
    cap[u][v]=c;
  }

  cout << max_flow(0,n-1) << endl;

  return 0;
}

Measured memory_bytes: 1204
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		string ans = "No";
		if(N*500>=M){
			ans = "Yes";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n; std::cin >> n;
  auto a = std::vector<std::vector<int>>(n + 2, std::vector<int>(n + 2, false));
  auto insert = [&] (size_t i, size_t j, bool k) {
    a[i][j] = k;
    a[j][i] = !k;
  };
  for (size_t i = 1; i <= n; i++) {
    insert(i, 0, true);
    insert(i, n + 1, true);
  }
  for (size_t i = 2; i <= n; i++) {
    for (size_t j = 1; j < i; j++) {
      char x; std::cin >> x;
      insert(i, j, x == '1');
    }
  }
  auto dp = std::vector<std::vector<int>>(n + 2, std::vector<int>(n + 2, false));
  for (size_t i = 0; i <= n; i++) dp[i][i + 1] = dp[i + 1][i] = true;
  for (size_t d = 2; d <= n + 1; d++) {
    for (size_t i = 0, j = d; j <= n + 1; i++, j++) {
      bool tmp = false;
      for (size_t k = i + 1; k < j; k++) {
        tmp |= dp[i][k] & dp[j][k] & (a[i][k] | a[j][k]);
      }
      dp[j][i] = dp[i][j] = tmp;
    }
  }
  int ret = 0;
  for (size_t i = 1; i <= n; i++) {
    if (dp[0][i] & dp[i][n + 1]) ret++;
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 33860
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll A, B, M;
    cin >> A >> B >> M;
    vector<ll> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    vector<ll> x(M), y(M), c(M);
    rep(i, M) { cin >> x[i] >> y[i] >> c[i]; }
    ll res = LINF;
    ll minA = LINF, minB = LINF;
    rep(i, A) { minA = min(a[i], minA); }
    rep(i, B) { minB = min(b[i], minB); }
    res = min(minA + minB, res);
    rep(i, M) { res = min(a[x[i] - 1] + b[y[i] - 1] - c[i], res); }
    cout << res << endl;
    return 0;
}

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

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
/*なるべく正の数が多くなるように操作を行う
*/


int main() {
   ll N;
   cin >> N;
   vector<ll> A(N);
   rep(i,N){
       cin >> A[i];
   }
   bool flag0 = false;//0があるか否か
   int c = 0;//A[i]<0となる個数
   rep(i,N){
       if(A[i] < 0) c++;
       if(A[i] == 0) flag0 = true;
   }
   ll ans = 0;
   ll sum = 0;
   ll m = 30000000000;//|A[i]|のmin 
   rep(i,N){
       m = min(m,abs(A[i]));
   }

    rep(i,N){
        sum += abs(A[i]);
    }
   
   if(c%2 == 0 || flag0){/*全てを非負にできる flag0の場合、0を起点として
   0の前後の任意の要素の符号を反転できるので、全て非負にできる */
       ans = sum;
   }
   else{//一つを除いて非負にできる
     ans = sum - 2*m;
   }
   cout << ans << endl;
 }


Measured memory_bytes: 1024
A,B,C,X,Y = map(int,input().split())

AB_set = C * 2

ans = min(A*X + B*Y, AB_set*max(X,Y), AB_set*min(X,Y) + A*abs(X-min(X,Y)) + B*abs(Y-min(X,Y)))

print(ans)

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

using namespace std;

const int MOD = 1000000007;

int solve(const vector<int>& A, const vector<int>& B){
    const int N = A.size();
    const int M = B.size();
    int cntA = 0;
    int cntB = 0;
    int rest = 0;
    long long res = 1;
    for(int i=N*M;i>=1;i--){
        bool checkA = (cntA < N && A[N-1-cntA] == i);
        bool checkB = (cntB < M && B[M-1-cntB] == i);
        if(checkA && checkB){
            rest += cntA + cntB;
            ++cntA;
            ++cntB;
        } else if(checkA){
            res = (cntB * res) % MOD;
            rest += cntB - 1;
            ++cntA;
        } else if(checkB){
            res = (cntA * res) % MOD;
            rest += cntA - 1;
            ++cntB;
        } else {
            if(rest <= 0) return 0;
            res = (rest * res) % MOD;
            --rest;
        }
    }
    return (int)res;
}

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<int> A(N);
        vector<int> B(M);
        for(auto& t : A) cin >> t;
        for(auto& t : B) cin >> t;
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        cout << solve(A, B) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int num;

void Search(string s, int ma) {
	if (s.size() == num) {
		cout << s << "\n";
		return;
	}
	int i;
	for(i = 0; i <= ma; i++) {
		char c = 'a' + i;
		Search(s + c, max(ma, i + 1));
	}
	return;
}

int main(void) {
	int i;
	string s = "a";
	cin >> num;
	Search(s, 1);
	return 0;
}

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

int main(){
  int D,N;
  cin>>D>>N;
  int a=1;
  for(int i=0; i<D; i++){
    a *= 100;
  }
  if(N == 100){
    N++;
  }
  cout<<a*N<<endl;
}


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

ll max(ll a, ll b){
    if (a > b) return a;
    else return b;
}

int main(void){
    ll A, B, K; cin >> A >> B >> K;
    
    ll A2, B2, K2;
    A2 = max(0, A - K);
    K2 = max(0, K - A);
    B2 = max(0, B - K2);
    
    cout << A2 << ' ' << B2 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  long long int ans=0;
  cin >> N;
  int d[N];
  for(int i=0; i<N; i++) cin >> d[i];
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(i != j) ans += d[i]*d[j];
    }
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
    "os"
    "sort"
    "strconv"
    "strings"
)

func main() {
    var input []string 

    sc := bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        input = append(input, sc.Text())
    }

    N, _ := strconv.Atoi(input[0])
    aStr := strings.Split(input[1], " ")

    a := make([]int, N)
    for i := range aStr {
        vInt, _ := strconv.Atoi(aStr[i])
        a[i] = vInt
    }

    sort.Sort(sort.Reverse(sort.IntSlice(a)))

    var alice, bob int
    for i := range a {                                                                             
        if i%2 == 0 {
            alice += a[i]
        } else {
            bob += a[i]
        }
    }

    fmt.Println(alice - bob)
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
    int n,m,k;
    cin>>n>>m>>k;
    Graph G(n);
    Graph block(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,k){
        int c,d;
        cin>>c>>d;
        c--; d--;
        block[c].pb(d);
        block[d].pb(c);
    }
    vbl seen(n,0);
    vin ans(n,0);
    
    
    rep(i,n){
        if(seen[i]){
            cout<<ans[i]<<" ";
            continue;
        }
        queue<int> q;
        set<int> r;
        q.push(i);
        r.insert(i);
        while(!q.empty()){
            int x=q.fn();
            q.pop();
            for(int y:G[x]){
                if(seen[y]) continue;
                q.push(y);
                r.insert(y);
                seen[y]=true;
                
            }
        }
        for(auto x: r){
            ans[x]=r.size();
            for(auto y:block[x]){
                if(r.count(y)) ans[x]--;
            }
            ans[x]-=G[x].size();
            ans[x]--;
        }
        cout<<ans[i]<<" ";
    }
    cout<<endl;
   
   
   
}


Measured memory_bytes: 19664
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        string[] input2 = input[1].Split('.');
        long a = long.Parse(input[0]);
        long b = long.Parse(input2[0])*100 + long.Parse(input2[1]);
        Console.WriteLine(a * b / 100);
    }
}

Measured memory_bytes: 27540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc118_a
{
    class Program
    {
        public static int Calculation(int A, int B)
        {
            if (B % A == 0) return A + B;
            else return B - A;
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            Console.WriteLine(Calculation(A, B));
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{   int flag=0,n,i=0,k=-1;
    cin>>n; 
    ll a[n]={0};
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}    
	while(flag==0)
	{
		++k;
	for(i=0;i<n;i++)
	{
		if(a[i]%2==1)
		{
			flag=1;
			continue;
		}
		a[i]=a[i]/2;
	}
	
		
	}
	cout<<k;
	
	return 0;
    
}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tar=str(i)+str(j)+str(k)
            now=0
            for l in range(n):
                
                if tar[0+now]==s[l]:now+=1
                if now==3:
                    ans+=1
                    break
print(ans)                    

Measured memory_bytes: 68316
function main()
    s = pread(String)
    c = 0
    for i in 1:length(s)
        c += s[i] - '0'
    end
    println(c%9 == 0 ? "Yes" : "No")
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, N, A[110000];
signed main() {
    cin >> H >> N;
    int sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum >= H) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }

}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i,j,k,l,n = sc.nextInt(),diff,cnt = 0,flag = 0;
		char[] target = sc.next().toCharArray();
		char[][] old = new char[n][];
		for(i = 0; i < n; i ++ ){
			old[i] = sc.next().toCharArray();
n1:			for(k = 0; k < old[i].length; k ++ ){
				if(target[0] == old[i][k]){
					for(j = k + 1; j < old[i].length; j ++ ){				
						if(target[target.length-1] == old[i][j]){
							if((j - k) % (target.length-1) != 0)continue;
							diff = (j - k) / (target.length-1);
							flag = 2;
							for(l = 1; l <= target.length; l ++ ){
								if(target[l] == old[i][k + l * diff]){
									flag ++;
									if(flag == target.length){
										cnt ++;
										break n1;
									}
								}
								else break;
							}
						}
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

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

#define NREP() for(ull i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ull i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ull ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n;
    vl a(n), b(n), c(n);
    NREP() {
        cin >> a[i];
    }

    NREP() {
        cin >> b[i];
    }

    NREP() {
        cin >> c[i];
    }

    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));

    NREP() {
        auto itr_a = lower_bound(ALL(a), b[i]);
        auto itr_c = upper_bound(ALL(c), b[i]);
        ans += (itr_a - a.begin()) * (c.end() - itr_c);
    }

    MSG(ans)
}


Measured memory_bytes: 2560
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>


using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

const int limit = 100010;
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}

int main(void){
  int n;
  cin >> n;
  
  rep(i, n-1){
    int a, b, c;
    cin >> a >> b>> c;
    a--, b--;
    tree[a].push_back({b , c});
    tree[b].push_back({a, c});
  }
  int q, k;
  cin >> q >> k;
  k--;
  dfs(k, -1, 0);
  rep(i, q){
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x]+depth[y] << endl;
  }
  return 0;
}
  
  

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define pi 3.1415926536
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define INF 2147483647
#define _INF -2147483647
#define MM multimap
#define PB push_back
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    if (A >= 13) {
        cout << B << endl;
    } else if (6 <= A && A <= 12) {
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int n,m;
  cin>>n>>m;

  cout<< (n-1)*(m-1)<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    vector<ll> ans;
    ll L = 0, R = 0;
    ll cp = 0;
    cin >> S;
    ans.resize(S.size());
    rep(i, S.size()) {
        if(S[i] == 'R') {
            if(L > 0) {
                if(cp > 0) ans[cp - 1] = (R - 1) / 2 + L / 2 + 1;
                ans[cp] = R / 2 + (L - 1) / 2 + 1;
                R = 0;
                L = 0;
            }
            R++;
        } else {
            if(L == 0) cp = i;
            L++;
        }
    }
    if(L > 0) {
        if(cp > 0) ans[cp - 1] = (R - 1) / 2 + L / 2 + 1;
        ans[cp] = R / 2 + (L - 1) / 2 + 1;
    } else if(R > 0) {
        ans.back() = R;
    }
    iter(a, ans) cout << a << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
    #include <cstdio>
    #include <vector>
    #include <map>
    #include <algorithm>
    using namespace std;
    const int inf = 0x3f3f3f3f;
    typedef long long ll;
    typedef pair<ll,ll> ii;
    ll n,mxr[55];
    struct 
    {
    	ll value;
    	ll biao;
    }maxx,minn;
    vector<ii>tt;
    int main()
    {
    	int ans=0;
    	scanf("%lld",&n);
    	maxx.value=-inf;
    	minn.value=inf;
    	for(ll i=1;i<=n;i++)
    	{
    		scanf("%lld",&mxr[i]);
    		if(maxx.value<mxr[i])
    		{
    			maxx.value=mxr[i];
    			maxx.biao=i;
    		}
    		if(minn.value>mxr[i])
    		{
    			minn.value=mxr[i];
    			minn.biao=i;
    		}
    	}
    	if(minn.value==maxx.value)
    	{
    		printf("0\n");
    		return 0;
    	}
    	else if(-minn.value<maxx.value)
    	{
    		for(ll i=2;i<=n;i++)
    		{
    			while(mxr[i]<mxr[i-1])
    			{
    				ans++;
    				ii dui(maxx.biao,i);
    				tt.push_back(dui);
    				mxr[i]+=maxx.value;
    				if(mxr[i]>maxx.value)
    				{
    					maxx.value=mxr[i];
    					maxx.biao=i;
    				}
    			}
    		}
    			
    	}
    	else {
    		for(ll i=n-1;i>0;i--)
    		{
    			while(mxr[i]>mxr[i+1])
    			{
    				ans++;
    				ii dui(minn.biao,i);
    				tt.push_back(dui);
    				mxr[i]+=minn.value;
    				if(mxr[i]<minn.value)
    				{
    					minn.value=mxr[i];
    					minn.biao=i;
    				}
    			}
    		}
    	}
    	printf("%d\n",ans);
    	for(ll i=0;i<tt.size();i++)
    	{
    		printf("%lld %lld\n",tt[i].first,tt[i].second);
    	}
    	return 0;
    }

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

ll a, b, x;

int main(){
        cin.sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> x;
    ll d = a % x;
    if(d) a += (x - d);
    if(a > b){
        cout << 0;
        return 0;
    }
    
    
    ll ans = 1;
    ans += (b-a)/x;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let (a, b, c): (Vec<usize>, Vec<usize>, Vec<i64>) = {
        let (mut a, mut b, mut c) = (vec![], vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
            c.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b, c)
    };

    const INF: i64 = 1e14 as i64;
    let mut dp = vec![INF; N + 1];
    dp[1] = 0;
    for k in 0..N {
        for i in 0..M {
            dp[b[i]] = std::cmp::min(dp[b[i]], dp[a[i]] + (-c[i]))
        }
    }
    for k in 0..N {
        for i in 0..M {
            if dp[a[i]] + (-c[i]) < dp[b[i]] {
                dp[b[i]] = -INF;
            }
        }
    }

    let ans = if dp[N] <= -INF {
        "inf".to_string()
    } else {
        (-dp[N]).to_string()
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
local n = io.read("*n")
local a = {}
local minus = false
local absmax, pos = 0, 1
local mma, mab = math.max, math.abs
for i = 1, n do
  a[i] = io.read("*n")
  if a[i] < 0 then
    if absmax < -a[i] then
      absmax = -a[i]
      pos = i
      minus = true
    end
  else
    if absmax < a[i] then
      absmax = a[i]
      pos = i
      minus = false
    end
  end
end
print(2 * n - 2)
for i = 1, n do
  if i ~= pos then
    print(pos .. " " .. i)
  end
end
if minus then
  for i = n, 2, -1 do
    print(i .. " " .. i - 1)
  end
else
  for i = 1, n - 1 do
    print(i .. " " .. i + 1)
  end
end


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    
    ll n; cin >> n;
    vvc c(n,vc(n));
    rep(i,n)rep(j,n)cin>>c[i][j];
    ll res = 0;

    rep(dif,n){
        bool flag = true;
        auto cc = c;
        rep(i,n)rep(j,n)cc[i][ (j + dif) % n] = c[i][j];
        rep(i,n)rep(j,n){
            if(cc[i][j] != cc[j][i])flag = false;
        }
        if(flag)res+=n;
    }
    out(res);
}

Measured memory_bytes: 3828
// ABC170.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

// A ///////////////////

int main()
{
	int x[5] = { 0 };

	for (int i = 1; i <= 5; i++) {
		cin >> x[i - 1];
	}

	for (int i = 1; i <= 5; i++) {
		if (x[i-1] == 0)
			cout << i;
	}

	return 0;
}


Measured memory_bytes: 3124
n,t=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append(tuple(map(int,input().split())))

l=sorted(l,key=lambda x:x[0])
for i in l:
    if i[1]<=t:
        print(i[0])
        exit()
print('TLE')


Measured memory_bytes: 2940
program atcoder
    implicit none
    integer(8) :: i,j,n
    integer(8),allocatable,dimension(:,:) :: dpf,dps
    integer(8),allocatable,dimension(:) :: a
    read*,n
    allocate(dpf(0:n,0:n))
    allocate(dps(0:n,0:n))
    allocate(a(n))
    read(*,*)(a(i),i=1,n)

    ! dpf(i,j) := [i,j]の区間でゲームを行った際の先攻の人の得点
    ! dps(i,j) := [i,j]の区間でゲームを行った際の後攻の人の得点

    do i = 1,n
        dpf(i,i) = a(i)
        dps(i,i) = 0
        !区間が[i,i]の時、先攻はa[i]点、後攻の人は0点
    enddo
    

    do i = 1,n
        do j = 1,n-i
            
            ! 区間[j,i+j]で先攻の人の得点は 
            ! ( a(j)+区間[j+1,i+j]で後攻の人の得点 )　と　( a(j+i)+区間[j,i+j-1]で後攻の人の得点 ) の大きい方
            dpf(j,i+j) = max( dps(j+1,j+i)+a(j) , dps(j,j+i-1)+a(j+i) )

            ! 区間[j,i+j]で後攻の人の得点は 
            ! 先攻の人がa(j)を取った場合 -> 区間(j+1,i+j)の先攻の人の得点
            ! 先攻の人がa(i+j)を取った場合 -> 区間(j,i+j-1)の先攻の人の得点
            if( dps(j+1,j+i)+a(j) > dps(j,j+i-1)+a(j+i) )then
                dps(j,j+i) = dpf(j+1,j+i)
            else
                dps(j,j+i) = dpf(j,j+i-1)
            endif

        enddo
    enddo

    write(*,'(I0)')dpf(1,n)-dps(1,n)


    stop 
contains
end program atcoder


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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> l(2 * n);
	for (int i = 0; i < 2 * n; i++) cin >> l[i];
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0; i < n; i++) ans += l[2 * i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200000
int a[N];
int n;
int max(int a[]){
  int res = 0;
  for(int i=0;i<n;i++){
    if(res < a[i])res = a[i];
  }
  return res;
}
void solve(){
  int k,i;
  scanf("%d%d", &n,&k);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  int l=0,r=max(a);
  while(r-l>1){
    int mid = (l+r)/2;
    int tmp = 0;
    for(i=0;i<n;i++){
      tmp += (a[i]+mid-1)/mid - 1;
    }
    if(tmp <= k){
      r = mid;
    }else{
      l = mid;
    }
  }
  printf("%d\n", r);
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 2452