akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int n;
const int maxn = 2e5 + 5;
char a[maxn];


int ksm(int a, int b, int mod = 1e9 + 7) {
    int res = 1;
    while (b) {
        if (b & 1) {
            res = 1ll * res * a % mod;
        }
        b >>= 1;
        a = 1ll * a * a % mod;
    }
    return res;
}


int main() {
    cin >> n;
    int tot = 0;
    scanf("%s", a + 1);
    
    for (int i = 1; i <= n; ++i) {
        if (a[i] == '1') ++tot;
    }
    int cnt1 = 0, cnt2 = 0, p1 = tot + 1, p2 = tot - 1;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == '1') {
            cnt1 = (cnt1 + ksm(2, n - i, p1)) % p1;
            if (p2 > 0) cnt2 = (cnt2 + ksm(2, n - i, p2)) % p2;
        }
    }

    int t, ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = 1;
        if (a[i] == '0') t = (cnt1 + ksm(2, n - i, p1) + p1) % p1;
        else if (p2 <= 0) {
            puts("0");
            continue;
        }else {
            t = (cnt2 - ksm(2, n - i, p2) + p2) % p2;
        }

        if (!t) cout << ans << endl;
        else {
            while (t) {
                ++ans;
                t = t % __builtin_popcount(t);
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n; cin>>n;
        string s; cin>>s;
        int k; cin>>k;
        char x=s[k-1];
        each(it,s)
        {
                if(it==x)continue;
                it='*';
        }
        cout<<s<<endl;
}

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


void solve(long long N, long long K, std::vector<long long> H){
    sort(H.begin(),H.end());
    long long sum=0;
    for(unsigned int i=0;i+K<H.size();i++)
        sum+=H[i];
    if(sum<=0)
        cout<<0<<endl;
    else
        cout<<sum<<endl;
}

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


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int n;
    cin >> n;

    bool f = false;
    REP(i, 2) {
        f |= n % 10 == 9;
        n /= 10;
    }

    print(f ? "Yes" : "No");
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		double n = Double.parseDouble(str);
		double x = 100000;
		double r = 0;

		for(int i=0; i<n; i++){
			x *= 1.05;
			r = x%1000;
			if(r != 0)
				x = x + 1000 - r;
		}



		System.out.println((int)x);

	}
}

Measured memory_bytes: 16904
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    char C;
    cin >> C;
    cout << (char)(C+1) << endl;
    return 0;
}


Measured memory_bytes: 3644
package main

import "fmt"


func main() {
	var s string
	fmt.Scan(&s)


	var ans int
	switch s {
	case "SUN":
		ans = 7
	case "MON":
		ans = 6
	case "TUE":
		ans = 5
	case "WED":
		ans = 4
	case "THU":
		ans = 3
	case "FRI":
		ans = 2
	case "SAT":
		ans = 1
	}

	fmt.Println(ans)

}


Measured memory_bytes: 512
A, B, C = list(map(int, input().split()))

# x = max(A,B,C) * 3 - (A + B + C)


sum_ = A + B + C
max_sum = max(A,B,C) * 3

ans = 0

if (sum_ % 2) == (max_sum % 2):
    ans = (max_sum - sum_) // 2
else:
    ans = ((max(A,B,C) + 1 ) * 3 - sum_) // 2

print(ans)


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

using namespace std;

int main()
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    printf("%.6lf ",w*h/2);
    int v=0;
    if(2*x==w and 2*y==h)v=1;
    cout<<v<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL n,a,b;
    cin>>n>>a>>b;
    LL ans=1L*mod*mod;
    if((b-a)%2==0){
        ans=(b-a)/2;
    }
    if(1){
        LL ta=a,tb=b;
        ta-=a-1;
        tb-=a-1;
        ans=min(ans,tb/2+a-1);
    }
    if(1){
        LL ta=a,tb=b;
        ta+=n-b;
        tb+=n-b;
        ans=min(ans,n-b+(n-ta+1)/2);
    }
    ans=min(ans,b-1);
    ans=min(ans,n-a);
    cout<<ans;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
abss = [abs(x) for x in a]
ans = sum(abss)
minus = [-x for x in a if x <= 0]

if len(minus) % 2 == 0:
    print(ans)
    exit(0)

ans -= 2 * min(abss)

print(ans)

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

#define NMAX 1000

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int nGems;
int diff[20];

int main()
{
    int aux;
    cin >> nGems;
    for(int i = 0; i < nGems; i++)
        cin >> diff[i];
    for(int i = 0; i < nGems; i++)
    {
        cin >> aux;
        diff[i] -= aux;
    }

    int totalValue = 0;
    for(int i = 0; i < nGems; i++)
        if(diff[i] > 0) totalValue += diff[i];

    cout << totalValue << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
  ll n,m;
  cin>>n>>m;
  vcl h(n+1),p(n+1,1);
  ll a[m][2];
  for(ll i=1;i<=n;i++){
      cin>>h[i];
  }
  rep(i,m)rep(j,2)cin>>a[i][j];
for(ll i=0;i<m;i++){
    if(h[a[i][0]]<h[a[i][1]]) p[a[i][0]]=0;
else if (h[a[i][0]]>h[a[i][1]])p[a[i][1]]=0;
else if((h[a[i][0]]==h[a[i][1]])){
    p[a[i][0]]=0;
    p[a[i][1]]=0;
}
}
ll ans=0;
for(ll i=1;i<=n;i++){
    if(p[i]==1)ans++;}
    cout<<ans<<endl;
}



Measured memory_bytes: 6428
n=input()
l=[1,-1]
l1=[0,"+","-"]
s=""
for i in l:
  for j in l:
    for k in l:
      if int(n[0])+i*int(n[1])+j*int(n[2])+k*int(n[3])==7:
        s=n[0]+l1[i]+n[1]+l1[j]+n[2]+l1[k]+n[3]+"=7"
print(s)

Measured memory_bytes: 3060
N = int(input())
X = []
for i in range(N):
	A = int(input())
	X.append(A)

X = sorted(X)

M = []
m = []
for i in range(N // 2):
	M.append(X[-1 - i])
	m.append(X[i])
M = sorted(M)

if N % 2 == 0:
	n = N
else:
	n = N - 1
s = []
for i in range(n):
	if i % 2 == 0:
		s.append(M[i // 2])
	else:
		s.append(m[i // 2])
ans = 0
for i in range(n - 1):
	ans += abs(s[i + 1] - s[i])
if N % 2 == 1:
	ans += max(abs(X[N // 2] - s[0]), abs(X[N // 2] - s[-1]))
print(ans)

Measured memory_bytes: 9284
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
const ll N = 1000000000;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int> > ar(h), dp(h);
    for (int i = 0; i < h; ++i) {
        dp[i].resize(w, N);
        for (int j = 0; j < w; ++j) {
            char c; cin >> c;
            dp[i][j] = c == '.' ? 0 : 1;
        }
    }

    for (int i = 0; i < h; ++i) {
        ar[i].resize(w, N);
        for (int j=0;j<w;++j) {
            if (i + j == 0) ar[i][j] = dp[i][j];
            else {
                if (i) {
                    int c = dp[i - 1][j] != dp[i][j] && dp[i][j];
                    ar[i][j] = min(ar[i-1][j] + c, ar[i][j]);
                }
                if (j) {
                    int c = dp[i][j - 1] != dp[i][j] && dp[i][j];
                    ar[i][j] = min(ar[i][j-1] + c, ar[i][j]);
                }
            }
        }
    }

    cout << ar[h - 1][w - 1];
    return 0;
}


Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
//#include<map>
//#include<set>
//#include<vector>
//#include<cstring>
//#include<iterator>
//#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    //ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
 //   cout.tie(0);
    int n,d;
    cin>>n>>d;
    int c=0;
    while(n--)
    {
        int x,y;
        cin>>x>>y;

        ll res=pow(x,2)+pow(y,2);
 
         double res2=sqrt(res);

        if(res2<=(double)d)
        {
          
            c++;
        }
     
    }
    cout<<c<<endl;



    return 0;
}


Measured memory_bytes: 3676
N = int(input())
S = input()
cnts = []
for i in range(N-1):
    A = set(S[0:i+1])
    B = set(S[i+1:N])
    cnt = 0
    for a in A:
        if a in B:
            cnt += 1
    cnts.append(cnt)
print(max(cnts))

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<ll, ll> pll;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

pll solveH(int h, int w){
    if(h == 1) return pll(-1, -1);
    int mid = h/2;
    ll mx = max(mid*1ll*w, (h-mid)*1ll*w);
    ll mn = min(mid*1ll*w, (h-mid)*1ll*w);
    return pll(mx, mn);
}

pll solveW(int h, int w){
    if(w == 1) return pll(-1, -1);
    int mid = w/2;
    ll mx = max(mid*1ll*h, (w-mid)*1ll*h);
    ll mn = min(mid*1ll*h, (w-mid)*1ll*h);
    return pll(mx, mn);
}

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    ll ans = 1e18;
    for(int i=1;i<=h-1;i++){
        pll q1 = solveH(h-i, w);
        pll q2 = solveW(h-i, w);
        if(q1.first != -1){
            ll mx = max(i*1ll*w, q1.first);
            ll mn = min(i*1ll*w, q1.second);
            ans = min(ans, mx-mn);
        }
        if(q2.first != -1){
            ll mx = max(i*1ll*w, q2.first);
            ll mn = min(i*1ll*w, q2.second);
            ans = min(ans, mx-mn);   
        }
    }
    for(int i=1;i<=w-1;i++){
        pll q1 = solveH(h, w-i);
        pll q2 = solveW(h, w-i);
        if(q1.first != -1){
            ll mx = max(i*1ll*h, q1.first);
            ll mn = min(i*1ll*h, q1.second);
            ans = min(ans, mx-mn);
        }
        if(q2.first != -1){
            ll mx = max(i*1ll*h, q2.first);
            ll mn = min(i*1ll*h, q2.second);
            ans = min(ans, mx-mn);   
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int n,k,c;cin>>n>>k>>c;
  string s;cin>>s;
  vector<int> left, right;
  rep(i,s.size()){
    if(s[i]=='o'){
        left.push_back(i);
        i += c;
    }
  }
  if(left.size() >= k + 1){
    cout<<endl;
    return 0;
  }

  REP(i,s.size()){
    if(s[i] == 'o'){
        right.push_back(i);
        i -= c;
    }
  }
  reverse(all(right));
  assert(left.size() == right.size());
  rep(i,left.size()){
    if(left[i] == right[i]){
        cout<<left[i]+1<<endl;
    }
  }
}

Measured memory_bytes: 3468
# インプットをリストで用意
abcd = list(map(int, list(input())))

s = ''
# 全体で2*2*2通りある
for i in range(8):
    s = str(abcd[0])    #文字でのストック
    tmp = abcd[0]       #合計値のストック
    for j in range(3):
        # １を左にｊビットずらして、iと論理積を取る
        # つまり、iの左からj番目のビットが0かを調べてる
        if (1 << j) & i == 0:
            s += '+'
            tmp += abcd[j + 1]
        else:
            s += '-'
            tmp -= abcd[j + 1]
        s += str(abcd[j + 1])
    s += '=7'
    if tmp == 7:
        break
print(s)


Measured memory_bytes: 38384
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	while (cin >> n) {
		if (!n)return 0;
		int a[114514]; for (int i = 0; i < n; i++)cin >> a[i];
		string s; cin >> s;
		for (int i = 0; i < s.size(); i++) 
			for (int j = 0; j < a[i%n]; j++)
				if (s[i] == 'A')s[i] = 'z';
				else if (s[i] == 'a')s[i] = 'Z';
				else s[i]--;
		cout << s << endl;
	}
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,gc,mx=0,v[200005];
cin>>n>>k;
cin>>gc;
int ok=0;
mx=gc;
for(int i=2;i<=n;++i){
  int x;
  cin>>x;
  gc=std::__gcd(x,gc);
  mx=max(mx,x);
  if(x==k)ok=1;
  }
if(k%gc==0&&mx>=k)ok=1;
if(!ok) cout<<"IM";
cout<<"POSSIBLE\n";
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define n 10000
#define q 500

int main(){
 
 int i,j,count=0;
  int S[n],T[q];
  int Ain,Bin;
  
  scanf("%d",&Ain);  
  for(i=0;i<Ain;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&Bin);
  for(i=0;i<Bin;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<Bin;i++){
    for(j=0;j<Ain;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI C(N-1), S(N-1), F(N-1);
		REP(i, N-1) cin>>C[i]>>S[i]>>F[i];
		REP(i, N) {
			ll t = 0;
			RANGE(j, i, N-1) {
				maxUpdate(t, S[j]);
				t = (t+F[j]-1)/F[j]*F[j];
				t += C[j];
			}
			cout<<t<<endl;
		}
	}
	
	return 0;
}


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

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
int main() {
  int N;
	cin >> N;
  cout << N * N * N << endl;
  return 0;
}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static final int MAX = 100;
	static final int INF = 1 << 21;
	static final int WHITE = 0;
	static final int GRAY = 1;
	static final int BLACK = 2;
	static int n;
	static int[][]M;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			n = sc.nextInt();
			if(n == 0) break;
			M = new int[n][n];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					M[i][j] = INF;
				}
			}
			int m = sc.nextInt();
			for(int i = 0; i < m; i++) {
				String[] s = sc.next().split(",");
				int a = Integer.parseInt(s[0]);
				int b = Integer.parseInt(s[1]);
				int c = Integer.parseInt(s[2]);
				M[a][b] = c;
				M[b][a] = c;
			}
			int t = prim();
			System.out.println(t / 100 - n + 1);
		}
		sc.close();
	}
	static int prim() {
		int u, minV;
		int[]d = new int[MAX];
		int[]p = new int[MAX];
		int[]color = new int[MAX];
		for(int i = 0; i < n; i++) {
			d[i] = INF;
			p[i] = -1;
			color[i] = WHITE;
		}
		d[0] = 0;
		while(true) {
			minV = INF;
			u = -1;
			for(int i = 0; i < n; i++) {
				if(minV > d[i] && color[i] != BLACK) {
					u = i;
					minV = d[i];
				}
			}
			if(u == -1) {
				break;
			}
			color[u] = BLACK;
			for(int v = 0; v < n; v++) {
				if(color[v] != BLACK && M[u][v] != INF) {
					if(d[v] > M[u][v]) {
						d[v] = M[u][v];
						p[v] = u;
						color[v] = GRAY;
					}
				}
			}
		}
		int sum = 0;
		for(int i = 0; i < n; i++) {
			if(p[i] != -1) {
				sum += M[i][p[i]];
			}
		}
		return sum;
	}
}


Measured memory_bytes: 39944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] P;
        public int[] A, B;
        public void Run()
        {
            N = Input.ReadInt();
            P = Input.ReadIntArray();

            A = new int[N];
            B = new int[N];

            for (int i = 0; i < N; i++)
            {
                A[i] = N * (i + 1);
                B[i] = N * (N - i);
            }

            for (int i = 0; i < N; i++)
            {
                B[P[i] - 1] += i;
            }

            Console.WriteLine(string.Join(" ", A));
            Console.WriteLine(string.Join(" ", B));
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

int n;

int main() {
  cin >> n;
  vector<int> a(3*n);
  rep (i, 3*n) {
    cin >> a[i];
  }
  ll ans = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    ans += a[3*n-i*2-2];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    int l_max=0, r_min=10000000;
    rep(i, m){
        cin >> l[i] >> r[i];
        if(l[i]>l_max) l_max = l[i];
        if(r[i]<r_min) r_min = r[i];
    } 
    int res=0;
    if(r_min >= l_max)
        res = r_min - l_max + 1;
    else
        res = 0;
    

    cout << res << endl;
}

Measured memory_bytes: 3948
#include <cstring>
#include <string>
#include <memory>
#include <iostream>

/**
@note prime number and less than 1,000,000
*/
constexpr int max_size()
{
    return 1000003;
}

constexpr int null_val()
{
    return -1;
}

class dictionary {
public:
    dictionary()
        : _data(std::make_unique<int[]>(max_size()))
    {
        for (int i = 0; i < max_size(); ++i) {
            _data[i] = null_val();
        }
    }

    void insert(const std::string& str) {
        return insert(str2key(str), 0);
        return;
    }

    bool find(const std::string& str) {
        return find(str2key(str), 0);
    }

private:
    int str2int(const char ch) {
        if (ch == 'A') {
            return 1;
        }
        if (ch == 'C') {
            return 2;
        }
        if (ch == 'G') {
            return 3;
        }
        if (ch == 'T') {
            return 4;
        }
        return 0;
    }

    int str2key(const std::string& str)
    {
        int sum = 0;

        for (std::size_t i = 0; i < str.size(); ++i) {
            sum += str2int(str[i]);
            sum *= 5;   //move up;
        }
        
        return sum;
    }

    int base_hash(const int key) const
    {
        return key % max_size();
    }

    int collision_hash(const int key) const
    {
        constexpr int modulo = max_size() + 1;
        return 1 + key % modulo;
    }

    int create_hash(const int key, const int r) const 
    {
        const int base = base_hash(key);
        const int collision = collision_hash(key);
        const int h = (base + r * collision) % max_size();
        return h;
    }

    void insert(const int key, const int r)
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            _data[h] = key;
            return;
        }
        if (_data[h] == key) {
            return;
        }

        return insert(key, r + 1);
    }

    bool find(const int key, const int r) const
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            return false;
        }
        if (_data[h] == key) {
            return true;
        }

        return find(key, r + 1);
    }

    bool is_empty(const int idx) const {
        return _data[idx] == null_val();
    }

private:
    std::unique_ptr<int[]> _data;
};

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

    int n;
    std::cin >> n;
    std::cin.ignore();

    dictionary dict;
    std::string buf;
    std::string ret;
    ret.reserve(4 * max_size());
    for (int i = 0; i < n; ++i) {
        getline(std::cin, buf);
        if (buf.front() == 'i') {
            static const std::size_t size = strlen("insert ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            dict.insert(val);
        }
        else {
            static const std::size_t size = strlen("find ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            ret += dict.find(val) ? "yes\n" : "no\n";
        }
    }

    std::cout << ret;
    return 0;
}

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int main() {
	string A, B, C;

	cin >> A >> B >> C;

	cout << A[0] << B[0] << C[0] << endl;

	return 0;
}


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

int main()
{
    int n;
    double t, a;
    cin >> n >> t >> a;

    int res;
    double diff = 100000.0;
    rep(i, n) {
        double h;
        cin >> h;
        if (diff > abs(a - (t - h * 0.006))) {
            diff = abs(a - (t - h * 0.006));
            res = i;
        }
    }

    cout << res + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void No() { cout << "No" << endl; }
	void Yes() { cout << "Yes" << endl; }
	void Solve() {
		UL N; cin >> N;
		vector<UL> A(N); rep(i, N) cin >> A[i];
		sort(A.begin(), A.end());
		UL lower = A[0], higher = A[N - 1];
		if (higher - lower >= 2) { No(); return; }
		if (lower == higher) {
			if(lower > N / 2 && lower != N - 1) { No(); return; }
			else Yes(); return;
		}
		else {
			UL lowerSz = 0;
			rep(i, N) { if (A[i] == lower) lowerSz++; }
			UL higherSz = N - lowerSz;
			if (higherSz == 1) { No(); return; }
			if (lowerSz + 1 > higher) { No(); return; }
			if (higher > lowerSz + higherSz / 2) { No(); return; }
			else Yes(); return;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

a, b = LI()

a_s = str(a) * b
b_s = str(b) * a
if a_s > b_s:
    print(b_s)
else:
    print(a_s)

Measured memory_bytes: 10896
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> c(8,0);
    int free = 0;

    for(int i = 0; i < N; i++){
        int a;
        cin >> a;

        if(a/400 < 8){
            c[a/400] = 1;
        }else{
            free++;
        }
    }

    int sum = 0;

    for(int i = 0; i < 8; i++){
        sum += c[i];
    }

    if(sum == 0){
        cout << 1 << " ";
    }else{
        cout << sum << " ";
    }

    cout << sum+free << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){

  int a[10000];
  int n;
  int i,j;
  int hit=0,cnt=0;

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

  for(i=0;i<n;i++){
    hit=0;
    for(j=2;j<=sqrt(a[i]);j++){
      if((a[i]%j)==0){
	hit=1;
	break;
      }
    }
    if(hit==0)cnt++;
  }

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

  return 0;
}




Measured memory_bytes: 2084
s = input()
ans = []
count = 1
ans_sum = 0
key = s[0]
def goukei(a):
    if a == 0 or a == -1:
        return 0
    if a == 1:
        return 1
    else:
        return (1+a)/2*a
for i in range(1,len(s)):
    if key == s[i]:
        count += 1
    else:
        ans.append(count)
        count = 1
        key = s[i]

ans.append(count)

if s[0] == "<":
    if len(ans)%2==1:
        ans.append(0)
    for a,b in zip(ans[0::2],ans[1::2]):
        #print("{} {}".format(a,b))
        if a < b:
            ans_sum += goukei(a-1)
            if b == 1:
                ans_sum += 0
            else:
                ans_sum += goukei(b)
        elif b < a:
            ans_sum += goukei(a)
            ans_sum += goukei(b-1)
        else:
            ans_sum += goukei(a)
            ans_sum += goukei(b-1)
        #print(ans_sum)
else:
    ans_sum += goukei(ans[0])
    if len(ans[1:])%2 == 1:
        ans.append(0)
    for a,b in zip(ans[1::2],ans[2::2]):
        if a < b:
            ans_sum += goukei(a-1)
            if b == 1:
                ans_sum += 0
            else:
                ans_sum += goukei(b)
        elif b < a:
            ans_sum += goukei(a)
            ans_sum += goukei(b-1)
        else:
            ans_sum += goukei(a)
            ans_sum += goukei(b-1)

print(int(ans_sum))


Measured memory_bytes: 8348
n,yen=map(int,input().split())
x,y,z=-1,-1,-1
for i in range(n+1):
  for j in range(n+1-i):
    k=n-i-j
    if i*10000+j*5000+k*1000==yen:
      x,y,z=i,j,k
print(x,y,z)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;

map<int,int> mm;
int ans[ms];
int ar[ms];
vector<pair<int,pair<int,int>>> vv;
int bit[ms]={0};


void update(int i,int n,int v)
{
    while(i<=n)
    {
        bit[i]+=v;
        i+=(i&-i);
    }
}

int query(int i)
{
    int r=0;
    while(i>0)
    {
        r+=bit[i];
        i-=(i&-i);
    }
    return r;
}






int main()
{
    idfc;

    int n,q;
    cin>>n>>q;
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];
    int a,b;
    for(i=1;i<=q;i++)
    {
        cin>>a>>b;
        vv.pb({b,{a,i}});
    }

    sort(vv.begin(),vv.end());

    int ind;
    int p=1;
    int j;
    for(i=0;i<q;i++)
    {
        b=vv[i].first;
        a=vv[i].second.first;
        ind=vv[i].second.second;
        while(p<=b)
        {
            if(mm.count(ar[p]))
            {
                update(mm[ar[p]],n,-1);
                mm[ar[p]]=p;
                update(p,n,1);
            }
            else{
                mm[ar[p]]=p;
                update(p,n,1);
            }
            p++;
        }

        ans[ind]=mm.size();
        ans[ind]-=query(a-1);
    }

    for(i=1;i<=q;i++)cout<<ans[i]<<"\n";

    return 0;
}

Measured memory_bytes: 38928
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 

int A[111111] ; 
int tmpA[111111] ; 

int main()
{
    int N ;
    scanf("%d", &N) ; 
    for(int i = 0 ; i != N ; i++)
        scanf("%d", A+i) ; 
    for(int i = 0 ; i != N ; i++)
        tmpA[i] = A[i] ; 
    sort(tmpA, tmpA+N) ; 
    set<int> even ; 
    for(int i = 0 ; i < N ; i += 2)
        even.insert(tmpA[i]) ; 
    int ans = 0 ; 
    for(int i = 0 ; i < N ; i += 2) {
        if(even.find(A[i]) == even.end())
            ans++ ; 
    }
    printf("%d\n", ans) ; 
    return 0 ; 
}



Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if (A==B) printf("%d\n", C);
	else if (A==C) printf("%d\n", B);
	else printf("%d\n", A);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
x,y=zip(*sorted(sorted(map(int,input().split())) for _ in range(n)))
p=max(range(n),key=lambda i:y[i])
r=a=x[-1]
b=d=10**9
for i in range(p):
    if b<=x[i]:
        break
    a=max(a,y[i])
    b=min(b,y[i])
    d=min(d,a-min(b,x[i+1]))
print(min((x[-1]-x[0])*(y[p]-min(y)),(y[p]-x[0])*d))

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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

int n;
int a[100100];
int mn = 10000, mx = 0;

int main() {
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		mn = min(mn, x);
		mx = max(mx, x);
	}	

	cout << mx - mn;

	return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a-2*b <= 0) cout << 0 << endl;
	else cout << a-2*b << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    int A[M];
    for(int i = 0; i < M; i++){
        cin >> A[i];
        N -= A[i];
    }
    N = max(N, -1);
    cout << N;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(a) for(int i=0; i<a; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
bool cmp(int a, int b)
{
	return a > b;
}
vector<edge> V[n + 50];
bool visit[n + 50];
lli arr[n + 50], a, b, c, d;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge one, two;
	one.from = a; one.to = b; one.weight = c;
	two.from = b; two.to = a; two.weight = c;
	V[a].push_back(one);
	V[b].push_back(two);
}


//////////////////////////////////////////


void solve()
{
	cin >> a;
	lli psum[a], table[a + 50];
	loop(a) cin >> arr[i];
	loop(a)
	{
		if(!i) psum[i] = arr[i];
		else   psum[i] = psum[i - 1] + arr[i]; 
	}
	loop(a)
	{
		if(!i) table[i + 1] = i + 1;
		else   table[i + 1] = table[i] + i + 1;
	}
	lli left = 0, ans = 0, temp = 0;
	for(int i=0; i<a; i++)
	{
		lli hoho = temp ^ arr[i];
		while(temp + arr[i] != hoho && left < i)
		{
			temp -= (lli)arr[left++];
			hoho = (lli)temp ^ arr[i];
		}
		ans += (lli)i - left + 1;
		temp += (lli)arr[i];
//		printf("%d %d\n",ans, left);
	}
	printf("%lld",ans);
}
int main()
{
	int times = 1;
//	cin << times;
	loop(times)
	{
		solve();
		printf("\n");
	}
	return 0;
}


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

using namespace std;

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

    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i];
    }

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

    for (int i = 0; i < N; ++i) {
        for (int j = w[i]; j <= W; ++j) {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }

    cout << dp[W] << '\n';

    return 0;
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
    cin >> n;
    vector<lli> a(n), b(n), c(n), d(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n){
        if(a[i] > b[i]) d[i]+=a[i]-b[i];
        else if(a[i] < b[i]){
            if(a[i]%2 != b[i]%2){
                d[i]++;
            }
            c[i]+=((b[i]+d[i])-a[i])/2;
        }
    }
    lli sc, sd;
    sc = sd = 0;
    rep(i, n){
        sc+=c[i], sd+=d[i];
    }
    if(sc >= sd) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3956
#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>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> x(m);
    for(auto &I:x){cin>>I;}
    sort(x.begin(),x.end());
    vector<ll> F(m-1);
    ll sum=0;
    for(int i=1;i<m;i++){
        F[i-1]=x[i]-x[i-1];
        sum+=F[i-1];
    }
    sort(F.begin(),F.end());
    for(ll i=0;i<n-1 && !F.empty();i++){sum-=F.back(); F.pop_back();}
    cout<<sum<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

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

const int maxn=5e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

char s[maxn];

ll n;
int check(ll num){
	ll tmp=n;
	while(tmp%num==0) tmp/=num;
	if(tmp%num==1){
		return 1;
	}
	else return 0;
}

int main(){	
	scanf("%lld",&n);
	ll ans=2;	
	if(n==2){
		printf("1");return 0;
	}
	for(ll i=2;i*i<=n;i++){
		ans+=check(i);
		if(n/i!=i) ans+=check(n/i);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left


h, w, m = map(int, input().split())
bomb = [list(map(int, input().split())) for _ in range(m)]

numbh = [0 for _ in range(h)]
numbw = [0 for _ in range(w)]

for b in bomb:
    bh, bw = b
    bh -= 1; bw -= 1
    numbh[bh] += 1
    numbw[bw] += 1

mbh, mbw = max(numbh), max(numbw)

mbh_i, mbw_i = [], []
for i in range(h):
    if mbh == numbh[i]:
        mbh_i.append(i)
for i in range(w):
    if mbw == numbw[i]:
        mbw_i.append(i)

cnt = 0
for b in bomb:
    bh, bw = b
    bh -= 1; bw -= 1
    p = bisect_left(mbh_i, bh)
    q = bisect_left(mbw_i, bw)
    if p < len(mbh_i) and mbh_i[p] == bh and q < len(mbw_i) and mbw_i[q] == bw:
        cnt += 1

ans = mbh+mbw
if cnt == len(mbh_i)*len(mbw_i):
    ans -= 1
print(ans)

Measured memory_bytes: 167896
import sys
# import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def solve():
	n, w = read(); 
	dp = [[0 for i in range(w+1)] for j in range(3)]
	w_v_list = [read() for i in range(n)]
	# for i in dp:print(*i)
	# print("\n")
	# print(w_v_list)
	for i in range(n):
		for j in range(w+1):
			elem_w, elem_v = w_v_list[i]
			if elem_w <= j:
				dp[i%3][j] = max(elem_v + dp[(i-1)%3][j - elem_w], dp[i%3][j-1], dp[(i-1)%3][j])
				# w_v_list[i][1] = 0
			else:
				dp[i%3][j] = max(dp[i%3][j-1], dp[(i-1)%3][j])
		for k in range(w+1):
			dp[(i+1)%3][k] = 0
		# for i in dp:print(*i)
		# print("\n")
	print(dp[(n-1)%3][w])




if __name__ == "__main__":
	solve()

Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll D,T,S;
    cin >> D >> T >> S;
    if(S*T>=D){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

mat graph;
template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, u, v;
    cin >> N >> u >> v;
    u--; v--;
    graph.assign(N, vec());
    vector<pair<ll, ll>> edges(N-1);
    Rep (i, N-1) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        edges[i] = {A, B};
        graph[A].push_back(B);
        graph[B].push_back(A);
    }

    vec dt(N, -1), da(N, -1);
    dt[u] = 0, da[v] = 0;
    stack<ll> st, sa;
    st.push(u);
    while (st.size()) {
        ll e = st.top();
        st.pop();
        for (ll f : graph[e]) {
            if (dt[f] != -1) continue;
            dt[f] = dt[e] + 1;
            st.push(f);
        }
    }

    sa.push(v);
    while (sa.size()) {
        ll e = sa.top();
        sa.pop();
        for (ll f : graph[e]) {
            if (da[f] != -1) continue;
            da[f] = da[e] + 1;
            sa.push(f);
        }
    }

    // Rep (i, N) {
    //     cout << dt[i] << " \n"[i==N-1];
    // }
    // Rep (i, N) {
    //     cout << da[i] << " \n"[i==N-1];
    // }

    mat graph2(N, vec());
    for (auto e : edges) {
        ll a = e.first, b = e.second;
        if (dt[a] < da[a] && dt[b] < da[b]) {
            graph2[a].push_back(b);
            graph2[b].push_back(a);
            // cout << a << " " << b << "\n";
        }
    }

    ll ans = -1;
    stack<ll> s;
    s.push(u);
    vector<bool> seen(N, false);
    while (s.size()) {
        ll e = s.top();
        s.pop();
        for (ll f : graph2[e]) {
            if (seen[f]) continue;
            // cout << f << " ";
            chmax(ans, da[f]);
            seen[f] = true;
            s.push(f);
        }
    }

    if (ans != -1) {
        cout << ans - 1 << endl;
        return 0;
    }

    ans = 1;
    for (ll e : graph[u]) {
        if (e == v) ans = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15616
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

void solve()
{
  string s;
  int n,k;
  cin >> k >> s;
  n=s.length();
  if(n<=k)
    cout << s << '\n';
  else
  {
    string x=s.substr(0,k);
    x+="...";
    cout << x << '\n';
  }
  return;
} 

signed main()
{
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3668