akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n],
    }

    let asum: usize = a.iter().sum();
    let bsum: usize = b.iter().sum();

    if asum > bsum {
        println!("No");
        return;
    }

    let mut atemp = 0;
    let mut btemp = 0;
    for i in 0..n {
        if a[i] > b[i] {
            atemp += a[i] - b[i];
        } else {
            btemp += ((b[i] - a[i]) + 1) / 2;
        }
    }

    if atemp <= bsum - asum && btemp <= bsum - asum {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)
struct edge
{
    int t;
    int w;
};

vector<edge> E[pow10(5)];
int V[pow10(5)];
int flg[pow10(5)];

void rec(int v)
{
    for (auto e : E[v])
    {
        if (flg[e.t] == 0)
        {
            V[e.t]   = (V[v] + (e.w % 2 == 1)) % 2;
            flg[e.t] = true;
            rec(e.t);
        }
    }
}

void solve()
{
    int N;
    cin >> N;

    REP0 (i, N)
    {
        int u, v, w;
        cin >> u >> v >> w;
        E[u].push_back(edge{v, w});
        E[v].push_back(edge{u, w});
    }

    flg[1] = 1;
    rec(1);
    REP1(i, N)
    {
        cout << V[i] << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

public class Main {
    String fileName = "";


    public void solve() throws IOException {
        long a = nextInt();
        long b = nextInt();
        long c = nextInt();
        long d = nextInt();
        long e = nextInt();
        long f = nextInt();
        long max = -1;
        long sum = 0;
        long sug = 0;
        long lastsum = 1;
        for (long water1 = 0; water1 <= f; water1 += 100 * a) {
            for (long water2 = 0; water2 <= f; water2 += 100 * b) {
                for (long sugar1 = 0; sugar1 <= f; sugar1 += c) {
                    for (long sugar2 = 0; sugar2 <= f; sugar2 += d) {
                        if (water1 + water2 + sugar1 + sugar2 <= f
                                && (sugar1 + sugar2) * (100 + e) <= e * (water1 + water2 + sugar1 + sugar2)
                                && (sugar1 + sugar2) * 100 * lastsum >= max * (water1 + water2 + sugar1 + sugar2)) {
                            max = (sugar1 + sugar2) * 100;
                            lastsum = water1 + water2 + sugar1 + sugar2;
                            sum = water1 + water2 + sugar1 + sugar2;
                            sug = sugar1 + sugar2;
                        }
                    }
                }
            }
        }
        if (sum == 0) {
            sum = a * 100;
        }
        out.println(sum + " " + sug);
    }

    public void run() {
        try {
            if ("".equals(fileName)) {
                br = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                br = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<math.h>
#include<set>
using namespace std;

void itsvgg() 
{
    ios::sync_with_stdio(0);cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt", "w", stdout);
    #endif
} 



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);	
    itsvgg();
	
	int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];

    double dp[n+1][n+1];
    dp[0][0]=1;

    for(int i=1;i<n+1;i++)
    {
    	//cout<<p[i-1]<<endl;
    	dp[0][i]=dp[0][i-1]*(1-p[i-1]);
    	dp[i][i]=dp[i-1][i-1]*p[i-1];	
    	for(int j=1;j<i;j++)
    	{
    		dp[j][i]=dp[j][i-1]*(1-p[i-1]);
    		dp[j][i]+=dp[j-1][i-1]*p[i-1];
    		//cout<<dp[j][i]<<" ";
    	}

    }
    /*for(int i=0;i<n+1;i++)
    {
    	for(int j=0;j<=i;j++)
    		cout<<dp[j][i]<<" ";
    	cout<<endl;
    }*/
    double total=0;
    for(int i=(n+1)/2;i<=n;i++)
    		total+=dp[i][n];
    cout.precision(15);	
    cout<<total<<endl;	
}


Measured memory_bytes: 49304
import java.io.*; 
import java.util.*;
import java.util.Map.Entry;

public class Main {

	

	public static void main(String[] args) throws IOException {
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		StringTokenizer ana = new StringTokenizer(jk.readLine()) ;
		int  n =Integer.parseInt(ana.nextToken()) ; 
		int siz = Integer.parseInt(ana.nextToken())  ;
		long v[]= new long[n] ; int w []=new int[n] ; 
		for(int i=0 ; i<n ;i++)
		{
			ana = new StringTokenizer(jk.readLine()) ;
			w[i] = Integer.parseInt(ana.nextToken()) ; 
			v[i]= Long.parseLong(ana.nextToken())  ;
		}
		long dp[][]= new long[n][siz+1]  ;
		for(int i=0 ;i<n ;i++)
		{
			for(int j=0 ; j<siz+1 ;j++) dp[i][j]=-1 ; 
		}
		
		dp[0][0]=0 ; dp[0][w[0]]= v[0] ; 
		for(int i=1 ; i<n ;i++)
		{
			for(int we=0 ;we<=siz ;we++ )
			{
				long y = dp[i-1][we] ; 
				if(y!=-1)
				{
					dp[i][we]= Long.max(dp[i][we], dp[i-1][we]) ;
					if(we+w[i]<=siz) dp[i][we+w[i]] = Long.max(dp[i][we+w[i]], dp[i-1][we]+v[i]) ; 
				}
			}
		}
		long res = 0 ;
		for(int j=0 ; j<=siz ;j++) res = Long.max(res, dp[n-1][j]) ;
		out.println(res);
		
		out.flush(); 
	}

}




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

#define pb push_back
#define left lleft
#define right rright
#define lld long long

using namespace std;

int N;
int a[102],cnt[102];

void impossible(){
	puts("Impossible");
	exit(0);
}

int main(){
	scanf("%d",&N);
	int big = 0;
	for(int i=1; i<=N; i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		big = max(big,a[i]);
	}
	if(cnt[big] < 2) impossible();
	for(int i=0; i<=big; i++){
		if(cnt[max(i,big-i)] == 0) impossible();
		cnt[max(i,big-i)]--;
	}
	for(int i=1; i<N; i++){
		if(cnt[i] == 0) continue;
		if(i < max(big/2,big-big/2)+1) impossible();
	}
	puts("Possible");

	return 0;
}

Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N,Q = list(map(int,input().split()))
    edges = [[] for i in range(N+1)]
    for i in range(N-1):
        a,b = list(map(int,input().split()))
        edges[a].append(b)
        edges[b].append(a)

    add = [0]*(N+1)
    for i in range(Q):
        p,x = list(map(int,input().split()))
        add[p] += x

    stack = [(1,0)]
    ans = [0]*(N+1)
    not_checked = [True]*(N+1)
    while stack:
        v,cnt = stack.pop()
        ans[v] = cnt+add[v]
        not_checked[v] = False
        for edge in edges[v]:
            if not_checked[edge]:
                stack.append((edge,ans[v]))

    for i in range(1,N):
        print(ans[i],end=" ")
    print(ans[N])

if __name__ == "__main__":
    main()

Measured memory_bytes: 101504
#include<iostream>
using namespace std;
char c[101][101];
int d[101][101];
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=a;i++)
	{
		for(int o=1;o<=b;o++)
		{
			cin>>c[i][o];
			if(c[i][o]=='#')
			{
				d[i][o]=-100;
				d[i+1][o]+=1;
				d[i+1][o+1]+=1;
				d[i+1][o-1]+=1;
				d[i][o+1]+=1;
				d[i][o-1]+=1;
				d[i-1][o]+=1;
				d[i-1][o+1]+=1;
				d[i-1][o-1]+=1;
			}
		}
	}
	for(int i=1;i<=a;i++)
	{
		for(int o=1;o<=b;o++)
		{
			if(d[i][o]<0)
				cout<<"#";
			else
				cout<<d[i][o];
		}
		cout<<"\n";
	}
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

string s;
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> s;
    cout << string((int)s.size(), 'x') << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(void){
	int i, n, new_n;
	char oct_n_str[MAX];
	while(1){
		scanf("%d",&n);
		if(n == 0){ break; }
		sprintf(oct_n_str, "%o", n);
		for(i = 0; oct_n_str[i] != 0; i++){
			if(oct_n_str[i] >= '5'){
				putchar(oct_n_str[i] + 2);
			}else if(oct_n_str[i] >= '4'){
				putchar(oct_n_str[i] + 1);
			}else{
				putchar(oct_n_str[i]);
			}
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int k, d[50][100005];

int f(int p, int q) {
	int i, mn = 1e9;
	if (p > 45) return 1e9;
	if (q == 0) return p;
	if (d[p][q]) return d[p][q];
	d[p][q] = 1e9;
	for (i = 0; i <= 9; i++)
		mn = min(mn, f(p + i, (q * 10 + i) % k));
	return d[p][q] = mn;
}

int main()
{
	int i, mn = 1e9;
	cin >> k;
	for (i = 1; i <= 9; i++) mn = min(mn, f(i, i % k));
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 224384
N, Q = map(int, input().split())
S = input()
a = [0]*(N+1)
for i in range(N):
    if S[i:i+2] == 'AC':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = a[i]
for _ in range(Q):
    b, c = map(int, input().split())
    print(a[c-1]-a[b-1])    


Measured memory_bytes: 11616
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll x;
    cin >> x;
    int a=x/100;
    int b=x%100;
    if(5*a >= b){
        cout << "1" << endl;
        return 0;
    }else{
        cout << "0" << endl;
        return 0;
    }
}

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

int main (){
  char a,b;
  cin>>a>>b;
  if(a>b){
    cout<<'>'<<endl;
  }
  if(a==b){
    cout<<'='<<endl;
  }
  if(a<b){
    cout<<'<'<<endl;
  }
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long N, D, X, Y, k=0;
    cin >> N >> D;
    for (int i = 0; i < N; i++)
    {
        cin >> X >> Y;
        if (X*X + Y*Y <= D*D)
        {
            k++;
        }
    }
    cout << k;
    return 0;
}


Measured memory_bytes: 3584
N = int(input())
S = input()
count = 0

for i in range(0, 10):
    if str(i) in S:
        idx = S.index(str(i))
        for j in range(0, 10):
            if str(j) in S[idx+1:]:
                idx2 = S[idx+1:].index(str(j)) + idx + 1
                for k in range(0, 10):
                    if str(k) in S[idx2+1:]:
                        count += 1

print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int N;
    cin >> N;
    int okane = N % 1000;
    int oturi = 1000 - okane;
    if (oturi == 1000) {
        cout << 0 << endl;
    } else {
        cout << oturi << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long H, long long W, long long d){

}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long d;
    scanf("%lld",&d);
    solve(H, W, d);
	if(d%2==1){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j)%2){
					cout << "R";
				}
				else{
					cout << "G";
				}
			}
			cout << endl;
		}
		return 0;
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			int x=(i+j)/d;
			int y=(i+W-j)/d;
			if(x%2){
				if(y%2){
					cout << "R";
				}
				else{
					cout << "G";
				}
			}
			else{
				if(y%2){
					cout << "B";
				}
				else{
					cout << "Y";
				}
			}
		}
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 512
//
//  main.cpp
//
// g++ -std=c++14 main.cpp
//

//#include "main.hpp"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;

int main(void){
    int INF = 1e9;
    int v, e, t, d[205][205];
    cin >> v >> e >> t;
    
    vector<int> r;
    for (int i = 0; i < t; i++) {
        int tmp;
        cin >> tmp;
        r.push_back(tmp - 1);
    }
    
    for (int i = 0; i < v; i++) {
        for (int j = 0; j < v; j++) {
            if (i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }
    
    for (int i = 0; i < e; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        d[a][b] = d[b][a] = c;
    }
    
    //warshall_floyd
    for (int k = 0; k < v; k++) {
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    
    sort(r.begin(), r.end());
    
    int mn = 1e9;
    do {
        int tp = 0;
        for (int i = 0; i < t - 1; i++) tp += d[r[i]][r[i + 1]];
        mn = min(mn, tp);
    } while (next_permutation(r.begin(), r.end()));
    
    cout << mn << endl;
}


Measured memory_bytes: 384
# frozen_string_literal: true

# ABC 087 B - Coins

input_a = STDIN.gets.to_i
input_b = STDIN.gets.to_i
input_c = STDIN.gets.to_i
input_x = STDIN.gets.to_i
result = 0

(0..input_a).each do |a|
  (0..input_b).each do |b|
    (0..input_c).each do |c|
      result += 1 if 500 * a + 100 * b + 50 * c == input_x
    end
  end
end

puts result


Measured memory_bytes: 1916
#include <iostream>
#include <stdlib.h>

int count = 0;
int m = 11;
int G[11] = {88573, 29524, 9841, 3280, 1093, 364,121, 40, 13, 4,1};
int m_number = m;
bool first = true;

void insertion_sort(int n, int g, int* A)
{
    if (g > n) {
        m_number--;
    } else if (first == true){
        std::cout << m_number << std::endl;
        for (int i = m - m_number; i < m; i++) {
            std::cout << G[i];
            if (i != m - 1) {
                std::cout << " ";
            } else {
                std::cout << "\n";
            }
        }
        first = false;
    }
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            count++;
        }
        A[j + g] = v;
    }
}

void shell_sort(int n, int* A)
{
    count = 0;
    for (int i = 0; i < m; i++) {
        insertion_sort(n, G[i], A);
    }
}

int main() {
    int n = 0;
    std::cin >> n;
    int A[n] = {};
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    shell_sort(n, A);

    std::cout << count << std::endl;
    for (int i = 0; i < n; i++) {
        std::cout << A[i] << std::endl;
    }
    return 0;
}



Measured memory_bytes: 6968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int a[N];
    rep(i,N){
        cin>>a[i];
        a[i]--;
    }
    int x=0;
    int ans=0;
    rep(i,N){
        ans++;
        x=a[x];
        if(x==1){
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    



}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

// 1-indexed
struct BIT {
    int size;
    int pow2_less;
    vector<int> data;
    BIT(int n): size(n + 1), data(n + 1, 0) {
        pow2_less = 1;
        while ((pow2_less << 1) <= size)
            pow2_less <<= 1;
    }
    void add(int i, int x) {
        while (i < size) {
            data[i] += x;
            i += i & -i;
        }
    }
    int sum(int i) {
        int ret = 0;
        while (i > 0) {
            ret += data[i];
            i -= i & -i;
        }
        return ret;
    }
    // sum(x) >= w となる最小のxを返す
    int lower_bound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = pow2_less; k > 0; k >>= 1) {
            if (x + k < size && data[x + k] < w) {
                w -= data[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

signed main() {
    int N, K;
    cin >> N >> K;
    vi A(N);
    cin >> A;
    vi S = A;
    psum(S);

    vi b(N);
    rep(i, 0, N) {
        b[i] = S[i] - (i + 1) * K;
    }

    vi comp = b;
    comp.push_back(0);
    sort(all(comp));
    comp.erase(unique(all(comp)), comp.end());
    auto getidx = [&](int x) { return lower_bound(all(comp), x) - comp.begin() + 5; };

    BIT bit(N + 10);
    bit.add(getidx(0), 1);

    int ans = 0;
    rep(i, 0, N) {
        int tmp = bit.sum(getidx(b[i]));
        ans += tmp;
        bit.add(getidx(b[i]), 1);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 9472
S = input()
while S:
    if S[-5:] == 'dream' or S[-5:] == 'erase':
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 3188
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
//#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
signed main() {
	int x;
	cin >> x;
	int ans = (x / 500) * 1000;
	x %= 500;
	cout << ans + x / 5 * 5 << endl;
	return 0;
}

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

int n,x,y;
char t[10][10];
int dx[] = {-1,1,0,0};
int dy[] = {0,0,1,-1};

void solve(int x,int y){
	t[y][x] = '0';

	for(int i=0;i<4;i++){
		for(int j=1;j<=3;j++){
			int nx = x + j * dx[i];
			int ny = y + j * dy[i];
			if(nx>=0 && nx<8 && ny>=0 && ny<8 && t[ny][nx]=='1'){
				solve(nx,ny);
			}
		}
	}

}

int main(void){
	cin>>n;
	for(int set=1;set<=n;set++){
		cout<<"Data "<<set<<":"<<endl;
		for(int i=0;i<8;i++){
			cin>>t[i];
		}
		cin>>x>>y;
		solve(x-1,y-1);

		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cout<<t[i][j];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long ll;

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

int main()
{
    ll res=0;
    int k; cin >> k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                res += gcd(gcd(i,j),l);
            }
        }
    }
    cout << res << endl;
}

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

int main()
{
    int n,t;
    cin>>n>>t;
    bool done=false;
    int ans=INT_MAX;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        if(t>=b)
        {
          ans=min(ans,a);
          done=true;
        }
    }
    if(done==false)
    {
        cout<<"TLE"<<endl;
    }
    else
    {
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define EPS 1.0e-8

typedef complex<double> P;
namespace std{bool operator<(const P& a, const P& b){
  return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
}}
double inP(const P& p, const P& q){ return real(conj(p)*q); }
double outP(const P& p, const P& q){ return imag(conj(p)*q); }
struct L : public vector<P> {
  L(const P& a, const P& b){ push_back(a); push_back(b); }
};
typedef vector<P> G;

int ccw(P a, P b, P c){
  b-=a; c-=a;
  if(outP(b,c)>0) return +1;
  if(outP(b,c)<0) return -1;
  if(inP(b,c)<0) return +2;
  if(norm(b)<norm(c)) return -2;
  return 0;
}

G convex_hull(vector<P> &ps){
  int n=ps.size(),k=0;
  sort(ps.begin(),ps.end());
  vector<P> ch(2*n);
  for(int i=0;i<n;ch[k++]=ps[i++])
    while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  for(int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])
    while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])<= 0)--k;
  ch.resize(k-1);
  return ch;
}

double dist(const P& x, const P& y){
  return sqrt((real(x)-real(y))*(real(x)-real(y)) + (imag(x)-imag(y))*(imag(x)-imag(y)));
}

bool check(const P& U, double R, const vector<P>& v){
  rep(i,v.size()){
    double tmp = dist(U, v[i]);
    if(R + EPS < tmp) return false;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<P> ps;
  rep(i,N){
    int x, y;
    cin >> x >> y;
    ps.push_back(P(x,y));
  }

  if(N == 2){
    printf("%.12lf\n", dist(ps[0], ps[1]) / 2.0);
    return 0;
  }

  G cvx = convex_hull(ps);

  double ret = 10000000000;
  double PI = acos(0)*2.0;
  rep(i,cvx.size()){
    rep(j,cvx.size()){
      double a = dist(cvx[i], cvx[j]);
      double R = a/2.0;
      P U = (cvx[j]-cvx[i])/2.0 + cvx[i];
      if(check(U,R,ps)){
        ret = min(ret, R);
      }
    }
  }
  rep(i,cvx.size()){
    rep(j,cvx.size()){
      rep(k,cvx.size()){
        double a = dist(cvx[i], cvx[j]);
        double b = dist(cvx[j], cvx[k]);
        double c = dist(cvx[k], cvx[i]);

        P A = cvx[k];
        P B = cvx[i];
        P C = cvx[j];
        
        P U = a*a*(b*b+c*c-a*a)*A + b*b*(c*c+a*a-b*b)*B + c*c*(a*a+b*b-c*c)*C;
        U /= a*a*(b*b+c*c-a*a) + b*b*(c*c+a*a-b*b) + c*c*(a*a+b*b-c*c);
        
        double R = (a*b*c) / sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
        if(check(U,R,ps)){
          ret = min(ret, R);
        }
      }
    }
  }

  printf("%.12lf\n", ret);
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod=1e9+7;
static const ll INF=1LL<<50;
using namespace std;

int main() {
	int a,b,c;
  cin>>a>>b>>c;
  int maxv=max({a,b,c});
  cout<<a+b+c-maxv<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int N;
string S;
string ansS;
void solve() {
	for (int i = 1; i < N + 1; ++i) {
		if ('o' == S[i]) {
			if ('S' == ansS[i]) {
				ansS += ansS[i - 1];
			}
			else {
				if ('S' == ansS[i - 1]) {
					ansS += "W";
				}
				else {
					ansS += "S";
				}
			}
		}
		else {
			if ('W' == ansS[i]) {
				ansS += ansS[i - 1];
			}
			else {
				if ('S' == ansS[i - 1]) {
					ansS += "W";
				}
				else {
					ansS += "S";
				}
			}
		}
	}
}
int main() {
	cin >> N;
	cin >> S;
	S += S;
	string S[] = { "SS","WW","SW","WS" };
	for (int i = 0; i < 4; ++i) {
		ansS = S[i];
		solve();
		if ((ansS[0] == ansS[N])&&(ansS[1] == ansS[N+1])){
			cout << ansS.substr(0,N)<<endl;
			return 0;
		};
	}
	cout << -1 << endl;
	return 0;
}

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

const int INF = 1001001001;

int first(int n){
    while(n / 10 != 0){
        n /= 10;
    }
    return n;
}

int end(int n){
    return n % 10;
}

int main() {
    int n; cin >> n;
    int ans = 0;
    vector<vector<int>> c(10, vector<int>(10, 0));
    // cout << first(n) << endl;
    for(int i = 1; i <= n; i++){
        c[first(i)][end(i)]++;
    }
    rep(i, 10)rep(j, 10){
        ans += c[i][j]*c[j][i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = []
c = []
a.sort!
for i in 0...a.size
	if(i % 2 == 0)then
		c.push(a[i])
	else
		b.push(a[i])
	end
end
if(c.inject(:+) > b.inject(:+))then
	puts c.inject(:+) - b.inject(:+)
else
	puts b.inject(:+) - c.inject(:+)
end

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

int main() {
  int A; //1234
  cin >> A;
  int B = A % 10;//4
  int C = A % 100 - B;//30
  int D = A % 1000 - C - B;//200
    if(B == C / 10 && B == D / 100)
      cout << "Yes" << endl;
    else if (C == D /10 && C == (A - D - C - B) / 100)
      cout << "Yes" << endl;
      else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
#define itn int
signed main(void){
    int r; cin>>r;
    cout<<3*r*r<<endl;
}


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

using namespace std;

typedef unsigned long long ull;

#define pb push_back
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<vector<double> > v;
        rep(i, n){
            vector<double> d; double p;
            rep(j, n){cin >> p; d.pb(p);}
            v.pb(d);
        }

        double dp[110][110];
        memset(dp, 0, sizeof(dp));
        rep(i, n) dp[0][i] = 1;
        for(int i=1; i <= m; i++){
            for(int j=0; j < n; j++){
                for(int k=0; k < n; k++){
                    dp[i][j] = max(dp[i][j], dp[i-1][k]*v[k][j]);
                }
            }
        }
        double ma = -1.0;
        rep(i, n) ma = max(ma, dp[m-1][i]);
        printf("%.2f\n",ma);
    }
}

Measured memory_bytes: 1472
def make_them_even(H: int, W: int, A: list)->list:
    odds = []
    for h in range(H):
        for w in range(W):
            if h % 2 == 0 and A[h][w] % 2 == 1:
                odds.append((h+1, w+1))
            elif h % 2 == 1 and A[h][W-w-1] % 2 == 1:
                odds.append((h+1, W-w))

    res = []
    for i in range(len(odds) // 2):
        (h1, w1), (h2, w2) = odds[2*i], odds[2*i+1]

        while h1 != h2 or w1 != w2:
            # 目的地に着くまで繰り返す

            # 横方向の目的地をきめる
            if h1 == h2:
                # 縦方向が目標位置なら w2 まで移動する
                target_w = w2
            elif h1 % 2 == 1:
                # 縦方向が目標位置でなく、奇数列なら右端に向かう
                target_w = W
            else:
                # 縦方向が目標位置でなく、偶数列なら左端に向かう
                target_w = 1

            # 横方向の移動を実際に行う。
            step = 1 if w1 < target_w else -1
            while w1 != target_w:
                res.append((h1, w1, h1, w1+step))
                w1 = w1 + step

            # 縦方向の目標位置でないなら、縦方向に一度うごく
            if h1 != h2:
                res.append((h1, w1, h1+1, w1))
                h1 += 1

    return res


if __name__ == "__main__":
    H = 0
    H, W = map(int, input().split())
    A = [[int(s) for s in input().split()] for _ in range(H)]
    ans = make_them_even(H, W, A)
    print(len(ans))
    for a in ans:
        print(' '.join(map(str, a)))


Measured memory_bytes: 43876
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Cubes c = new Cubes(s);
		System.out.println(c.getAns());
	}
}
class Cubes{
	char[] ary;
	Cubes(String s){
		ary = s.toCharArray();
	}
	int getAns(){
		int count0 = 0;
		int count1 = 0;
		for(char c : ary){
			if(c == '0'){
				count0++;
			}else{
				count1++;
			}
		}
		return Math.min(count0, count1) * 2;
	}
}


Measured memory_bytes: 26952
n = int(input())
P = list(map(int, input().split()))
output = 0

for i in range(1, n - 1):
    if P[i - 1] < P[i] < P[i + 1] or P[i + 1] < P[i] < P[i - 1]:
        output += 1

print(output)


Measured memory_bytes: 2940
# Problem A - Range Product

# input
a, b = map(int, input().split())

# calc
if (a==0 or b==0) or (a<0 and b>0) or (a>0 and b<0):
    print("Zero")
elif a>0 and b>0:
    print("Positive")
elif a<0 and b<0:
    nums = abs(b - a) + 1
    if nums%2==1:
        print("Negative")
    else:
        print("Positive")


Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    string s = to_string(i);
    bool flag = true;
    for (int i = 0; i < s.size() / 2; i++) {
      if (s[i] != s[s.size() - i - 1]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int x, a;
    cin >> x >> a;

    cout << (x < a ? 0 : 10) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x) make_pair(x)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {

    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)    cin>>a.at(i);
    vector<int> b(n);
    rep(i,n)    b[i]=a[i];

    sort(all(b));
    int ma1=b[n-1];
    int ma2=b[n-2];

    rep(i,n) {
        if(a[i]==ma1)   cout<<ma2<<endl;
        else    cout<<ma1<<endl;     
    }

 return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n,m;
	int ans=0;
	bool flag[3]={0,0,0};
	cin>>n>>m;
	REP(i,m)
	{
		int s,c;
		cin>>s>>c;
		if(s>n)
		{
			cout<<-1<<endl;
			return 0;
		}
		if(s==1&&c==0&&n!=1)
		{
			cout<<-1<<endl;
			return 0;
		}
		if(s==1)if(flag[s-1]==1&&((ans/100!=c&&n==3)||(ans/10!=c&&n==2)||ans!=c&&n==1))
		{
			cout<<-1<<endl;
			return 0;
		}
		else if(flag[s-1]==0){if(n==3)ans+=100*c;if(n==2)ans+=10*c;if(n==1)ans+=c;flag[s-1]=1;}
		if(s==2)if(flag[s-1]==1&&((n==3&&n%100/10!=c)||(n==2&&n/10!=c))){
			cout<<-1<<endl;
			return 0;
		}
		else if(flag[s-1]==0){if(n==3)ans+=10*c;if(n==2)ans+=c;flag[s-1]=1;}
		if(s==3)if(flag[s-1]==1&&ans%10!=c)
		{
			cout<<-1<<endl;
			return 0;
		}
		else if(flag[s-1]==0){ans+=c;flag[s-1]=1;}
	 }
	 if(n==3)
	 {
	 	if(flag[0]==0)ans+=100;
	 }
	 if(n==2)
	 {
	 	if(flag[0]==0)ans+=10;
	  } 
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main()
{
	char s[1200];
	int i;
	
	fgets(s,1200,stdin);
	
	for(i = 0;i < strlen(s);i++){
		if(s[i] >= 'a' &&  s[i] <= 'z')
			s[i] = toupper(s[i]);	
			
		else if(s[i] >= 'A' &&  s[i] <= 'Z')
			s[i] = tolower(s[i]);
		
	
	}

	fputs(s,stdout);

return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,k,in[M];
int main()
{
    while (~scanf("%d%d", &n, &k)) {
        REP(i,1,n) scanf("%d", &in[i]);
        sort(in+1, in+n+1);

        int ans = 2000000000;
        REP(i,k,n) ans = min(ans, in[i]-in[i-k+1]);
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<iostream>
#include<stdlib.h>
using namespace std;
typedef long long ll;

int main() {
	ll N,sum=0;
	cin >> N;
	ll tmp = N;
	while (true) {
		if (tmp < 10) {
			sum += tmp;
			break;
		}
		sum += tmp % 10;
		tmp = (tmp - tmp% 10) / 10;
	}
	if (N%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(map(float, input().split()))

heap = [-Ai for Ai in A]
heapq.heapify(heap)
for _ in range(M):
    heapq.heapreplace(heap, heap[0]/2)
A = [int(-p) for p in heap]
print(sum(A))


Measured memory_bytes: 78444
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int ans = 0;
    int N, D;
    cin >> N >> D;
    float X[N][D];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> X[i][j];
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int norm = 0;
            for (int k = 0; k < D; ++k)
            {
                int diff = abs(X[i][k] - X[j][k]);
                norm += diff * diff;
            }
            bool flag = false;
            for (int k = 0; k <= norm; ++k)
            {
                if (k * k == norm)
                {
                    flag = true;
                }
            }
            if (flag)
                ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  System.out.print(s.charAt(0));
  System.out.print(s.length() - 2);
  System.out.println(s.charAt(s.length()-1));
}}

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

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

    int h, w, n;
    cin >> h >> w >> n;

    cout << (n + max(h, w) - 1) / max(h, w) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x;
    int i = 1;
    do
    {
        scanf("%d", &x);
        if (x != 0)
        {
            printf("Case %d: %d\n", i, x);
        }
        i++;
    } while (x != 0);
    return 0;
}


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

int main(){
    long long X, K, D;
    std::cin >> X >> K >> D;
    if(X < 0){
        X = std::abs(X);
    }
    
    if(X / D >= K){
        std::cout << X - K * D << std::endl;
        return 0;
    }
    
    long long tmp = X / D;
    X = X % D;
    K -= tmp;
    if(K % 2 == 0){
        std::cout << X << std::endl;
    }else{
        X = X - D;
        X = std::abs(X);
        std::cout << X << std::endl;
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3636
N = int(input())
a = list(map(int,input().split()))

b = [0]*N 

if N % 2 == 0:
    even = N//2
    odd = even - 1
    for i in range(N):
        if i % 2 == 0:
            b[even] = str(a[i])
            even += 1
        else:
            b[odd] = str(a[i])
            odd -= 1
else:
    even = N//2
    odd = even + 1
    for i in range(N):
        if i % 2 == 0:
            b[even] = str(a[i])
            even -= 1
        else:
            b[odd] = str(a[i])
            odd += 1

print(' '.join(b))


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

int main() {
    ll N, ans = 0;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());
    int idx = 1;
    ans += A[0];
    for(int i = 2; i < N; i++) {
        ans += A[idx];
        if(i % 2 == 1)
            idx++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4788
#include<stdio.h>
 
int main(){
    int  s=100000;
 
    int n;
    scanf("%d",&n);
 
 
    for(;n--;){
        if(int(s*1.05)%1000==0){
            s=int(s*1.05);
        }else{
            s= int(s*1.05) + (1000- int(s*1.05) % 1000);
        }
    }
    printf("%d\n",s);
 
    return 0;
}

Measured memory_bytes: 1020
main :: IO ()
main = readLn >>= putStrLn . solve 

-- | 
-- >>> solve (-9)
-- "1011"
-- >>> solve 123456789
-- "11000101011001101110100010101"
-- >>> solve 0
-- "0"
solve :: Int -> String
solve 0 = "0"
solve x = walk [] x
    where
        walk acc n
            | n == 0 = acc
            | m == -1 = walk ('1' : acc) $ r + 1
            | otherwise = walk ((head $ show m) : acc) r
            where
                (r, m) = n `divMod` (-2)

Measured memory_bytes: 508
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n;
    while(cin >> n && n){
        int m,p;
        int x,y;
        cin >> p;
        complex<double> v[p];
        for(int i=0;i<p;i++){
            cin >> x >> y;
            v[i] = complex<double>(x,y);
        }
        complex<double> e[p-1];
        for(int i=1;i<p;i++){
            e[i-1] = v[i] - v[i-1];
            //cerr << e[i-1] << endl;
        }

        for(int i=0;i<n;i++){
            cin >> m;
            complex<double> tgt[m];
            complex<double> tgte[m-1];
            for(int j=0;j<m;j++){
                cin >> x >> y;
                tgt[j] = complex<double>(x,y);
            }

            //if no. of vertex is different
            if(p != m) continue;

            for(int j=1;j<m;j++){
                tgte[j-1] = tgt[j] - tgt[j-1];
                //cerr << tgte[j-1] << endl;
            }
            bool ismatched;
            for(int j=0;j<4;j++){
                ismatched = true;
                for(int k=0;k<m-1;k++){
                    //cerr << "compare:" << e[k] << " and " << tgte[k] << endl; 
                    if(e[k] != tgte[k]){
                        ismatched = false;
                        break;
                    }
                }
                if(ismatched){
                    cout << i+1 << endl;
                    break;
                }

                ismatched = true;
                for(int k=0;k<m-1;k++){
                    //cerr << "compare:" << e[k] << " and " << tgte[m-k-2] << endl;
                    if(e[k] != tgte[m-k-2]){
                        ismatched = false;
                        break;
                    }
                }
                if(ismatched){
                    cout << i+1 << endl;
                    break;
                }else{
                    for(int k=0;k<m-1;k++){
                        tgte[k] *= complex<double>(0,1);
                    }
                }
            }
        }
        cout << "+++++" << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long long>A(N+1);
  vector<long long>B(N);
  for(int i=0;i<N+1;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  long long sum=0;
  for(int i=0;i<N;i++){
    if(B.at(i)>=A.at(i)){
      sum=sum+A.at(i);
      B.at(i)=B.at(i)-A.at(i);
      if(B.at(i)>=A.at(i+1)){
        sum=sum+A.at(i+1);
        A.at(i+1)=0;
      }
      else{
        sum=sum+B.at(i);
        A.at(i+1)=A.at(i+1)-B.at(i);
      }
    }
    else{
      sum=sum+B.at(i);
      A.at(i)=A.at(i)-B.at(i);
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
s=input()
t=input()
s1={}
t1={}
for i in range(len(s)):
    if s[i] in s1 and t[i] in t1:
        if s1[s[i]]!=t1[t[i]]:
            print("No")
            break
    elif s[i] not in s1 and t[i] not in t1:
        s1[s[i]]=i
        t1[t[i]]=i
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 9504
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b,c=mp()
for i in range(10**5):
    if (a*i)%b==c:
        print("YES")
        exit()
print("NO")

Measured memory_bytes: 5076