akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int dx[62], Tlen, Plen;
string T, P;

int suffix(char c) {
    if ('0' <= c && c <= '9') {
        return (c - 48);
    }
    else if ('a' <= c && c <= 'z') {
        return (c - 87);
    }
    else if ('A' <= c && c <= 'Z') {
        return (c - 29);
    }
}

void init() {
    Tlen = T.size();
    Plen = P.size();
    for (int i = 0; i < 62; i++)
        dx[i] = -1;
    for (int i = Plen - 2, v = 1; i >= 0; i--, v++) {
        if (dx[suffix(P[i])] == -1) {
            dx[suffix(P[i])] = v;
        }
    }
    for (int i = 0; i < 62; i++) {
        if (dx[i] == -1) {
            dx[i] = Plen;
        }
    }
}

int main() {
    cin >> T >> P;
    init();

    int pos = Plen - 1;
    while (pos < Tlen) {
        for (int i = 0; i < Plen; i++) {
            if (T[pos - i] != P[Plen - i - 1]) {
                pos = (pos - i) + max(dx[suffix(T[pos - i])], i + 1);
                break;
            }
            if (i == Plen - 1) {
                cout << pos - i << endl;
                pos++;
            }
        }
    }
    
    return 0;
}

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

n = readline().rstrip().decode()[::-1]
memo = ['2', '4', '5', '7', '9']
memo1 = ['0', '1', '6', '8']
if n[0] in memo:
    print('hon')
elif n[0] in memo1:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 61664
import sys
def input(): return sys.stdin.readline()


from collections import deque
h, w = map(int, input().split())
a, b = map(int, input().split())
c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = [list(input()) for i in range(h)]
now = 0
dd = [(-1, 0), (1, 0), (0, 1), (0, -1)]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            de = deque([(i, j)])
            s[i][j] = now
            while de:
                x, y = de.popleft()
                for p, q in dd:
                    if 0 <= x + p < h and 0 <= y + q < w and s[x + p][y + q] == ".":
                        s[x + p][y + q] = now
                        de.append((x + p, y + q))
            now += 1
st = s[a][b]
en = s[c][d]
es = [set() for i in range(now)]
for i in range(h):
    for j in range(w):
        if s[i][j] != "#":
            for p in range(-2, 3):
                for q in range(-2, 3):
                    if 0 <= i + p < h and 0 <= j + q < w and s[i + p][j + q] != "#":
                        es[s[i][j]].add(s[i + p][j + q])
                        es[s[i + p][j + q]].add(s[i][j])
from heapq import heappush, heapify, heappop


def dijkstra(s):
    INF = 1 << 32
    d = [INF] * now  # 頂点sからの最短距離
    v = -1
    que = [(0, s)]
    heapify(que)
    d[s] = 0
    while que:
        p = heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for e in es[v]:
            if d[e] > d[v] + 1:
                d[e] = d[v] + 1
                heappush(que, (d[e], e))
    return d[en] if d[en] < INF else -1


print(dijkstra(st))


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

int find(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int N , A , B;
	cin >> N >> A >> B;
	int c = 0;
	for (int i = 1; i <= N; i++) {
		int sum = find(i);

		if (A <= sum && sum <= B) {
			c += i;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
if a == 1 and b == 2:
    print(3)
elif a == 1 and b == 3:
    print(2)
elif a == 2 and b == 1:
    print(3)
elif a == 2 and b == 3:
    print(1)
elif a == 3 and b == 1:
    print(2)
elif a == 3 and b == 2:
    print(1)    

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


struct ModInt{
    ll a;
    ModInt() : a(0) {}
    ModInt(ll x) {
        x%=MOD;
        if(x<0) x+=MOD;
        a=x;
    }

    ModInt operator+=(const ModInt p){
        a+=p.a;
        if( a>=MOD ) a-=MOD;
        return *this;
    }
    ModInt operator-=(const ModInt p){
        a-=p.a;
        if(a<0) a+=MOD;
        return *this;
    }
    ModInt operator*=(const ModInt p){
        a=(a*p.a)%MOD;
        return *this;
    }
    ModInt operator/=(const ModInt p){
        *this*=p.inverse();
        return *this;
    }

    ModInt operator+(const ModInt p){
        ModInt x(a);
        return x+=p;
    }
    ModInt operator-(const ModInt p){
        ModInt x(a);
        return x-=p;
    }
    ModInt operator*(const ModInt p){
        ModInt x(a);
        return x*=p;
    }
    ModInt operator/(const ModInt p){
        ModInt x(a);
        return x*=p.inverse();
    }

    ModInt operator=(ll p){
        p%=MOD;
        if(p<0) p+=MOD;
        a=p;
        return *this;
    }

    bool operator==(const ModInt p){
        return a==p.a;
    }

    bool operator!=(const ModInt p){
        return a!=p.a;
    }

    ModInt pow(ll N) const{
        ModInt ans(1),p(a);
        while(N>0){
            if(bit(N,0)){
                ans*=p;
            }
            p*=p;
            N>>=1;
        }
        return ans;
    }
    ModInt inverse() const{
        return pow(MOD-2);
    }

};

ModInt Mr(ll p){
    p%=MOD;
    if(p<0) p+=MOD;
    ModInt x(p);
    return x;
}



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

    int N;
    cin>>N;
    vector<ll> x(N);
    for(int i=0;i<N;i++) cin>>x[i];
    ll now=1;
    for(int i=0;i<N;i++){
        if(x[i]>=now){
            x[i]=now;
            now+=2;
        }else{
            continue;
        }
    }
    ModInt ans(1);
    ll count=0;
    for(int i=0;i<N;i++){
        if(x[i]%2==1) count++;
        else{
            count++;
            ans*=Mr(count);
            count--;
        }
    }
    while(count!=0){
        ans*=Mr(count);
        count--;
    }
    cout<<ans.a<<endl;

}

Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);

        HashMap<String,Integer> blueCards = initMap();
        HashMap<String,Integer> redCards = initMap();

        int ans = 0;

        for (Map.Entry<String, Integer> entry : blueCards.entrySet()) {
            String key = entry.getKey();
            int val = entry.getValue();
            int thisPoint = 0;
            if (redCards.containsKey(key)) {
                thisPoint = val - redCards.get(key);
            } else {
                thisPoint = val;
            }
            if (thisPoint > ans) ans = thisPoint;
        }
        System.out.println(ans);
        sc.close();
    }

    public static HashMap<String, Integer> initMap(){
        HashMap<String,Integer> cards = new HashMap<>();
        IntStream.range(0,sc.nextInt())
                .forEach(i->{
                    String key = sc.next();
                    int val = 0;
                    if (cards.containsKey(key)){
                        val = cards.get(key);
                        cards.replace(key,val+1);
                    }else{
                        cards.put(key, 1);
                    }
                });
        return cards;
    }
}

Measured memory_bytes: 26836
#include <stdio.h>

int n, k, q;
int a[100010];
int main(void) {
	scanf("%d %d %d", &n, &k, &q);
	for (int i = 1; i <= q; i++) {
		int x;
		scanf("%d", &x);
		a[x]++;
	}

	for(int i = 1; i <= n; i++) {
		if (k - q + a[i] > 0) printf("Yes\n");
		else printf("No\n");
	}
}

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

#define int long long
signed main(){
    string s; int n,q;
    cin >> n >> s >>q;
    int k[q];
    for(int i=0;i<q;i++){
        cin >> k[i];
    }
    
   
    int b=0;
    int a=0;
  
    int x;
    int y;
    int x0;
    int ans;
 
    for(int i = 0;i<q;i++){
    
        x=0;
        a=0;
        b=0;
        ans=0;
        for(int j=0;j<s.size();j++){
            if(s[j]=='D')a++;
            else{
                if(s[j]=='M'){
                    b++;
                    x+=a;
                }
                else{
                    if(s[j]=='C')ans+=x;
                }
            }
            if(j>k[i]-2){
                if(s[j-k[i]+1]=='D'){
                    a--;
                    x-=b;
                }
                else if(s[j-k[i]+1]=='M')b--;

                
            }

        }
        cout << ans << endl;

    }
   
 
    return 0;

}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long N,k,sum=0;
 cin >> N >> k;
 vector<long long> Hi(N);
 for (int i = 0; i < N; i++)
   cin >> Hi.at(i);
 sort(Hi.begin(),Hi.end());
 while(1){
   k--;
   if(Hi.size()==0||k<0)
     break;
   Hi.pop_back();
 }
 for (int i = 0; i < Hi.size(); i++)
   sum+=Hi.at(i);
 cout<<sum<<endl;
}

Measured memory_bytes: 1792
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let n: usize = read();
    let mut v: Vec<i32> = read_vec();
    let ans:i32 = v.iter().sum::<i32>() - n as i32;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
int main()
{
	char a[10]={};
	int c,i,leap=0;
	while(gets(a)){
		c=strlen(a);
		for(i=0;i<c;i++){
			if(a[i]==a[i+1]){
				leap=1;
				break;
			}
		}if(leap==1){
			printf("Bad\n");
		}else{
			printf("Good\n");
		}leap=0;
	}
}

Measured memory_bytes: 128
import sys

a=[]
for t in range(4):
    a.append([])
    for f in range(3):
        a[t].append([])
        for r in range(10):
            a[t][f].append(0)

lines = [line for line in sys.stdin]

n = lines[0]

for l in lines[1:]:
    b, f, r, v  = map(int,l.split())
    b -= 1
    f -= 1
    r -= 1
    a[b][f][r] += v

for i,t in enumerate(a):
    for f in t:
        print (" " +" ".join(map(str,f)))
    if len(a) != i +1:
        print ('#'*20)

Measured memory_bytes: 6460
// https://atcoder.jp/contests/abc130/tasks/abc130_a

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int X, A;
  cin >> X >> A;

  cout << (X < A ? 0 : 10) << '\n';
  return 0;
}


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

int main()
{
	int a[10001];
	a[0] = 0;
	a[1] = 2;
	for(int i=2;i<10001;i++)
	{
		a[i] = a[i-1] + i;
	}

	int n;
	while(cin >> n)
	{
		cout << a[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = in.nextLine();
        while (!".".equals(s)) {
            //System.out.println("GET: " + s);
            String t = in.nextLine();

            if (s.equals(t)) {
                out.println("IDENTICAL");
                s = in.nextLine();
                continue;
            }

            List<String> st = parse(s, false), tt = parse(t, false), sk = parse(s, true), tk = parse(t, true);
            if (!sk.equals(tk) || st.size() != tt.size()) {
                out.println("DIFFERENT");
                s = in.nextLine();
                continue;
            }

            int cnt = 0;
            for (int i = 0; i < st.size(); i++) {
                if (!st.get(i).equals(tt.get(i))) cnt++;
            }

            out.println(cnt == 0 ? "IDENTICAL" : cnt == 1 ? "CLOSE" : "DIFFERENT");


            s = in.nextLine();
        }
        out.flush();
    }

    private static List<String> parse(String s, boolean init) {
        List<String> res = new ArrayList<>();
        boolean q = init;
        StringBuilder sb = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (c == '"') {
                if (q) {
                    res.add(sb.toString());
                    q = false;
                } else {
                    sb.setLength(0);
                    q = true;
                }
            } else if (q) {
                sb.append(c);
            }
        }
        if (q) {
            res.add(sb.toString());
        }
        return res;
    }

}



Measured memory_bytes: 29596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
int main()
{
    long c[9];
    long sum=0;
    for(long i=0; i<9; i++){
        std::cin >> c[i];
        sum+=c[i];
    }
    if(sum==(c[0]+c[4]+c[8])*3){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    int n = Integer.parseInt(data[0]);
    int x = Integer.parseInt(data[1]);
    int y = Integer.parseInt(data[2]);
    int[][] distArray = new int[n][n];
    Route route = new Route(n);
    route.shortcut(x, y);
    for (int i=0; i<n; i++){
      distArray[i] = route.calcDist(i);
    }
    int[] result = new int[n];
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
        result[distArray[i][j]]++;
      }
    }
    StringBuilder s = new StringBuilder();
    for (int i=1; i<result.length; i++){
      result[i]/=2;
      s.append(result[i]);
      s.append("\n");
    }
    System.out.println(s);
  }
}

class Route{
  List<int[]> nodes;
  Route(int size){
    nodes = new ArrayList<>();
    for (int i=0; i<size; i++){
      if (i==0){
        nodes.add(new int[]{1});
      } else if (i==size-1){
        nodes.add(new int[]{size-1-1});
      } else {
        nodes.add(new int[]{i-1, i+1});
      }
    }
  }
  void shortcut(int idx1, int idx2){
    int[] a = nodes.get(idx1-1);
    int[] b = nodes.get(idx2-1);
    int[] newa = new int[a.length+1];
    int[] newb = new int[b.length+1];
    System.arraycopy(a, 0, newa, 0, a.length);
    System.arraycopy(b, 0, newb, 0, b.length);
    newa[a.length] = idx2-1;
    newb[b.length] = idx1-1;
    nodes.set(idx1-1, newa);
    nodes.set(idx2-1, newb);
  }
  int[] calcDist(int startIdx){
    int[] result = new int[nodes.size()];
    Arrays.fill(result, nodes.size());
    result[startIdx] = 0;
    Map<Integer, int[]> nextNode = new HashMap<>();
    nextNode.put(startIdx, nodes.get(startIdx));
    for (int i=0; !nextNode.isEmpty(); i++){
      Map<Integer, int[]> next = new HashMap<>();
      for (Map.Entry<Integer, int[]> entry : nextNode.entrySet()){
        for (int node : entry.getValue()){
          if (i < result[node]) {
            next.put(node, nodes.get(node));
            result[node] = Math.min(result[node], i + 1);
          }
        }
        nextNode = next;
      }
    }
    return result;
  }
}

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

int main(){
  int A , B ,C ,D;
  cin >> A >> B >>C >> D;

  while(1){
    C -= B; //高橋くんの攻撃
    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D; //青木くんの攻撃
    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }
    
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int N = 1000*100 + 10;
long long a[N] , b[N] , val[N];
int main(){

	long long n , p, num = 0 , pt = 0;
	cin >> n >> p;

	for(int i = 0 ; i < n ; i++){
		cin >> a[i] >> b[i];
		val[i] = (100 - p)*a[i] + p*b[i];
		num += a[i];
	}
	
	num = (100 - p)*num;
	sort(val , val + n);
	
	while(pt < n && num >= val[pt])
	   num -= val[pt++];
	   
	cout << n - pt << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void) {
    int h,w;
    for (;;){
        cin >> h >> w;
        if (!h && !w) break;
        for (int i=0; i<h; i++) {
            cout << string(w,'#') << endl;
        }
        cout << endl;
    }
    return 0;
}

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

int n,m,u,v;
vector<int> edge[110000];

int memo[110000];
bool done[110000];

int dp(int v){
    if(done[v]) return memo[v];
    int ans=0;
    for(int to: edge[v]){
        ans=max(ans,dp(to)+1);
    }
    done[v]=true;
    memo[v]=ans;
    return ans;
}

int main() {
    cin>>n>>m;
    rep(i,m){
        cin>>u>>v;
        edge[u].push_back(v);
    }

    int ans=0;
    for(int v=1;v<=n;v++){
        ans=max(ans,dp(v));
    }
    cout<<ans<<endl;
}

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

"""
しゃくとり法
・前にやったのとか参考にして自力実装
"""
 
N = int(input())
aN = list(map(int, input().split()))

l,r,ans = 0,0,0
sm = xor = 0
# 外ループで左を動かす
while l < N:
    # 内ループは条件を満たす限り右を動かす
    while r < N and sm + aN[r] == xor ^ aN[r]:
        ans += 1
        sm += aN[r]
        xor ^= aN[r]
        r += 1
    # 左右の差分-1
    ans += r - l - 1
    # ※今回はl==rの時whileの条件を確実に満たすので、
    # ここでl==rになることはなく、このif文は本当は必要ない。
    if l == r:
        # 左が右に追いついたら、右も左に合わせて+1する
        r += 1
    else:
        # 左を動かす分の合計を引く
        sm -= aN[l]
        xor ^= aN[l]
    l += 1
print(ans)


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

void fnInput(map<int, int>& rmpCity)
{
  int nCitySiz, nRoadSiz;
  cin >> nCitySiz >> nRoadSiz;

  for (int i = 0; i < nCitySiz; i++)
    rmpCity[i + 1] = 0;

  for (int i = 0; i < nRoadSiz; i++)
  {
    int nFromCity, nToCity;
    cin >> nFromCity >> nToCity;
    rmpCity[nFromCity]++;
    rmpCity[nToCity]++;
  }
}

int fnRoadNumOut(const map<int, int>& cnrmpCity)
{
  for (pair<const int, int> PCity : cnrmpCity)
    cout << PCity.second << endl;
}

int main()
{
  map<int, int> mpCity;

  fnInput(mpCity);
  fnRoadNumOut(mpCity);

  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

if k%2 != 0:
    print((n//k)**3)
    exit()

counter1 = 0
counter2 = 0
for i in range(1, n+1):
    if i%k == 0:
        counter1 += 1
    elif i%k == k//2:
        counter2 += 1

print(counter1**3 + counter2**3)

Measured memory_bytes: 3060
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int n = readln.chomp.to!int;
  enum int ofs = 10;
  int[] t = readln.chomp.split.map!(to!int).map!(a => a * ofs).array;
  int[] u = [0];
  foreach (a; t)
  {
    u ~= u.back + a;
  }
  t ~= 0;
  int[] v = readln.chomp.split.map!(to!int).map!(a => a * ofs).array;
  v ~= 0;
  int[] valid = new int[](u.back + 1);
  valid[] = int.max;
  foreach (i, a; u)
  {
    foreach (j; 0 .. t[i]) {
      valid[a + j] = min(valid[a + j], v[i]);
    }
    foreach (j; 0 .. a + 1)
    {
      valid[a - j] = min(valid[a - j], v[i] + j);
    }
  }
  // foreach (i, a; valid)
  // {
  //   stderr.writeln(i, " : ", a);
  // }
  int w = 0;
  long sum = 0;
  foreach (i, a; valid)
  {
    if (w < a)
    {
      sum += w * 2;
      ++w;
      ++sum;
    }
    else if (w > a)
    {
      --w;
      sum += w * 2;
      --sum;
    } else {
      sum += w * 2;
    }
    // stderr.writeln(i, " : ", w, " ... ", sum, " / ", sum / 2);
  }
  writefln("%.4f", cast(double)sum / (2.0 * ofs * ofs));
}


Measured memory_bytes: 2556
#include "bits/stdc++.h"
using namespace std;

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

    vector<int> ans = {};
    for (int i = 3; i * (i - 1) / 2 <= 100000; i++) {
        ans.push_back(i * (i - 1) / 2);
    }

    bool flag = false;
    int keep = 0;
    for (int i = 0; i < ans.size(); i++) {
        if (N == ans[i]) {
            keep = i;
            flag = true;
        }
    }

    if (N == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << 1 << " " << 1 << endl;
        cout << 1 << " " << 1 << endl;
    }
    else {
        if (flag) {
            int k = keep + 3;
            cout << "Yes" << endl;
            cout << k << endl;

            vector<vector<int>> res(k, vector<int>(0));
            int cnt = 0;
            while (cnt < N * 2) {
                for (int a1 = 0; a1 < k - 1; a1++) {
                    for (int a2 = a1 + 1; a2 < k; a2++) {
                        res[a1].push_back(cnt / 2 + 1);
                        cnt++;
                        res[a2].push_back(cnt / 2 + 1);
                        cnt++;
                    }
                }
            }

            for (int j = 0; j < k; j++) {
                cout << k - 1 << " ";
                for (int l = 0; l < k - 1; l++) {
                    if (l != k - 2) {
                        cout << res[j][l] << " ";
                    }
                    else {
                        cout << res[j][l] << endl;
                    }
                }
            }
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n;
    cin >> n;
    string s;
    while(n!=0){
        n--;
        s += (char)('a'+n%26);
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    int INF = -1e9;
    vector<int> dpk(N + 1, INF), A(M);
    for(int i = 0; i < M; i++) cin >> A[i];
    sort(A.begin(), A.end());
    vector<int> cost(M);
    for(int i = 0; i < M; i++){
        if(A[i] == 1) cost[i] = 2;
        else if(A[i] == 2 || A[i] == 3 || A[i] == 5) cost[i] = 5;
        else if(A[i] == 4) cost[i] = 4;
        else if(A[i] == 6 || A[i] == 9) cost[i] = 6;
        else if(A[i] == 7) cost[i] = 3;
        else cost[i] = 7;
    }
    dpk[0] = 0;
    for(int i = 1; i < N + 1; i++){
        for(int j = 0; j < M; j++){
            if(i - cost[j] >= 0) dpk[i] = max(dpk[i], dpk[i - cost[j]] + 1);
        }
    }
    int keta = dpk[N];
    vector<int> ke(keta);
    int i = 0;
    while(N > 0){
        for(int j = M - 1; j >= 0; j--){
            if(N - cost[j] >= 0 && dpk[N] == dpk[N - cost[j]] + 1){
                ke[i] = A[j];
                i++;
                N -= cost[j];
                break;
            }
        }
    }
    for(int i = 0; i < keta; i++){
        cout << ke[i];
    }
    cout << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; cin>>a>>b;
    if(a%2==0||b%2==0) cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[200001];
	int size;
} max_heap;

void push(data x, max_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key > h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(max_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key > h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key > h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, K, P[200002];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(P[i]));
	
	int ans = 1;
	data d;
	max_heap h[2];
	h[0].size = 0;
	h[1].size = 0;
	for (i = 1; i <= K; i++) {
		d.key = -P[i];
		d.id = i;
		push(d, &(h[0]));
		d.key *= -1;
		push(d, &(h[1]));
	}
	for (i = 1; i <= N - K; i++) {
		while (h[0].obj[0].id < i) pop(&(h[0]));
		while (h[1].obj[0].id < i) pop(&(h[1]));
		
		if (!(h[0].obj[0].id == i && h[1].obj[0].key < P[i+K])) ans++;
		
		d.key = -P[i+K];
		d.id = i + K;
		push(d, &(h[0]));
		d.key *= -1;
		push(d, &(h[1]));
	}
	
	int seq = 1, tmp = 0;
	for (i = 2, P[N+1] = -1; i <= N + 1; i++) {
		if (P[i-1] < P[i]) seq++;
		else {
			if (seq >= K) tmp++;
			seq = 1;
		}
	}
	
	if (tmp > 1) ans -= tmp - 1;
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5588
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(x...)
#endif
using namespace std;

int a, b;

bool isprime(int n){
    if(n == 1)
        return true;
    for(int i = 2; i*i <= n; ++i)
        if(n%i == 0)
            return false;
    return true;
}

void solve(){
    cin >> a >> b;
    vector<int> cdiv;
    for(int i = 1; i*i <= a; ++i){
        if(a%i == 0){
            if(b%i == 0 and isprime(i))
                cdiv.emplace_back(i);
            if(b%(a/i) == 0 and a != i*i and isprime(a/i))
                cdiv.emplace_back(a/i);
        }
    }
    cout << (cdiv.empty() ? 0 : cdiv.size()) << endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3580
s=list(input())
r=list(reversed(s))
acon=0
zcon=0
for i in range(len(s)):
  if s[i]=="A":
    break
  else:
    acon+=1
for i in range(len(s)):
  if r[i]=="Z":
    break
  else:
    zcon+=1
print(len(s)-(acon+zcon))

Measured memory_bytes: 6308
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut ans: usize = 0;
    let mut rest: usize = 0;
    for i in 0..n {
        ans += (rest + a[i]) / 2;
        rest = if a[i] == 0 {
            0
        } else {
            (rest + a[i]) % 2
        };
    }
    ans.to_string()
}


Measured memory_bytes: 3908
X, K, D = [int(x) for x in input().split()]

count = abs(X) // D


if K >= count:
    if count % 2 == 0:
        if K % 2 == 0:
            print(abs(X) % D)
            exit()
        else:
            print(abs((abs(X) % D) - D))
            exit()
    else:
        if K % 2 == 1:
            print(abs(X) % D)
            exit()
        else:
            print(abs((abs(X) % D) - D))
            exit()

if X < 0:
    print(abs(X + (K * D)))
else:
    print(X - (K * D))


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
using namespace std;

int a[22][22];
long long dp[22][2107152];

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

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) cin >> a[i][j];

	dp[0][0] = 1;
	int nnn = 1 << n;
	for (int i = 0; i < n; i++) {
		for (int mask = 0; mask < nnn; mask++) {
			if (__builtin_popcount(mask) != i) continue;
			for (int j = 0; j < n; j++) {
				if (a[i][j] && (mask & (1 << j)) == 0) {
					int newMask = mask | (1 << j);
					dp[i + 1][newMask] += dp[i][mask];
					if (dp[i + 1][newMask] >= MOD) {
						dp[i + 1][newMask] -= MOD;
					}
				}
			}
		}
	}

	cout << dp[n][(1 << n) - 1];

	return 0;
}

Measured memory_bytes: 309504
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    int cnt[100002] ={};
    rep(i, N) {
        if (a[i] <= 100000){
            cnt[a[i]]++;
        } else {
            cnt[100001]++;
        }
    }
    int ans = 0;
    rep(i, 100001){
        //dump(cnt[i]);
        //dump(i-cnt[i]);
        if (cnt[i] > i) ans += cnt[i] - i;
        else if ( cnt[i] < i) ans += cnt[i];
    }
    ans += cnt[100001];
    cout << ans << endl;



    return 0;
}


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

int main()
{
    int n, out=1,max=0;
    cin >> n;
    for (int i=1;i<=n;++i){
        int cnt=0;
        int j=i;
        while(j%2==0 && j!=0){
            j=j/2;
            ++cnt;
        }
        if (cnt>max){
            out = i;
            max = cnt;
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
ll N, A[1000000];
ll M, V, P;
int main()
{
	cin >> N>>M>>V>>P;
	rep(i, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	reverse(A, A + N);
	
	P--;
	ll ub = N; ll lb = 0;
	while (ub - lb > 1) {
		int mid = (ub + lb) / 2;
		ll ulim = A[mid] + M;
		ll res = 0;
		bool flag = false;
		for (int x = P; x < mid; x++) {
			if (ulim - A[x] < 0) {
				flag = true;
				ub = mid;
				break;
			}
			res += ulim - A[x];
			
		}
		if (flag)continue;
		res += M * ll(P + N - mid);
		if (res >= M * V) {
			lb = mid;
		}
		else {
			ub = mid;
		}
		//cout <<ll(P-1+N - mid) <<" "<<P-1<<" "<<N-mid<<" "<< A[mid] << " " << mid << endl;
	}
	cout << lb+1 << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    lint a,b,c;cin>>a>>b>>c;
    bool ans;
    lint tmp=a+b-c;
    if(tmp>=0)ans=false;
    else{
        if(tmp*tmp>4*a*b)ans=true;
        else ans=false;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << max({10*a+b+c, a+10*b+c, a+b+10*c}) << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < (n - 1) / 2; i++){    //第一轮判断整个s是否是回文串
        if (s[i] != s[n-i-1]){                //如果不是，直接输出并return 0
            cout << "No" << endl;
            return 0;
        }
    }
    int _n = (n-1) / 2;
    for (int i = 0; i < _n / 2; i++){    //第二轮判断前半部分是否是回文串
                                         //记住字符串数组的下标是从0开始的，要记得减一，下同。
        if (s[i] != s[_n-i-1]){          //同理，如果不是，直接输出并return 0
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = (n+3)/2-1; i < n; i++){    //第三轮判断后半部分是否是回文串
        if (s[i] != s[n-i-1]){              //再同理，如果不是，直接输出并return 0
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;    //到最后，那就肯定满足条件，输出"Yes"
    return 0;
}

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

int main(){
  int a, b; cin >> a >> b;
  
  string result="Draw";
  if(a==1){
    if(b!=1){
      result="Alice";
    }
  }else{
    if(b==1){
      result="Bob";
    }else if(a>b){
      result="Alice";
    }else if(b>a){
      result="Bob";
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
class Main
  def self.run
    a, b = read_input
    comparator = Comparator.new(a, b)
    puts comparator.result
  end

  private

  def self.read_input
    gets.split(" ").map {|x| x.to_i}
  end
end

class Comparator
  def initialize(a, b)
    @a = a
    @b = b
  end

  def result
    case
      when @a < @b then "a < b"
      when @a > @b then "a > b"
      else "a == b"
    end
  end
end

Main.run

Measured memory_bytes: 8600
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define sqr(x) ((x) * (x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define fill(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb emplace_back
#define popcnt __builtin_popcount
#define ctz __builtin_ctz

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
template <class T> using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;
    return in;
}

template <class T>
ostream& operator << (ostream &out, vector <T> &a) {
    for (T &i: a) out << i << ' ';
    return out;
}

template <class T>
ostream& operator << (ostream &out, set <T> &a) {
    for (auto &i: a) out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator >> (istream &in, pair <T, U> &p) {
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator << (ostream &out, pair <T, U> &p) {
    out << p.first << ' ' << p.second;
    return out;
}

void fastIO() {
    ios_base:: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
}

ll n, a, b;

signed main() {
    fastIO();

    cin >> n >> a >> b;
    ll ans = n / (a + b) * a;
    ans += min(a, n % (a + b));

    cout << ans;

    return 0;
}

/// ЗАПУСКАЕМ ГУСЯ:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DPredictionAndRestriction solver = new DPredictionAndRestriction();
        solver.solve(1, in, out);
        out.close();
    }

    static class DPredictionAndRestriction {
        int n;
        int k;
        long r;
        long s;
        long p;
        String a;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            n = in.nextInt();
            k = in.nextInt();
            r = in.nextInt();
            s = in.nextInt();
            p = in.nextInt();

            a = in.next();
            long res = solveMe();
            out.println(res);
        }

        private long solveMe() {
            long res = 0;
            int[] choices = new int[k];
            for (int i = 0; i < n; i++) {
                if (i < k || choices[i % k] != a.charAt(i)) {
                    res += winning(a.charAt(i));

                    choices[i % k] = a.charAt(i);
                } else {
                    choices[i % k] = -1;
                }
            }
            return res;
        }

        private long winning(char c) {
            if (c == 'r') {
                return p;
            } else if (c == 's') {
                return r;
            } else {
                return s;
            }
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24660
if __name__ == '__main__':
    N = int(input())
    V = list(map(int, input().rstrip().split()))
    C = list(map(int, input().rstrip().split()))

    # 価値とコストの差が正になるものだけを全部足す
    ans = 0
    for i in range(N):
        if V[i] - C[i] > 0:
            ans += V[i] - C[i]

    print(ans)


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

using namespace std;
typedef long long ll;

void solve()
{
   ll x,y;
   cin>>x>>y;
   string ans="No";
   for(int i=0;i<=x;i++)
   {
       ll temp=x-i;
       if(i*4+temp*2==y)
       {
           ans="Yes";
           break;
       }

   }
   cout<<ans<<endl;

}
int main()
{

    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }



}





Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define REP(i, b, e) for (int i = (b); i < (e); i++)
#define rep(i, n) REP(i, 0, n)

#define dump(x) cout << #x << ":" << x << endl

int n;

typedef enum {
	TOP,
	BOTTOM,
	FRONT,
	BACK,
	RIGHT,
	LEFT
} Surface;

class Dice
{
private:
	int surface[6];
public:
	Dice() {
		surface[TOP] = 1;
		surface[FRONT] = 2;
		surface[RIGHT] = 3;
		surface[BOTTOM] = 6;
		surface[BACK] = 5;
		surface[LEFT] = 4;
	}

	void rotate(Surface a, Surface b, Surface c, Surface d)
	{
		int buf = surface[a];
		surface[a] = surface[b];
		surface[b] = surface[c];
		surface[c] = surface[d];
		surface[d] = buf;
	}

	void north()	{ rotate(TOP, FRONT, BOTTOM, BACK); }
	void east()		{ rotate(TOP, LEFT, BOTTOM, RIGHT); }
	void west()		{ rotate(TOP, RIGHT, BOTTOM, LEFT); }
	void south()	{ rotate(TOP, BACK, BOTTOM, FRONT); }
	void right()	{ rotate(FRONT, RIGHT, BACK, LEFT); }
	void left()		{ rotate(FRONT, LEFT, BACK, RIGHT); }

	int operator[](Surface idx)
	{
		return surface[idx];
	}
};

int main()
{
	while (cin >> n, n) {
		Dice dice;
		int ans = dice[TOP];
		rep(t, n) {
			string direc;
			cin >> direc;
			if (direc == "North")
				dice.north();
			else if (direc == "East")
				dice.east();
			else if (direc == "South")
				dice.south();
			else if (direc == "West")
				dice.west();
			else if (direc == "Right")
				dice.right();
			else if (direc == "Left")
				dice.left();
			ans += dice[TOP];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a == b) {
		if (a == c)cout << 1 << endl;
		else cout << 2 << endl;
	}
	else if (a == c)cout << 2 << endl;
	else if (b == c)cout << 2 << endl;
	else cout << 3 << endl;
}

Measured memory_bytes: 256
N,T=map(int,input().split())
t=list(map(int,input().split()))
ans=0
if N==1:
  print(T)
else:
  for i in range(1,N):
    if i==0:
      continue
    if i==N-1:
      if t[i]-t[i-1]>T:
        ans+=T
      else:
        ans+=(t[i]-t[i-1])
      ans+=T
      break
    if t[i]-t[i-1]>T:
      ans+=T
    else:
      ans+=(t[i]-t[i-1])
  print(ans)

Measured memory_bytes: 30836
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n, m;
    cin >> n;
    vector<int> d(n);
    rep(i, n)cin >> d.at(i);
    cin >> m;
    vector<int> t(m);
    rep(i, m)cin >> t.at(i);
    sort(all(d));
    sort(all(t));
    int di = 0, ti = 0;
    bool ans = false;
    while(!ans && di < n && ti < m){
        if(d[di] == t[ti])ti++;
        di++;
        if(ti >= m)ans = true;
    }
    if(ans)cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 1920
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

Int inv[3000];
Int fact[3000];
Int invfact[3000];
Int comb(Int n, Int r) {
    if(n < r)
        return 0;
    if(n < 0 || r < 0)
        return 0;
    return fact[n] * (invfact[n-r] * invfact[r] %MOD)%MOD;
}
int main(void) {
    int N,K;

    cin>>N>>K;

    inv[1] = 1;
    fact[0] = fact[1] = 1;
    invfact[0] = invfact[1] = 1;

    for(int i = 2;i <= N;i++) {
        fact[i] = i*fact[i-1] % MOD;
        inv[i] = MOD - (MOD / i)*inv[MOD % i] % MOD;
        invfact[i] = invfact[i-1]*inv[i] % MOD;
    }

    for(Int i = 1;i <= K;i++) {
        Int sum = 0;
        sum = comb(N-K+1,i)*comb(K-1,i-1)%MOD;
        cout<<sum<<endl;
    }

    return 0;
}






Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,y,z,t;
    scanf("%d %d %d",&x,&y,&z);
    t=x;
    x=y;
    y=t;
    t=x;
    x=z;
    z=t;
    printf("%d %d %d",x,y,z);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, m; cin >> n >> m;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  ll sum = accumulate(All(v), 0);
  sort(All(v), greater<int>());
  bool f = true;
  rep(i, m){
    if(v[i]*4*m < sum)f = false;
  }
  if(f)cout << "Yes" << endl;
  else cout << "No" << endl;
  system("pause");
}


Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

int n, k, i, ans, x, bg;

int gcd(int a, int b) {
    if (a < b) swap(a, b);

    while (b > 0) {
        a %= b;
        swap(a, b);
    }

    return a;
}

int main()
{
    //freopen("test.in","r",stdin);

    cin >> n >> k; ans = 0;
    for (i = 1; i <= n; i++) {
        cin >> x;
        ans = gcd(ans, x);
        bg = max(bg, x);
    }

    if (k % ans == 0 && bg >= k)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";



    return 0;
}


Measured memory_bytes: 256