akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

int main(){
	int n;
	char* s;
	int i;
	int x = 0;
	int max;

	max = x;
	scanf("%d",&n);
	s = (char*)calloc(n+1,sizeof(char));
	scanf("%s",s);

	for(i=0; i<n; i++){
		if( s[i] == 'I') x++;
		if( s[i] == 'D') x--;
		if( x > max ) max = x;
	}

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

	return 0;
}

Measured memory_bytes: 128
import sys
def input():
    return sys.stdin.readline().strip()

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

x = []
h = {} # x:h
for _ in range(n):
    i, j = map(int, input().split())
    x.append(i)
    h[i] = j
x.sort()
x.append(x[-1] + 2*d + 1)

# attackで累積和を用いる
ans = 0
attack = [0 for _ in range(n+1)]
for i in range(n):
    attack[i] += attack[i-1]
    if attack[i] >= h[x[i]]:
        continue

    if (h[x[i]] - attack[i]) % a == 0:
        j = (h[x[i]] - attack[i]) // a
    else:
        j = (h[x[i]] - attack[i]) // a + 1
    attack[i] += a * j
    ans += j

    # 二分探索で、x[y] > x[i] + 2*d、を満たす最小のyを求める
    # start <= y <= stop
    start = i + 1
    stop = n
    k = stop - start + 1
    while k > 1:
        if x[start + k//2 - 1] <= x[i] + 2*d:
            start += k//2
        else:
            stop = start + k//2 - 1
        k = stop - start + 1
    attack[start] -= a * j

print(ans)

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int h,w;
    cin>>h>>w;
    int ch,cw;
    cin>>ch>>cw;
    ch--;cw--;
    int dh,dw;
    cin>>dh>>dw;
    dh--;dw--;
    vector<string> f(h);
    for(int i=0;i<h;++i)cin>>f[i];
    deque<pair<int,int>> q;
    vector<vector<int>> dp(h,vector<int>(w,inf));
    vector<pair<int,int>> d1 = {{-1,0},{0,-1},{1,0},{0,1}};
    q.push_back({ch,cw});
    dp[ch][cw] = 0;
    while(!q.empty()){
        auto cur = q.front();q.pop_front();
        int y = cur.first;
        int x = cur.second;
        if(y == dh and x == dw)break;
        for(auto & d : d1){
            int dy = y + d.first;
            int dx = x + d.second;
            if(dy < 0 or dx < 0 or dy > h-1 or dx > w-1 or f[dy][dx] == '#')continue;
            if(dp[dy][dx] > dp[y][x]){
                q.push_front({dy,dx});
                dp[dy][dx] = dp[y][x];
            }
        }
        for(int i=-2;i<=2;++i)for(int j=-2;j<=2;++j){
            if(i ==0 and j==0)continue;
            if((i==1 and j==0) or (i==0 and j==1) or(i==-1 and j==0) or(i == 0 and j==-1))continue;
            int dy = y + i;
            int dx = x + j;
            if(dy < 0 or dx < 0 or dy > h-1 or dx > w-1 or f[dy][dx] == '#')continue;
            if(dp[dy][dx] > dp[y][x] + 1){
                q.push_back({dy,dx});
                dp[dy][dx] = dp[y][x] + 1;
            }
        }
    }
    
    if(dp[dh][dw] == inf) cout << -1 << endl;
    else cout << dp[dh][dw] << endl;
    return 0;
    
}


Measured memory_bytes: 8724
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    rep(i,n) vsort(s[i]);
    vsort(s);

    ll cnt[n];
    rep(i,n) cnt[i] = 1;
    
    int num = 0;
    rep(i,n-1){
        if (s[i] == s[i+1]) cnt[num]++;
        else num++;
    }

    ll ans = 0;
    rep(i,n){
        if (2 <= cnt[i]) ans += cnt[i] * (cnt[i]-1) / 2;
    }

    cout << ans << endl;
}





//              g++ -std=c++1z


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

int main(){
    string s;
    cin>>s;
    
    bool flag=true;
    int cnt=0;
    for(int i=0;i<s.length();i++){
        if(i==0){
            if(s[i]!='A') flag=false;
        }else if(i>=2&&i<=s.length()-2){
            if(s[i]=='C') cnt++;
        }else if(s[i]>='A'&&s[i]<='Z') flag=false;
    }
    if(cnt!=1) flag=false;
    if(flag) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

Measured memory_bytes: 3596
N=int(input())
S=input()
l=list(S)
E=[0]*N
W=[0]*N

if S[0]=='E':
    E[0]=1
else:
    W[0]=1

for i in range(1,N):
    if S[i]=='E':
        E[i]=E[i-1]+1
        W[i]=W[i-1]
    else:
        E[i]=E[i-1]
        W[i]=W[i-1]+1
#print(E)
#print(W)
ans=N
ans=min(ans,E[N-1]-E[0])#i=0 is a leader

#i=1 to N-1 is a leader
for i in range(1,N):
    ans=min(ans,E[N-1]-E[i]+W[i-1])
    #ruisekiwa
print(ans)

Measured memory_bytes: 20120
#include <stdio.h>
int main(){
  int a,max,min,s,sum,i;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    max=-1;
    min=1001;
    sum=0;
    for(i=0;i<a;i++){
      scanf("%d",&s);
      sum+=s;
      if(max<s)max=s;
      if(min>s)min=s;
    }
    sum-=max;
    sum-=min;
    sum=sum/(a-2);
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int r;
  cin>>r;
  double ans=3.141*2*r;
  cout<<fixed<<setprecision(5)<<ans<<endl;
}


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

int main()
{
    int N, M,i,hang,c;
    cin >> N;
    cin >> M;
    int A[M];
    c = 0;
    for(i=0;i<M;i++)
    {
        cin >> A[i];
        c = c + A[i];
    }

    hang = N - c;

    if(hang>=0)
    {
        cout << hang << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    

    return 0;
}


Measured memory_bytes: 3668
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int n;
	cin >> n;
	vector<ll>a(n), b(n), d(n, 0);
	int pos = 0;
	bool all = true;
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
		d[i] = a[i] - b[i];
		if (d[i] > 0)pos++;
		if (d[i] != 0)all = false;
	}
	if (all) {
		cout << 0;
		return 0;
	}
	if (pos < 2) {
		ll Aa = 0;
		ll Ab = 0;
		rep(i, 0, n) {
			if (d[i] > 0)Ab += d[i];
			else if (d[i] <= 0 && a[i] > 0)Aa += a[i];
		}

		cout << Aa + Ab;
	}
	else {
		ll sum = 0;
		ll mi = LLONG_MAX;
		rep(i, 0, n) {
			sum += a[i];
			if (d[i] > 0 && b[i] < mi) {
				mi = b[i];
			}
		}
		sum = sum - mi;
		cout << sum;
	}
	return 0;
}





Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}


//小さい順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//変換(文字から整数)
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}

//要素数
int HM(char a[]){
    int cnt=0;
    while(a[cnt]!=0){
        cnt++;
    }
    return cnt;
}

int main(void){
    int N;
    int sum=0;
    i_cin(N);
    int A[N];
    int B[N-1];
    rept(i,0,N-1){
        i_cin(B[i]);
    }
    A[0]=B[0];
    rept(i,0,N-1){
        A[i+1]=B[i];
        if(A[i]>B[i]){
            A[i]=B[i];
        }
    }
    rept(i,0,N){
        sum+=A[i];
    }
    i_cout(sum);
}

    




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

int main(){
  int N,X;
  cin>>N>>X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin>>m.at(i);
    X-=m.at(i);
  }
  sort(m.begin(),m.end());
  cout<<N+X/m.at(0)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin>>a;
    if(a<=999)
    {
        cout << "ABC"<<endl;
    }
    else{
        cout << "ABD"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
counter = [0]*(10**5)
sum = 0
ans = []
N = int(input())
number = list(int(x) for x in input().split())
for i in number:
    sum += i
    counter[i-1] += 1
Q = int(input())
for i in range(Q):
    B, C = (int(x) for x in input().split())
    # sum計算
    count = counter[B-1]
    sum -= B * count
    sum += C * count
    ans.append(sum)
    # counter処理
    counter[B-1] = 0
    counter[C-1] += count
for i in ans:
    print(i)


Measured memory_bytes: 21660
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n;

ll solve() {
    ll res = 1e18;
    for (ll i = 1; i*i<=n; i++) {
        if (n % i == 0) {
            res = min(res, i + n/i - 2);
        }
    }
    return res;
}

void input() {
    cin >> n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n, k, d; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, 0, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        v[j].k++;
        m++;
    }
    void tsort() {
        vector<int> q(n);
        int i0 = 0, i1 = 0;
        for (int i = 0; i < n; i++) {
            if (v[i].k == 0) q[i1++] = i, v[i].d = 0;
        }
        while (i0 < i1) {
            int i = q[i0++];
            for (int j = v[i].n; j >= 0; j = e[j].n) {
                Edge &o = e[j];
                if (--v[o.i].k == 0) q[i1++] = o.i, v[o.i].d = v[i].d + 1;
            }
        }
        if (i1 < n) {
            cout << -1 << endl;
        } else {
            cout << v[q[i1 - 1]].d + 1 << endl;
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    auto f = [&](int x, int y) {
        if (x < y) swap(x, y);
        return x * (x - 1) / 2 + y;
    };

    Graph g(n * (n - 1) / 2, n * (n - 2));
    for (int i = 0; i < n; i++) {
        int p;
        for (int j = 0; j < n - 1; j++) {
            int a;
            cin >> a;
            a--;

            if (j > 0) {
                g.add_edge(f(i, p), f(i, a));
            }
            p = a;
        }
    }

    g.tsort();

    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;
ll mypow(ll a, ll b) {
  if (b == 0) {
	  return 1;
	}
  if (b % 2 == 1) {
	  return a * mypow(a, b - 1) % mod;
	}
  ll c = mypow(a, b / 2);
  return c * c % mod;
}

ll inv(ll a) {
  return mypow(a, mod - 2);
}

ll comb(ll n, ll a) {
  ll ans = 1;
  REP1(i, a) {
	ans = ans * (n - i + 1) % mod;
	ans = ans * inv(i) % mod;
  }
  return ans;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = (mypow(2, n) + 1) % mod;
  ans = (ans - comb(n, a) + mod - 1) % mod;
  ans = (ans - comb(n, b) + mod - 1) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll c = 0, n = s.size();
  std::vector<ll> num(n+1, 0);
  for(int i=0;i<n;i++){
    if((i==0||s[i-1]=='>')&&s[i]=='<'){
      c = 0;
      while(i+c<n&&s[i+c]=='<'){
        num[i+c+1] = max(num[i+c+1], c+1);
        c++;
      }
    }
    if((i==n-1||s[i+1]=='<')&&s[i]=='>'){
      c = 0;
      while(i-c>=0&&s[i-c]=='>'){
        num[i-c] = max(num[i-c], c+1);
        c++;
      }
    }
  }
  ll ans = 0;
  for(int i=0;i<=n;i++) ans += num[i];
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int n, a, b; scanf("%d%d%d", &n, &a, &b);
	string s; cin >> s;
	int cnt = 0;
	int kaigai = 0;
	rep(i, s.size()) {
		if (s[i] == 'a'&&cnt < a + b) {
			puts("Yes");
			cnt++;
		}
		else if (s[i] == 'b'&&kaigai < b&&cnt < a + b) {
			puts("Yes");
			cnt++;
			kaigai++;
		}
		else puts("No");
	}
}

Measured memory_bytes: 896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, A, B = MAP()
X = LIST()
ans = 0
for i in range(N-1):
	ans += min((X[i+1]-X[i])*A, B)
print(ans)


Measured memory_bytes: 15068
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int INF = 1<<28;

struct Edge {
    int to, cost;
    Edge(int to, int cost) : to(to), cost(cost) {}
};
int N;
vector< vector<Edge> > G;
void calcDist(int v, vector<int>& D) {
    D.clear(); D.resize(N, INF);
    D[v] = 0;
    queue<int> Q;
    Q.push(v);
    while (!Q.empty()) {
        int c = Q.front(); Q.pop();
        for (int i = 0; i < G[c].size(); i++) {
            Edge& e = G[c][i];
            if (D[e.to] > D[c] + e.cost) {
                D[e.to] = D[c] + e.cost;
                Q.push(e.to);
            }
        }
    }
}
// vの最遠点のひとつを返す
int farthest(int v) {
    static vector<int> D; calcDist(v, D);
    int ret = -1, dist = -1;
    for (int i = 0; i < N; i++) {
        if (dist < D[i]) {
            ret = i;
            dist = D[i];
        }
    }
    return ret;
}
void calcHeight(vector<int>& H) {
    int x = farthest(0);
    int y = farthest(x);
    vector<int> DX; calcDist(x, DX);
    vector<int> DY; calcDist(y, DY);
    H.clear(); H.resize(N);
    for (int i = 0; i < N; i++) H[i] = max(DX[i], DY[i]);
}
int main() {
    cin >> N;
    G.clear(); G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int s, t, w; cin >> s >> t >> w;
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }
    vector<int> H;
    calcHeight(H);
    for (int i = 0; i < N; i++) cout << H[i] << endl;
    return 0;
}

Measured memory_bytes: 2036
#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <list>
#include <stack>

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef vector<ll> VL;
typedef vector<VL> VVL;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	VP A;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		A.emplace_back(x, i+1);
	}
	sort(A.begin(), A.end());
	ll sol = 0;
	set<int> s = {0, n+1};
	for (auto & pr : A) {
		ll i = pr.first;
		auto it = s.upper_bound(pr.second);
		int r = *it;
		int l = *(--it);
		--r; ++l;
		//cout << i << ' ' << l << ' ' << r << " = ";
		if (l == r) sol += i;
		else if (l+1 == r) sol += i*2LL;
		else {
			ll M = pr.second;
			if (M > l && M < r)
				sol += i * (M-l) * (r-M);
			sol += i * (r-l+1);
		}
		//cout << endl;
		s.insert(pr.second);
	}
	cout << sol;
}

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

using namespace std;

using ll = long long;

ll Solve(ll a, ll b) {
    if (b < a) swap(a, b);
    if (a == b || a + 1 == b) return 2 * a - 2;

    ll c = sqrt(a * b);
    if (a * b <= c * c) --c;

    if (a * b <= c * (c + 1)) return 2 * c - 2;
    else return 2 * c - 1;
}

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

    int q;
    cin >> q;
    while (q--) {
        ll a, b;
        cin >> a >> b;
        cout << Solve(a, b) << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[5];
int main(){
	scanf("%s", s+1);
	for(int i=1;i<=3;i++){
		if(s[i] == '1') s[i] = '9';
		else if(s[i] == '9') s[i] = '1';
	}
	printf("%s", s+1);
}

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

using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define INF 1000000000000000

ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}



int main()
{
    
      string s,t;
     cin>>s>>t;
     ll i,j,ans=100000000000;
     for(i=0;i<s.length()-t.length()+1;i++)
     {
         ll diff=0;
         for(j=0;j<t.length();j++)
         {
             if(s[i+j]!=t[j])diff++;
         }
         ans=min(diff,ans);
     }
    cout<<ans;
}

Measured memory_bytes: 3624
S = input()
kisuu = S[::2]
guusuu = S[1::2]
hantei = []
ans = 0

for i in kisuu:
  if i == 'R' or i == 'U' or i == 'D':
    hantei.append('ok')
  else:
    hantei.append('no')

for j in guusuu:
  if j == 'L' or j == 'U' or j == 'D':
    hantei.append('ok')
  else:
    hantei.append('no')

ans = hantei.count('no')
if ans > 0:
  print('No')
else:
  print('Yes')


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

const int INF = 1e9;

int main() {
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  int l[q],r[q];
  for(int i=0;i<q;i++){
    cin>>l[i]>>r[i];
  }

  int acc[n];
  acc[0]=0;
  int idx=1;
  while(idx<n){
    if(s[idx-1]=='A'&&s[idx]=='C'){
      acc[idx]=acc[idx-1]+1;
    } else {
      acc[idx]=acc[idx-1];
    }
    ++idx;
  }
  for(int i=0;i<q;i++){
    cout<<acc[r[i]-1]-acc[l[i]-1]<<endl;
  }


}

Measured memory_bytes: 2176
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(String).chars().collect::<Vec<_>>();
    println!("{}", if n[1] == n[2] && (n[0] == n[1] || n[2] == n[3]) { "Yes" } else { "No" });
}

Measured memory_bytes: 2112
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int K,X;
    R(K,X);
    FOR(i,X-K+1,X+K-1)W(i);
    return 0;
}


Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, a[10000]; cin >> N;
  int ans = 0;
  REP(i, N) {
    cin >> a[i];
    while(a[i] % 2 == 0){
      ans++; a[i] /= 2;
    }
  }
  cout << ans << endl;

}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> l(n);
  for (int& x : l) {
    cin >> x;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (l[j] == l[i]) {
        continue;
      }
      for (int k = j + 1; k < n; k++) {
        if (l[k] == l[j] || l[k] == l[i]) {
          continue;
        }
        if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
          ans++;
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main()
{
	int L;
	cin >> L;
	if (L >= 3)
		cout << long(pow((double)L / 3, 3));
	else
		cout << double(pow((double)L / 3, 3));
	return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())
int X;

int pow5(int t){
	return t*t*t*t*t;
}

void attempt(int y){
	//A-B=y
	//db(y);
	FOR(b,-120,120){
		if (pow5(b+y)-pow5(b)==X){
			cout<<(b+y)<<" "<<b<<"\n";
			exit(0);
		}
	}
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>X;
	FOR(i,1,X/i){
		attempt(i);
		attempt(X/i);
	}
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

int H, W, A, B;

void solve() {
    REP (h, H) {
        REP (w, W) {
            cout << ((w < A) ^ (h < B)) ? 1 : 0;
        }
        cout << "\n";
    }
}

int main() {
    cin >> H >> W >> A >> B;
    solve();
}

Measured memory_bytes: 1280
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let S = cin.getStr(), K = cin.getInt();
    let A = [];
    for (let n = 0; n < S.length; n++) {
        for (let m = 1; m <= Math.min(K, S.length - n); m++) {
            A.push(S.substr(n, m));
        }
    }
    A.sort();
    let k = 0, n = 0, s = "";
    do {
        if (s == A[n]) continue;
        s = A[n];
        if (++k == K) {
            console.log(s);
            return;
        }
    } while (++n);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8872
#include<bits/stdc++.h>
using namespace std;
int main()
{
	set<string>se;
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
	{
		string k;
		cin>>k;
		se.insert(k);
	}
	cout<<se.size();
	return 0;
}


Measured memory_bytes: 19228
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s = sc.next();
		int[] num = new int[s.length() + 1];
		for (int i = 0; i < s.length() + 1; i++) {
			num[i] = -1;
		}
		int now = 0;
		for (int i = s.length() - 1; i >= 0; i--) {
			if (s.charAt(i) == '>') {
				if (now == 0) {
					num[i + 1] = Math.max(0, num[i + 1]);
					num[i] = Math.max(1, num[i]);
					now = 1;
				} else {
					num[i] = Math.max(num[i + 1] + 1, num[i]);
				}
			} else {
				now = 0;
			}
		}
		now = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '<') {
				if (now == 0) {
					num[i] = Math.max(0, num[i]);
					num[i + 1] = Math.max(1, num[i + 1]);
					now = 1;
				} else {
					num[i + 1] = Math.max(num[i] + 1, num[i + 1]);
				}
			} else {
				now = 0;
			}
		}
		long sum = 0;
		for (int i = 0; i < s.length() + 1; i++) {
			sum += num[i];
		}
		System.out.println(sum);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 26068
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,double> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
string s,t;
int dp[1010][1010];
int main(){
	cin >> s >> t;
	for(int i=0;i<=s.size();i++)dp[i][0]=i;
	for(int i=0;i<=t.size();i++)dp[0][i]=i;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<t.size();j++){
			dp[i+1][j+1]=INF;
			chmin(dp[i+1][j+1],dp[i][j+1]+1);
			chmin(dp[i+1][j+1],dp[i+1][j]+1);
			if(s[i]==t[j])chmin(dp[i+1][j+1],dp[i][j]);
			else chmin(dp[i+1][j+1],dp[i][j]+1);
			//cout << dp[i][j] << ' ';
		}
		//cout << endl;
	}
	cout << dp[s.size()][t.size()] << endl;
	return 0;
}


Measured memory_bytes: 7180
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
int n,a[N];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    int sg=0;
    for(int i=1;i<=n;i++){
        if(a[i+1]<=i){
            int pos=i;
            while(a[pos+1]==i)pos++;
            if((a[i]-i+1)&(pos-i+1)&1)puts("Second");
            else puts("First");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for(int i=0;i<M;i++) cin >> L[i] >> R[i];

  int l, r;
  l = L[0];
  r = R[0];
  for(int i = 1; i < M; i++){
    l = max(l, L[i]);
    r = min(r, R[i]);
  }

  cout << max(0, r - l + 1) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define opt ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long int
#define ull unsigned long long int
#define I int
#define S string
#define D long double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
// I might be a loser, but I have nothing to lose :p
// g++ -std=gnu++14 A.cpp
int main()
{
opt;
S n;
cin>>n;
S ans1(n.size(),n[0]);
S ans2(n.size(),n[0]+1);
if(stoi(ans1)>=stoi(n))
    cout<<ans1;
else
    cout<<ans2;
return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

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

    for (int n = 1; n <= N; n++) {
        // d(n);
        int cnt = 0;
        for (int x = 1; x * x <= n; x++) {
            for (int y = x; y * y <= n; y++) {
                for (int z = y; z * z <= n; z++) {
                    // dd(x, y);
                    // d(z);
                    if (x * x + y * y + z * z + x * y + y * z + z * x == n) {

                        set<int> se;
                        se.insert(x);
                        se.insert(y);
                        se.insert(z);
                        int t = se.size();
                        if (t == 3) cnt += 6;
                        if (t == 2) cnt += 3;
                        if (t == 1) cnt += 1;
                    }
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
// RAKSHIT KADAM
 
//  -- Declare array globally...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000003
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 200006
    #define pi 3.1415926535897932384626433832795
#define ld long doubles
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 200003;
void solve()
{
    string ac = "AC",tle ="TLE",re ="RE",wa="WA";
    map<string,ll>m;
    ll n;cin>>n;
    for(ll i=0;i<n;i++)
    {
        string s;cin>>s;
        m[s]++;
    }
    cout<<ac<<" x "<<m[ac]<<endl;
    cout<<wa<<" x "<<m[wa]<<endl;
    cout<<tle<<" x "<<m[tle]<<endl;
    cout<<re<<" x "<<m[re]<<endl;
    
}
signed main()
{
   Need_for_speed(activated);
 
//satisfy
//    {
//  solve();
//   }
//
    solve();
    return 0;
}


Measured memory_bytes: 3668
import copy

n,l = map(int,input().split())

n_L = list(range(n))
a_L = list(map(lambda x:l+x,n_L))
# out of rangeを防ぐため
a_L.append(0)

allsum = sum(a_L)

result_L = []

diff = abs(allsum-sum(a_L[1:]))

for val in range(n):
    b_L = copy.copy(a_L)
    b_L.pop(val)
    temp_sum = sum(b_L)

    if abs(allsum-temp_sum) <= diff:
        result = temp_sum
    diff = abs(allsum-temp_sum)

print(result)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define op_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i=a;i<b;i++)
using namespace std;
typedef vector<int> vi;

int solve(vi heights,int k){
  int res[heights.size()];
  res[0] = 0;
  res[1] = abs(heights[1] - heights[0]);
  fo(i,2,heights.size()){
    res[i] = INT_MAX;
    int fi = max(i-k,0);
    fo(j,fi,i){
      res[i] = min(res[i], res[j] + abs(heights[i] - heights[j]));
    }
  }
  return res[heights.size()-1];
}


int main(){
  op_io;
  int n,k;
  cin>>n>>k;
  vi heights(n,0);
  fo(i,0,n){
    cin>>heights[i];
  }
  cout<<solve(heights,k)<<endl;
  return 0;
}


Measured memory_bytes: 1536
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}


signed main() {
    int a,b,n;cin >>a>>b>>n;
    if(b==1){
        cout <<0<<endl;
        return 0;
    }else if(n==1){
        cout <<max(a*1/b-a*(1/b),a*0/b-a*(0/b))<<endl;
    }

    if(n>=b){
        cout <<a*(b-1)/b-a*((b-1)/b);
    }else{
        cout <<a*n/b-a*(n/b)<<endl;
    }

}

















Measured memory_bytes: 3620
//بسم الله الرحمن الرحيم
//اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
//Allah in the name of The Most Affectionate, the Merciful
//अल्लाह के नाम से जो दयालु और कृपाशील है
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll
#define pb push_back

#define endl '\n'
#define mod 1000000007

#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define MEMSET(t) memset(t,0,sizeof(t));
#define time clock_t tStart
#define Start clock()
#define Time printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC)

string lcs(string s, string t)
{
    int nS= s.length();
    int nT= t.length();

    int dp[nS+1][nT+1];
    memset(dp,0,sizeof(dp));

    FOR(i,1,nS+1){
        FOR(j,1,nT+1){
            if(s[i-1]==t[j-1]){
                dp[i][j]= 1+dp[i-1][j-1];
            }
            else dp[i][j]= max(dp[i-1][j],dp[i][j-1]);
        }
    }

   /// FOR(i,0,nS+1) { FOR(j,0,nT+1) cout<<dp[i][j]<<" "; cout<<endl; }
    if(dp[nS][nT]==0) return " ";

    string ans;

    int i=nS,j=nT;

  //  cout<<dp[nS][nT]<<endl; // number of lcs
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1]){
            ans+=s[i-1];
            i--; j--;
        }
        else if(dp[i][j-1]>dp[i-1][j]) j--;
        else i--;
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
int main()
{
    fastio;
    int t=1; //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        cout<<lcs(s,t);

    }
    return 0;
}   

Measured memory_bytes: 38808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	int p = n%10;
	if(p==3){ cout<<"bon"; return 0; }
	if(p==0||p==1||p==6||p==8){ cout<<"pon"; return 0; }
	cout<<"hon";
	
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll h, a;
  cin >> h >> a;
  cout << (int)ceil((ld)h / a) << endl;
}


Measured memory_bytes: 256
#19 Print a Chessboard

a=[]
b=[]
while True:
    x,y=map(int,input().split())
    if x==0 and y==0:
        break
    a.append(x)
    b.append(y)

for i in range(len(a)):                         #全体で繰り返す回数
    for i2 in range(a[i]):                      #一個の四角形で繰り返す数
        if i2%2 == 0:
            if b[i]%2 == 0:
                print("#."*(b[i]//2))
            if b[i]%2 != 0:
                print("#."*(b[i]//2) + '#')
        if i2%2 != 0:
            if b[i]%2 == 0:
                print(".#"*(b[i]//2))
            if b[i]%2 != 0:
                print(".#"*(b[i]//2) + '.')
    print('')


Measured memory_bytes: 5628