akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, w, h;
vector<int> xIndex[100010];
vector<int> yIndex[100010];
int xs[100010];
int ys[100010];
bool visit[100010];

int main() {
  while (scanf("%d %d %d", &n, &w, &h) > 0) {
    MEMSET(visit, false);
    REP(i, 100010) { xIndex[i].clear(); yIndex[i].clear(); }
    int edge = 0;
    int ans = n - 2;
    REP(i, n) {
      int x, y;
      scanf("%d %d", &x, &y);
      if (x == 1 || x == w || y == 1 || y == h) { edge = 1; }
      x--; y--;
      xs[i] = x; ys[i] = y;
      xIndex[x].push_back(i);
      yIndex[y].push_back(i);
    }
    REP(i, n) {
      if (visit[i]) { continue; }
      visit[i] = true;
      ans++;
      queue<int> que;
      que.push(i);
      while (!que.empty()) {
        int index = que.front();
        que.pop();
        FORIT(it, xIndex[xs[index]]) {
          if (visit[*it]) { continue; }
          visit[*it] = true;
          que.push(*it);
        }
        FORIT(it, yIndex[ys[index]]) {
          if (visit[*it]) { continue; }
          visit[*it] = true;
          que.push(*it);
        }
      }
    }
    if (ans != n - 1 && !edge) { ans++; }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w,cnt=0;
	cin>>h>>w;
	char c;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c;
			if(c=='#'){
				cnt++;
			}
		}
	}
	if(h+w-1==cnt){
		cout<<"Possible";
	}else{
		cout<<"Impossible";
	}
	return 0;
}

Measured memory_bytes: 256
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	int k;
	cin >> a >> b >> c >> k;
	int cmax = 0;
	rep(i, k) {
		if (a < c && b < c)c *= 2;
		else if (a < b && c < b)b *= 2;
		else c *= 2;
	}
	cout << a + b + c << rt;
	please AC;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, X, T;

int main() {
  std::cin >> N >> X >> T;

  std::cout << (N+X-1)/X*T << endl;

  return 0;
}

Measured memory_bytes: 3628
n = int(input())
A = list(map(int,input().split()))
lis = [0 for _ in range(10**5 + 1)]
S = sum(A)
for a in A:
    lis[a] += 1
q = int(input())
for _ in range(q):
    b,c = map(int,input().split())
    S += (c-b)*lis[b]
    if not lis[b] == 0:
        temp = lis[b]
        lis[b] = 0
        lis[c] += temp
    print(S)

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

int  main()
{
	string s; cin >> s;
	rep(i, s.size())
	{
		cout << "x";
	}
	cout << endl;
	return (0);
}

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

using namespace std;

int N;

long long int A[200005];

vector<long long int > V;

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
	}

	sort(V.rbegin(), V.rend());

	long long int ans = 0;

	int cnt = 0;

	if (N == 2) {
		cout << V[0] << endl; return 0;
	}

	ans += V[0]; cnt++;

	for (int i = 1; i < N; i++) {

		ans += V[i]; cnt++; if (cnt >= N - 1) { break; }
		ans += V[i]; cnt++; if (cnt >= N - 1) { break; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6600
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;

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

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i %3 == 0) continue;
    if (i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    
    //setを使った解
    set<int> values;
    for(int i=0; i<n; i++){
        values.insert(d[i]);
        //setは重複を許さない順序付き集合
        //insert時に重複データを自動で削除してくれる
    }
    cout << values.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
           int i,j,b,c=0,x,y,m=0,n,k,p,h=0,t1,d;
      string a[100],s[100];
      int g[100];
      cin>>n;
      for(i=0;i<n;i++)
      {
          cin>>a[i];
      }
      cin>>p;
      for(i=0;i<p;i++)
      {
          cin>>s[i];
      }
       for(i=0;i<n;i++)
      {
          if(a[i]!="0")
          {
              m = 1;
          for(j=i+1;j<n;j++)
          {
              if(a[i]==a[j])
              {
                 m++;
                 a[j]='0';
              }
          }
          }
          for(k=0;k<p;k++)
          {
              if(a[i]!="0")
              {
                  if(a[i]==s[k])
                  {
                     h++;
                  }
              }
          }
          g[c] = m-h;
          c++;
          m = 0;
          h = 0;
      }
      d = c;
       sort(g,g+d);
       if(g[d-1]<=0)
       {
           cout<<"0"<<endl;
       }
       else
       cout<<g[d-1]<<endl;


      return 0;
      }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))

const int N=22,Mod=1e9+7;

int n,m,k,nxt[N][N],dp[N][1<<20],Ml[N];

void Init() {
	int a,b,c;
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=m;++i)
		for (int j=1;j<=n;++j) nxt[i][j]=-1;
	for (int i=1;i<=k;++i) {
		scanf("%d%d%d",&a,&b,&c);
		nxt[a][b]=c;
	}
}

void Add(int &a,int b) {
	a+=b;
	if (a>=Mod) a-=Mod;
}

void Solve() { 
	int Max=1<<n;
	Ml[n]=Max-1; for (int i=n-1;i>=0;--i) Ml[i]=Ml[i+1]^(1<<i);
	dp[1][0]=1;
	for (int i=1;i<=m;++i) {
		for (int j=1;j<n;++j) 
			for (int s=0;s<Max;++s) if (dp[j][s]) {
				if (nxt[i][j]!=1 && ((s>>(j-1))&1)==0) Add(dp[j+1][s],dp[j][s]);
				if (nxt[i][j]!=0) {
					if (((s>>(j-1))&1)==0) Add(dp[j+1][(s-(lowbit(s>>(j-1))<<(j-1)))|(1<<(j-1))],dp[j][s]);
					else Add(dp[j+1][s],dp[j][s]);
				}
			}
		for (int s=0;s<Max;++s) dp[1][s]=dp[n][s];
		for (int j=2;j<=n;++j)
			for (int s=0;s<Max;++s) dp[j][s]=0;
	}
	int ans=0; for (int s=0;s<Max;++s) Add(ans,dp[1][s]);
	printf("%d\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 84224
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		if(S.equals("SUN")){
			System.out.println(7);
		}
		else if(S.equals("MON")){
			System.out.println(6);
		}
		else if(S.equals("TUE")){
			System.out.println(5);
		}
		else if(S.equals("WED")){
			System.out.println(4);
		}
		else if(S.equals("THU")){
			System.out.println(3);
		}
		else if(S.equals("FRI")){
			System.out.println(2);
		}
		else{
			System.out.println(1);
		}
		stdIn.close();
	}
}


Measured memory_bytes: 35244
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

ll a,k,s=0;
vec<ll> m;

int go(ll d, int fl){
    vec<ll> mn, pl;
    ll s1=0, s2=0;
    for(ll i : m){
        //if(i%d==0) continue;
        if(i%d<d-(i%d)) mn.pb(i%d), s1+=mn.back();
        else pl.pb(d-(i%d)), s2+=pl.back();
    }
    sort(mn.begin(), mn.end());
    reverse(mn.begin(), mn.end());
    sort(pl.begin(), pl.end());
    reverse(pl.begin(), pl.end());
    ll o = max(s1,s2), c1 = s1, c2 = s2;
    if(s1>s2){
        for(ll i : mn){
            c1-=i;
            c2+=d-i;
            o = min(o, max(c1,c2));
        }
    }
    else{
        for(ll i : pl){
            c2-=i;
            c1+=d-i;
            o = min(o, max(c1,c2));
        }
    }
    return o<=k;
}

int main() {
    fast;
    cin>>a>>k;
    m = vec<ll>(a);
    for(int q=0; q<a; q++) cin>>m[q], s+=m[q];
    ll mx = 1;
    for(int q=1; q*q<=s; q++){
        if(s%q) continue;
        ll c1 = s/q, c2 = q;
        //cout<<c1<<": "<<go(c1, 1)<<endl;
        //cout<<c2<<": "<<go(c2, 1)<<endl;
        if(go(c1, 0)) mx = max(mx, c1);
        if(go(c2, 0)) mx = max(mx, c2);
    }
    cout<<mx;
}

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

int n, A[50];

int solve(int i, int m) {
  if (m == 0) return 1; //もしm == 0ならそれまでに選んだ組み合わせで整数mが作れる
  if (i > n) return 0; //もしm > n ならそれまでに選んだ組み合わせでは整数mが作れない
  //上2つが終了条件

  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%d", &M);
    if ( solve(0, M) ) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}



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

int64_t factorical(int64_t n) {
  int64_t ans = 1;
  while (1 < n) {
    ans *= n;
    n--;
    ans %= 1000000007;
  }
  return ans;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;

  if (n == m) {
    const auto v = factorical(n) * factorical(m) * 2;
    std::cout << v % 1000000007 << std::endl;
  } else if (std::abs(n - m) == 1) {
    const auto v = factorical(n) * factorical(m);
    std::cout << v % 1000000007 << std::endl;
  } else {
    std::cout << 0 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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 FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N;
	cin >> N;
	if(N == 2){
		out(1);
		return 0;
	}
	int ans = 2;
	for(int i = 2;i * i <= N;i++){
		if(N % i)continue;
		int n = N;
		while(n % i == 0)n /= i;
		if(n % i == 1)++ans;
		if(i == N / i)continue;
		n = N;
		while(n % (N / i) == 0)n /= N / i;
		if(n % (N / i) == 1)++ans;
	}
	--N;
	for(int i = 2;i * i <= N;i++){
		if(N % i)continue;
		if((N + 1) % i)++ans;
		if(i == N / i)continue;
		if((N + 1) % (N / i))++ans;
	}
	out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i;
  string r,d;
  cin >> r >> d;
  if(r.at(0) == d.at(0)) i++;
  if(r.at(1) == d.at(1)) i++;
  if(r.at(2) == d.at(2)) i++;
  
  cout << i  << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

typedef vector<bool> vb;

int n;
vi a;
vector<vll> dp;
vector<vb> recorded;

ll rec(int l, int r) {
	if(recorded[l][r]) return dp[l][r];
	recorded[l][r] = true;
	bool first = (n - (r - l + 1)) % 2 == 0;
	if(l == r && first) return dp[l][r] = a[l];
	else if(l == r && !first) return dp[l][r] = -a[l];
	else if(first) return dp[l][r] = max(rec(l + 1, r) + a[l], rec(l, r - 1) + a[r]);
	else return dp[l][r] = min(rec(l + 1, r) - a[l], rec(l, r - 1) - a[r]);
}

int main() {
//	cout << fixed << setprecision(15);
	cin >> n;
	a = vi(n);
	rep(i, n) cin >> a[i];

	dp = vector<vll>(n, vll(n));
	recorded = vector<vb>(n, vb(n));
	cout << rec(0, n - 1) << endl;
}


Measured memory_bytes: 72064
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main() {

    int N,yakusu=1,ans=0;
    cin >> N;
  if(N%2==0)N--;
  for(int k=N; k>=105;k=k-2){
    int no =k;
    yakusu=1;
   for(int i=2;i<=N;i++){
     int cnt=0;
     while(no%i==0){no/=i;cnt++;}
     yakusu*=(cnt+1);
     }
  if(yakusu==8)ans++;}
    cout<<ans<<endl;
}
    



Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    long long int n=0;
    scanf("%lld",&n);

    long long int a[n];
    long long int i=0,j=0;
    long long int mem=0;

    for(i=0;i<n;i++){
        scanf("%lld",&mem);
        a[i]=mem;
    }

    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            if(a[i]>a[j]){
                mem=a[i];
                a[i]=a[j];
                a[j]=mem;
            }
        }
    }

    mem=0;
    for(i=0;i<n;i++){
        mem=mem+a[i];
    }

    printf("%lld %lld %lld\n",a[0],a[n-1],mem);

    return 0;
}

Measured memory_bytes: 680
x = int(input())

for i in range(1000):
    #for j in range(10)
    #print(i ** 5)
    for j in range(1000):
        #print(i ** 5 - j ** 5)
        if i ** 5 - j ** 5 == x:
            print(i, j)
            quit()
        elif i ** 5 - (-j) ** 5 == x:
            print(i, -j)
            quit()
        elif (-i) ** 5 - j ** 5 == x:
            print(-i, j)
            quit()
        elif (-i) ** 5 - (-j) ** 5 == x:
            print(-i, -j)
            quit()

Measured memory_bytes: 65940
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn is_prime(n: usize) -> bool{

    for div in 2..(n as f64).sqrt().ceil() as usize + 1{
        if n%div == 0{
            return false;
        }
    }

    true
}

fn main(){
    let q = read_as_vec::<usize>()[0];
    let n = 100000;
    let mut v = vec![false;n];
    let mut primes = vec![false;n];
    primes[2] = true;
    for i in 1..n/2{
        primes[i*2+1] = is_prime(i*2+1);
        v[i*2+1] = primes[i*2+1] && primes[i+1];

    }
    let mut acc_v = vec![0;n+1];
    let mut acc = 0;
    for i in 1..n{
        if v[i]{
            acc += 1;
        }
        acc_v[i] = acc;
    }

    for _ in 0..q{
        let line = read_as_vec::<usize>();
        let (l, r) = (line[0], line[1]);

        println!("{}", acc_v[r] - acc_v[l-1]);
    }
}


Measured memory_bytes: 4732
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

static const int kBASE = 26;

int main() {
  // vector<int> X(5);
  // int x1, x2, x3, x4, x5;
  long long N;
  cin >> N;

  vector<long long> rank(13);
  rank[0] = 0;
  rank[1] = 1;
  
  // cout << "rank[1]: " << rank[1] << endl;

  for (int i = 2; i <= 12; i++) {
    rank[i] = (long long) rank[i - 1] + pow(kBASE, i-1);
    // cout << "rank[" << i << "]: " << rank[i] << endl;
  }

  long long offset = 0;
  int r = 0;
  for (int i = 1; i <= 12; i++) {
    if (rank[i] > N) {
      r = i - 1;
      offset = N - rank[r];
      break;
    }
  }

  // cout << "rank: " << r << endl;
  // cout << "offset: " << offset << endl;

  vector<long long> oss(r + 1);
  long long remainder = offset;
  for (int i = r; i > 1; i--) {
    oss[i] = remainder / (long long) pow(kBASE, i - 1);
    remainder = remainder % (long long) pow(kBASE, i - 1);
    // cout << "oss[i]: " << i << ": " << oss[i] << endl;
  }

  oss[1] = offset % kBASE;
  // cout << "oss[1]: " << ": " << oss[1] << endl;

  for (int i = r; i >= 1; i--) {
    cout << (char) ('a' + oss[i]);
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 3496
#include <cstdio>
#include <cctype>

    int counter[26] = {};
    char ch;

int main(){
    while (scanf("%c", &ch) != EOF){
        if (!isalpha(ch)) continue;
        if (isupper(ch)) ch = tolower(ch);
        counter[ch - 'a']++;
    }
    for (int i = 0; i < 26; i++){
            printf("%c : %d\n", 'a' + i, counter[i]);
        }
    
    return 0;
}

Measured memory_bytes: 2704
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

struct TNode {
	int num, weight;
	TNode(int a = 0, int b = 0) : num(a), weight(b) {
	}
};

bool operator < (TNode a, TNode b) {
	return a.weight < b.weight;
}

priority_queue<TNode> Q;
vector<TNode> G[NUM];
int x, y, _max, n;
int d[NUM], color[NUM];

void dijkstra(int s, int* max_node) {
	d[s] = 0;
	TNode node(s, 0);
	Q.push(node);
	while (!Q.empty()) {
		node = Q.top();
		Q.pop();
		int u = node.num;
		if (node.weight > _max) {
			_max = node.weight;
			*max_node = u;
		}
		color[u] = 2;
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i].num;
			if (color[v] != 2) {
				if (d[u] + G[u][i].weight > d[v]) {
					d[v] = d[u] + G[u][i].weight;
					node.weight = d[v];
					node.num = v;
					Q.push(node);
					color[v] = 1;
				}
			}
		}
	}
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int s;
	TNode T(0, 0);
	cin >> n;
	for (int i = 1; i < n; i++) {
		scanf("%d%d%d", &s, &T.num, &T.weight);
		G[s].push_back(T);
		swap(s, T.num);
		G[s].push_back(T);
	}
	memset(d, -1, sizeof(d));
	dijkstra(0, &x);
	memset(color, 0, sizeof(color));
	memset(d, -1, sizeof(d));
	_max = 0;
	dijkstra(x, &y);
	cout << _max << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 10180
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<ctime>
#define ll long long
#define pr(a) cerr<<#a<<"="<<a<<endl
#define pri(a,lo) {cerr<<#a<<"={";for (ll ol=0;ol<=lo;ol++)cerr<<a[ol]<<",";cerr<<"}\n";}
using namespace std;
#define N 410000
typedef pair<ll,ll> pa;
#define md 1000000007
vector<pa> b;
vector<ll> e1[N],st,a[N];
ll n,o,p,g[N],fa[N][20],i,d,dep[N],cnt,cnt1[N],cnt0[N],l[N],r[N],ans,size,pw[N];
struct node{ll to,next;} e[N];
ll qpow(ll x,ll y){ll ret=1;for(;y;y>>=1,x=x*x%md)if (y&1) ret=ret*x%md;return ret;}
void add(ll o,ll p){e[++size].to=p,e[size].next=g[o];g[o]=size;}
void dfs(ll x)
{
	a[dep[x]].push_back(x);
	l[x]=++cnt;
	for (i=1;i<=18;i++) fa[x][i]=fa[fa[x][i-1]][i-1];
	for (ll k=g[x];k;k=e[k].next) 
	{
		ll y=e[k].to;
		dep[y]=dep[x]+1;
		fa[y][0]=x;
		dfs(y);
	}
	r[x]=cnt;
}
ll lca(ll x,ll y)
{
	if(dep[x]<dep[y]) swap(x,y);
	ll d=dep[x]-dep[y];
	for (ll i=0;i<=18;i++) if(d&(1ll<<i)) x=fa[x][i];
	if (x==y) return x;
	for (ll i=18;i>=0;i--) if (fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
ll solve(ll x)
{
	//pr(x);
	if (e1[x].empty()) {cnt1[x]=1,cnt0[x]=1;return 1;}
	ll tot=1,tot0=1;
	for (ll k=0;k<(ll)e1[x].size();k++)
	{
		ll y=e1[x][k];
		solve(y);
		tot=tot*((cnt1[y]+cnt0[y])%md)%md;
		tot0=tot0*cnt0[y]%md;
	}
	cnt1[x]=0;
	for (ll k=0;k<(ll)e1[x].size();k++)
	{	
		ll y=e1[x][k];
		cnt1[x]=(cnt1[x]+cnt1[y]*tot0%md*qpow(cnt0[y],md-2)%md)%md;
	}
	cnt0[x]=((tot-cnt1[x])%md+md)%md;
	//cout<<x<<":"<<endl;pr(tot);pr(tot0);pr(cnt1[x]),pr(cnt0[x]);
	return cnt1[x];
}	
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&o),add(o,i);n++;
	pw[0]=1;for (i=1;i<=n;i++) pw[i]=pw[i-1]*2%md;
	dep[0]=1;dfs(0);
	//pri(l,n);pri(r,n);
	for (d=1;d<=n;d++)
	{
		vector<pa>().swap(b);
		if (a[d].size()==0) break;
		for (i=0;i<(ll)a[d].size();i++) b.push_back(make_pair(l[a[d][i]],a[d][i]));
		for (i=0;i<(ll)a[d].size()-1;i++)  
		{
			o=lca(a[d][i],a[d][i+1]);
			b.push_back(make_pair(l[o],o));
		}
		sort(b.begin(),b.end());b.erase(unique(b.begin(),b.end()),b.end());
		//pr(b.size());
		for (i=0;i<b.size();i++) vector<ll>().swap(e1[b[i].second]);//,printf("v:%d %d\n",b[i].second,b[i].first);
		vector<ll>().swap(st);
		for (i=0;i<(ll)b.size();i++)
		{
			while (!st.empty()&&r[st.back()]<l[b[i].second]) st.pop_back();
			if (!st.empty()) e1[st.back()].push_back(b[i].second);//,printf("%d -> %d \n",st.back(),b[i].second);
			st.push_back(b[i].second);
		}
		ans=(ans+pw[n-a[d].size()]*solve(b[0].second)%md)%md;
		//pr(ans);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 92032
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, k, q;
    cin >> n >> k >> q;
    vl a(q);
    for (int i = 0; i < q; ++i) {
        cin >> a[i];
        a[i]--;
    }
    vl ret(n, k - q);
    for (int i = 0; i < q; ++i) {
        ret[a[i]]++;
    }
    for (int i = 0; i < n; ++i) {
        if (ret[i] > 0)
            cout << "Yes"
                 << "\n";
        else
            cout << "No"
                 << "\n";
    }
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, s; cin >> n >> s;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  V<lint> c(n + 1); for (int i = 0; i < n; ++i) c[i + 1] = c[i] + a[i];
  int res = 1e9;
  for (int i = 0; i < n; ++i) {
    auto itr = lower_bound(begin(c), end(c), s + c[i]);
    if (itr != end(c)) res = min<int>(res, distance(next(begin(c), i), itr));
  }
  cout << (res != 1e9 ? res : 0) << '\n';
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a - c) * (b - d) << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
name = [input() for i in range(N)]
m = 0
a = 0
r = 0
c = 0
h = 0
for i in name :
    if i[0] == 'M' :
        m += 1
    elif i[0] == 'A' :
        a += 1
    elif i[0] == 'R' :
        r += 1
    elif i[0] == 'C' :
        c += 1
    elif i[0] == 'H' :
        h += 1

li = [m,a,r,c,h]
ans = 0
for i in range(5) :
    for j in range(i+1,5) :
        for k in range(j+1,5) :
            ans += li[i]*li[j]*li[k]
print(ans)

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

int main() {
  int A, N, x, y;
  cin >> N >> A;
  x=N/500;
  y=N-500*x;
  if(y<=A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	int n, a, b;
	cin >> n >> a >> b;

	a *= n;

	if (a < b) cout << a << endl;
	else cout << b << endl;

	return 0;
}


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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


auto solve() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for (int &i : a) cin >> i;
	for (int &i : b) cin >> i;
	int cnt = 0;
	vector<int> pa(n + 1), pb(m + 1);
	for (int i = 1; i <= n; i++) pa[i] = pa[i - 1] + a[i - 1];
	for (int i = 1; i <= m; i++) pb[i] = pb[i - 1] + b[i - 1];
	int ma = upper_bound(range(pa), k) - pa.begin() - 1;

	for (int i = 0; i <= ma; i++) {
		int remTime = k - pa[i];
		int remCnt = upper_bound(range(pb), remTime) - pb.begin() - 1;
		cnt = max(cnt, i + remCnt);
	}

	return cnt;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 9532
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    char hash[125000000] = {};
    int N, A, flag = 0;
    scanf("%d",&N);
    scanf("%d",&A);
    hash[(A-1)/8] |= 1<<((A-1)%8);
    for(int i = 1; i < N && flag == 0; i++)
    {
        scanf("%d",&A);
        //printf("%x\n",hash[(A-1)/8]);
        if(hash[(A-1)/8] & (1<<((A-1)%8)))
            flag = 1;
        else
            hash[(A-1)/8] |= 1<<((A-1)%8);
    }
    printf("%s\n",(flag==0)? "YES":"NO");
}


Measured memory_bytes: 122368
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   string s;
   cin >>s;
   if((s.at(0)==s.at(1))+(s.at(0)==s.at(2))+(s.at(0)==s.at(3))+(s.at(1)==s.at(2))+(s.at(1)==s.at(3))+(s.at(2)==s.at(3))==2)
    cout<<"Yes"<<endl;
   
   else{
   cout<<"No"<<endl;
   }
   

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int cnt[201010];

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

    for(int i=1;i<201010;i++){
        int pp=__builtin_popcount(i);
        cnt[i]=cnt[i%pp]+1;
    }

    reverse(all(x));
    int cn=0;
    rep(i,n){
        if(x[i]=='1') cn++;
    }

    int tot1=0,p1=1;
    int tot2=0,p2=1;
    rep(i,n){
        if(x[i]=='1'){
            tot1=(tot1+p1)%(cn+1);
            if(2<=cn) tot2=(tot2+p2)%(cn-1);
        }

        p1=(p1*2)%(cn+1);
        if(2<=cn) p2=(p2*2)%(cn-1);
    }

    vector<int> ans;
    p1=1;
    p2=1;
    rep(i,n){
        if(x[i]=='1'){
            if(cn==1){
                ans.push_back(0);
            }
            else{
                int x=(tot2-p2+cn-1)%(cn-1);
                ans.push_back(cnt[x]+1);
            }
        }
        else{
            int x=(tot1+p1+cn+1)%(cn+1);
            ans.push_back(cnt[x]+1);
        }

        p1=(p1*2)%(cn+1);
        if(2<=cn) p2=(p2*2)%(cn-1);
    }

    reverse(all(ans));
    rep(i,n) cout<<ans[i]<<endl;
}


Measured memory_bytes: 5260
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i128> = vec![];
    for _ in 0..n {
        a.push(read());
    }

    for i in 0..a.len() {
        if a[i] == 0 {
            println!("0");
            return;
        }
    }

    let mut ans = 1;
    for i in 0..a.len() {
        let ai = a[i];
        ans *= ai;
        if ans > 1_000_000_000_000_000_000 {
            println!("{}", -1);
            return;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int n;
 
int main()
{
	cin >> n;
 
	if (n / 100 == 7 || (n % 100) / 10 == 7 || n % 10 == 7)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
//#define int long long
typedef long long ll;
#define MAXN 800006
int n , m;
int A[MAXN];
signed main() {
    cin >> n >> m;
    cout << max( 0 , n - 2 * m );
}

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

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

//INSERT ABOVE HERE
signed main(){
  Int n,g;
  cin>>n>>g;
  vector<Int> p(n),c(n);
  for(Int i=0;i<n;i++) cin>>p[i]>>c[i];

  Int ans=0;
  for(Int i=0;i<n;i++) ans+=p[i];

  for(Int b=0;b<(1<<n);b++){
    Int res=0,sum=0;
    for(Int i=0;i<n;i++){
      if(b&(1<<i)){
	res+=p[i];
	sum+=p[i]*100*(i+1)+c[i];
      }
    }
    //cout<<res<<" "<<sum<<endl;
    for(Int i=n-1;i>=0;i--){
      if(b&(1<<i)) continue;
      Int x=p[i];
      chmin(x,(g-sum+100*(i+1)-1)/(100*(i+1)));
      chmax(x,0);
      res+=x;
      sum+=x*100*(i+1);
    }
    //cout<<res<<" "<<sum<<endl;
    if(sum>=g) chmin(ans,res);
  }

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


Measured memory_bytes: 256
/**
*	created: 21.09.2020 15:46:01
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
// #define endl '\n'
#define int long long
#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 rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
#define len(x) ll(x.size())
using ll = long long;
using P = pair<int,int>;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
inline void print(P a) {cout << a.first << " " << a.second << endl;}
template<typename T> T pow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

struct edge {
    int to, id;
    edge(int to_, int id_) : to(to_), id(id_) {}
};

vector<edge> eg[100100];
int ans[100100];

void dfs(int v, int c, int p) {
    int k = 1;
    for (auto e : eg[v]) {
        int u = e.to;
        int i = e.id;
        if (u == p) continue;
        if (k == c) k++;
        ans[i] = k;
        k++;
        dfs(u,ans[i],v);
    }
}

signed main() {
    int n; cin >> n;
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        edge e1(b,i), e2(a,i);
        eg[a].push_back(e1);
        eg[b].push_back(e2);
    }
    dfs(0,-1,-1);
    int num = 0;
    rep(i,n-1) chmax(num,len(eg[i]));
    cout << num << endl;
    rep(i,n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 13960
fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val phrase = Array(n){
        val (s, l, p) = readLine()!!.trim().split(' ').map(String::toInt)
        Phrase(s, l, p)
    }
    val length = Array(394){Phrase(0, 0, 0)}
    length[phrase.first().minLength] = phrase.first()
    for (i in 1 until phrase.size){
        val p = phrase[i]
        for (j in 0 .. 393) {
            if (length[j].minLength > 0 || j == 0){
                var new = p + length[j]
                while(new.minLength <= 393) {
                    val old = length[new.minLength]
                    if (new.maxLength >= old.maxLength && new.point >= old.point) {
                        length[new.minLength] = new
                        break
                    } else if (new.maxLength <= old.maxLength && new.point <= old.point) {
                        break
                    }else {
                        length[new.minLength] = Phrase(new.minLength, Math.min(new.maxLength, old.maxLength), Math.max(new.point, old.point))
                        new = Phrase(Math.min(new.maxLength, old.maxLength) + 1, Math.max(new.maxLength, old.maxLength), Math.min(new.point, old.point))
                    }
                }
            }
        }
    }
    val maxPoint = IntArray(394){-1}
    for (p in length) if (p.point > 0){
        for (i in p.minLength .. Math.min(393, p.maxLength)) maxPoint[i] = Math.max(maxPoint[i], p.point)
    }
    println(IntArray(readLine()!!.trim().toInt()){maxPoint[readLine()!!.trim().toInt()]}.takeUnless{it.contains(-1)}?.joinToString("\n") ?: -1)
}
data class Phrase(val minLength: Int, val maxLength: Int, val point: Int) {
    operator fun plus(that: Phrase): Phrase = Phrase(minLength + that.minLength, maxLength + that.maxLength, point + that.point)
}


Measured memory_bytes: 36424
#include <unistd.h>
#include <stdlib.h>

char    *create_array(char *s, char *new_arr, char *t, int size)
{
	int i;
	int j;

	i = -1;
	while (s[++i])
		new_arr[i] = s[i];
	free(s);
	j = 0;
	while (j < size)
		new_arr[i++] = t[j++];   
	new_arr[i] = 0;
	return (new_arr);
}

char    *get_data(char *s)
{
	int     size;
	int     sum_size;
	char    t[1000];
	char    *new_arr;

	sum_size = 0;
	while ((size = read(0, t, 1000)))
	{
		if (size == -1)
			return (NULL);
		sum_size += size;
		if (!(new_arr = (char*)malloc(sum_size + 1)))
			return (NULL);
		s = create_array(s, new_arr, t, size);
	}
	return (s);
}

void    write_num(int num)
{
	char c;

	if (num < 10)
	{
		c = num + '0';
		write(1, &c, 1);
	}
	else
	{
		write_num(num / 10);
		write_num(num % 10);
	}
}

int     get_num(char *s, int pass_flag)
{
	int i;
	int num;
	int count;
	
    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (s[i++] != 10)
			;
	num = 0;
	while ('0' <= s[i] && s[i] <= '9')
		num = num * 10 + s[i++] - '0';
	return (num);
}

char    *get_string(char *tmp, int pass_flag, int count)
{
	int     i;
	int     j;
	int     k;
	char    *new_arr;

	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	j = 0;
	while (31 < tmp[i + j] && tmp[i + j] < 127)
		j++;
	new_arr = (char*)malloc(j + 1);
	k = -1;
	while (++k < j)
		new_arr[k] = tmp[i + k];
	new_arr[k] = 0;
	return (new_arr);
}

char    **get_strings(char *tmp, int pass_flag, int size)
{
	int     i;
	int     j;
	int     count;
	char    **new_arr;

	new_arr = (char**)malloc(sizeof(char*) * (size + 1));
	count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	j = -1;
	while (++j < size)
		new_arr[j] = get_string(&tmp[i], j, 0);
	new_arr[j] = 0;
	return (new_arr);
}

void    all_free(int blue_num, char **blue, int red_num, char **red)
{
	int i;

	i = -1;
	while (++i < blue_num)
		free(blue[i]);
	i = -1;
	while (++i < red_num)
		free(red[i]);
	free(blue);
	free(red);
}

int     ft_strcmp(char *s1, char *s2)
{
        while (*s1++ == *s2++)
                if (!*s1 && !*s2)
                        return (0);
        return (*(s1 - 1) - *(s2 - 1));
}

void    get_ans(int blue_num, char **blue, int red_num, char **red)
{
	int i;
	int j;
	int max;
	int count;

	max = 0;
	i = -1;
	while (++i < blue_num)
	{
		count = 1;
		j = i;
		while (++j < blue_num)
			if (!(ft_strcmp(blue[i], blue[j])))
				count++;
		j = -1;
		while (++j < red_num)
			if (!(ft_strcmp(blue[i], red[j])))
				count--;
		if (max < count)
			max = count;
	}
	write_num(max);
}

int     main(void)
{
	char    *s;
	int     blue_num;
	char    **blue;
	int     red_num;
	char    **red;

	s = malloc(1);
	s = get_data(s);
	blue_num = get_num(s, 0);
	blue = get_strings(s, 1, blue_num);
	red_num = get_num(s, blue_num + 1);
	red = get_strings(s, blue_num + 2, red_num);
	get_ans(blue_num, blue, red_num, red);
	free(s);
	all_free(blue_num, blue, red_num, red);
	return (0);
}


Measured memory_bytes: 128
import queue
procs = queue.Queue()

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

for i in range(n):
    name,time = input().split()
    procs.put((name,int(time)))
time=0
doneprocs = queue.Queue()
while True:
    if procs.empty():
        break
    temp = procs.get()
    if temp[1] <= q:
        time += temp[1]
        doneprocs.put((temp[0],time))
    else:
        time+= q
        procs.put((temp[0],temp[1]-q))
for i in range(n):
    temp = doneprocs.get()
    print(temp[0],temp[1])

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

int main(int argc, const char * argv[]) {
    int n,sum=1,top=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    top = a[0];
    
    for(int i=1;i<n;i++){
        if(a[i]>=top){
            sum ++;
            top = a[i];
        }
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;
using ll = long long;


int a[55];
ll dp[55][5555];

main(){
    int n , A;
    scanf("%d %d" , &n , &A);

    for(int i = 0 ; i < n ; i ++){
        scanf("%d" , &a[i]);
        a[i] -= A;
    }

    dp[0][2500] = 1;

    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j <= 5000 ; j ++){
            if(j - a[i] >= 0){
                dp[i+1][j] = dp[i][j] + dp[i][j - a[i]];
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    printf("%lld\n" , dp[n][2500] -1);

    return 0;
}


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

using namespace std;

#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(x)  (x).begin(), (x).end()
#define ll long long

int main()
{
	string s;

	cin >> s;

	int ans = 1000;
	rep (i, s.length()-2)
		ans = min(ans, abs(753 - stoi(s.substr(i, 3).c_str())));

	cout << ans << endl;
}



Measured memory_bytes: 256
def insertionSort(A,n,g,cnt):
    for i in range(g,n):
        v=A[i]
        j=i-g
        while j>=0 and A[j]>v:
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v
    return A,cnt

def shellSort(A,n):
    cnt=0
    G=[1]
    h=1
    while h<=n//9:
        h=3*h+1
        G.append(h)
    m=len(G)
    G.reverse()

    for i in range(m):
        A,cnt=insertionSort(A,n,G[i],cnt)
    return A,G,m,cnt

if __name__=="__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(int(input()))
    A,G,m,cnt=shellSort(A,n)
    print(m)
    print(' '.join(map(str,G)))
    print(cnt)
    print('\n'.join(map(str,A)))


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

int main(void){
  int N, A, B;
  cin >> N >> A >> B;
  
  if ( N * A < B ){
    cout << N * A << endl;
  }
  else if( N * A > B ){
    cout << B << endl;
  }
  else{
    cout << N * A << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/* Mere paradesiyaan ki yahi hai nishaani
   Ankhiyaan bilor ki, shishe ki jawaani
*/
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"
#define forn(i,n) for(ll i=0;i<int(n);i++)

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

const ll INF = 1e18;
const ll inf = 1e9;
const ll MOD = 1e9 + 7;
const ll nax = 1000000 + 10;

ll n, a[nax];
ll ans=2;
int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    for(ll i=0;i<n;i++) cin>>a[i];
    reverse(a,a+n);
    ll l=2,r=2;
    forn(i,n)
    {
       // cout<<l<<" "<<r<<endl;
        ll x=(l/a[i])*a[i];
        if(x<l) l=x+a[i];
        if(l>r) return cout<<-1,0;
        r=(r/a[i])*a[i];
        r+=a[i]-1;
    }
    cout<<l<<" "<<r;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+15;
bool seive[A];
void gen()
{
    memset(seive, 1, sizeof seive);
    seive[0] = seive[1] = 0;
    for (ll i = 2; i * i <= 1e5+10; i++)
    {
        if (seive[i])
        {
            for (ll j = i * i; j <= 1e5+10; j += i)
                seive[j] = 0;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    gen();
    for (int i = n; i < A; i++)
    {
        if (seive[i])
            return cout << i, 0;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; ++i) { cin >> s[i]; }

	int cnt1 = 0;
	int cnt2 = 0;
	int cnt3 = 0;
	for (int i = 0; i < N; ++i) {
		int len = s[i].size();
		if ((s[i][0] == 'B') && (s[i][len - 1] == 'A')) { ++cnt1; }
		if ((s[i][0] != 'B') && (s[i][len - 1] == 'A')) { ++cnt2; }
		if ((s[i][0] == 'B') && (s[i][len - 1] != 'A')) { ++cnt3; }
	}

	ll res = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < s[i].size() - 1; ++j) {
			if ((s[i][j] == 'A') && (s[i][j + 1] == 'B')) { ++res; }
		}
	}

	if (cnt1 >= 2) {
		res += (cnt1 - 1);
		if (cnt2 > 0) {
			res += 1;
			cnt2 -= 1;
		}
		if (cnt3 > 0) {
			res += 1;
			cnt3 -= 1;
		}
	} else {
		if (cnt2 < cnt3) { cnt2 += cnt1; }
		else { cnt3 += cnt1; }
	}

	res += min(cnt2, cnt3);

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 768
program main
    use iso_fortran_env
    implicit none
    integer(int64) :: ans
    integer(int64) :: n
    integer(int64) :: k, i

    read *, n
    ans = 0

    do k = 1, n
        i = int( n/k )
        ans = ans + k * (i * (i + 1) / 2)
    enddo

    print *, ans

end program main


Measured memory_bytes: 2828
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;
// #define sz(x) int((x).size())

int main() {
#ifdef LOCAL
    freopen("a.in", "r", stdin);
#endif

    string s;
    cin >> s;
    int c = 0;
    for (char a: s) {
        if (c == 0 && a == 'C') c = 1;
        if (c == 1 && a == 'F') c = 2;
    }
    if (c==2) cout << "Yes" << endl;
    else cout << "No";


#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 764