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

using namespace std;

#define ll long long

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<ll> x(N), y(N), z(N);
  
  for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> z[i];
  
  vector<vector<ll>> xyz(8, vector<ll>(N));
  
  for(int i = 0; i < N; i++){
    xyz[0][i] = x[i] + y[i] + z[i];
    xyz[1][i] = x[i] + y[i] - z[i];
    xyz[2][i] = x[i] - y[i] + z[i];
    xyz[3][i] = x[i] - y[i] - z[i];
    xyz[4][i] = -x[i] + y[i] + z[i];
    xyz[5][i] = -x[i] + y[i] - z[i];
    xyz[6][i] = -x[i] - y[i] + z[i];
    xyz[7][i] = -x[i] - y[i] - z[i];
  }
  
  for(int t = 0; t < 8; t++){
    sort(xyz[t].begin(), xyz[t].end());
  }
  
  ll maximum = 0;
  for(int t = 0; t < 8; t++){
    ll cm = 0;
    for(int i = N - 1; i >= N - M; i--){
      cm += xyz[t][i];
    }
    
    maximum = max(cm, maximum);
  }
  
  cout << maximum << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void)
{
    int N,A;
    cin >> N >> A;

    int X=N%500;

    if(N<=A){
        cout << "Yes" <<endl;
    }else if(X<=A){
        cout <<"Yes"<<endl;
    }else{
        cout << "No" <<endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
string s;
ll dp[3][maxn];
const int mod=2019;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	ll ans=0;
	int n=s.size();
	rep(i,0,n)
	{
		int x=s[i]-'0';
		rept(j,0,mod) dp[i&1][j]=0;
		rept(j,0,mod)
		{
			dp[i&1][(j*10+x)%mod]+=dp[(i+1)&1][j];
		}
		dp[i&1][x]++;
		ans+=dp[i&1][0];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3812
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: u32 = read();
    let k: u32 = read();

    let mut ans = 0.0;

    for i in 1..n + 1 {
        let mut tmp = 1.0 / n as f64;
        let mut now = i;
        while now < k {
            now *= 2;
            tmp /= 2.0;
        }
        ans += tmp
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n);
	vector<int> y(m);
	rep(i, 0, n)cin >> x[i];
	rep(i, 0, m)cin >> y[i];
	bool judge = false;
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	if (x[n - 1] < y[0]) {
		rep(z, x[n - 1] + 1, y[0] + 1) {
			if (X < z && z <= Y) {
				judge = true;
			}
		}
	}
	if (judge)cout << "No War" << endl;
	else cout << "War" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pii, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct SegTree {
    int siz;
    vector<int> node;

    SegTree(int N) : siz(1) {
        while (siz < N)
            siz *= 2;
        node.resize(2 * siz - 1, 0);
    }

    void update(int k, int x) {
        k += siz - 1;
        node[k] = x;
        while (k > 0) {
            k = (k - 1) / 2;
            node[k] = max(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        if (r <= a || b <= l)
            return 0;
        if (a <= l && r <= b)
            return node[k];
        int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return max(vl, vr);
    }
};

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

    int N, K;
    cin >> N >> K;
    SegTree seg(300010);
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        int res = seg.query(max(A - K, 0), min(A + K + 1, 300001));
        seg.update(A, res + 1);
    }

    cout << seg.query(0, 300001) << endl;

    return 0;
}


Measured memory_bytes: 7476
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

float cal_h(int x){}


int main(){
  int n,t,a,h,index;
  float result_old,result_new;


  cin >> n >> t >> a;
  result_old = 100000.000;
  for(int i=0;i<n;i++){
    cin >> h;
    result_new = abs(t - (h * 0.006) - a);
    if(result_new < result_old){
      index = i+1;
      result_old = result_new;
    }
  }
  cout << index << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  vector<int> v{ A + B, A - B, A * B };
  sort(v.begin(), v.end());
  cout << v[2] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {                        
  public static void main(String[] args) {   
     
   Scanner sc = new Scanner(System.in);                                                                                     
    
   int a[] = new int[8];
   
   int N = sc.nextInt();
   
   int maxcnt = 0;
   
   for(int i = 0;i < N;i++){
       int b = sc.nextInt();
       if(b < 400){
           a[0] = 1;
       }else if(b < 800){
           a[1] = 1;
       }else if(b < 1200){
           a[2] = 1;
       }else if(b < 1600){
           a[3] = 1;
       }else if(b < 2000){
           a[4] = 1;
       }else if(b < 2400){
           a[5] = 1;
       }else if(b < 2800){
           a[6] = 1;
       }else if(b < 3200){
           a[7] = 1;
       }else if(b <= 4800){
           maxcnt++;
       }
   }
   
   int sum = 0;
   
   for(int i = 0;i <= 7;i++){
       if(a[i] == 1){
           sum++;
       }       
   }
   
   if(sum == 0){
       System.out.println(1 + " " + maxcnt);
       return;
   }   
    
   int min = 0;
   int max = 0;
   
   min = sum;
   max = sum + maxcnt;
       
   System.out.println(min + " " + max);
              
  }             
}



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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    for(int i=0;i<5;i++)   
    {
        int temp;
        cin>>temp;
        if(temp==0)
            t=i+1;
    }
    cout<<t;
    return 0;
}

Measured memory_bytes: 10616
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _Ty> static _Ty tp_abs(const _Ty& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _Ty> static _Ty tp_min(_Ty a, _Ty b) {
	return a < b ? a : b;
}
template <class _Ty> static _Ty tp_max(_Ty a, _Ty b) {
	return a > b ? a : b;
}
template<class T> static void getint(T& a) {
	const char* fmt = " %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class T> static void getint(T& a, T& b) {
	const char* fmt = " %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class T> static void getint(T& a, T& b, T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const int EduDp_INF = 1100000000;
static const int MOD_NUM = 1000000007;
static void F_task();

#if 1
int main()
{
	F_task();
	fflush(stdout);
	return 0;
}
#endif


static void F_task()
{
	auto ss = new char[3001];
	auto tt = new char[3001];

	getstring(ss);
	getstring(tt);

	int sslen = strlen(ss);
	int ttlen = strlen(tt);
	std::string lcs;
	
	std::vector<std::vector<int>> ndp(sslen + 1, std::vector<int>(ttlen + 1, 0));
	std::vector<std::vector<std::pair<int, int>>>
		from(sslen + 1, 
			std::vector<std::pair<int, int>>(ttlen + 1, std::pair<int, int>(-1, -1))
		);
	for (int i = 0; i < sslen; i++) {
		for (int j = 0; j < ttlen; j++) {
			if (ss[i] == tt[j]) {
				int newlen = ndp[i][j] + 1;
				if (newlen > ndp[i + 1][j + 1]) {
					ndp[i + 1][j + 1] = newlen;
					from[i + 1][j + 1] = std::pair<int, int>(i, j);
				}
			}
			if (ndp[i + 1][j + 1] < ndp[i][j + 1]) {
				ndp[i + 1][j + 1] = ndp[i][j + 1];
				from[i + 1][j + 1] = from[i][j + 1];
			}

			if (ndp[i + 1][j + 1] < ndp[i + 1][j]) {
				ndp[i + 1][j + 1] = ndp[i + 1][j];
				from[i + 1][j + 1] = from[i + 1][j];
			}
		}
	}

	std::pair<int, int> next = from[sslen][ttlen];
	while (next.first >= 0) {
		lcs.insert(lcs.begin(), ss[next.first]);
		next = from[next.first][next.second];
	}

	printf("%s\n", lcs.c_str());
	delete[] ss;
	delete[] tt;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;
  n--;
  m--;
  cout << n*m << endl;
  
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import defaultdict
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve(q):
    N, M = map(int, readline().split())
    if N == M == 0:
        return False
    if q:
        write("\n")
    INF = 10**18
    G = [[] for i in range(N)]
    E = [[INF]*N for i in range(N)]
    for i in range(M):
        a, b, c = map(int, readline().split())
        G[a-1].append((b-1, c))
        G[b-1].append((a-1, c))
        E[a-1][b-1] = E[b-1][a-1] = c
    prv = [-1]*N
    L = int(readline())
    P = []; R = []; I = [0]*L
    B = [0]*L
    que = []
    for i in range(L):
        a, b, c, s = readline().strip().split()
        P.append(s)
        a = int(a)-1; b = int(b)-1; c = int(c)
        dist = [INF] * N
        dist[b] = 0
        que1 = [(0, b)]
        while que1:
            cost, v = heappop(que1)
            if dist[v] < cost:
                continue
            for w, d in G[v]:
                r = cost + d
                if r < dist[w]:
                    dist[w] = r
                    prv[w] = v
                    heappush(que1, (r, w))
                elif r == dist[w]:
                    prv[w] = min(prv[w], v)
        rt = []
        B[i] = b
        v = a
        while v != b:
            rt.append(v)
            v = prv[v]
        rt.append(b)
        R.append(rt)
        que.append((c, 1, i))
    heapify(que)
    res = [0]*L
    QS = [[] for i in range(N)]; rest = L
    D = [defaultdict(list) for i in range(N)]
    F = [{} for i in range(N)]
    U = [1]*N
    while rest:
        t = que[0][0]
        while que and que[0][0] == t:
            _, p, i = heappop(que)
            if p:
                v = R[i][I[i]]
                I[i] += 1
                if B[i] == v:
                    rest -= 1
                    res[i] = t
                else:
                    w = R[i][I[i]]
                    heappush(QS[v], (t, w, i))
                    D[v][w].append(i)
                    F[v][i] = 0
            else:
                U[i] = 1
        for v in range(N):
            if QS[v]:
                qv = QS[v]
                while qv and F[v][qv[0][2]]:
                    heappop(qv)
            if not U[v] or not QS[v]:
                continue
            _, w, k = heappop(QS[v])
            d = E[v][w]
            for k0 in D[v][w]:
                F[v][k0] = 1
                heappush(que, (t+d, 1, k0))
            D[v][w] = []
            heappush(que, (t+d+d, 0, v))
            U[v] = 0
    ans = []
    for i in range(L):
        ans.append((res[i], P[i]))
    ans.sort()
    for e, s in ans:
        write("%s %d\n" % (s, e))
    return True
q = 0
while solve(q):
    q += 1


Measured memory_bytes: 7104
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {

    string s;
    cin >> s;
    
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    
    
}


Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] s2 = System.Console.ReadLine().Trim().Split(' ');
            string sS = s2[0];
            string sT = s2[1];
            s2 = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(s2[0]);
            int iB = int.Parse(s2[1]);
            s2 = System.Console.ReadLine().Trim().Split(' ');
            string sU = s2[0];

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            if (sS == sU) { iA -= 1; }
            if (sT == sU) { iB -= 1; }

            // 出力
            System.Console.WriteLine("{0}", (iA.ToString() + " " + iB.ToString()).Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

if n == 1
  puts a.first
  exit
end

ind = []
init_n = n

while true
  ind.push(n)
  break if n <= 2
  n -= 2
end

if n == 1
  n = 2
elsif n == 2
  n = 1
end

while true
  ind.push(n)
  break if init_n - 2 <= n
  n += 2
end

b = []

ind.each do |i|
  b.push(a[i-1])
end

puts b.join(' ')


Measured memory_bytes: 28988
from itertools import accumulate
from collections import defaultdict
import bisect

n,k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + list(accumulate([(i-1) % k for i in a]))
a = [i % k for i in a]
ans = 0
maps = defaultdict(list)
for k1,v in enumerate(a):
  maps[v].append(k1)
for i in range(n):
  v = a[i]
  ans += bisect.bisect_right(maps[v],i+k-1) - bisect.bisect_right(maps[v],i)
print(ans)

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, A, B;
    cin >> N >> A >> B;

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

Measured memory_bytes: 256
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

const double pi = 3.14159265358979323846;
signed main()
{   
    int x, y;
    cin>>x>>y;
    int flag = 0;
    for(int i=1; i<=x; i++)
    {
        if((2*i + (x-i)*4) == y || (4*i + (x-i)*2) == y)
            flag = 1;
    }
    if(flag == 0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
	return 0;
}

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

int d[323456];//d[i]:i個のグループの数
int dwa[323456];//dwa[i]:sum[0,i) of d
int dkwa[323456];//dkwa[i]:sum[0,i) of k*d[k]
int f[323456];//f[i]:i個列を作るときの最大長さ
//=( sum[0,i)k*d[k] + i*sum[i,INF)*d )/i
//=( dkwa[i]+i*(dwa[INF]-dwa[i]) )/i

signed main(){
  int n;cin>>n;
  map<int,int> m;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    m[a]++;
  }
  for(auto p:m)d[p.second]++;
  for(int i=0;i<323400;i++)dwa[i+1]=dwa[i]+d[i];
  for(int i=0;i<323400;i++)dkwa[i+1]=dkwa[i]+i*d[i];
  for(int i=1;i<323400;i++)f[i]=(dkwa[i]+i*(dwa[323300]-dwa[i]))/i;
  int now=n;
  for(int i=1;i<=n;i++){
    while(now&&f[now]<i)now--;
    cout<<now<<endl;
  }
}

/*
解説AC
えーこれは解けた気がするけど解説見るまで全く思いつかなかったな
考え方としては二分探索に近い
x個列を作るとしたときの寄与度を考える
見方をちょうど90度だけ変えて考えてあげるのは流石に典型
*/

Measured memory_bytes: 18432
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

vector<int> nums(102, 0);

void solve() {
  int x, n;
  cin >> x >> n;

  rep(i,n) {
    int p;
    cin >> p;
    nums[p] = 1;
  }

  int l = x;
  int r = x;
  while (nums[l]) {
    l--;
  }
  while (nums[r]) {
    r++;
  }
  
  int left = abs(l-x);
  int right = abs(r-x);

  if (left <= right) cout << l << endl;
  else cout << r << endl;

}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#define N_MAX 100
#define W_MAX 100
#define D_MAX 100
using namespace std;



class Cake {
public:
  int n;
  int w, h;
  Cake(int w, int h, int n) : w(w), h(h), n(n){}
  bool operator <(const Cake &c) const {
    if(n != c.n) return n < c.n;
    return w*h < c.w * c.h;
  }
};

vector<Cake> v;
int cutTime;

void cut(int p, int s) {
  s %= v[p].w + v[p].h;
  if(s < v[p].w) {
    v.push_back(Cake(v[p].w-s, v[p].h, cutTime));
    v[p].w = s;
    v[p].n = cutTime;
  } else {
    s -= v[p].w;
    v.push_back(Cake(v[p].w, v[p].h-s, cutTime));
    v[p].h = s;
    v[p].n = cutTime;
  }
  sort(v.begin(), v.end());
  ++cutTime;
}

main() {
  int n, w, d;
  while(( cin >> n >> w >> d ) && (n || w || d)) {
    v.clear();
    v.push_back(Cake(0, 0, -1));
    v.push_back(Cake(w, d, 0));
    sort(v.begin(), v.end());
    cutTime = 1;
    for(int i = 0; i < n; ++i) {
      int p, s;
      cin >> p >> s;
      cut(p, s);
    }

    vector<int> tmpV;
    for(int i = 1; i < v.size(); ++i) {
      tmpV.push_back(v[i].w * v[i].h);
    }
    sort(tmpV.begin(), tmpV.end());

    for(int i = 0; i < tmpV.size(); ++i) {
      if(i != 0) cout << " ";
      cout << tmpV[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
import sys

def calc(a, H, W):
    # 横方向
    for j in range(H):
        prev = 0
        start = 0
        for i in range(W + 1):
            if a[j][i] > 0:
                if prev == 0:
                    start = i
                    prev = 1
            else:
                if prev == 1:
                    num = i - start
                    for k in range(start, i):
                        a[j][k] = num
                    prev = 0
    # 縦方向
    for i in range(W):
        prev = 0
        start = 0
        for j in range(H + 1):
            if a[j][i] > 0:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    num = j - start
                    for k in range(start, j):
                        a[k][i] += num - 1
                    prev = 0


sin = sys.stdin
H, W = map(int, sin.readline().split())
a = [[0] * (W + 1) for _ in range(H + 1)]

for j in range(H):
    for i, c in enumerate(sin.readline()):
        if c == '.':
            a[j][i] = 1

calc(a, H, W)

ans = 0
for row in a:
    ans = max(ans, max(row))
print(ans)


Measured memory_bytes: 77532
# coding: utf-8
import sys
from collections import deque

output_str = deque()
data_cnt =  int(input())  

for i in range(data_cnt):
    in_command = input().rstrip().split(" ")
    
    if in_command[0] == "insert":
        output_str.appendleft(in_command[1])
    elif in_command[0] == "delete":
        try:
            output_str.remove(in_command[1])
        except:
            pass
    elif in_command[0] == "deleteFirst":
        output_str.popleft()
    elif in_command[0] == "deleteLast": 
        output_str.pop()

print(" ".join(output_str))

Measured memory_bytes: 71896
#include<bits/stdc++.h>
using namespace std;
const int N =1e6+5;
const long long M = (long long)1e9+7;
#define     ll      long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%I64d",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>t abs(t a) {
    if(a>=0)return a;
    return -a;
}
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     vi          vector<int>
#define     vl          vector<ll>
#define     pb          push_back
#define     all(x)      x.begin(),x.end()
#define     LB          lower_bound
#define     UB          upper_bound
#define     Mx(a,b)     (a>b)?a:b
#define     Mn(a,b)     (a<b)?a:b

int a[N];

int main() {
    string s;
    cin>>s;
    for(int i=0;s[i];i++)
    {
        a[s[i]]++;
    }
    int x=0;
    for(int i='a';i<='z';i++)
    {
        if(a[i]==0)return printf("%c",i),0;
    }
    puts("None");
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        int N;
            cin >> N;
                int P = 0, W = 0, G = 0, Y = 0;
        vector<char> S(N);
            for(int i = 0; i < N; i++){
                cin >> S.at(i);
                    if(S.at(i) == 'P'){
                        P = 1;
                    }else if(S.at(i) == 'W'){
                        W = 1;
                    }else if(S.at(i) == 'G'){
                        G = 1;
                    }else if(S.at(i) == 'Y'){
                        Y = 1;
                    }else{}
            }
                if(P + W + G + Y == 3){
                    cout << "Three" << endl;
                }else{
                    cout << "Four" << endl;
                }
    return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int pow(int A, int P){
	int a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	int adash = a * a;
	if(p % 2) return pow(adash, p / 2) * a;
	else return pow(adash, p / 2);
}

int main(){
	string S;
	cin >> S;
	int A[4];
	A[0] =S[0] - '0';
	A[1] =S[1] - '0';
	A[2] =S[2] - '0';
	A[3] =S[3] - '0';
	int ansi = -1;
	for(int i=0;i<8;i++){
		int idash = i;
		int ans = A[0];
		for(int j=1;j<=3;j++){
			if(idash % 2){
				ans += A[j];
			}
			else{
				ans -= A[j];
			}
			idash /= 2;
		}
		if(ans == 7) ansi = i;
	}
	cout << S[0];
	for(int j=1;j<=3;j++){
		if(ansi % 2){
			cout << "+";
		}
		else{
			cout << "-";
		}
		cout << S[j];
		ansi /= 2;
	}
	cout << "=7" << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t;
  cin >> s >> t;
  
  int num = s.length();
  
  string r = t.substr(0,num);
  
  if(s == r){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
   	string s1,s2;
   	cin>>s1>>s2;
   	s2+=s1;
   	cout<<s2;
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3568
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]
l=1;r=max(h)//b+1
while l!=r:
  x=(l+r)//2
  ct=0
  for i in range(n):
    ct+=((a-b-1)+max(0,h[i]-b*x))//(a-b)
  if ct>x:
    l=x+1
  else:
    r=x
print(l)

Measured memory_bytes: 7112
#include<iostream>
#include<string>
using namespace std;
int main() {
	string code;
	cin >> code;
	int answer = 0;
	answer = code.size() / 2;
	for (int i = 0; i < code.size(); ++i) {
		if (code[i] == 'p') {
			--answer;
		}
	}
	cout << answer << endl;
	return 0;
}

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

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

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main(){
  //ll bkt[500000010];
  ll n,m; cin >> n >> m;
  vector<ll> a(n);
  for(ll i=0; i<n; i++){
    cin >> a.at(i);
  }
  ll A = a.at(0);
  ll count = 0;
  ll div_tim = 0;
  while(A%2==0){
    count++;
    A = A/2;
  }
  ll LCM = a.at(0)/2;
  div_tim = count;
  for(ll i=1; i<n; i++){
    if(a.at(i)%2!=0||a.at(i)==0){continue;}
    A = a.at(i);
    count = 0;
    while(A%2==0){
      count++;
      A = A/2;
    }
    if(div_tim!=count){cout << 0 << endl;return 0;}
    div_tim = count;
    LCM = lcm(LCM,a.at(i)/2);
    if(1000000000<LCM){cout << 0 << endl;return 0;}
  }
  //cout << LCM << endl;
  ll ans=0;
  for(ll i=1; i*LCM<=m; i +=2){
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <string>


using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> H(N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &H[i]);
    }

    int maxCount = 0;
    int count = 0;
    for(int i = 0; i < N - 1; ++i){
        if(H[i + 1] <= H[i]){
            ++count;
        }
        else{
            count = 0;
        }
        maxCount = max(count, maxCount);
    }

    cout << maxCount << endl;

    return 0;
}


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

ll N,P,Q;
ll C[500005];
ll D[500005];
ll ans,sum,x;

int main(){
  cin>>N>>P>>Q;
  for(int i=0;i<N;i++){
    scanf("%lld",&C[i]);
    D[i]=C[i]-(Q-i)*P;
    sum+=C[i];
  }
  sort(D,D+N);
  ans=sum;
  for(int i=0;i<N;i++){
    sum-=D[i];
    x+=2*i*P;
    ans=max(ans,sum+x);
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  long push=0;
  int a[N];
  int b[N];
  for(int i=0;i<N;i++)cin >> a[i] >> b[i];
  for(int i=N-1;i>-1;i--){
    if((a[i]+push)%b[i]!=0){
      int x;
      x=b[i]-(a[i]+push)%b[i];
      push+=x;
    }
  }
  cout << push;
}

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

int main() {
  int n; cin>>n;
  vector<int> d(101, 0);
  for (int i=2;i<=n;i++) {
    int X=i;
    for (int div=2; div<=i; div++) {
      int cnt=0;
      while (X%div==0) {
        cnt++;
        X/=div;
      }
      d[div]+=cnt;
    }
  }
  int d2=0, d4=0, d14=0, d24=0, d74=0;
  for (int i=0;i<76;i++) {
    if (d[i]>=2) d2++;
    if (d[i]>=4) d4++;
    if (d[i]>=14) d14++;
    if (d[i]>=24) d24++;
    if (d[i]>=74) d74++;
  }
  int ans=0;
  ans+=max(0, d74);
  ans+=max(0, d24*(d2-1));
  ans+=max(0, d14*(d4-1));
  ans+=max(0, d4*(d4-1)*(d2-2)/2);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    string s, s2 = "";
    getline(cin, s);
    for (int i=0; i<(int)s.size(); ++i) {
        s2 += islower(s[i]) ? toupper(s[i]) : s[i];
    }
    cout << s2 << endl;
    return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple


int main(void)
{
    string S, T;
    cin >> S >> T;
    cout << T+S << endl;
    return 0;
}


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

int main (){
  string s;
  string ss;
  int count=0;
  int i;
  cin >> s;
  for(i=0;i<s.size();i++){
    if('A'<=s[i] && s[i]<='Z')s[i]+='a'-'A';
  }
  cin >> ss;
  while(ss!="END_OF_TEXT"){
    for(i=0;i<ss.size();i++){
      if('A'<=ss[i] && ss[i]<='Z')ss[i]+='a'-'A';
    }
    if(s==ss)count ++;
    cin >> ss;
  }
  cout << count << endl;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF = 1000000000;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    set<string> ss;
    for(int i=0;i<n;++i){
    string s;
    cin>>s;
    ss.insert(s);
    }
    cout<<(int)ss.size()<<'\n';
    return 0;
}

Measured memory_bytes: 19272
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,K;
    cin >> N >> K;
    vector<double> p(N);
    rep(i,N){
        cin >> p[i];
        p[i] = (1+p[i])/2;
    }
    double ans = 0;
    double now = 0;
    rep(i,N){
        if(i<K)now += p[i];
        else {
            now += p[i];
            now -= p[i-K];
        }
        ans = max(ans,now);
    }
    cout << ans << endl;
}

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

using namespace std;

int a[100010];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    int ans = 0;
    int record = a[0];
    int temp_ans = 0;
    for(int i=1;i<n;i++){
        if(a[i]<=record){
            temp_ans += 1;
            record = a[i];
        }
        else{
            ans = max(temp_ans, ans);
            temp_ans = 0;
            record = a[i];
        }
    }
    ans = max(temp_ans, ans);

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,W;
  cin>>n>>W;
  long long val[n],wt[n];
  for(long long i=0;i<n;i++)
  {
    cin>>wt[i]>>val[i];
  }
long long K[n+1][W+1]; 
for (long long i = 0; i <= n; i++) 
   { 
       for (long long w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   }
  cout<<K[n][W]<<"\n";
}


Measured memory_bytes: 79104
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn digit_sum(n: i64) -> i64 {
    let mut sum = 0;
    let mut tmp_n = n;

    loop {
        sum += tmp_n % 10;
        tmp_n = tmp_n / 10;

        if tmp_n == 0 {
            break;
        }
    }
    sum
}

fn main() {
    from_line!(m: i64);
    println!("{}", 48 - m);
}


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

using namespace std;
clock_t s, t;
using ll = long long;

const int M = 2e5 + 10;
int n, m;
ll a[M] = {0}, b[M] = {0}, k;


int main() {
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    // s = clock();

    scanf("%d%d%lld", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= m; i++) {
        scanf("%lld", &b[i]);
        b[i] += b[i - 1];
    }
    int l = upper_bound(a, a + n + 1, k) - a - 1;
    // printf("%d)", l);
    int r = upper_bound(b, b + m + 1, k - a[l]) - b - 1;
    int num = l + r;
    for (int i = l - 1; i >= 0; i--) {
        int tmp = upper_bound(b, b + m + 1, k - a[i]) - b - 1;
        if (num < i + tmp) {
            num = i + tmp;
        }
    }
    // t = clock();
    printf("%d", num);
    return 0;
}

Measured memory_bytes: 6900
#include <iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<cmath>
#include<set>
#define N 1000000007
using namespace std;
using ll = long long;

#define FastIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll maxi(ll a, ll b) {
    return a > b ? a:b;
}



void solve() {
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*c, a*d), max(b*c, b*d));
}

//Driver code
int main() {
    FastIO;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error", "w", stderr);
    // int t;
    // cin>>t;
    // while(t--) {
        solve();
    // }

}


Measured memory_bytes: 3648
import java.util.*;
import java.io.*;

public class Main{

	
	public static void main(String[] args){
	
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		double ans = 0;

		if(N % 2 == 0){
			ans = 1.0 / 2.0;
		}
		else{
			ans = (N / 2 + 1) / (double)N;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(let* ((s (read-line))
	   (n (length s)))
  (princ (aref s 0))
  (princ (- n 2))
  (princ (aref s (1- n))))


Measured memory_bytes: 6452
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
using ll = long long;
static const int MAX_N = 100;
static const int MAX_V = 100;

int k,x;
int main(){
    cin >> k >> x;
    for(int i=0;i<2*k-1;i++){
        if(x-k+1>=-1000000 && x+k+1<=1000000){
            printf("%d ",x-k+1+i);
        }
    }
    return 0;
}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int ab = Integer.parseInt(strArr[0]);
		int bc = Integer.parseInt(strArr[1]);
		System.out.println(ab * bc / 2);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='A')
        cout<<"T"<<endl;
    if(s[0]=='G')
        cout<<"C"<<endl;
    if(s[0]=='T')
        cout<<"A"<<endl;
    if(s[0]=='C')
        cout<<"G"<<endl;
}


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

int x[100000], y[100000];
int r[18][100000], c[18][100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &x[i]), y[n - i - 1] = INF - x[i];
	int l, q; scanf("%d%d", &l, &q);
	rep(i, n) {
		r[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1;
		c[0][i] = upper_bound(y, y + n, y[i] + l) - y - 1;
	}
	for (int i = 1; i < 18; i++) {
		rep(j, n) {
			r[i][j] = r[i - 1][r[i - 1][j]];
			c[i][j] = c[i - 1][c[i - 1][j]];
		}
	}
	rep(i, q) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		int lb = 0, rb = INF;
		while (lb != rb) {
			int t = (lb + rb) / 2;
			int e = a, f = b;
			if (e > f)e = n - 1 - e, f = n - 1 - f;
			for (int i = 17; i >= 0; i--) {
				if (a < b && (t >> i & 1))e = r[i][e];
				else if (t >> i & 1)e = c[i][e];
			}
			if (e >= f)rb = t;
			else lb = t + 1;
		}
		printf("%d\n", lb);
	}
}

Measured memory_bytes: 15616
x = input()
cur = x[0]
cnt = 0
rle = []
for i in x:
    if i == cur:
        cnt += 1
    else:
        rle.append([cur, cnt])
        cur = i
        cnt = 1
rle.append([cur, cnt])

n = len(rle)
ans = 0
for i, (cur, cnt) in enumerate(rle):
    if cur == "T":
        continue
    if i+1 < n:
        nxt, nxt_cnt = rle[i+1]
        if cnt <= nxt_cnt:
            ans += cnt
        else:
            ans += nxt_cnt
            if i+2 < n:
                rle[i+2][1] += cnt-nxt_cnt
print(len(x) - 2*ans)

Measured memory_bytes: 60364
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#include <map>
#define ll long long 
#define PI 3.14159265358979323846
#define INF 10000000000
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N, con = 0;
	cin >> N;
	vector<ll> a(N+1);
	for (ll i = 1; i < N + 1; i++) {
		cin >> a[i];
		if (i % 2 != 0 && a[i] % 2 != 0) con++;
	}
	cout << con << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, m, r;
ll dp[210][210];
vector<int> vi;

int main() {
	rep(i, 210)rep(j, 210) {
		if (i != j)dp[i][j] = INF;
	}
	cin >> n >> m >> r;
	rep(i, r) {
		int num;
		cin >> num;
		num--;
		vi.push_back(num);
	}
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		dp[a][b] = c;
		dp[b][a] = c;
	}
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	ll ans = INF;
	sort(ALL(vi));
	do {
		bool f = 1;
		ll num = 0;
		rep(i, r - 1) {
			num += dp[vi[i]][vi[i + 1]];
		}
		if(f)ans = min(ans, num);
	} while (next_permutation(ALL(vi)));
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int n;
  cin >> n;
  ll int a[100000];
  ll int sum = 0;
  ll int sum2 = 0;
  REP(i, n){
    cin >> a[i];
    sum += a[i];
    if(i%2 == 1) sum2 += a[i];
  }
  ll int x1 = sum - 2 * sum2;
  cout << x1 << " ";
  ll int tmp = x1;
  REP(i, n-1){
    cout << 2 *a[i] - tmp << " ";
    tmp = (2 * a[i] - tmp);
  }
  cout << endl;


}

Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
#define N 1010
char a[N];
char b[N];
int dp[N][N];
//int LCS(int i, int j){
//    if(i == -1 || j == -1) return 0;
//    if(a[i] == b[j]) return LCS(i-1, j-1) + 1;
//    else return LCS(i-1, j) > LCS(i, j-1) ? LCS(i-1, j) : LCS(i, j-1);
//}
int main(){
    int k;
    scanf("%d", &k);
    while(k--){
        scanf("%s", a);
        scanf("%s", b);
        int n = strlen(a);
        int m = strlen(b);
        for(int i = n-1; i >= 0; i--) a[i+1] = a[i];
        for(int i = m-1; i >= 0; i--) b[i+1] = b[i];
        int max = n > m ? n : m;
        for(int i = 0; i <= max; i++) dp[0][i] = dp[i][0] = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(a[i] == b[j]) dp[i][j] = dp[i-1][j-1] + 1;
                else {
                    dp[i][j] = dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1];
                }
            }
        }
        printf("%d\n", dp[n][m]);
        //printf("%d\n", LCS(strlen(a)-1, strlen(b)-1));
    }
    return 0;
}


Measured memory_bytes: 6636
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define MOD 1000000007;

void solve(){
  int n; cin >> n;
  long long ans = 1;
  vector<int> pn;
  map<int, int> mp;
  for(int i = 2; i <= n; ++i){
    int cnt = 0;
    for(int j = 1; j <= i; ++j){
      if(i % j == 0)cnt++;
    }
    if(cnt == 2) pn.push_back(i);
  }
  for(int i = 2; i <= n; ++i){
    int tmp = i;
    while(tmp !=1){
      for(auto p : pn){
        if(tmp%p == 0) {
          mp[p]++;
          tmp/=p;
          if(tmp == 1)break;
        }
      }
    }
  }
  for(auto m: mp){
    ans *= (m.second+1);
    ans %= MOD;
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0; 
}

Measured memory_bytes: 3600
import Control.Monad
main = do
    a <- replicateM 5 readLn
    let s = sum (map ((*10) . (flip div 10) . (+9)) a)
    let m = maximum $ 0:[10 - (x `mod` 10) | x <- a , x `mod` 10 > 0]
    print $ s - m

Measured memory_bytes: 508
package main

import (
        "fmt"
        "strconv"
)

func solution(n int) string {
        t := strconv.Itoa(n)
        ans := ""

        switch t[len(t)-1] {
        case '2', '4', '5', '7', '9':
                ans = "hon"
        case '0', '1', '6', '8':
                ans = "pon"
        case '3':
                ans = "bon"
        }
        return ans
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

Measured memory_bytes: 1756
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

fulset = set(list(slist))
Sset = set(list(S))
kouho = fulset-Sset

ans = "None"
if len(kouho)!=0:
    ans = min(kouho)
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3956