akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
char s[100005];
int fuck,FUCK[100005];
int main()
{
	scanf("%s",s+1);
	int ans=0;
	int len=strlen(s+1);
	for(int i=1;i<=len;++i)
	{
		if(fuck&&s[i]!=FUCK[fuck]) fuck--,ans+=2;
		else FUCK[++fuck]=s[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 768
S = list(input())
T = list(input())

s = len(S)
t = len(T)

ans = float('inf')

for i in range(s-t+1):
    k = 0
    for j in range(t):
        if S[i+j] != T[j]:
            k += 1
    ans = min(k,ans)

print(ans)

Measured memory_bytes: 9124
#include <iostream>
using namespace std;
int main(void){
    int k, s;
    cin >> k >> s;
    int tmp = 0, cnt = 0;
    for (int x = 0; x <= k; x++)
    {
        for (int y = 0; y <= k; y++)
        {
            tmp = s - (x + y);
            if (0 <= tmp && tmp <= k) cnt++;            
        }
        
    }
    
    cout << cnt << endl;
    return 0;

}

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

#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define ss second
#define ff first
#define sz(s) (int)s.size()
#define all(a) a.begin(),a.end()

#ifndef ONLINE_JUDGE
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

#else
#define trace(args...) { }
#endif

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

int main()
{
  IOS;
  ll n, m;
  cin >> n >> m;
  vector< pair<ll, ll> > drink(n);
  for(int i = 0; i < n; i++){
    cin >> drink[i].ff >> drink[i].ss;
  }
  sort(all(drink));
  ll req = m, i = 0, ans = 0;
  while(req > 0 && i < n){
    if(req >= drink[i].ss){
      req -= drink[i].ss;
      ans += (drink[i].ff * drink[i].ss);
    }
    else{
      ans += (drink[i].ff * req);
      req = 0;
    }
    i++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
N=int(input())
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

T=[]
for i in range(N):
    T.append(int(input()))

if N==1:
    print(T[0])
else:
    a=lcm(T[0],T[1])
    for i in range(N):
        a=lcm(a,T[i])
    print(a)

    



Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

ll MOD = 1000000007;
ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }

int main() {
  //
  int n;
  cin >> n;
  ll ans = INT_MAX;
  vi a(n);
  rep(i, n) cin >> a[i];
  REP(x, -100, 101) {
    ll total = 0;
    rep(i, n) { total += (x - a[i]) * (x - a[i]); }
    ans = min(total, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  vector<vector<mint>> dp(n + 1, vector<mint>(4, 0));
  dp[0][0] = 1;
  rep(i, n) {
    if(s[i] == 'C' || s[i] == '?') dp[i + 1][3] += dp[i][2];
    if(s[i] == 'B' || s[i] == '?') dp[i + 1][2] += dp[i][1];
    if(s[i] == 'A' || s[i] == '?') dp[i + 1][1] += dp[i][0];
    if(s[i] == '?')
      rep(j, 4) dp[i + 1][j] += dp[i][j] * 3;
    else
      rep(j, 4) dp[i + 1][j] += dp[i][j];
  }
  cout << dp[n][3] << endl;
}

Measured memory_bytes: 10388
N = int(input())
A = list(map(int, input().split()))
right = 0
ans = 0
A_xor = 0
A_sum = 0
for left in range(N):
    while right<N and (A_xor^A[right])==(A_sum+A[right]):
        A_xor ^= A[right]
        A_sum += A[right]
        right += 1
    ans += right-left
    if right==left:
        right += 1
    else:
        A_xor ^= A[left]
        A_sum -= A[left]
print(ans)

Measured memory_bytes: 24840
n = int(input())
g = [[]*(n) for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ds = [0]*n
de = [0]*n
from collections import deque
def bfs(s,d):
    q = deque()
    q.append((s,1))
    visit = [False]*n
    visit[s] = True
    cnt =1
    while q:
        s,p = q.popleft()
        if cnt==n: break
        for i in g[s]:
            if not visit[i]:
                d[i] = p
                visit[i] = True
                cnt += 1
                q.append((i,p+1))
bfs(0,ds)
bfs(n-1,de)
s,e=0,0
for i in range(n):
    if ds[i]<=de[i]:
        s+=1
    else:
        e+=1
if s>e:
    print('Fennec')
else:
    print('Snuke')



Measured memory_bytes: 91432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int k,x;
    cin >> k >> x;
    for(int i = x - k + 1;i <= x + k - 1; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int N,L,MAX=-1;
vi a;

int main(){
	cin>>N>>L;
	a=vi(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	for(int i=0;i<N-1;i++){
		if(a[i]+a[i+1]>=L){
			MAX=i+1;
			break;
		}
	}
	if(MAX==-1){
		cout<<"Impossible"<<endl;
		return 0;
	}
	cout<<"Possible"<<endl;
	for(int i=1;i<MAX;i++) cout<<i<<endl;
	for(int i=N-1;i>=MAX;i--) cout<<i<<endl;
	return 0;
}

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

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


Measured memory_bytes: 3088
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

X = int(input())

l = []
for i in range(0, 1000):
    l.append(i ** 5)

for i in range(len(l)):
    for j in range(len(l)):
        if l[i] - l[j] == X:
            print(i, j)
            sys.exit()
        if l[i] + l[j] == X:
            print(i, -j)
            sys.exit()


Measured memory_bytes: 89948
N, M, K = map(int, input().split())
flag = False
for i in range(N+1):
    for j in range(M+1):
        cnt = i*M+j*N-2*i*j
        if cnt == K:
            flag = True
            break
    if flag:
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
n,m = [int(i) for i in input().split()]
sw = []
for j in range(m):
    k,*l = [int(i)-1 for i in input().split()]
    sw.append(l)
p = [int(i) for i in input().split()]

#print(sw,p)
ans = 0
for i in range(2**n):
    ok=1
    for j in range(m): # スイッチ番号
        a=0
        for c in sw[j]:
                a += (1 if i&(2**c) else 0)
#        print(i,j,a)
        if a%2 != p[j]:
            ok=0
            break

    if ok:
        ans += 1
#        print(i)
            
print(ans)    



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    int n;
    cin >> n;
    ll zero = 0;
    map<pair<ll, ll>, pair<ll, ll>> mp;
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0)
        {
            zero++;
            continue;
        }
        if (y < 0)
        {
            x = -x;
            y = -y;
        }
        if (y == 0 && x < 0)
        {
            x = -x;
            y = -y;
        }

        bool rot90 = false;
        if (x <= 0)
        {
            rot90 = true;
            ll tmp = x;
            x = y;
            y = -tmp;
        }
        ll g = __gcd(x, y);
        ll a = x / g;
        ll b = y / g;
        if (!rot90)
        {
            mp[{a, b}].fi++;
        }
        else
        {
            mp[{a, b}].se++;
        }
    }

    mint ans = 1;
    for (auto m : mp)
    {
        mint tmp1 = mint(2).pow(m.se.fi) - 1;
        mint tmp2 = mint(2).pow(m.se.se) - 1;
        ans *= (tmp1 + tmp2 + 1);
    }
    ans -= 1;
    ans += zero;

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

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

inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b);}
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b);}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, t;
    cin>>n>>t;
    int arr[n];
    ll ans = 0;
    for (int i =0; i<n; i++){
        cin>>arr[i];

    }
    for (int i =1; i<n; i++){
        if(arr[i] - arr[i-1] <=t){
            ans+=arr[i]-arr[i-1];
        }
        else{
            ans+=t;
        }
    }
    ans+=t;
    cout<<ans<<"\n";

}


Measured memory_bytes: 4380
from collections import Counter

n=int(input())
a=list(map(int,input().split()))

q1=[]
q2=[]

for i in range(n):
  q1.append(i+a[i])
  q2.append(i-a[i])

c1=Counter(q1)
c2=Counter(q2)

ans=0
for i in c1.keys():
  num1=c1[i]
  num2=c2[i]
  ans+=num1*num2

print(ans)

Measured memory_bytes: 63628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  vector<int> ans(3);
  ans.at(0) = A + B;
  ans.at(1) = A - B;
  ans.at(2) = A * B;
  
  cout << max(ans.at(0), max( ans.at(1),ans.at(2) )) << endl;
}


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

using namespace std;

long long q,h,s,d,n;

int main(){
	scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);
	
	q *= 4;
	h *= 2;
	
	long long mn = min(min(q, h), s);
	
	if(d < mn * 2){
		printf("%lld\n", d * (n / 2) + mn * (n % 2));
	}
	else{
		printf("%lld\n", mn * n);
	}
}


Measured memory_bytes: 256
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define maxn 100001
#define pb push_back
using namespace std;
void solve(){
    ll n,k,cnt=1;
    cin>>n;
    if(n%2==0){
        cout<<"-1";
        return;
    }else{
        k=7;
        while(1){
            if(k%n==0){
                cout<<cnt;return;
            }
            if(cnt>n){
                cout<<"-1";return;
            }
            k*=10;
            k+=7;
            cnt++;
            k%=n;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 3576
A, B = map(int, input().split())
ans = 0
if A == 1:
    ans += 300000
elif A == 2:
    ans += 200000
elif A == 3:
    ans += 100000

if B == 1:
    ans += 300000
elif B == 2:
    ans += 200000
elif B == 3:
    ans += 100000

if A == B == 1:
    ans += 400000

print(ans)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 062 D / Link: http://abc062.contest.atcoder.jp/tasks/abc062_d  ----- */


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

	LL N;
	cin >> N;
	vector<LL> a(3 * N);
	for (int i = 0; i < 3 * N; ++i) {
		cin >> a[i];
	}
	VL frontmaxsum(3 * N, 0); { // [0..i]
		multiset<LL>front;
		LL sum = 0;
		FOR(i, 0, 2 * N) {
			sum += a[i];
			front.insert(a[i]);
			if (SZ(front) > N) {
				auto it = front.begin();
				sum -= *it;
				front.erase(it);
			}

			frontmaxsum[i] = sum;
		}
	}

	VL backminsum(3 * N, 0); {//[i..3N*-1]
		multiset<LL>back;
		LL sum = 0;
		FORR(i, 3 * N - 1, N - 1) {
			sum += a[i];
			back.insert(a[i]);
			if (SZ(back) > N) {
				auto it = prev(back.end());
				sum -= *it;
				back.erase(it);
			}

			backminsum[i] = sum;
		}

	}

	LL ans =-LINF;
	FOR(i, N - 1, 2 * N) {
		ans = max(ans, frontmaxsum[i] - backminsum[i + 1]);
	}

	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 12032
#!/usr/local/bin/ruby
while line=gets
a=line.split(" ").map(&:to_i)
b=gets.split(" ").map(&:to_i)
g,h=0,0
   for i in 0..3
      for j in 0..3
         if b[i]==a[j]
            if i == j
               h = h+1
            else
               g =g +1
            end
         end
      end
   end
   puts "#{h} #{g}"
end

Measured memory_bytes: 6108
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; ++i) {
        cout << i << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int a,b;
        string op;
        cin>>a>>op>>b;
        if(op=="?"){
            return 0;
        }
        if(op=="+"){
            cout<<a+b<<endl;
            continue;
        }
        if(op=="-"){
            cout<<a-b<<endl;
            continue;
        }
        if(op=="*"){
            cout<<a*b<<endl;
            continue;
        }
        if(op=="/"){
            cout<<a/b<<endl;
        }
    }
}


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

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<ll>s,t, x(Q);
	s.push_back(-1e15);
	for (int i = 1; i <= A; ++i) {
		ll a; cin >> a;
		s.push_back(a);
	}
	s.push_back(1e15);
	t.push_back(-1e15);
	for (int i = 0; i < B; ++i) {
		ll b; cin >> b;
		t.push_back(b);
	}
	t.push_back(1e15);
	for (int i = 0; i < Q; ++i)cin >> x[i];
	for (int i = 0; i < Q; ++i) {
		ll S[2];
	    S[0] = s[lower_bound(s.begin(), s.end(), x[i]) - s.begin()-1];
		S[1] = s[lower_bound(s.begin(), s.end(), x[i]) - s.begin()];
		ll T[2];
		T[0] = t[lower_bound(t.begin(), t.end(), x[i]) - t.begin() - 1];
		T[1] = t[lower_bound(t.begin(), t.end(), x[i]) - t.begin()];
		ll ans = 1e17;
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				for (int l = 0; l < 2; ++l) {
					ll key = 0;
					if (j == 0) {
						key += abs(S[k] - x[i]);
						key += abs(S[k] - T[l]);
					}
					else {
						key += abs(T[l] - x[i]);
						key += abs(T[l] - S[k]);
					}
					ans = min(ans, key);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int M, D;
int main(void){
    cin >> M >> D;
    int count=0;
    for (int m=1;m<=M;m++){
        for (int d=11;d<=D;d++){
            int a = d%10;
            int b = d/10;
            if (a>1 and b>1 and a*b == m) count++;
        }
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int num , count = 0;
	float weight , height;
	while(scanf("%d,%f,%f" , &num , &weight , &height)!=EOF){
		if(weight/height/height >= 25){
			printf("%d\n" , num);
			count++;
		}
	}
	if(count==0) printf("ツ該ツ督鳴づ按つオ\n");
	return 0;
}

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

int main() {
  int n,m;
  cin>> n >> m;
  ll sum=0;
  vector<int> v(n),ans(n);
  r(i,n)cin >> v[i];
  sort(v.begin(),v.end());
  vector<P> koukan(m);
  r(i,m)cin >> koukan[i].second>> koukan[i].first;
  sort(koukan.begin(),koukan.end());
  reverse(koukan.begin(),koukan.end());
  int j=0;
  r(i,n){
    ans[i]=koukan[j].first;
    koukan[j].second--;
    if(koukan[j].second==0)j++;
    if(j==m)break;
  }
  r(i,n)v[i]=max(v[i],ans[i]);
  r(i,n)sum+=v[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>


int main(){
  int H,W;
  char S[2002][2002];
  int C[2002][2002];
  int L[2002][2002];
  int max=0;

  scanf("%d %d\n",&H,&W);

  for(int j=0;j<=W+1;j++){
    S[0][j] = '#';
    S[H+1][j] = '#';
  }
  
  for(int i=1;i<=H;i++){
    S[i][0] = '#';
    scanf("%s",S[i]+1);
    S[i][W+1] = '#';
  }
  

  for(int i=1;i<=H;i++){
    C[i][0] = 0;
    for(int j=1;j<=W;j++)
      C[i][j] = (S[i][j] == '.') ? C[i][j-1]+1 : 0;

    C[i][W+1] = 0;
    for(int j=W;j>0;j--)
      if( S[i][j] == '.' && S[i][j+1] == '.' )
        C[i][j] =  C[i][j+1];  
  }

  for(int j=1;j<=W;j++){
    L[0][j] = 0;
    for(int i=1;i<=H;i++)
      L[i][j] = (S[i][j] == '.') ? L[i-1][j]+1 : 0;

    L[H+1][j] = 0;
    for(int i=H;i>0;i--)
      if( S[i][j] == '.' && S[i+1][j] == '.' )
        L[i][j] =  L[i+1][j];  
      
  }

  for(int j=1;j<=W;j++)
    for(int i=1;i<=H;i++)
      if (max < L[i][j]+C[i][j]-1 )
        max = L[i][j]+C[i][j]-1;

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


Measured memory_bytes: 35328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct pp{
	char s[15];
	int p,id;
}e[110];
int cmp(const pp&a,const pp&b)
{
	if(strcmp(a.s,b.s)>0) return 0;
	if(strcmp(a.s,b.s)<0) return 1;
	if(a.p>b.p) return 1;
	return 0;
}
int main ()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%s",e[i].s);
		scanf("%d",&e[i].p);
		e[i].id=i;
	}
	sort(e+1,e+1+n,cmp);
	for(i=1;i<=n;++i) printf("%d\n",e[i].id);
} 

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

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




    
return 0;
}


Measured memory_bytes: 3632
ans=114514
D,G=map(x->parse(Int,x),split(readline()))
P=Array{Int}(0)
C=Array{Int}(0)
for i=1:D
	p,c=map(x->parse(Int,x),split(readline()))
	push!(P,p)
	push!(C,c)
end
for i=0:(1<<D)-1
	h=-1
	now=0
	c=0
	for j=1:D
		if (i>>(j-1))%2==1
			now+=C[j]+P[j]*j*100
			c+=P[j]
		else
			h=j
		end
	end
	if h>0
		t=cld(max(G-now,0),h*100)
		if P[h]>=t
			now+=t*h*100
			c+=t
		end
	end
	if now>=G
		ans=min(ans,c)
	end
end
println(ans)


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n;cin>>n;
  res=1;
  for(i=1;i<=n;i++){
    qmod(res,i);
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };

int main() {
	ll n, x;
	cin >> n >> x;
	vector<int> a(n);
	vector<int> b(n - 1);
	rep(i, n) {
		cin >> a.at(i);
	}
	ll ans = 0;
	rep(i, n - 1) {
		b.at(i) = a.at(i) + a.at(i + 1);
		ll num = b.at(i) - x;
		if (num <= 0) {
			continue;
		}
		else if (a.at(i + 1) >= num) {
			a.at(i + 1) = a.at(i + 1) - num;
		}
		else if (a.at(i + 1) < num) {
			a.at(i) = a.at(i) - (num - a.at(i + 1));
			a.at(i + 1) = 0;
		}
		ans += num;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#-*-coding:utf-8-*-

def main():
    k = int(input())
    if k % 2 == 0:
        ans = (k // 2) ** 2
    else:
        ans = (k // 2) * ((k // 2) + 1)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i, 0, N) cin >> W[i];
    vector<int> sum(N + 1);
    sum[0] = 0;
    rep(i, 0, N)
    {
        sum[i + 1] = sum[i] + W[i];
    }
    int ans = 1 << 30;
    rep(i, 0, N)
    {
        chmin(ans, abs((sum[N] - sum[i + 1]) - sum[i + 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


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

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << max(A + B - N, 0) << endl;
}

Measured memory_bytes: 764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int H, W, T, Q;

template <int Height, int Width>
struct bit_sum_2d {
    int arr[Height+1][Width+1];
    int height, width;

    bit_sum_2d() {
        height = Height;
        width = Width;
        for (int j = 0; j < height+1; ++j) {
            fill(arr[j], arr[j]+width+1, 0);
        }
    }

    void update(int h, int w, int a) {
        for (int j = h+1; j <= height; j += j&-j) {
            for (int k = w+1; k <= width; k += k&-k) {
                arr[j][k] += a;
            }
        }
    }

    int query(int h, int w) {
        int sum = 0;
        for (int j = h+1; j > 0; j -= j&-j) {
            for (int k = w+1; k > 0; k -= k&-k) {
                sum += arr[j][k];
            }
        }
        return sum;
    }

    int query(int h1, int w1, int h2, int w2) {
        return query(h2, w2) - query(h1-1, w2) - query(h2, w1-1) + query(h1-1, w1-1);
    }
};

struct taiyaki_t {
    int t; int h, w;
    taiyaki_t(int a, int b, int c): t(a), h(b), w(c) {}
};

bit_sum_2d<2000, 2000> b1, b2;
char status[2000][2000];

int main() {
    scanf("%d%d%d%d", &H, &W, &T, &Q);
    queue<taiyaki_t> tq;
    for (int j = 0; j < H; ++j) fill(status[j], status[j]+W, 0);
    for (int j = 0; j < Q; ++j) {
        int t, c, h, w, hh, ww;
        scanf("%d%d%d%d", &t, &c, &h, &w);
        --h; --w;

        while(!tq.empty() && tq.front().t <= t) {
            taiyaki_t f = tq.front(); tq.pop();
            b1.update(f.h, f.w, -1);
            b2.update(f.h, f.w, 1);
            status[f.h][f.w] = 1;
        }

        if (c == 0) {
            tq.emplace(t+T, h, w);
            b1.update(h, w, 1);
        } else if (c == 1) {
            if (status[h][w]) {
                status[h][w] = 0;
                b2.update(h, w, -1);
            }
        } else if (c == 2) {
            scanf("%d%d", &hh, &ww);
            --hh; --ww;

            cout << b2.query(h, w, hh, ww) << " " << b1.query(h, w, hh, ww) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 39276
#include<iostream>
#include<algorithm>
#define F 100000
using namespace std;
int c[F],s[F],e[F];
int main(){
	int n,k,qtop;
	while(true){
	cin>>n>>k;
	if(!n&&!k)break;
	for(int i=0;i<k;i++)cin>>c[i];
	sort(c,c+k);
	bool t=false;
	if(!c[0])t=true;
	qtop=1,s[0]=c[t];
	for(int i=1+t;i<k;i++){
		if(c[i]!=c[i-1]+1){
			e[qtop-1]=c[i-1];
			s[qtop]=c[i];
			qtop++;
		}
	}
	e[qtop-1]=c[k-1];
	int ans=0;
	for(int i=0;i<qtop;i++)ans=max(ans,e[i]-s[i]+1);
	if(t){
		ans=min(ans+1,k);
		for(int i=0;i<qtop-1;i++)if(e[i]+2==s[i+1])ans=max(ans,e[i]+e[i+1]-s[i]-s[i+1]+3);
	}
	cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;
struct wow
{
    int zile,nr;
}v[100005];
int compare (wow a,wow b)
{
    return a.zile<b.zile;
}
priority_queue <long long > q;
long long sum,n,m,i,poz;
int main()
{
    cin>>n>>m;
    for (i=1;i<=n;i++)
    {
        cin>>v[i].zile>>v[i].nr;
    }
    sort (v+1,v+n+1,compare);
    poz=1;
    for (i=1;i<=m;i++)
    {
        while (v[poz].zile<=i&&poz<=n)
        {
            q.push(v[poz].nr);
            poz++;
        }
        if (!q.empty())
        {
            sum=sum+q.top();
        q.pop();
        }
    }
    cout<<sum;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;
    a*=b;
    if(a&1)cout<<"Odd"<<endl;
    else cout<<"Even"<<endl;
    return 0;
}


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

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

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

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

std::vector<int> operator * (const std::vector<int> &v1, const std::vector<int> &v2) {
  size_t N = v1.size();
  std::vector<int> res(N);
  for (int i: range(0, N)) {
    res[i] = v2[v1[i]];
  }
  return res;
}

std::vector<int> power(std::vector<int> vec, int64_t exp) {
  size_t N = vec.size();
  std::vector<int> res(N);
  std::iota(res.begin(), res.end(), 0);
  while (exp > 0) {
    if (exp & 1) res = res * vec;
    vec = vec * vec;
    exp >>= 1;
  }
  return res;
}

int main() {
  int N;
  int64_t K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
    --x;
  }
  auto ans = power(A, K);
  std::cout << ans.front() + 1 << '\n';
  return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xmod int(1e9+7)
#define hmod 1223334444555553LL
using namespace std;

int n;
char s[105],t[105];
int main(){
	scanf("%d\n%s%s",&n,&s,&t);
	for (int i=0;i<n;i++){
		printf("%c%c",s[i],t[i]);
	}
	printf("\n");
    return 0;
}	

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxdig = 16;
int sum(long long x) {
	int ret = 0;
	while (x > 0) {
		ret += x % 10;
		x /= 10;
	}
	return ret;
}
int main() {
	int n;
	cin >> n;
	long long cur = 1;
	for (int i = 0; i < n; ++i) {
		cout << cur << '\n';
		string s = to_string(cur);
		s = string(maxdig - s.size(), '0') + s;
		vector<long long> vl;
		for (int j = maxdig - 1; j >= 0; --j) {
			while (s[j] < '9') {
				++s[j];
				for (int k = maxdig - 1; k > j; --k) {
					s[k] = '0';
				}
				vl.push_back(stoll(s));
				for (int k = maxdig - 1; k > j; --k) {
					while (s[k] < '9') {
						++s[k];
						vl.push_back(stoll(s));
					}
				}
			}
		}
		cur = *min_element(vl.begin(), vl.end(), [](long long x, long long y) { return x * sum(y) < y * sum(x); });
	}
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  long long int N, tmp;
  std::vector<long long int> A;

  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
  }
  
  long long int approve = 1;
  for(long long int i = 0; i < N; i++){
    if(A[i]%2 == 0 && A[i]%3 != 0 && A[i]%5 != 0){
      approve = 0;
      break;
    }
  }

  std::cerr << "Answer: " << std::endl;

  if(approve){
    std::cout << "APPROVED" << std::endl;
  }
  else{
    std::cout << "DENIED" << std::endl;
  }

  return 0;

}


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

int Digs(int n)
{
    int res = 0;
    while (n) {
        res++;
        n /= 10;
    }
    return res;
}

int main()
{
    int n; scanf("%d", &n);
    int res = 0;
    for (int i = 1; i <= n; i++)
        res += Digs(i) % 2;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 384
#include<algorithm> 
#include<cstdio>
#include<cstring>

const int INF = 0x6ffffff; 
int ans = INF, num; 

inline int get(int x){
    int res = 0; 
    while (x) {
        res += x % 10; 
        x /= 10; 
    }
    return res; 
}

int main(){
    scanf("%d", &num); 
    for (int i = 1; i <= num / 2; i++) {
        ans = std::min(ans, get(i) + get(num - i)); 
    }
    printf("%d\n", ans); 
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string.h>
#define MAX_V 300
#define INF 100000000000000
using namespace std;

struct edge {long long to,cap,rev;};

vector<edge> G[MAX_V];
long long level[MAX_V],iter[MAX_V];

void add_edge(int from, int to, long long cap){
	G[from].push_back((edge){to,cap,(long long)G[to].size()});
	G[to].push_back((edge){from,0,(long long)G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

long long dfs(int v, int t, long long f){
	if(v==t) return f;
	for(int i = iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
		int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
	
long long max_flow(int s, int t){
	long long flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		long long f;
		while((f=dfs(s,t,INF))>0){
			flow += f;
		}
	}
}
pair<int,int> p[100];
int main(){
	int i,j,n;
	cin >> n;
	for(i=1;i<=n;i++){
		int a,b;
		cin >> a >> b;
		p[i] = {a,b};
		add_edge(0,i,1);
	}
	for(i=1;i<=n;i++){
		int c,d;
		cin >> c >> d;
		for(j=1;j<=n;j++){
			if(p[j].first<c && p[j].second<d){
				add_edge(j,i + n,1);
			}
		}
		add_edge(i+n,2*n+1,1);
	}
	cout << max_flow(0,2*n+1) << endl;
}

Measured memory_bytes: 512
h,w=map(int,input().split())
a=[]
for _ in range(h):
  a.append(list(input()))
#print(a)
dp=[[0 for _ in range(w)] for _ in range(h)]
dp[0][0]=1
#print(dp)
MOD=10**9+7
for i in range(h):
  for j in range(w):
    #print(i,j)
    if i+1<h and a[i+1][j]==".":
      dp[i+1][j]+=dp[i][j]
      if dp[i+1][j]>=MOD:
        dp[i+1][j]-=MOD
    if j+1<w and a[i][j+1]==".":
      dp[i][j+1]+=dp[i][j]
      if dp[i][j+1]>=MOD:
        dp[i][j+1]-=MOD
#print(dp)
print(dp[h-1][w-1])

Measured memory_bytes: 116200
program main
implicit None
	integer(8)::n,m
	read *,n,m
	
	if(n*m == 1)then
		print 101,1
		stop
	endif
	
	if(n == 1 .or. m == 1)then
		print 101,n*m-2
		stop
	endif
	
	print 101,(n-2)*(m-2)
101 format(i0)
end program main

Measured memory_bytes: 256
# B - Homework

# N日の夏休みの間に、M個の宿題が出されており
# i番目の宿題にはAi日かかる。
# 夏休み中、最大何日遊ぶことができるか

N, M = map(int, input().split())
A = list(map(int, input().split()))

answer = N - sum(A)

if answer < 0:
    print(-1)
else:
    print(answer)


Measured memory_bytes: 10044
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
bool comp(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return (a.first/a.second) < (b.first/b.second);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> v;
    REP(i,n)
    {
        ll x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    /*for(auto i:v)
    {
        cout<<i.first<<" "<<i.second<<"\n";
    }*/

    ll ans=0;
    ll count=0;
    for(auto i:v)
    {
        if(count==m)
        break;
        if(count+i.second>m)
        {
            ans+=1LL*i.first*(m-count);
            count=m;
        }
        else
        {
            ans+=1LL*(i.first)*(i.second);
            count+=i.second;
        }
    }
    cout<<ans<<"\n";
  }  
  return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  map<int, int> order;
  for(int i=1;i<=n;i++){
    int a;cin>>a;
    order[a] = i;
  }
  for(int i=1;i<=n;i++){
    cout<<order[i]<<" ";
  }
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a > c) cout << 0 << endl;
  else if(a+b < c) cout << "NA" << endl;
  else cout << c-a << endl;
  return (0);
}



Measured memory_bytes: 3112