akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()


ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

const int MAX=510000;
const int MOD=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,MAX){
    if(i>1){
      fac[i]=fac[i-1]*i%MOD;
      inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
      finv[i]=finv[i-1]*inv[i]%MOD;
    }
  }
}

ll COM(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 
int main(){
  int N,K;
  cin>>N>>K;
  COMinit();
  if(N-1<=K) cout<<COM(2*N-1,N-1)<<endl;
  else{
    ll ans=0;
    while(K>=1){
      ll X=COM(N,K)*COM(N-1,K)%MOD;
      ans=(ans+X)%MOD;
      K-=1;
    }
    if(K%2==0) ans++;
    cout<<ans<<endl;
  }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  lli I, O, T, J, L, S, Z;
  while (cin >> I >> O >> T >> J >> L >> S >> Z) {
    lli a = (J / 2 * 2) + (L / 2 * 2) + (I / 2 * 2) + O;
    lli b = 0;
    if (I && J && L) {
      b = 3 + ((J - 1) / 2 * 2) + ((L - 1) / 2 * 2) + ((I - 1) / 2 * 2) + O;
    }
    cout << max(a, b) << endl;
  }

  /*
    fn(a, b, c) = max(fn(a-2, b, c), fn(a-1, b-2, c), fn(a-1, b, c-2), fn(a, b-1, c-1))

    oooo
    xxxx

    oo
    oo

    xooo
    xxxo

    xxxooo
    xiiiio

    xiiiio
    xxxooo

  */
  
  return 0;
}


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

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

    string s;
    cin >> s;
    
    vector<char> ans;
    rep(i, s.size()){
        if(s[i]=='B'){
            if(ans.size() != 0){
                ans.erase( ans.end() - 1 );
            }
        }else{
            ans.push_back(s[i]);
        }
    }
    
    rep(i, ans.size()){
        cout << ans[i];
    }
    
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

const int INF = 1e9 + 10;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    int dp[100010];
    rep(i, n+1){
        dp[i] = INF;
    }
    rep(i, n){
        *lower_bound(dp, dp+n, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp+n, INF) - dp << endl;
    return 0;
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef pair<int, int> ii;
typedef vector <int> vi;
typedef vector<ii> vii;
typedef vector <vii> vvii;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vi nums(n);
    int flag = 1;
    for (int i = 0; i < n; ++i) {
        nums[i] = s[i] - '1';
        if (nums[i] == 1) flag = 0;
    }
    for (int j = 0; j < n; ++j) {
        if (nums[j] == 2) nums[j] = flag;
    }
    int ans = 0;
    for (int k = 0; k < n; ++k) {
        if (nums[k] && (((n-1)|k) == n-1)) ans++;
        if (ans == 2) ans = 0;
    }
    if (flag){
        if (ans) cout << "2\n";
        else cout << "0\n";
    }else{
        if (ans == 0) cout << "0\n";
        else cout << "1\n";
    }
}



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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 998244353;

ll N, S, ans=0, tmp=0;
vector<ll> A;
vector<vector<ll>> DP;

signed main(){
    cin >> N >> S;
    DP.resize(N+1);
    for(int i=0;i<N+1;i++) {
        DP[i].resize(S+1,0);
        DP[i][0] = 1;
    }
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=0;i<N;i++) {
        for(int j=0;j<=S;j++) {
            DP[i+1][j] += DP[i][j];
            if(j>=A[i]) DP[i+1][j] += DP[i][j-A[i]];
            DP[i+1][j] %= MOD;
        }
        ans += DP[i+1][S];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 74144
#!/usr/bin/env python3
import sys

INF = 100000000
def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):

    V = 10
    # WF
    # c = [[INF] * (V) for i in range(V)]
    for k in range(V):
        for i in range(V):
            if c[i][k] == INF : continue
            for j in range(V):
                if c[k][j] == INF: continue
                c[i][j] = min(c[i][j], c[i][k]+c[k][j])

    ans = 0
    for i in range(H):
        for j in range(W):
            if(A[i][j] != -1):
                ans += c[A[i][j]][1]
    
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [ [ int(next(tokens)) for _ in range(9-0+1) ] for _ in range(9-0+1) ]  # type: "List[List[int]]"
    A = [ [ int(next(tokens)) for _ in range(W) ] for _ in range(H) ]  # type: "List[List[int]]"
    solve(H, W, c, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>

#define loop(i,st,en) for(int i=st;i<en;i++)
#define loop0n(i,n) for(int i=0;i<n;i++)

int main() {
  unsigned long long int money=100,X=0;
  int year=0;
  scanf("%I64lld",&X);
  // printf("%I64d\n",money);
  while(money<X){
    money += floor(money*0.01);
    // printf("%I64d\n",money);
    year++;
  }
  printf("%d\n",year);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#define N 100
using namespace std;

struct Edge{
	int to, next;
}edge[N];

int head[N], low[N], dfn[N];
int m, n, cnt, ans, c_time;

inline void addEdge(int u, int v) {
	edge[++cnt].to = v;
	edge[cnt].next = head[u];
	head[u] = cnt;
}

void Tarjan(int x, int fa) {
	low[x] = dfn[x] = ++c_time;
	for(int i = head[x]; i != -1; i = edge[i].next) {
		int u = edge[i].to;
		if(!dfn[u]) {
			Tarjan(u, i);
			low[x] = min(low[x], low[u]);
			if(dfn[x] < low[u]) ans++;
		}
		else if((i + 1) / 2 != (fa + 1) / 2) low[x] = min(low[x], dfn[u]);
	}
}

int main() {
	int u, v;
	memset(head, -1, sizeof(head));
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d %d", &u, &v);
		addEdge(u, v);
		addEdge(v, u);
	}
	for(int i = 1; i <= n; i++)
		if(!dfn[i])
			Tarjan(i, 0);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
cnt = 0
for i in range(10):
    if str(i) in s:
        idx_i = s.index(str(i)) + 1
        t = s[idx_i:]
        
        for j in range(10):
            if str(j) in t:
                idx_j = t.index(str(j)) + 1
                u = t[idx_j:]
                
                for k in range(10):
                    if str(k) in u:
                        cnt += 1
print(cnt)


Measured memory_bytes: 3188
#include<stdio.h>

int main()
{
    int a,b;
    char O;
    scanf("%d %c %d",&a,&O,&b);
    if(1<=a && a<=1000000000 && 1<=b && b<=1000000000){
        if(O=='+') printf("%d",a+b);
        if(O=='-') printf("%d",a-b);
    }
return 0;
}

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

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int dis[3];
    dis[0] = abs(a-b);
    dis[1] = abs(b-c);
    dis[2] = abs(a-c);
    if(dis[2] <=d || dis[0] <= d && dis[1] <=d){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
    
    
    return 0;
}
































































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

int N,M;
int a[1050],b[1050],c[1050][20];

void input()
{
    cin>>N>>M;
    for(int i=1;i<=M;i++)
    {
             cin>>a[i]>>b[i];
             for(int j=1;j<=b[i];j++)
               cin>>c[i][j];
    }
}

void solve()
{
     input();
  	 const int inf=1e9;   
  	 vector<int> dp(5000,inf);
  dp[0]=0;
  	 for(int item=1;item<=M;item++)
     {
          int mask=0;
         for(int i=1;i<=b[item];i++)
            mask|=(1<<c[item][i]-1);    
       
         for(int bits=0;bits<(1<<N);bits++)
            dp[bits|mask]=min(dp[bits|mask],dp[bits]+a[item]);
     }
   if(dp[(1<<N)-1]==inf) dp[(1<<N)-1]=-1;
 
 cout<<dp[(1<<N)-1]<<endl;    
}



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

Measured memory_bytes: 384
while True:
    n = int(input())
    if n == 0:
        break
    player = [0 for i in range(n)]
    cards = list(input())
    g = 0
    for i in range(100):
        if cards[i] == "M":
            player[i%n] += 1
        elif cards[i] == "S":
            g += player[i%n]+1
            player[i%n] = 0
        else:
            player[i%n] += g+1
            g = 0
    player.sort()
    for p in player:
        print(p,end = " ")
    print(g)


Measured memory_bytes: 5616
#include <stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(void) {
	int a, b;
	cin >> a >> b;
	if (a % (2 * b + 1) == 0)cout << a / (2 * b + 1) << endl;
	else cout << a / (2 * b + 1) + 1 << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll c[252521], d[252521];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m;
  ll k, a[252521], b[252521];
  cin>>n>>m>>k;
  REP(i, n){
    cin>>a[i];
    c[i+1]=c[i]+a[i];
  }
  REP(i, m){
    cin>>b[i];
    d[i+1]=d[i]+b[i];
  }
  int ans=0;
  REP(i, n+1){
    if(c[i]>k){
      continue;
    }
    int tmp=upper_bound(d, d+m+1, k-c[i])-d;
    // DEBUG(tmp);
    if(tmp>0){
      --tmp;
    }
    CHMAX(ans, i+tmp);
    // DEBUG(ans);
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 9912
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 26 03:56:38 2019

@author: matsui
"""

A,B,C=map(int,input().split())
ans=False

L=[A,B,C]
if 7 in L:
    L.remove(7)
    if L == [5,5]:
        ans=True
if ans:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
int d[10][10];
//main
signed main(){
  int N;string s;cin>>N>>s;
  std::vector<int> ans(9);
  memset(d,0,sizeof(d));
  for(int i=1;i<N;i++)d[s[i-1]-'0'][s[i]-'0']++;
  std::vector<int> v(9);
  for(int i=0;i<9;i++)v[i]=i+1;
  int mi=1e9;
  do{
    int res=0;
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
        res+=(abs(i/3-j/3)+abs(i%3-j%3))*d[v[i]][v[j]];
      }
    }
    if(res<mi){
      mi=res;
      for(int i=0;i<9;i++)ans[i]=v[i];
    }
  }while (std::next_permutation(v.begin(), v.end()));
  for(int i=0;i<9;i++){
    cout<<ans[i];
    if(i%3==2)cout<<endl;
  }
  /*
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++)cout<<d[i][j]<<" ";
    cout<<endl;
  }
  */
}



Measured memory_bytes: 3368
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N,K=rl()
print(N-K if K >1 else 0)

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

int main(){
    int n;
    cin >>n;
    int a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    cout << a[n-1]-a[0] << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
from math import log2
from math import ceil
a,b,c = map(int,input().split())
k = int(input())
s1 = max(ceil(log2((a+1)/b)),0)
s2 = max(ceil(log2((b*2**s1+1)/c)),0)
if s1+s2 <= k:
  print('Yes')
else:
  print('No')


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

namespace Contest
{
	class Program
	{
		static void Main()
		{
            var NK = Console.ReadLine().Split().Select(int.Parse);
            int N = NK.First(), K = NK.Last();
            var l = Console.ReadLine().Split().Select(int.Parse);
            Console.WriteLine(l.OrderByDescending(item => item).Take(K).Sum());
#if DEBUG
            Console.ReadKey();
#endif
		}
	}
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	string s;
	int k;
	cin >> s >> k;
	string t = s;
	int ans = 0;
	if (s.size() == 1) {
		cout << k / 2 << endl;
		return 0;
	}
	rep(i, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			ans++;
			s[i + 1] = 'A';
		}
	}
	if (s[0] != s[s.size() - 1]) {
		cout << ans * k << endl;
	}
	else {
		int ans2 = 1;
		t[0] = 'A';
		rep(i, s.size() - 1) {
			if (t[i] == t[i + 1]) {
				t[i + 1] = 'A';
				ans2++;
			}
		}
		if (s[0] == t[s.size() - 1]) {
			cout << ans + ans2 * (k - 1) << endl;
			return 0;
		}
		else {
			if (k % 2 == 0) {
				cout << (ans + ans2) * (k / 2) << endl;
			}
			else {
				cout << (ans + ans2) * (k / 2) + ans << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
/* ********************************* JAI SAI RAM ************************************* */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lb;
#define endl "\n"
ll P=1000000007;
ll MAX=P*(P-7);
int main()
{
    ll i,j,k,l,m,n,o,p,q,r,s,t,start,end,mid;
    long double a,b,c;
    ll ans;
    cin>>a>>b;
   
    c=a*b;
    ans=c;
    cout<<ans<<endl;
    return 0;
}


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

const int MAXN = (int)(1e6 + 7);
int n, k, h;

int main(){
 cin >> n >> k;
  int res = 0;
  for(int i = 1; i <= n; i++){
    cin >> h;
    if(h >= k) ++res;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

ll N, res, l, r, a[100000], L[100000][2], R[100000][2];
pair<ll, ll>p[100000];


int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i].first >> p[i].second;
		res = max(res, p[i].second - p[i].first + 1);
	}
	sort(p, p + N);
	l = 0;
	r = intmax;
	for (int i = 0; i < N - 1; i++) {
		l = p[i].first;
		r = min(r, p[i].second);
		a[i] = r - l + 1;
		L[i][0] = l;
		L[i][1] = r;
	}
	l = p[N - 1].first;
	r = intmax;
	for (int i = N - 2; i >= 0; i--) {
		r = min(r, p[i + 1].second);
		a[i] += r - l + 1;
		R[i + 1][0] = l;
		R[i + 1][1] = r;
	}
	for (int i = 0; i <= N - 2; i++) {
		res = max(res, a[i]);
	}
	for (int i = 1; i <= N - 2; i++) {
		res = max(res, p[i].second - p[i].first + 1 + max(0ll, min(L[i - 1][1], R[i + 1][1]) - max(L[i - 1][0], R[i + 1][0]) + 1));
	}
	cout << res << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
    int N, M, K, i, j, b;
    scanf("%d%d%d", &N, &M, &K);
    b=0;
    for (i=0; i<=N; i++) {
        for (j=0; j<=M; j++) {
            if (M*i+N*j-2*i*j==K) {
                b=1;
                break;
            }
            // printf("(%d, %d): %d\n", i, j, M*i+N*j-2*i*j);
        }
        if (b==1) break;
    }
    if (b==1) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
list = []

while True:
    a, b = [int(i) for i in input().split()]
    if a == 0 and b == 0:
        break
    if a < b:
        list.append([a,b])
    else:
        list.append([b,a])

for i in range(len(list)):
    print(list[i][0], list[i][1])

Measured memory_bytes: 8248
#include  <stdio.h>
#include  <stdlib.h>
int main()
{
	long t,i, count=0,min=200000;
	scanf("%ld",&t);
	long *p = (long *)malloc(200001*sizeof(long));
	for(i=0; i<t ;i++ )
	{
		scanf("%ld",(p+i)); 
		if(min >= *(p+i))
		{
			min = *(p+i);
			count++;
		}
	}
	printf("%ld",count);
	return 0;
}

Measured memory_bytes: 1792
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a){
    boost::multiprecision::cpp_int aa(1);
    if(*min_element(a.begin(), a.end() )== 0){
    cout << 0 << endl;
    return;
  }  
  for(int i = 0; i < n; ++i){
        aa *= a[i];
    
          if(aa > 1000000000000000000LL){
            cout << -1 << endl;
            return;
        }
    }
    cout << aa << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4096
n = int(input())
p = [int(x) for x in input().split()]
buf = 0

for i in range(1,n-1) :
    if p[i] != min(p[i-1],p[i],p[i+1]) :
        if p[i] != max(p[i-1],p[i],p[i+1]) :
            buf += 1

print(buf)

Measured memory_bytes: 3060
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#dp[i][j]: iまでからj枚えらんで和がkになるのは何通り
def main():
	r = int(input())
	print(3*r**2)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

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

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 63212
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(y==0)return x;return igcd(y,x%y);}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,a,b;
	string s;
	cin>>n>>a>>b>>s;
	
	int sum=0;	//参加確定者人数
	int o=0;	//海外人数
	vector<bool> ans(n,false);
	REP(i,n){
		if(s[i]=='a'){
			if(sum<a+b){
				ans[i]=true;
				sum++;
			}
		}else if(s[i]=='b'){
			o++;
			if(sum<a+b and o<=b){
				ans[i]=true;
				sum++;
			}
		}
	}
	
	REP(i,n) cout<<((ans[i])?"Yes":"No")<<endl;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int H, W, D; cin >> H >> W >> D;
    map<int, pair<int,int>> A;

    REP(i, H){
      REP(j, W){
        int a;  cin >> a;
        A[a] = make_pair(j, i);
      }
    }

    V memo_field(H*W+1);
    //メモ初期化
    for(int i = H*W ; i < H*W-D ; i--)  memo_field[i] = 0;
    
    for(int i = 0 ; i < D ; i++){
      for(int j = H*W-D-i; 1 <= j ; j -= D){
        memo_field[j] = memo_field[j+D] + abs(A[j+D].first - A[j].first) + abs(A[j+D].second - A[j].second);
      }
    }
    
    int Q;  cin >> Q;
    REP(i, Q){
      int L, R;  cin >> L >> R;
      cout << memo_field[L] - memo_field[R] << endl;
    }

	return 0;
}


Measured memory_bytes: 7168
#include<iostream>
#define k 10001
#define number 2000000
using namespace std;

void countingsort();

int n,A[number],B[number],C[k];

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

  countingsort();

  for(int i=0 ; i < n ; i++){
    if(i == n-1){
      cout <<B[i]<<endl;
    }else{
      cout <<B[i]<<" ";
    }
  }
  
  return 0;
}

void countingsort(){
  
  for(int i=0 ; i < k ; i++)C[i]=0;
  
  for(int i=0 ; i < n ; i++)C[A[i]]++;
  
  for(int i=1 ; i < k ; i++)C[i]=C[i]+C[i-1];
  
  for(int i=n-1 ; i >= 0 ; i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
  
}

Measured memory_bytes: 16824
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 200100;
int n, op, maxd, a, b;
vector <int> v[N];

void dfs(int node, int d = 1, int t = -1) {

	if(d > maxd) {
		maxd = d; 
		op = node;
	}

	for(auto i : v[node])
		if(i != t)
			dfs(i, d + 1, node);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i < n; i++) {
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	maxd = 0;
	dfs(1);
	maxd = 0;
	dfs(op);
	cout << (maxd % 3 != 2 ? "First" : "Second") << '\n';
}	




Measured memory_bytes: 20608
def main():
    n = int(input())
    l = tuple([int(t)for t in input().split()])

    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                lst = sorted([l[i],l[j],l[k]])
                if len(set(lst))==3:
                    if lst[2] < lst[0]+lst[1]:
                        ans+=1
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9204
#include <stdio.h>
int main(void) {
    int i,j,min,num,temp,count=0,array[101];
    scanf("%d",&num);
    for (i=0; i<num; i++) scanf("%d",&array[i]);
    for (i=0; i<num; i++) {
        min = i;
        for (j=i; j<num; j++) {
            if (array[j]<array[min]) min = j;
        }
        if (i!=min) {
            temp = array[i];
            array[i] = array[min];
            array[min] = temp;
            count++;
        }
    }
    for (i=0; i<num; i++) {
        if (i) printf(" ");
        printf("%d",array[i]);
    }
    printf("\n%d\n",count);
    return 0;
}

Measured memory_bytes: 604
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
 int n;
  string s;
  cin>>n>>s;
  int ans = 0;
  for(int i=0;i<n;i++){
   int j = i;
    while(j+1<n && s[j+1] == s[i])j++;
    ans++;
    i = j;
  }
  cout<<ans;
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    ll min;
    ll max;
    for (int i = 0; i < n; i++)
    {
        ll num; 
        cin >> num;

        if (i == 0)
        {
            min = num;
            max = num;
            continue;
        }
        
        if (num < min)
        {
            min = num;
        }
        if (num > max)
        {
            max = num;
        }
    }
    
    cout << abs(max - min) << endl;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int K; cin>>K;

    string out="";
    rep(i,K){
        out+="ACL";
    }
    cout<<out<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    string S;
    cin >> N >> S;
    rep(i,S.size())
        S[i] = (S[i] - 'A' + N) % 26 + 'A';
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;

procedure main is
   x: Integer;
begin
   for i in 0..4 loop
      get(x);
      if (x = 0) then put(i + 1, 0);
      end if;
   end loop;
end main;

Measured memory_bytes: 3656
S = input()

N = len(S)
left = S[:(N-1)//2]
right = S[(N+3)//2 - 1:]

left_rev = list(reversed(left))
right_rev = list(reversed(right))

error = 0
for i in range((N-1)//2):
    #Sが回文かチェック
    if left[i] != right_rev[i]:
        error = 1
        break

    #leftが回文かチェック
    if left[i] != left_rev[i]:
        error = 2
        break

    #rightが回文かチェック
    if right[i] != right_rev[i]:
        error = 3
        break

if error == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    char s[5000],tmp[60];
    int i,j,H,W;
    int flg = 0;

    scanf("%d%d",&H,&W);
    for(i=0;i<5000;i++){
        s[i] = '.';
    }

    i = W + 3;
    while(i<(W+2)*(H+1)){
        scanf("%s",tmp);
        for(j=0;j<W;j++){
            s[i] = tmp[j];
            i++;
        }
        i += 2;
    }

    if( (H == 1 ) && ( W == 1 ) ){
        if( s[4] == '#' ){
            printf("Yes\n");
            return 0;
        }
        printf("No\n");
        return 0;
    }

    i = W + 3;
    while(i<(W+2)*(H+1)-1){
        for(j=0;j<W;j++){
            if( s[i] == '#' ){
                if( ( s[i-(W+2)] == '.' ) && ( s[i-1] == '.' ) && ( s[i+1] == '.' ) && ( s[i+(W+2)] == '.' ) ){
                    printf("No\n");
                    return 0;
                }
            }
            i++;
        }
        i += 2;
    }

    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni(), k = ni();

        long[] a = nla(n);

        long sum = 0;
        long tmp1 = 0;
        long tmp2 = 0;

        for (int i = 0; i < n; i++) {
            if (a[i] > 0) sum += a[i];
            if (i < k && a[i] > 0) tmp1 += a[i];
            if (i < k && a[i] < 0) tmp2 += a[i];
        }

        long ans = Math.max(sum + tmp2, sum - tmp1);

        for (int i = k; i < n; i++) {
            if (a[i] > 0) {
                tmp1 += a[i];
            } else {
                tmp2 += a[i];
            }
            if (a[i - k] > 0) {
                tmp1 -= a[i - k];
            } else {
                tmp2 -= a[i - k];
            }
            ans = Math.max(ans, sum + tmp2);
            ans = Math.max(ans, sum - tmp1);
        }

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    class INA {
        int[][] a;

        INA(int n, int m) throws IOException {
            this(n, m, -1);
        }

        INA(int n, int m, int t) throws IOException {
            a = new int[m][n];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[j][i] = ni() + t;
                }
            }
        }

        int[] get(int i) {
            return a[i - 1];
        }
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 31272
import math
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    a[i] -= i+1

# ave = sum(a)/n
# ave1= math.ceil(ave)
# ave2= math.floor(ave)


# print(min(sum([abs(a[i]-ave1) for i in range(n)]),sum([abs(a[i]-ave2) for i in range(n)])))

a.sort()
med1=a[n//2-1]
med3=a[n//2]

print(min(sum([abs(a[i]-med1) for i in range(n)]),sum([abs(a[i]-med3) for i in range(n)])))

Measured memory_bytes: 25964
#include <iostream>
int main() {
  int n, q, t;
  std::cin >> n;
  int S[n];
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }
  std::cin >> q;
  int count = 0;
  for (int i = 0; i < q; i++) {
    std::cin >> t;
    int left_idx = 0;
    int right_idx = n;
    while (left_idx < right_idx) {
      int mid_idx = (right_idx + left_idx) / 2;
      if (S[mid_idx] == t) {
        count++;
        break;
      } else if (t < S[mid_idx]) {
        right_idx = mid_idx;
      } else if (t > S[mid_idx]) {
        left_idx = mid_idx + 1;
      }
      if (left_idx >= right_idx) break;
    }
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 3448
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }

    return ret;
}

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

    Int n;
    cin >> n;

    vector<Int> d{93668, 201177, 313925, 430062, 548725, 669422, 791780, 915548, 1040630, 1166750, 1293935, 1421996, 1550902, 1680578, 1810953, 1942002, 2073666, 2205986, 2338763, 2472113, 2606008, 2740315, 2875085, 3010305, 3145958, 3281973, 3418435, 3555195, 3692338, 3829833, 3967622, 4105787, 4244274, 4382991, 4522065, 4661460, 4801042, 4940922, 5081120, 5221472, 5362138, 5503108, 5644159, 5785585, 5927210, 6069000, 6211021, 6353304, 6495814, 6638449, 6781292, 6924353, 7067636, 7211106, 7354711, 7498504, 7642514, 7786669, 7931004, 8075504, 8220199, 8364997, 8510049, 8655190, 8800484, 8945974, 9091590, 9237328, 9383292, 9529316, 9675504, 9821898, 9968324, 10114972, 10261748, 10408621, 10555635, 10702823, 10850034, 10997454, 11145096, 11292653, 11440411, 11588376, 11736313, 11884447, 12032740, 12181098, 12329547, 12478206, 12626845, 12775675, 12924562, 13073587, 13222720, 13372007, 13521286, 13670825, 13820360};
    Int ans = 0;
    if (1 <= (n - 1) / 10000) {
        ans = d[((n - 1) / 10000) - 1];
    }
    for (Int i = ((n - 1) / 10000) * 10000 + 1; i < n; i++) {
        ans += divisor(i).size();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void) {
  int m, n, i, j;
  scanf("%d%d", &n, &m);
  int a[n][m], b[m];
  for(i = 0; i < n; ++i) for(j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  for(i = 0; i < m; ++i) scanf("%d", &b[i]);
  for(i = 0; i < n; ++i) {
    int ans = 0;
    for(j = 0; j < m; ++j) {
      ans += a[i][j] * b[j];
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2792
#include <iostream>
#include <algorithm>

using namespace std;
const int N = 1e5+3;

int a[N];

int32_t main() {

    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    int n,ans = 0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    a[0]--;
    for(int i=1;i<n;i++) if(a[i]>a[i-1]) a[i]--;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 640
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t a,b,c;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> a>>b>>c;
	out << (c / a) * b << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 1005
#define MAXW 20005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n;
ll dp[MAXN][MAXW];
struct block
{
    ll w,s,v;
}a[MAXN];
bool cmp(block p,block q)
{
    return q.s-p.w>p.s-q.w;
}
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++) scanf("%lld%lld%lld",&a[i].w,&a[i].s,&a[i].v);
    sort(a+1,a+n+1,cmp);
    for(ll i=0;i<=n;i++) for(ll j=0;j<=20000;j++) dp[i][j]=-INF;
    dp[0][0]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=20000;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=a[i].w&&a[i].s>=j-a[i].w) dp[i][j]=max(dp[i][j],dp[i-1][j-a[i].w]+a[i].v);
        }
    }
    ll ans=0;
    for(ll j=0;j<=20000;j++) ans=max(ans,dp[n][j]);
    printf("%lld\n",ans);
    return 0;
}



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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
 //    fast

    int n,d;
    cin>>n>>d;
    int c=(n+(2*d));
    int m=(2*d)+1;
    pt(c/m);
    
    
    

}


/*

// 

*/

Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
using namespace std;
long long a[200020],id[200020];
long long n,now=0,ans;
int main()
	{
		cin>>n;
		for(int i=1;i<=n;i++)
			{
				cin>>a[i];
				id[a[i]]=i;
			}
		for(int i=1;i<=n;i++)
			{
				if(id[i]<id[i-1])
					{
						if(i!=1) now=1;
						else now=0;
					}
				else{
					now++;
					ans=max(ans,now);	
					} 
			}
		cout<<n-ans<<endl;
	}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

#define rep2(i, b, n) for(int i=b; i < n; ++i)
#define rep(i, n) rep2(i, 0, n)
#define sz(x) x.size()
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)
#define P first
#define D second

using namespace std;

typedef pair<int, int> pii;

pii p[10000];

int main( void )
{
	int n, m;
	while(cin >> n >> m, n | m) {
		int sump = 0;
		rep(i, n) {
			cin >> p[i].D >> p[i].P;
			sump += (p[i].D * p[i].P);
		}
		sort(p, p+n, greater<pii>());
		rep(i, n) {
			if(p[i].P == 0) continue;
			int mm = min(p[i].D, m);
			sump -= (mm * p[i].P);
			m -= mm;
			if(m == 0) break;
		}
		cout << sump << endl;
	}
	return 0;
}

Measured memory_bytes: 944
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		boolean[][] judg = new boolean[n+1][n+1];
		for(int i=0;i<n+1;i++){
			Arrays.fill(judg[i],false);
		}
		ArrayList<ArrayList<Integer>> graph = new ArrayList<ArrayList<Integer>>();
		for(int i=0;i<2;i++){
			graph.add(new ArrayList<Integer>());
		}
		for(int i=0;i<n;i++){
			int u = stdIn.nextInt();
			int k = stdIn.nextInt();
			for(int j=0;j<k;j++){
				int v = stdIn.nextInt();
				judg[u][v] = true;
			}
		}
		
		int[] d = new int[n+1];
		Arrays.fill(d,-1);
		d[1] = 0;
		
		for(int i=0;i<n;i++){
			for(int k=1;k<=n;k++){
				if(d[k]==i){
					for(int j=1;j<=n;j++){
						if(judg[k][j] && d[j]==-1 && k!=j){
							d[j] = d[k] + 1;
						}
					}
				}
			}
		}
		
		for(int i=1;i<=n;i++){
			System.out.println(i+" "+d[i]);
		}
	}
}

Measured memory_bytes: 20872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=10001001000;
int main() {
    int N,M,R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for(int i=0; i<R; i++){
        cin >> r[i];
    }
    sort(r.begin(),r.end());
    vector<vector<ll>> d(250,vector<ll>(250,INF));
    for(int i=1; i<=N; i++) d[i][i]=0;
    for(int i=1; i<=M; i++){
        ll a,b,c;
        cin >> a >> b >> c;
        d[a][b]=c;
        d[b][a]=c;
    }
    for(int k=1; k<=N; k++){
        for(int i=1; i<=N; i++){
            for(int j=1; j<=N; j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll ans=INF;
    do{
        ll cost=0;
        for(int i=0; i<R-1; i++){
            cost+=d[r[i]][r[i+1]];
        }
        ans=min(ans,cost);
    }while(next_permutation(r.begin(),r.end()));
    cout << ans << endl;
    return 0;
}

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

int main(){
  int K,X;
  cin >> K >> X;
  
  int min = X - K + 1;
  int max = X + K - 1;
  
  for(min;min <= max; min++){
    cout << min << " ";
  }
}
  
  

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

int main() {
  string s;
  cin >> s;
  int N = 0;
  N = s.size() - 1;
  ll ans = 0;
  ll num_s = stoll(s);
  
  rep(tmp, 1 << (N)) {
    if (tmp == 0) {
        continue;
    }
    bitset<9> k(tmp);
    int pre = -1;
    vector<ll> num_list;
    rep(i, N) {
      if (k[i] == 1) {
        string num_str = s.substr(N - i, i - pre);
        pre = i;
        num_list.push_back(stoll(num_str));
      }
    }
    num_list.push_back(stoll(s.substr(0, N - pre)));
    ans += accumulate(num_list.begin(), num_list.end(), 0);
  }
  printf("%lld\n", ans + num_s);
  return 0;
}


Measured memory_bytes: 256