akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

const int loose = 0;
const int tight = 1;

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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n;
	cin >> n;
	if (n % 2 != 0) n++;

	cout << n / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()

ans1, ans2 = 0, 0

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == '0':
            ans1 += 1
        else:
            ans2 += 1
    else:
        if S[i] == '1':
            ans1 += 1
        else:
            ans2 += 1

print(min(ans1, ans2))

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int h, w;
string g[55];
char ans[55][55];

bool inside(int y, int x) {
    if (0 <= x && x < w && 0 <= y && y < h) return true;
    return false;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, h) {
        cin >> g[i];
    }
    rep(i, h)rep(j, w) {
        if (g[i][j] == '#') {
            ans[i][j] = '#';
            continue;
        }
        int cnt = 0;
        rep(k, 8) {
            int ny = i + dy8[k];
            int nx = j + dx8[k];
            if (inside(ny, nx)) {
                if (g[ny][nx] == '#') cnt++;
            }
        }
        //cout << cnt << endl;
        ans[i][j] = char(cnt + '0');
    }
    rep(i, h) {
        rep(j, w) cout << ans[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 256
import Foundation

// Example1
//let N = 6
//let M = 1
//let a = [3]

// Example2
//let N = 10
//let M = 2
//let a = [4, 5]

// Example3
//let N = 100
//let M = 5
//let a = [1, 23, 45, 67, 89]

let array = readLine()!.split(separator: " ")
let N = Int(array[0])!
let M = Int(array[1])!
var a = [Int](repeating: 0, count: M)
for m in 0 ..< M {
    a[m] = Int(readLine()!)!
}

/*
 Example1:
 ---------------------
 n | N1, N2 | S
 ---------------------
 0 |  1,  2 | 2 + 2 -> 4
 1 |  2,  3 | 2 + 0 -> 2
 2 |  3,  4 | 0 + 2 -> 2
 3 |  7,  7 | 0 + 0 -> 0
 4 |  5,  6 | 1 + 1 -> 2
 5 |  6,  7 | 1 + 0 -> 1
 6 |                   1 ; goal
 7 |                   0 ; over or broken
*/

var N1 = [Int](repeating: 0, count: N)
var N2 = [Int](repeating: 0, count: N)
var S = [Int](repeating: 0, count: N + 2)
S[N] = 1
S[N + 1] = 0

var m = 0

for n in 0 ..< N {
    let isStepBroken = m < M && a[m] == n
    if isStepBroken {
        N1[n] = N + 1
        N2[n] = N + 1
        m += 1
    } else {
        N1[n] = n + 1
        N2[n] = n + 2
    }
}
for n in (0 ..< N).reversed() {
    S[n] = (S[N1[n]] + S[N2[n]]) % 1_000_000_007
}
let answer = S[0]

print(answer)


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

void solve(int H, int W, int M, vector<int> h, vector<int> w)
{
    vector<int> cnt_h(H), cnt_w(W);
    for (int i = 0; i < M; i++)
    {
        cnt_h.at(h.at(i))++;
        cnt_w.at(w.at(i))++;
    }

    int mx_h = 0;
    set<int> idx_h;
    for (int i = 0; i < H; i++)
    {
        if (cnt_h.at(i) > mx_h)
        {
            mx_h = cnt_h.at(i);
            idx_h.clear();
            idx_h.insert(i);
        }
        else if (cnt_h.at(i) == mx_h)
            idx_h.insert(i);
    }

    int mx_w = 0;
    set<int> idx_w;
    for (int i = 0; i < W; i++)
    {
        if (cnt_w.at(i) > mx_w)
        {
            mx_w = cnt_w.at(i);
            idx_w.clear();
            idx_w.insert(i);
        }
        else if (cnt_w.at(i) == mx_w)
            idx_w.insert(i);
    }

    int res = mx_h + mx_w;
    if ((int64_t)idx_h.size() * (int64_t)idx_w.size() > (int64_t)(3 * 1e5))
    {
        cout << res << endl;
        return;
    }

    set<pair<int, int>> cand;
    for (auto &&i : idx_h)
    {
        for (auto &&j : idx_w)
        {
            cand.insert(make_pair(i, j));
        }
    }
    for (int i = 0; i < M; i++)
    {
        cand.erase(make_pair(h.at(i), w.at(i)));
    }
    if (cand.empty())
        cout << res - 1 << endl;
    else
        cout << res << endl;
}

int main()
{
    int H;
    cin >> H;
    int W;
    cin >> W;
    int M;
    cin >> M;
    vector<int> h(M);
    vector<int> w(M);
    for (int i = 0; i < M; i++)
    {
        cin >> h.at(i);
        cin >> w.at(i);
        h.at(i)--;
        w.at(i)--;
    }
    solve(H, W, M, move(h), move(w));
    return 0;
}


Measured memory_bytes: 35932
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin  >> n;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a.at(i)!=a.at(j)&&a.at(j)!=a.at(k)&&a.at(i)!=a.at(k)){
                    ll ze = a.at(i)+a.at(j)+a.at(k);
                    if(ze-a.at(i)>a.at(i)&&ze-a.at(j)>a.at(j)&&ze-a.at(k)>a.at(k))ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}
    



Measured memory_bytes: 3644
N, Y = map(int, input().split())

a = 0

for i in range(N+1):

    for ii in range(N+1 - i):

        iii = N - i - ii
        ans = 10000 * i + 5000 * ii + 1000 * iii
        if ans == Y:
                print(i,ii,iii)
                a += 1
                break

    if a != 0:
        break

if a == 0:
    print(-1,-1,-1)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //int answer = 0;
        String answer="Good";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        String s[]=new String[S.length()];
        for (int i = 0; i < S.length(); i++)
        {
            s[i]=S.substring(i,i+1);
        }
        //System.err.println(Arrays.toString(s));
        for(int i=0;i<S.length()-1;i++)
        {
            if(s[i].equals(s[i+1]))
            {
                answer="Bad";
                break;
            }
        }
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}



int main(){
  string s1,s2;
  cin>>s1>>s2;
  for(int i = 0; i < s2.length(); i++){
    cout<<s1[i]<<s2[i];
  }
  if(s1.length()>s2.length()){
    cout<<s1[s1.length()-1];
  }
  cout<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b!=c)cout<<"Yes"<<endl;
    else if(a==c&&a!=b)cout<<"Yes"<<endl;
    else if(b==c&&b!=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=[]
for i in range(n):
    d.append(abs(a[i]-b[i]))
d1=d2=d3=0
for e in d:
    d1+=e
    d2+=e**2
    d3+=e**3
d2=d2**(1/2)
d3=d3**(1/3)
dinf=max(d)
print('{:7f}'.format(d1))
print('{:7f}'.format(d2))
print('{:7f}'.format(d3))
print('{:7f}'.format(dinf))


Measured memory_bytes: 5652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
ll mod_pow(ll a, ll n, ll p) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2, p);
		return (tmp * tmp) % p;
	}
	return (a * mod_pow(a, n - 1, p)) % p;
}
bool divisible(vector<ll> &f, ll p) {
	int N = f.size() - 1;
	for (int i = N; i >= p; i--) {
		ll t = f[i];
		f[i] = 0;
		(f[i - (p - 1)] += p - (p - 1)*t%p) %= p;
	}
	for (int i = 0; i < N; i++) if (f[i]) return 0;
	return 1;
}
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll a[10001];
bool prime[10001];
int main() {
	int N;
	cin >> N;
	for (int i = N; i >= 0; i--) cin >> a[i];
	memset(prime, -1, sizeof(prime));
	prime[0] = prime[1] = 0;
	for (int i = 2; i <= N; i++) {
		if (!prime[i]) continue;
		for (int j = i * 2; j <= N; j += i) prime[j] = 0;
	}
	vector<ll> f(N + 1);
	set<ll> ans;
	for (ll i = 2; i <= N; i++) {
		if (!prime[i]) continue;
		for (int j = 0; j <= N; j++) {
			f[j] = a[j];
			if (f[j] < 0) f[j] += (abs(f[j]) / i + 1)*i;
			f[j] %= i;
		}
		if (divisible(f, i)) {
			ans.insert(i);
		}
	}
	ll G = 0;
	for (int i = 0; i <= N; i++) {
		G = gcd(G, abs(a[i]));
	}
	for (ll i = 2; i*i <= G; i++) {
		if (G%i == 0) {
			ans.insert(i);
			while (G%i == 0) G /= i;
		}
	}
	if (G > 1) ans.insert(G);
	for (ll d : ans) {
		cout << d << endl;
	}
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

int main(void){
 
  char S[11],T[11];
  
  scanf("%s %s\n",S,T);
  
  int A,B;
  
  scanf("%d %d\n",&A,&B);
   
  char U[11];
  
  scanf("%s\n",U);
    
   if(strcmp(S,U)==0){
    printf("%d %d\n",A-1,B);
   }else{
    printf("%d %d\n",A,B-1);
   }
  return 0;
  
}

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    int prev = -1;
    int sequence = 0;
    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        if(prev == t){
            sequence++;
        }else{
            // cout << sequence << "," << ans<< endl;
            if(sequence == 1) ans += 1; 
            else ans += (sequence+1)/2;
            sequence = 0;
            prev = t;
        }
    }
    // cout << sequence << "," << ans << endl;
    if(sequence == 1) ans += 1; 
    else ans += (sequence+1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
K, T = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if K == T:
    print(0)
    exit()

if T == 1:
    print(K - T)
    exit()

b = a[0]
c = a[1]

for i in range(2, T):
    if b >= c:
        c += a[i]
    else:
        b += a[i]

print(max(abs(b - c) - 1, 0))


Measured memory_bytes: 9108
#include<iostream>
#include<vector>

int main(){
    
    int n, m, c;
    int ans = 0;

    std::cin >> n >> m >> c;

    std::vector<int> b(m);

    for(auto&& e : b){
        std::cin >> e;
    }

    for(int i = 0; i < n; i++){
        int tmp = 0;
        for(int j = 0; j < m; j++){
            int a;
            std::cin >> a;
            tmp += a * b[j];
        }
        if(tmp + c > 0) ans++;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vi adj[(int)2e5];
vi start((int)2e5);
vi len((int)2e5, -1);
pii intersect(int i, int j){
   if(len[i] == -1 && len[j] == -1)return mp(0, -1);
   if(len[i] == -1)return mp(start[j], len[j]);
   if(len[j] == -1)return mp(start[i], len[i]);
   if(start[i] % 2 != start[j] % 2)return mp(0, 0);
   int s = max(start[i],start[j]);
   int e = min(start[i] + len[i]*2 - 2, start[j] + len[j]*2 -2);
   if(e < s)return mp(0, 0);
   return mp(s, (e- s)/2 + 1);
}
void calc(int i, int k){
    //need to adjust the range for the child
    if(len[i] != -1)start[i]--,len[i]++;
    pii temp = intersect(i, k);
    if(len[i] != -1)start[i]++,len[i]--;
    start[k] = temp.first;
    len[k] = temp.second;
}
bool check(int cur, int P){
    for(int child: adj[cur]){
        if(child != P){
            if(check(child, cur))return true;
            calc(child, cur);
        }
    } 
//    cout << cur << " " << start[cur] << " " << len[cur]  <<endl;
    if(len[cur] == 0)return true;
    return false;
}
void dfs(int cur, int P){
    if(P != -1){
        int pval = start[P];
        if(len[cur] == -1)start[cur] = pval + 1;
        else{
            if(start[cur] < pval)start[cur] = pval -1;
            else start[cur] = pval+1;
        }
        len[cur] = 1;
    }
    for(int child: adj[cur]){
        if(child != P){
            dfs(child, cur);
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    int n;cin >> n;
    int x, y;
    FOR(i, n -1){
        cin >>x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int k;cin >> k;
    FOR(i, k){
        cin >>x >> y;
        start[x] = y;
        len[x] = 1;
    }
    if(check(1, -1))cout << "No";
    else{
        cout << "Yes" << "\n";
        //assuming start[1] = 0 if not set otherwise the set value will be used
        len[1] = 1;
        dfs(1, -1);
        FOR1(i, n){
            cout << start[i] << "\n";
        }
    }
}




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

from operator import itemgetter

s = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

a=((s-1)//1000000000)+1
b=a*1000000000-s

print("0 0 1000000000 {} 1 {}".format(b,a))

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
  int N;
  scanf("%d",&N);
  if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
    printf("hon\n");
  }if(N%10==0||N%10==1||N%10==6||N%10==8){
    printf("pon\n");
  }if(N%10==3){
    printf("bon\n");
  }
  
  return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

// A

void solve() {

}

int main() {
  
  int x;
  cin >> x;
  if( 400 <= x && x <= 599 ) {
    puts("8");
  } else if( x <= 799 ) {
    puts("7");
  } else if( x <= 999 ) {
    puts("6");
  } else if( x <= 1199 ) {
    puts("5");
  } else if( x <= 1399 ) {
    puts("4");
  } else if( x <= 1599 ) {
    puts("3");
  } else if( x <= 1799 ) {
    puts("2");
  } else if( x <= 1999 ) {
    puts("1");
  }
  

  return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
struct node {
	int key;
	node *pre, *nex;
};
node *nil;
void init() {
	nil = (node *)malloc(sizeof(node));
	nil->nex = nil;
	nil->pre = nil;
}
void insert(int key) {
	node *a = (node*)malloc(sizeof(node));
	a ->key = key;
	a->nex = nil->nex;
	nil->nex->pre = a;
	nil->nex = a;
	a->pre = nil;
}
node* search(int key) {
	node *cur;
	cur = nil->nex;
	while (cur != nil && cur->key != key) {
		cur = cur->nex;
	}
	return cur;
}
void deletenode(node *pt) {
	/*if (pt != nil) {
		pt->nex->pre = pt->pre;
		pt->pre->nex = pt->nex;
		free(pt);
	}
	else return;*/
	if (pt == nil) return;
	pt->nex->pre = pt->pre;
	pt->pre->nex = pt->nex;
	free(pt);
}
void deleteFirst() {
	deletenode(nil->nex);
}
void deleteLast() {
	deletenode(nil->pre);
}
void deletekey(int key) {
	deletenode(search(key));
}
void printNode() {
	node *cur = nil->nex;
	/*while (cur != nil) {
		printf("%d", cur->key);
		cur = cur->nex;
	}*/
	int i = 0;
	while (1) {
		if(cur == nil)break;
		if (i++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->nex;
	}
	printf("\n");
}
int main() {
	int size = 0, np = 0, nd = 0;
	int n, key;
	char com[20];
	scanf("%d", &n);
	init();
	for (int i = 0; i < n; i++) {
		scanf("%s%d", com, &key);
		if (com[0] == 'i') {
			insert(key); np++; size++;
		}
		/*else if (com[6] == 'F') {
			deleteFirst();
		}
		else if (com[6] == 'L') {
			deleteLast();
		}
		else {
			deletekey(key);
		}*/
		else if (com[0] == 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F') {
					deleteFirst();
				}
				else if (com[6] == 'L') {
					deleteLast();
				}
}
				else {
					deletekey(key); nd++;
				}
				size--;

			}
		}
	
		printNode();
		return 0;
}

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

int main() {
  string c;
  cin>>c;
  if(c=="a"||c=="i"||c=="u"||c=="e"||c=="o"){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
import math
N,K = map(int, input().split())
x=0
ans=0
for i in range(1,N+1):
  if i >=K:
    ans += 1
  else: 
    j = math.log(K/i,2)
    x = math.ceil(j)
    ans += (0.5)**x
   
win_rate = ans/N 
print(win_rate) 

Measured memory_bytes: 38768
#include <stdio.h>

int F[50];

int fibonacci(int a){
  if(a==0 || a==1) return F[a]=1;
  if(F[a]!=-1) return F[a];
  return F[a]=fibonacci(a-2)+fibonacci(a-1);
}

int main(){
  int i,n;
  
  for(i=0;i<50;i++){
    F[i]=-1;
  }
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 10000
using namespace std;

vector<vector<int>> G;
vector<int>  dp;
queue<int> q;

int long_path(int x) {
    if (dp[x] != -1)return dp[x];

    int res = 0;
    for (auto p : G[x]) {
        res = max(res, long_path(p)+1);
    }
    dp[x] = res;
    return dp[x];
}

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

    G = vector<vector<int>>(N + 1);
    dp = vector<int>(N + 1, -1);
   
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
    }
    
    int ans = 0;
    for (int n = 1; n <= N; n++) {
        ans = max(ans, long_path(n));
    }
    cout << ans << endl;
}


Measured memory_bytes: 8192
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
typedef long long ll;

pair<ll, ll> ps[1 << 20];

int main(void) {

  int n;
  ll k, a[100010];
  scanf("%d %lld", &n, &k);
  rep(i, n) scanf("%lld", &a[i]);

  ll sum = 0, amax = k;
  rep(i, n) sum += a[i], amax = max(amax, a[i]);

  int N = 0;
  while (amax > (1LL << N)) N++;
 

  ll v[50] = {}, w[50] = {};
  rep(i, N) {
    w[i] = 1LL << i;
    rep(j, n) {
      if (!((a[j] >> i) & 1LL)) v[i]++;
    }
    v[i] = (2LL * v[i] - (ll)n) * w[i];
  }

  int N2 = N / 2LL;
  
  for (int i = 0; i < 1 << N2; i++) {
    ll sw = 0, sv = 0;
    for (int j = 0; j < N2; j++) {
      if (i >> j & 1) {
	sw += w[j];
	sv += v[j];
      }
    }
    ps[i] = make_pair(sw, sv);
  }
  sort(ps, ps + (1 << N2));
  int m = 1;
  for (int i = 1; i < 1 << N2; i++) {
    if (ps[m - 1].second < ps[i].second) {
      ps[m++] = ps[i];
    }
  }

  ll res = 0;
  for (int i = 0; i < 1 << (N - N2); i++) {
    ll sw = 0, sv = 0;
    for (int j = 0; j < (N - N2); j++) {
      if (i >> j & 1) {
	sw += w[N2 + j];
	sv += v[N2 + j];
      }
    }
    if (sw <= k) {
      ll tv = (lower_bound(ps, ps + m, make_pair(k - sw, LLONG_MAX)) - 1)->second;
      res = max(res, sv + tv);
    }
  }

  printf("%lld\n", sum + res);

  return 0;

}

Measured memory_bytes: 17408
#include <stdio.h>
int n,m,q,a,b,c,d,rui[1005][1005][3],ret[3];char f[1005][1005],e[3]={'J','O','I'};
int main(){
scanf("%d%d%d",&n,&m,&q);
for(int i=0;i<n;i++) scanf("%s",&f[i]);
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
rui[i][j][k]=rui[i-1][j][k]+rui[i][j-1][k]-rui[i-1][j-1][k]+(f[i-1][j-1]==e[k]);
for(int i=0;i<q;i++){
scanf("%d%d%d%d",&a,&b,&c,&d);
for(int j=0;j<3;j++) ret[j]=rui[c][d][j]-rui[c][b-1][j]-rui[a-1][d][j]+rui[a-1][b-1][j];
printf("%d %d %d\n",ret[0],ret[1],ret[2]);
}
}

Measured memory_bytes: 15224
def prime?(n)
  return 0 if n == 1
  return 1 if n == 2
  return 0 if n % 2 == 0
  i = 3
  limit = Math.sqrt(n)
  while i <= limit
    return 0 if n % i == 0
    i += 2
  end
  return 1
end

n = gets.to_i
as = []
n.times do
  as << gets.to_i
end

count = 0
as.each do |a|
  count += prime?(a)
end

puts count

Measured memory_bytes: 8924
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	string s;
  	int n,k;
	cin >> n >> k >> s;
	s[k-1] -= 'A'-'a';
  	cout << s << endl;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[]num=new int[n];
        for(int i=0;i<n;){
            num[i++]=sc.nextInt();
        }
        	
        Arrays.sort(num);
        int sum=1000000000;
        for(int i=0;i+m-1<n;i++){
            int nsum=0;
            nsum+=num[i+m-1]-num[i];
            sum=Math.min(sum,nsum);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 49440
#include<stdio.h>

int main(void){
    int N;
    scanf("%d", &N);

    int i, a[N];
    for(i=0;i<N;i++){
      scanf("%d", &a[i]);
      // printf("%p\n", &a[i]);
      // printf("%d\n", a[i]);
    }

    int flg[N];
    for(i=0;i<N;i++){
      flg[i]=0;
    }
    int count=0, next=a[0];
    flg[0]=1;
    for(i=0;i<N;i++){
      count++;
      if(next==2){
        break;
      }

      if(flg[next-1]==1){
        count=-1;
        break;
      }else{
        flg[next-1]=1;
      }

      next=a[next-1];

      if(i==N-1){
        count=-1;
        break;
      }


    }

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

    return 0;
}


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


int main(){
  int a,b,c;
  cin >>a >> b >>c;
  cout << min(b/a,c) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define pa pair<int, int>
#define pal pair<long long, long long>
#define pali pair<long long, int>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define COUT(v)                              \
    for (int64_t i = 0; i < (v).size(); ++i) \
    {                                        \
        cout << v.at(i) << endl;             \
    }
#define REP(i, n) for (int64_t i = 0; i < n; ++i)
#define FOR(i, r, n) for (int64_t i = (r); i < n; ++i)
#define VIN(v)                               \
    for (int64_t i = 0; i < (v).size(); ++i) \
    {                                        \
        cin >> (v).at(i);                    \
    }
 
typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pavec;
typedef vector<vector<pa> > pamat;
typedef vector<pali> palivec;
typedef vector<pal> palvec;
 
typedef vector<vector<bool> > bmat;
typedef vector<vector<int> > imat;
typedef vector<vector<long long> > lmat;
 
typedef vector<string> svec;
typedef vector<vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;
const ll MOD = 1000000007;
 
ll gcd(ll x, ll y)
{
    ll r = x % y;
    if (r == 0)
        return y;
    else
        return gcd(y, r);
}

ll lcm(ll x, ll y)
{
    return x * y / gcd(x, y);
}
 
lvec mfactor(ll n)
{
    bvec ip(n, true);
    lvec mf(n, -1);
    ip[0] = false;
    ip[1] = false;
    mf[0] = 0;
    mf[1] = 1;
    REP(i, n)
    {
        if (ip[i])
        {
            mf[i] = i;
            for (ll j = i * i; j < n; j += i)
            {
                ip[j] = false;
                if (mf[j] == -1)
                    mf[j] = i;
            }
        }
    }
    return mf;
}
 
palivec get_prime(ll n, const lvec &mf)
{
    palivec plist;
    while (n != 1)
    {
        int cnt = 0;
        ll m = mf[n];
        while (mf[n] == m)
        {
            cnt++;
            n /= m;
        }
        plist.pb(pali(m, cnt));
    }
    return plist;
}
 
void COMinit(int m, lvec &fac, lvec &finv)
{
    lvec inv(m);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < m; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
 
    }
}
 
ll pow_mod(ll a, ll n)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = x * a % MOD;
        }
        a = a * a % MOD;
        n >>= 1;
    }
    return x;
}
 
 
ll COM(int n, int k, const lvec &fac, const lvec &finv)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;
}
 
ll modinv(ll a, ll m)
{
    ll b = m, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}


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

    cout << r*r << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,aa,bb,cc,i;
    cin>>a>>b>>c;
    aa=a,bb=b,cc=c;
    if(aa%2||bb%2||cc%2)
        cout<<"0"<<endl;
    else if(a==b&&b==c)
        cout<<"-1"<<endl;
    else
    {
        for(i=1;; i++)
        {
            a=aa,b=bb,c=cc;
            if(aa%2||bb%2||cc%2)
            {
                cout<<i-1<<endl;
                break;
            }
            aa=(b/2)+(c/2);
            bb=(a/2)+(c/2);
            cc=(a/2)+(b/2);
        }
    }
}


Measured memory_bytes: 3568
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import deque

n, *a = map(int, read().split())
b = deque()
v = 1 if n % 2 == 0 else 0
for i, aa in enumerate(a):
    if i % 2 == v:
        b.appendleft(aa)
    else:
        b.append(aa)
print(*b)


Measured memory_bytes: 23656
N,M=map(int,input().split())
p=[0]*M
S=[0]*M

for i in range(0,M):
    p[i],S[i]=map(str,input().split())

fin=[0]*(N+1)
count_AC=0
count_WA=[0]*(N+1)

if(M!=0):
    for i in range(0,M):
        if(S[i]=="AC"):
            if(fin[int(p[i])]!=-1):
                count_AC+=1
                fin[int(p[i])]=-1
        else:
            if(fin[int(p[i])]!=-1):
                count_WA[int(p[i])]+=1
    
    for i in range(1,N+1):
        if(fin[i]!=-1):
            count_WA[i]=0
    
    print(count_AC,sum(count_WA))

else:
    print(count_AC,sum(count_WA))

Measured memory_bytes: 17236
#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)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;



int main() {
  ll l,r;
  cin >> l >> r;
  if(r-l >= 2019) cout << 0 << endl;
  else {
      ll res = 2018;
      for (ll i = l;i <  r;i++){
          for (ll j = i+1;j <= r;j++){
              res = min (res,(i * j)%2019);
          }
      }
    cout << res << endl;
  }
  
    
   
  

}



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


int main()
{


    int b; cin >> b;




    if(b < 600) {
        cout << 8 << endl;
        return 0;
    }
    if (b < 800)
    {
        cout << 7 << endl;
        return 0;
    }
    if (b < 1000)
    {
        cout << 6 << endl;
        return 0;
    }
    if (b < 1200)
    {
        cout << 5 << endl;
        return 0;
    }
    if (b < 1400)
    {
        cout << 4 << endl;
        return 0;
    }
    if (b < 1600)
    {
        cout << 3 << endl;
        return 0;
    }
    if (b < 1800)
    {
        cout << 2 << endl;
        return 0;
    }
    if (b < 2000)
    {
        cout << 1 << endl;
        return 0;
    }

    return 0;
}

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

#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define pi 3.141592653589
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod) ;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
// template<typename T>
// using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
//(*****FOR USING ORDERED SET CHANGE INT*******)


signed main() {
    quickie
    int n, k;
    cin >> n >> k;
    int a[n+1] ;
    int val[n+1] ;
    rep(i, 1, n+1) cin >> a[i] ;
    val[n] = 0 ;
    for(int i=n-1; i>=1; i--) {
        int j = i+1, kk = k, mn = 10000000000 ;
        while(kk && j <= n) {
            mn = min(abs(a[i]-a[j])+val[j], mn) ;
            j++ ;
            kk-- ;
        }
        val[i] = mn ;
    }
    cout << val[1] << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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

Measured memory_bytes: 5108
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
//    ifstream cin("C:\\Users\\riku\\Downloads\\in01.txt");
    int n;
    cin >> n;
    vector<ll> as(n), bs(n);
    for (ll &l:as)cin >> l;
    for (ll &l:bs)cin >> l;

    auto get = [&](int i) -> ll {
        return bs[(i + n) % n];
    };

    auto check = [&]() -> bool {
        rep(i, n) if (get(i) - (get(i + 1) + get(i - 1)) >= as[i]) return true;
        return false;
    };

    ll ans = 0;
    while (check()) {
        rep(i, n) {
            while (get(i) - (get(i + 1) + get(i - 1)) >= as[i]) {
                ll sum = get(i + 1) + get(i - 1);
                ans += ((bs[i] - as[i]) / sum);
                bs[i] -= ((bs[i] - as[i]) / sum) * sum;

            }
        }
    }

    if (as == bs) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

}


Measured memory_bytes: 6352
# Atcoder Problem Solving
# F - Takahashi's Basics in Education and Learning
import math
L, A, D, mod = map(int, input().split())
que = []

ans = 0
# 1桁、......20桁のグループに分類する
for i in range(1, 22):
    #10**(i-1) <= A+D*(j) < 10**(i)
    if (10**(i-1)-A+D) % D == 0:
        lowest = max(1, (10**(i-1)-A+D)//D)
    else:
        lowest = max(1, (10**(i-1)-A+D)//D+1)
    highest = 0
    if (10**i-A+D) % D == 0:
        highest = min((10**i-A+D)//D-1, L)

    else:
        highest = min((10**i-A+D)//D, L)

    if 1 <= lowest <= highest:
        que.append((i, lowest, highest))


def poly_sum(X, N, mod):
    # return X^N +    .... X^1+1 mod
    # O(logN)
    if N == 0:
        return 1
    if N == 1:
        return (X+1) % mod
    else:
        if N % 2 == 0:
            tmp_res = poly_sum(X, N//2, mod)
            return ((pow(X, N//2, mod)+1)*tmp_res-pow(X, N//2, mod)) % mod

        elif N % 2 != 0:
            tmp_res = poly_sum(X, N//2, mod)
            return (pow(X, N//2+1, mod)+1)*tmp_res % mod


def sum_of_poly_sum(X, N, mod):
    # return poly_sum(X,N,mod)+ poly_sum(X,N-1,mod) +poly_sum(X,N-2,mod) +.....  + poly_sum(X,1,mod) + poly_sum(X,0,mod)
    # O(logN*logN)
    if N == 0:
        return poly_sum(X, 0, mod)
    elif N == 1:
        return (poly_sum(X, 1, mod)+poly_sum(X, 0, mod)) % mod
    else:
        return ((sum_of_poly_sum(X, (N-1)//2, mod))*(pow(X, N//2+1, mod)+1)+(N//2+1)*poly_sum(X, N//2, mod)) % mod


def find_mod(length, lowest, highest, mod):
    # length 桁　の lowest 項目から highest 項目における連結巨大数のmodular
    X = pow(10, length, mod)
    if highest > lowest:
        base = (A+D*(lowest-1))*poly_sum(X, highest-lowest, mod) + \
            D*sum_of_poly_sum(X, highest-lowest - 1, mod)
    elif highest == lowest:
        base = A+D*(lowest-1)
    return base % mod


que.reverse()

digits = 0
for length, lowest, highest in que:
    ans += find_mod(length, lowest, highest, mod)*pow(10, digits, mod)
    ans %= mod
    digits += length*(highest+1-lowest)

print(ans % mod)

Measured memory_bytes: 9244
def main():
    A = input()
    K = int( input())
    N = len(A)
    dp = [ [ [0]*(K+1) for _ in range(2)] for _ in range(N)]
    t = int( A[0])
    dp[0][0][1] = 1
    dp[0][1][1] = t-1
    for i in range(N):
        dp[i][1][0] = 1
    for i in range(1,N):
        t = int(A[i])
        if t == 0:
            for k in range(1,K+1):
                dp[i][0][k] = dp[i-1][0][k]
        else:
            for k in range(K):
                dp[i][0][k+1] = dp[i-1][0][k]
        if t == 0:
            for k in range(1,K+1):
                dp[i][1][k] = dp[i-1][1][k] + dp[i-1][1][k-1]*9
        else:
            for k in range(1,K+1):
                dp[i][1][k] = dp[i-1][1][k] + dp[i-1][1][k-1]*9 + dp[i-1][0][k-1]*(t-1) + dp[i-1][0][k]
    print(dp[N-1][0][K] + dp[N-1][1][K])
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 1; i < n; i++){
		if((n / i) * i < n)
			ans += n / i;
		else
			ans += n / i - 1;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3600
s = input()
n = len(s) # sの長さn

a_only = "A" * n # Aがn文字続く文字列
b_only = "B" * n # Bがn文字続く文字列 

if s == a_only or s == b_only:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <fstream>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string res;
	char ch;

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> ch;
			if (i == j)
			{
				res += ch;
			}
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set> 
#include <iterator>
#include <bitset> 
#include <bits/stdc++.h> 
using namespace std;
typedef  long long int ll;
ll mod=1000000007;


int main() {
    int T=1;
    //cin>>t;
    while(T--)
    {    int d,t,s;
        cin>>d>>t>>s;
        double k=d/(double)s;
        k=ceil(k);
        if(t>=k)
            cout<<"Yes";
        else
            cout<<"No";
            
            
    }
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
vector<int>dx={-1,0,1,0};
vector<int>dy={0,-1,0,1};
int h,w,res=0;
vector<string>mp;
vector<vector<int>>dis;
queue<pair<int,int>>q;
pair<int,int>tmp;

int bfs(){
    while(q.size()){
        tmp = q.front();
        q.pop();
        for(int i=0;i<4;i++){
            int x = tmp.second + dx.at(i);
            int y = tmp.first + dy.at(i);
            if(0<=x&&x<w&&0<=y&&y<h&&dis.at(y).at(x)==-1){
                dis.at(y).at(x)=dis.at(tmp.first).at(tmp.second)+1;
                q.push(make_pair(y,x));
            }
        }
    }
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            res=max(res,dis.at(i).at(j));
    return res;
}

int main(){
    cin >> h >> w;
    mp.resize(h);
    dis.resize(h);
    for(int i=0;i<h;i++){
        dis.at(i).resize(w);
        cin >> mp.at(i);
    }
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            if(mp.at(i).at(j)=='#'){
                dis.at(i).at(j)=0;
                q.push(make_pair(i,j));
            }
            else
                dis.at(i).at(j)=-1;
    cout << bfs() << endl;
}

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

typedef unsigned long long ll;
const int maxn = 1000010;
int n, cur[maxn], len[maxn];
bool chk[26];
ll pw[maxn], pre[maxn];
char s[maxn];
unordered_map<ll, int> mp;

int main() {
    scanf("%d", &n);
    for (int i = pw[0] = 1; i <= 1000000; i++) {
        pw[i] = 19260817 * pw[i - 1];
    }
    for (int i = 1; i <= n; i++) {
        scanf("%s", s + cur[i]);
        len[i] = strlen(s + cur[i]);
        ll h = 0;
        for (int j = 0; j < len[i]; j++) {
            h = h * 19260817 + s[cur[i] + j];
        }
        mp[h]++, cur[i + 1] = cur[i] + len[i];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        memset(chk, 0, sizeof(chk));
        for (int j = 0; j < len[i]; j++) {
            pre[j] = (j ? pre[j - 1] : 0) * 19260817 + s[cur[i] + j];
        }
        auto get = [&](int l, int r) {
            return pre[r] - (l ? pre[l - 1] : 0) * pw[r - l + 1];
        };
        memset(chk, 0, sizeof(chk));
        for (int j = 0; j < len[i]; j++) {
            if (chk[s[cur[i] + j] - 'a']) continue;
            chk[s[cur[i] + j] - 'a'] = 1;
            for (int k = j; k < len[i]; k++) {
                auto t = s[cur[i] + j] * pw[len[i] - k - 1] + get(k + 1, len[i] - 1);
                if (mp.count(t)) ans += mp[t];
            }
        }
    }
    cout << ans - n << endl;
    return 0;
}

Measured memory_bytes: 21816
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int L;
int main(){
  int res;
  rd(N);
  rd(L);
  res = (2*L+N-1) * N / 2;
  if(L>=0){
    res -=L;
  }
  else if(L+N-1<=0){
    res -=L+N-1;
  }
  else{
    res -=0;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190706-1

// --- original code ---
// int N, L;
// {
//   int res;
//   rd(N,L);
//   res = (2*L+N-1) * N / 2;
//   res -= if[L>=0, L, L+N-1<=0, L+N-1, 0];
//   wt(res);
// }


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ====================================================================

int main() {
  ll n, m;
  cin >> n >> m;
  double ans = 0;

  double k = 1; // k…ACする確率
  for (int i = 0; i < m; i++) k /= 2;
  double kk = 1; // kk…連続してTLEを取る確率

  for (int i = 1; i < 1000000; i++) {
    ans += (double)(i * m * 1900 + i * (n - m) * 100) * kk * k;
    // cout << ans << " " << kk << endl;
    kk *= (1 - k);
  }
  cout << ans << endl;
}


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

ans = "-1 -1 -1"

for i in range(n+1):
    for j in range(n+1):
        if i + j > n:
            break
        k = n - i - j
        if 10000*i + 5000*j + 1000*k == y:
            ans = "{} {} {}".format(i, j, k)

print(ans)


Measured memory_bytes: 40944
#include<stdio.h>

int main(){
  int x, i, sum;
  sum = 100000;

  scanf("%d",&x);

  for(i = 0; i < x; i++){
    sum *= 1.05;
    if(sum % 1000 != 0){
      sum /= 1000;
      sum += 1;
      sum *= 1000;
    }
      
  }
  printf("%d\n",sum);

  return 0;

}

Measured memory_bytes: 0
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;


/* エラトステネスのふるい

   O(n log log n) だいたい線形。 10万とかは余裕
*/
template<typename T>
std::vector<T> sieve(T n)
{
    std::vector<T> primes;
    std::vector<bool> is_prime(n, true);
    is_prime[0] = is_prime[1] = false;

    for (T i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (T j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return primes;
}

int main()
{
    int64_t Q;
    std::cin >> Q;

    std::vector<int64_t> s;
    {
        auto primes = sieve<int64_t>(100000LL);
        for (auto p: primes) {
            auto pp = (p+1)/2;
            auto pos = std::find(std::begin(primes), std::end(primes), pp);
            if (pos != std::end(primes)) {
                s.push_back(p);
            }
        }
    }

    std::vector<int64_t> ss(100000LL);
    size_t sum = 0;
    int64_t prev = 0;
    for (auto e: s) {
        std::fill(&ss[prev], &ss[e], sum);
        sum++;
        prev = e;
    }
    std::fill(&ss[prev], &ss[100000], sum);

    for (decltype(Q) q = 0; q < Q; ++q) {
        int64_t l, r;
        std::cin >> l >> r;

        std::cout << ss[r] - ss[l-1] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1588
#include<stdio.h>
#include<math.h>
void p(long long n){
    int i;
    i=sqrt(n)/2;
    while(i*(i+1)/2<n){
        i++;
    }
    printf("%d",i);
}
main(){
    long long n;
    scanf("%lld",&n);
    p(n);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<pow(n,3)<<endl;
    return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;

    t.pop_back();

    if (s == t)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 3592