akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from collections import deque

N, D, A = map(int, input().split())
X = []
for _ in range(N):
    x, h = map(int, input().split())
    X.append((x << 30) + h)
X = sorted(X)[::-1]
Q = deque([])

ans = 0
k = 0
while X:
    if len(Q) == 0 or X[-1] >> 30 <= Q[0][0]:
        xh = X.pop()
        x, h = xh >> 30, xh % (1<<30)
        h = max(h - k * A, 0)
        a = (h + A - 1) // A
        ans += a
        k += a
        deque.append(Q, (x + 2 * D, a))
    else:
        x, a = deque.popleft(Q)
        k -= a

print(ans)

Measured memory_bytes: 62144
#include<iostream>
using namespace std;
int main(){
int m,d;
cin>>m>>d;
int ans=0;
for(int i=1;i<=m;i++){
for(int j=1;j<=d;j++){
int d1,d2;
d1=j/10;
d2=j%10;
if(d1>1&&d2>1){
if(d1*d2==i) ans++;
}
}
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        String P = scanner.next().toLowerCase();
        char p[] = P.toCharArray();
 
        String tmp;
        int ans = 0;
        boolean FLG;
 
        while(!(tmp = scanner.next()).equals("END_OF_TEXT")){
 
            char line[] = tmp.toLowerCase().toCharArray();
 
            if(line.length != p.length)continue;
 
            FLG = true;
            for(int i = 0; i < P.length(); i++){
                if(p[i] != line[i]){
                    FLG = false;
                    break;
                }
            }
            if(FLG)ans++;
        }
 
        System.out.println(ans);
    }
}


Measured memory_bytes: 26120
SENTINEL = 15001
v, e = map(int, input().split())

links = [set() for _ in range(v)]
bests = [[SENTINEL] * v for _ in range(1 << v)]

for _ in range(e):
    s, t, d = map(int, input().split())
    links[s].add((t, d))

bests[0][0] = 0

for visited, best in enumerate(bests):
    for last, cost in enumerate(best):
        for t, d in links[last]:
            bit = 1 << t
            if visited & bit:
                continue
            new_best = bests[visited | bit]
            new_best[t] = min(new_best[t], cost + d)

print(-1 if bests[-1][0] == 15001 else bests[-1][0])

Measured memory_bytes: 21564
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int maxn=1e6+10;
const int mod=1000003;
ll sum[mod];
ll ni[mod];
ll pows(ll a,ll b)
{
    ll re=1;
    while(b)
    {
        if(b&1)
            re=a*re%mod;
         a=a*a%mod;
         b/=2;
    }
    return re;
}
int main()
{
      int q,x,d,n;
      scanf("%d",&q);
       sum[0]=ni[0]=1;
       for(ll  i=1;i<mod;i++)
       {
           sum[i]=sum[i-1]*i%mod;
           ni[i]=pows(sum[i],mod-2);
       }
       while(q--)
       {
       scanf("%d%d%d",&x,&d,&n);
        if(d==0)
            printf("%lld\n",pows(x,n)%mod);
        else
        {
                 ll xx=x*pows(d,mod-2)%mod;
                if(xx+n-1>=mod) printf("0\n");
                else
                printf("%lld\n",(sum[xx+n-1]*ni[xx-1]%mod*(pows(d,n))%mod)%mod);

        }

       }

    return 0;
}



Measured memory_bytes: 16512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


signed main() {
	int N;
	cin >> N;
	if (N == 25) {
		cout << "Christmas\n";
	}
	if (N == 24) {
		cout << "Christmas Eve\n";
	}
	if (N == 23) {
		cout << "Christmas Eve Eve\n";
	}
	if (N == 22) {
		cout << "Christmas Eve Eve Eve\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >> s;
		int n = 0;
		for(char x:s)n+=x-'0';
		cout<<(n%9==0?"Yes":"No");
	}
	return 0;
}

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

int64_t modSum(int N) {
    int64_t sum = (int64_t)(N - 1) * N / 2;

    return sum;
}

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

    cout << modSum(N) << endl;

    return 0;
}

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

// global variables
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<ll, int> P;
// sort by P.first (asd)
bool comPair(const P &firstElof, const P &secondElof) {
    return firstElof.first < secondElof.first;
}

// moving 4-direction
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n, m;
    string s;
    vector<int> ans;
    vector<string> blue, red;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        blue.push_back(s);
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> s;
        red.push_back(s);
    }
    for (int i = 0; i < n; i++) {
        int res = 0;
        for (int j = i; j < n; j++) {
            if (blue[i] == blue[j]) res++;
        }
        for (int k = 0; k < m; k++) {
            if (blue[i] == red[k]) res--;
        }
        ans.push_back(res);
    }
    sort(ans.begin(), ans.end(), greater<int>());
    cout << max(0, ans[0]) << endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
num_list = [ int(v) for v in input().split() ]
ans_list = [ 0 ] * n

for i in range(n-1,-1,-1):

    if sum(ans_list[i::i+1]) % 2 == num_list[i]:
        ans_list[i] = 0
    else:
        ans_list[i] = 1

print(sum(ans_list))
for i in range(n):

    if ans_list[i] == 1:
        print(i+1)


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

typedef long long ll;

int N;
char S[200020] = {0};
int sum[100] = {0};
ll ans = 1;

int cha(char c)
{
    return c - 'a';
}

int main()
{
    scanf("%s",S);
    N = strlen(S);
    for(int i = 0; i < N; i++)sum[cha(S[i])]++;
    for(int i = 0; i < N; i++)
    {
        sum[cha(S[i])]--;
        ans += N - i - 1 - sum[cha(S[i])];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char ch[104];
int fc,sf;
int main() 
{
  scanf("%s",ch);
  int len=strlen(ch);
  fc=105;
  sf=0;
  for (int i=0;i<len;i++) if (ch[i]=='F') sf=i;
  for (int i=len-1;i>=0;i--) if (ch[i]=='C') fc=i;
  if (sf>fc) puts("Yes"); else puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int search(vll& a, int K, vector<int>& dp){
  if(dp[K]>=0) return dp[K];
  bool flag1=false;
  bool flag2=true;
  for(ll num : a){
    if(num <= K){
      flag1=true;

      int tmp = search(a, K-num, dp);
      if(tmp%2==0 && tmp>=0){
        flag2 = false;
        return dp[K] = tmp+1;
      }
    }
  }
  if(!flag1){
    return dp[K] = 0;
  }
  if(flag2){
    return dp[K] = 0;
  }
  return dp[K] = -1;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vll a(N);
  rep(i, 0, N){
    cin >> a[i];
  }
  vector<int> dp(K+1, -1);

  if(search(a, K, dp)%2==1) printf("First\n");
  else printf("Second\n");

  return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N, R;
  int res=0;
  cin >> N >> R ;

  res = R;
  if(N<10) res += 100 * (10-N);

  cout << res << endl;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

// int main() {
//   int n;
//   string s;
//   cin >> n >> s;
//   rep(i,s.size()) {
//     int x = s[i] - 'A';
//     x = (x + n) % 26;
//     cout << (char)(x + 'A');
//   }
//   cout << endl;
// }

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (s.size()%2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  rep(i,n/2) {
    if (s[i] != s[n/2+i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

typedef long long ll;

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

  int n, k, h;
  cin >> n >> k;

  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> h;
    if (h >= k){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  string S; cin>>S;
  lint N = stoll(S);
  lint ans = 0x3f3f3f3f;

  while(N >= 100) {
    lint n = N % 1000;
    ans = min(ans, abs(n - 753));
    N /= 10;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,i,a[200010],k=0,b,c;
scanf("%d\n",&n);
for(i=0;i<n;i++){
scanf("%d",&b);
if(b==0){
scanf("%d\n",&c);
a[k]=c;
k++;
}
else if(b==1){
scanf("%d\n",&c);
printf("%d\n",a[c]);
}
else{
k--;
}
}
return 0;
}


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

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

int main(){
  int x;
  int y;
  cin>>x>>y;

  cout<< gcd(x,y)<<endl;

  return 0;
}



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

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int ans;
    if(a == 0){
        ans = 1;
    }else if(b==0){
        ans = 2;
    }else if(c==0){
        ans = 3;
    }else if(d==0){
        ans = 4;
    }else if(e==0){
        ans = 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ


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

    vector<ll> a(n);

    rep(cnt,0,n) {

        cin >> a[cnt];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll x=0;
    rep(cnt, 0, n) {
        if (cnt % 2 == 0) {
            x += a[cnt];
        }
        else {
            x -= a[cnt];
        }

    }

    cout << x << endl;


    return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

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

const int INT_BIG = 1<<28;

int main() {
    string N;
    int K;
    cin >> N >> K;
    int len = N.length();

    vector<vector<vector<int>>> dp(len+1, vector<vector<int>>(2, vector<int>(K + 1, 0)));
    
    dp[0][0][0] = 1;

    rep(n, len) {
        int num = N[n] - '0';
        rep(smaller, 2) {
            rep(k, K+1) {
                rep(x, (smaller ? 10 : num + 1)) {
                    if (k != 3 || x == 0) {
                        dp[n+1][smaller || x < num][(x == 0) ? k : k+1] += dp[n][smaller][k];
                    }
                }
            }
        }
    }
    // cout << dp[2][1][1] << endl;
    cout << dp[len][0][K] + dp[len][1][K] << endl;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

int main(){

	int n, a, b;

	scanf("%d%d%d", &n, &a, &b);
	puts((b - a) % 2 ? "Borys" : "Alice");

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


int main()
{

  vector<int> N = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;

  cin >> K;

  cout << N[K-1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

vector<pair<int,int> > tonari[100000];
int change[200000];
int cost[100000];

int dp[100000];
int solve(int now){
    if(dp[now] != -1) return dp[now];
    int re = -1;
    for(int i=0; i<tonari[now].size(); i++){
        if(cost[now]-1 == cost[tonari[now][i].first]){
            int tmp = min(solve(tonari[now][i].first), change[tonari[now][i].second]);
            re = max(re, tmp);
        }
    }
    return dp[now] = re;
}

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

    int N,M,Q;
    cin >> N >> M >> Q;
    
    for(int i=0; i<M; i++){
        int u,v;
        cin >> u >> v;
        u--; v--;
        tonari[u].push_back(MP(v, i));
        tonari[v].push_back(MP(u, i));
        change[i] = INT_MAX;
    }
    for(int i=0; i<Q; i++){
        int tmp;
        cin >> tmp;
        tmp--;
        change[tmp] = i;
    }

    for(int i=0; i<N; i++) cost[i] = INT_MAX;
    cost[0] = 0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(int i=0; i<tonari[now].size(); i++){
            if(cost[tonari[now][i].first] > cost[now] + 1){
                cost[tonari[now][i].first] = cost[now] + 1;
                que.push(tonari[now][i].first);
            }
        }
    }

    for(int i=0; i<N; i++) dp[i] = -1;
    dp[0] = INT_MAX;
    int ans[200000] = {};
    for(int i=1; i<N; i++){
        //cout << cost[i] << " ";
        int tmp = solve(i);
        //cout << tmp << endl;
        if(tmp != INT_MAX) ans[tmp]++;
    }
    for(int i=1; i<Q; i++) ans[i] += ans[i-1];
    for(int i=0; i<Q; i++) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 16024
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

dp = [[0] * (N + 1) for _ in range(N + 1)]
maxv = 0

for i in range(N - 1, -1, -1):
    for j in range(N - 1, i, -1):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
        maxv = max(maxv, min(dp[i][j], j-i))
print(maxv)


Measured memory_bytes: 229896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  bool poor = false;
  if (a == b && b != c) poor = true;
  if (b == c && c != a) poor = true;
  if (c == a && a != b) poor = true;
  if (poor) yn;
  return 0;
}

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

int main() {
    long long n;
    cin >> n;
    long long t[n];
    for(int i=0;i<n;i++) cin >> t[i];
    if(n==1){
        cout << t[0] << endl;
        return 0;
    }
    long long ans=t[0]/__gcd(t[0],t[1])*t[1];
    for(int i=2;i<n;i++){
        ans=ans/__gcd(ans,t[i])*t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); int k = sc.nextInt();
		String S = sc.next(); List<Integer> group = new ArrayList<Integer>();
		int len = 0; char c = S.charAt(0); int sum = 0; int max = 0; int ML = 2 * k + 1;

		for(int i = 0; i < n; i++) {
			if(i == 0 && c != '1') group.add(0);
			if(c == S.charAt(i)) {
				len++;
			}else {
				group.add(len);
				len = 1;
				c = (c == '0') ? '1' : '0';
			}
			if(i == n - 1) {
				if(c == '1') {
					group.add(len);
				}else {
					group.add(len);
					group.add(0);
				}
			}
		}

		if(group.size() < ML) {
			for(int i : group) max += i;
		}else {
			for(int i = 0; i < ML;  i++) sum += group.get(i);
			max = sum;
			for(int i = 2; i + ML - 1 < group.size(); i += 2) {
				sum = sum + group.get(i + ML -1) + group.get(i + ML -2) - group.get(i-1) - group.get(i-2);
				max = Math.max(sum, max);
			}
		}
		System.out.println(max);

		sc.close();
	}

}

Measured memory_bytes: 25976
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(){

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

    int ans = 0;

    int first = 0, last = 0;

    map<int, int> gates;

    for (int i = 0; i < m; i++) {
        int temp;
        cin >> temp;
        gates[temp] = 1;
    }

    for (int i = x; i <= n; i++){
        if (gates.find(i) != gates.end()){
            first++;
        }
    }

    for (int i = x; i >= 1; i--){
        if (gates.find(i) != gates.end()){
            last++;
        }
    }

    ans = min(first, last);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//O(NlogN + Qlog^2N)の適当解法(クエリ入れ替えなし)
//意味が分からないバグに悩まされる。→セグメントツリーの子はind*2 + 1とind*2 + 2。間違えてたのに気づかなすぎたので、頭ない。
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;

int d;
int x[252521];
int q;
int l[100000], r[100000], e[100000];

const int INF = 1145141919;

const int depth = 17;		//ここをデバッグ用に6に設定していて、3WA出すなんて、あほすぎる。
class Segtree {
public:
	vector<int> data[1<<(depth+1)];
	
	void ini(int index = 0, int a = 0, int b = (1<<(depth)) - 1) {
		//[a, b]の昇順ソート列をdata[index]に入れる。
		for(int i = a; i <= b; i++ )
			data[index].push_back(x[i]);
		sort(data[index].begin(), data[index].end() );
		if ( b - a > 0 ) {
			ini(index*2 + 1, a, a + (b-a-1)/2);
			ini(index*2 + 2, a + (b-a+1)/2, b);
		}
	}
	
	//[l, r]にv以下の要素がいくつあるか。
	int count(int l, int r, int v, int index = 0, int a = 0, int b = (1<<(depth)) - 1) {
		if ( a > r || b < l || data[index].size() == 0 ) return 0;
		
		if ( l <= a && b <= r ) {			
			//[a, b]の昇順ソート列の中で、v(以下の要素のうち最大の要素)は何番目にある？
			//最初を0番とする。
			int st = -1, ed = data[index].size() - 1, medi;
			while( st <= ed ) {
				medi = (st + ed)/2;
				if ( data[index][medi] > v )
					ed = medi-1;
				else {
					if ( medi+1 == data[index].size() || data[index][medi+1] > v )
						break;
					st = medi+1;
				}
			}
			//Index + 1を返す
			return medi + 1;
		}
		int cnt1 = count(l, r, v, index*2 + 1, a, a + (b-a-1)/2);
		int cnt2 = count(l, r, v, index*2 + 2, a + (b-a+1)/2, b);
		return cnt1 + cnt2;
	}
}seg;

signed main() {
	int i, j;
	cin >> d;
	for( i = 0; i < d; i++ )
		cin >> x[i];
	for( i = d; i < 252521; i++ )
		x[i] = INF;
	
	seg.ini();
	
	cin >> q;
	for( i = 0; i < q; i++ ) {
		cin >> l[i] >> r[i] >> e[i];
		l[i]--; r[i]--;
		int a = max(x[l[i]], x[r[i]]) + e[i];
		int b = min(x[l[i]], x[r[i]]) - e[i];
		
		int cnt1 = seg.count(l[i], r[i], a);
		int cnt2 = seg.count(l[i], r[i], b-1);
		
		int ans = r[i] - l[i] + 1 - (cnt1 - cnt2);
		cout << ans << endl;
	}
	return 0;
}

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

const static ll MOD = (1e+9)+7;

int main(){
    int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
    rep(i,ty-sy)cout<<'U';
    rep(i,tx-sx)cout<<'R';
    rep(i,ty-sy)cout<<'D';
    rep(i,tx-sx)cout<<'L';
    cout<<'L';
    rep(i,ty-sy+1)cout<<'U';
    rep(i,tx-sx+1)cout<<'R';
    cout<<'D';
    cout<<'R';
    rep(i,ty-sy+1)cout<<'D';
    rep(i,tx-sx+1)cout<<'L';
    cout<<'U'<<endl;
    return 0;
}

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

int main() {
  vector<int> a(3);
  for(int i = 0; i < 3; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  cout << a.at(2) - a.at(0) << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$n);
$count=0;
$sum_divi=0;
while($n>1){
  $n = (int)($n/2);
  $sum_divi+=pow(2,$count);
  //echo $count."\n";
  $count++;
}
//echo $n."\n";

$sum_divi+=pow(2,$count);

echo $sum_divi;



Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int n,m;
bool cmp(string a,string b){
	reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    int ans=a<b;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    return ans;
}
string a[10212];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
		cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
    	cout<<a[i];
    }
    return 0;
}

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K = map(int, readline().split())
V = list(map(int, readline().split()))

answer = 0

for i in range(min(N, K)+1):
  for j in range(i+1):
    U = V[:j]+V[N-(i-j):]
    U.sort()
    rid = K - i
    for k in range(len(U)):
      if rid == 0:
        break
      if U[k] < 0:
        rid -= 1
        U[k] = 0
      else:
        break
    answer = max(sum(U), answer)   
print(answer)

Measured memory_bytes: 41304
#include <bits/stdc++.h>
    using namespace std;
    #define   nl   <<'\n'
    #define   pi   acos(-1.0);
    #define   ll   long long
    #define   pb   push_back
    #define   eb   emplace_back
    #define   tc   int t; cin>>t; while(t--)
    #define   fio  ios_base::sync_with_stdio(0); cin.tie(0)

    int main()
    {
        fio;
        int n;
        cin>>n;
        ll a=1,b=1,c=1;
        for(int i=0; i<n; i++)
        {
            a*=10;
            a%=1000000007;
            b*=9;
            b%=1000000007;
            c*=8;
            c%=1000000007;
        }
        //cout<<a nl<<b nl<<c nl;
        a=(((a-2*b+c)%1000000007)+1000000007)%1000000007;
        cout<<a nl;
    }  

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

#define N 100005
#define lgN 18
#define LL long long int
const int MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	LL a, b, k, ans = 1, x, got;
	cin >> k >> a >> b;

	if (b-a <= 2) {
		cout << 1 + k << '\n';
		return 0;
	}
	ans = 1 + k;
	got = 1;
	if (a-1 <= k) {
		k -= (a-1);
		got += a-1;
	} else {
		cout << ans << '\n';
		return 0;
	}
	got += (k/2) * (b - a);
	k = (k & 1);
	got += k;
	ans = max(ans, got);
	cout << ans << '\n';

	return 0;
}


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

int main(){
  int a,b,c; cin >>a >>b; bool q=0;
  for(int i=1; i<2000; i++)
  {
    if(floor(i*0.08)==a && floor(i*0.1)==b)
    {c=i; q=1; break;}
  }

  if(q) cout <<c;
  else cout <<"-1";

return 0;
}

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

typedef pair<int, int> Pii;

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



signed main(){

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A * N, B);
    
    return 0;
}


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

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
//#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g;
int n, m, k;
int a[20][20], pr[N], d[N];
string ss;

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	for (int mask = 0; mask < (1 << n); mask++){
		vector <int> v;
		for (int i = 0; i < n; i++){
			if (mask >> i & 1){
				v.pb(i);
			}
		}
		int sum = 0;
		for (int i = 0; i < v.size(); i++){
			for (int j = i + 1; j < v.size(); j++){
				sum += a[v[i]][v[j]];
			}
		}
		pr[mask] = sum;
	}
	for (int mask = 0; mask < (1 << n); mask++){
		d[mask] = pr[mask];
		for (int s = mask; s; s = (s - 1) & mask){
			d[mask] = max(d[mask], d[mask ^ s] + pr[s]);
		}
	}
	cout << d[(1 << n) - 1];
	return 0;
}












Measured memory_bytes: 2816
n, x, y = map(int, input().split())

l = [0]*(n-1)

for i in range(n):
    for j in range(i+1, n):
        dis = min(j-i, abs(j-y+1)+abs(i-x+1)+1)
        l[dis-1] += 1

for i in l:
    print(i)

Measured memory_bytes: 9280
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;





int main(){
    vector<ll> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    ll ans=abs(a[0]-a[1])+abs(a[1]-a[2]);
    ans=min(ans,abs(a[0]-a[2])+abs(a[1]-a[2]));
    ans=min(ans,abs(a[0]-a[2])+abs(a[1]-a[0]));
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char S[200001], T[200001];
	scanf("%s", S);
	scanf("%s", T);
	
	int i, count = 0;
	for (i = 0; S[i] != 0; i++) if (S[i] != T[i]) count++;
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2104
package main

import "fmt"

func main() {
	var n, x int
	ans := make([]int, 0)
	for {
		fmt.Scan(&n, &x)
		if n == 0 && x == 0 {
			break
		}
		cnt := 0
		for i := 1; i <= n; i++ {
			for j := i + 1; j <= n; j++ {
				for k := j + 1; k <= n; k++ {
					if i+j+k == x {
						cnt++
					}
				}
			}
		}
		ans = append(ans, cnt)
	}
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}



Measured memory_bytes: 1128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: f64,
        k: f64,
    }
    println!("{}", n.log(k).floor() + 1.0);
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define eb emplace_back

void fastio()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}

void solve()
{

  unordered_map<string,int> m;
  int n;cin>>n;
  string s;
  while(n--)
  {
  	cin>>s;
  	m[s]++;
  }
  cout<<"AC x "<<m["AC"]<<"\n";
  cout<<"WA x "<<m["WA"]<<"\n";
  cout<<"TLE x "<<m["TLE"]<<"\n";
  cout<<"RE x "<<m["RE"]<<"\n";
}

int32_t main()
{
    // fastio();
    // int t;cin>>t;
    // while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y,z;
  Point(double x=0,double y=0,double z=0):x(x),y(y),z(z){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y,z+p.z);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y,z-p.z);}
  Point operator*(double k){ return Point(x*k,y*k,z*k);}
  Point operator/(double k){ return Point(x/k,y/k,z/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : (y!=p.y ? y<p.y : z<p.z));}
  bool operator==(Point p)const{ 
    return (fabs(x-p.x)<eps && fabs(y-p.y)<eps &&  fabs(z-p.z)<eps);}
  
  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y+z*z);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

class sphere{
public:
  Point c;
  double r;
  sphere(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y+a.z*a.z);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y+a.z*b.z);}
Vector cross(Vector a,Vector b){ 
  Vector res;
  res.x=(a.y*b.z)-(a.z*b.y);
  res.y=(a.z*b.x)-(a.x*b.z);
  res.z=(a.x*b.y)-(a.y*b.x);
  return res;
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}

int main()
{
  int n,q;
  double a,b,c,x,y,z,r,m;
  vector<pair<sphere,long long> > vs;

  cin>>n>>q;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c>>r>>m;
    vs.push_back(mp(sphere(Point(a,b,c),r),m));
  }

  for(int i=0;i<q;i++){
    cin>>a>>b>>c>>x>>y>>z;
    Segment A(Point(a,b,c),Point(x,y,z));
    long long ans=0;
    for(int j=0;j<n;j++){
      // printf("%.10f %.10f\n",getDistanceSP(A,vs[j].f.c),vs[j].f.r);
      if((getDistanceSP(A,vs[j].f.c)-vs[j].f.r)<eps)ans+=vs[j].s;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int i,j;
string s;
main(){
  cin>>s;
  int len=s.size();
  for(i=0;i<len;i++){
    if(s[i]=='A'){
      for(j=len;j>0;j--){
        if(s[j]=='Z'){
          cout<<j-i+1<<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 640
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

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

    ll X, Y; cin >> X >> Y;
 
    string ans = abs(X - Y) <= 1 ? "Brown" : "Alice";
 
    cout << ans << endl;

    return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  ll s[n],t[m];
  for(int i=0;i<n;i++) cin>>s[i];
  for(int i=0;i<m;i++) cin>>t[i];
  ll dp[3000][3000];
  memset(dp,0,sizeof dp);
  dp[0][0]=1;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(i<n && j<m && s[i]==t[j]) dp[i+1][j+1]+=dp[i][j];
      dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MAX;
      dp[i][j+1]=(dp[i][j+1]+dp[i][j])%MAX;
      dp[i+1][j+1]=(dp[i+1][j+1]-dp[i][j])%MAX;
    }
  }
  if(dp[n][m]<0) dp[n][m]+=MAX;
  cout<<dp[n][m];
}

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

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

const int N = 200005;
const ll mod = 998244353;
pair<int, int> xd[N];
int ind[N];
ll dp[N], sdp[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	int x, d;
	for(int i = 0; i < n; i++){
		cin>>x>>d;
		xd[i] = {x, x + d - 1};
	}
	sort(xd, xd + n);
	stack<int> st;
	for(int i = n - 1; i >= 0; i--){
		if(i == n - 1){
			ind[i] = i + 1;
			st.push(i);
		}else{
			ind[i] = i + 1;
			while(!st.empty() && xd[st.top()].first <= xd[i].second){
				ind[i] = ind[st.top()];
				st.pop();
			}
			st.push(i);
		}
	}
	dp[n] = 1;
	sdp[n] = 1;
	for(int i = n - 1; i >= 0; i--){
		dp[i] = sdp[ind[i]];
		sdp[i] = (sdp[i + 1] + dp[i])%mod;
	}
	// for(int i = 0; i < n; i++){
	// 	cout<<ind[i]<<" ";
	// }
	cout<<sdp[0]<<endl;

	return 0;
}

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

 
int main() 
{ 
	/*
	char c = 'A'; 
	//cout << "The ASCII value of " << c << " is " << int(c) + 1; 
	
	int n = 65;
	cout << char(66);
	
	*/
	
	string s,u,t;
	cin >> s >> u;
	int x,y;
	cin >> x >> y;
	cin >> t;
	if(s==t){
		x--;
		}
	
	if(u==t){
		y--;
		}
	cout << x << " " << y;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0; 
} 


Measured memory_bytes: 256
import math
def func(num):
    lists = []
    root = math.floor(math.sqrt(num))
    
    while(num%2==0):
        num = num // 2
        if(num%2!=0):
            lists.append(2)
            
    for j in range(3,root+2,2):
        while(num%j==0):
            num = num //j
            if(num%j!=0):
                lists.append(j)
        if(num==1):
            break

    if(num>2):
        lists.append(num)
    return lists

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    
    lists1 = func(a)
    lists2 = func(b)
    
    ans = set(lists1) & set(lists2)
    print(len(ans)+1)

Measured memory_bytes: 3064
from itertools import accumulate

s = input()
t = input()
q = int(input())
abcd = [tuple(map(int,input().split())) for i in range(q)]

s_number = [2 if ab == 'B' else 1 for ab in s]
t_number = [2 if ab == 'B' else 1 for ab in t]

s_sum = [0] + s_number
s_sum = list(accumulate(s_sum))

t_sum = [0] + t_number
t_sum = list(accumulate(t_sum))

for a,b,c,d in abcd:

    s_i = s_sum[b]-s_sum[a-1]
    t_i = t_sum[d]-t_sum[c-1]

    if s_i%3 == t_i%3:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 35648
N,A,B,C = map(int,input().split())
C = {"A":A,"B":B,"C":C}
S = [input().strip() for _ in range(N)]
D = []
flag = 0
for i in range(N):
    a,b = S[i][0],S[i][1]
    if C[a]>C[b]:
        C[a] -= 1
        C[b] += 1
        D.append(b)
    elif C[b]>C[a]:
        C[b] -= 1
        C[a] += 1
        D.append(a)
    else:
        if C[a]>1:
            C[a] -= 1
            C[b] += 1
            D.append(b)
        elif C[a]==1:
            if i==N-1:
                D.append(b)
            elif S[i]==S[i+1]:
                C[a] -= 1
                C[b] += 1
                D.append(b)
            else:
                if a in S[i+1]:
                    C[a] += 1
                    C[b] -= 1
                    D.append(a)
                else:
                    C[a] -= 1
                    C[b] += 1
                    D.append(b)
        else:
            flag = 1
            break
    if C["A"]<0 or C["B"]<0 or C["C"]<0:
        flag = 1
        break
if flag==1:
    print("No")
else:
    print("Yes")
    for i in range(N):
        print(D[i])

Measured memory_bytes: 92228
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut h:usize = read!();
    let mut a:usize = 1;
    for i in 0..10000 {
        a*=2;
        if h<a {
            println!("{}",a-1);
            exit(0);
        }
    }
}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int a,b,c,d; cin >> a >> b >> c >> d;
		if(a&&b&&c&&d){
			int m=c*b-a;
			if(m<=0){
				cout << 0 << endl;
			}
			else{
				cout << (m+d-1)/d << endl;
			}
		}
		else break;
	}

}


Measured memory_bytes: 3136
n, m = map(int, input().split())
ds = []
for _ in range(n):
    a, b = map(int, input().split())
    ds.append((a, b))

ds.sort(key=lambda d: d[0])

cost = 0
for d in ds:
    if d[1] >= m:
        cost += m * d[0]
        break

    cost += d[0] * d[1]
    m -= d[1]

print(cost)

Measured memory_bytes: 18164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint& operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<modint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    modint operator()(int n, int k) {
        if (n < k || k < 0) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    modint h(int n, int k) {
        n += k - 1;
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2002002);

int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    ll n = h * w;
    modint ans = 0;
    for (ll c = 1; c <= h; c++) {
        ans += comb(n - 2, k - 2) * (h - c) * w * w * c;
    }
    for (ll c = 1; c <= w; c++) {
        ans += comb(n - 2, k - 2) * (w - c) * h * h * c;
    }
    cout << ans.value() << endl;
}


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

int main(){
    string g;
    int y, m, d;
    while(cin >> g, g != "#"){
        cin >> y >> m >> d;
        if(y>31 || (y==31 && m>=5))   g = "?", y -= 30;
        cout << g << " " << y << " " << m << " " << d << endl;
    }
    return 0;
}


Measured memory_bytes: 3064