akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
void solve(){
    ll n;
    cin>>n;
    ll x=1;
    while(x*1000<n){
        x++;
    }
    if(x*1000==n){
        cout<<0<<endl;
    }
    else{
        ll val=x*1000-n;
        cout<<val<<endl;
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){

	int taro[201],hanako[201],n,tmp,stage,num_of_taro,num_of_hanako,limit;
	bool FLG;


	while(true){

		scanf("%d",&n);
		if(n == 0)break;


		for(int i=0; i<201; i++){
			taro[i] = 0;
			hanako[i] = 1;
		}


		num_of_taro = num_of_hanako = n;

		for(int i=0; i < n; i++){
			scanf("%d",&tmp);
			taro[tmp] = 1;
			hanako[tmp] = 0;
		}

		stage = 0;

		limit = 2*n;
		while(num_of_taro > 0 && num_of_hanako > 0){
			if(stage == 0){
				FLG = true;
				for(int i=1; i <= limit;i++){
					if(taro[i] == 1){
						taro[i] = 0;
						stage = i;
						num_of_taro--;
						break;
					}
				}

				if(num_of_taro == 0)break;

				for(int i=1; i <= limit; i++){
					if(stage < i && hanako[i] == 1){
						stage = i;
						hanako[i] = 0;
						num_of_hanako--;
						FLG = false;
						break;
					}
				}

				if(num_of_hanako == 0)break;

				if(FLG)stage = 0;

			}else{
				FLG = true;
				for(int i=1; i <= limit;i++){
					if(stage < i && taro[i] == 1){
						taro[i] = 0;
						stage = i;
						FLG = false;
						num_of_taro--;
						break;
					}
				}

				if(num_of_taro == 0)break;

				if(FLG)stage = 0;

				FLG = true;
				for(int i=1; i <= limit; i++){
					if(stage < i && hanako[i] == 1){
						stage = i;
						hanako[i] = 0;
						num_of_hanako--;
						FLG = false;
						break;
					}
				}

				if(num_of_hanako == 0)break;

				if(FLG)stage = 0;

			}

		}

		if(num_of_taro == 0){
			printf("%d\n",num_of_hanako);
			printf("0\n");
		}else{
			printf("0\n");
			printf("%d\n",num_of_taro);
		}

	}

    return 0;
}

Measured memory_bytes: 2732
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

int main() {
  int n, c, k;
  scanf("%d%d%d", &n, &c, &k);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int ret = 0;
  for (int i = 0, j; i < n; i = j) {
    for (j = i + 1; j < n && a[j] - a[i] <= k && j - i + 1 <= c; ++j);
    // cout << i << " " << j << endl;
    ++ret;
  }
  printf("%d\n", ret);
  return 0;
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 1e5 + 1, mod = 1e9 + 7;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

int a[N], jc[N], inv[N];
LL s[N], pre[N], suf[N];

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

int main() {
	reg n = read();
	fo(i, 1, n) a[i] = read(), s[i] = s[i - 1] + a[i];
	fo(i, 1, n) pre[i] = (pre[i - 1] + s[i]) % mod;
	fd(i, n, 1) suf[i] = (suf[i + 1] + s[i]) % mod;
	jc[0] = 1; fo(i, 1, n) jc[i] = (LL)jc[i - 1] * i % mod;
	inv[n] = pow_mod(jc[n], mod - 2); fd(i, n, 1) inv[i - 1] = (LL)inv[i] * i % mod;
	reg ans = s[n] % mod;
	fo(i, 1, n - 1) {
		reg kk = (suf[i] - pre[n - i]) % mod;
		reg u1 = (s[i] + s[n] - s[n - i]) % mod;
		reg u2 = (kk - u1) % mod;
		if(i < n - 1) ans = (ans + (LL)jc[i] * jc[2] % mod * inv[i + 2] % mod * u2) % mod;
		ans = (ans + (LL)jc[i] * inv[i + 1] % mod * u1) % mod;
	} ans = ans < 0 ? ans + mod : ans;
	pr2((LL)ans * jc[n] % mod);
	return 0;
}



Measured memory_bytes: 3712
N = int(input())
#A = list(map(int,input().split()))

a=[0]*10**7
c=1
b=[]
a[N]+=1
for i in range(10**6+100):
    #print(b)
    c+=1
    if N%2==0:
        N=N//2
        b.append(N)
        if a[N]==0:
            a[N]+=1
        else:
            print(c)
            exit()
    else:
        N=3*N+1
        b.append(N)
        if a[N]==0:
            a[N]+=1
        else:
            print(c)
            exit()


Measured memory_bytes: 81140
import java.util.*;
public class Main {
 public static void main(String[] args){
	
	 Scanner scan = new Scanner(System.in);
	 
	 int n = scan.nextInt();
	 
	 int x[] = new int[n];
	 int y[] = new int[n];
	 int h[] = new int[n];
	 
	 for(int i=0; i<n; i++){
		 x[i]=scan.nextInt();
		 y[i]=scan.nextInt();
		 h[i]=scan.nextInt();
		 
	 }
	 
	 boolean flag = false;
	 
	 int cx=0;
	 int cy=0;
	 int ch=0;
	 
	 
	
	 for(int X=0; X<101; X++){
		 if(flag == true)break;
		 for(int Y=0; Y<101; Y++){
			 if(flag == true)break;
			 int H=0;
			 
			 for(int i=0;i<n;i++){
			  if(h[i]>0){
				  H=h[i]+Math.abs(x[i]-X)+Math.abs(y[i]-Y);
				  break;
			  }
			  
			 }
			 for(int i=0; i<n; i++){
				
				 if(h[i]!=Math.max(H-Math.abs(x[i]-X)-Math.abs(y[i]-Y),0)){
					 flag=false;
					 break;
				 }else{
					 cx = X;
					 cy = Y;
					 ch = H;
					 flag = true;
				 }
		     }
	     }
	 }
	
	 System.out.println(cx + " " + cy + " "+ ch);
	 
  }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b<c){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3528
#include<stdio.h>
int main()
{
	int a,b,c,d,e,f,r;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	r=a+b*5+c*10+d*50+e*100+f*500;
	if(r>=1000){
		printf("1\n");
	}else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 2660
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, a, b, c, d;
ll s, e;
ll now;

int main()
{
    scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
    now = b - a;
    s = c * (n - 1);
    e = d * (n - 1);
    if(s <= now && now <= e)
    {
        printf("YES\n");
        return 0;
    }
    for(ll i = 0; i < n - 1; i++)
    {
        s -= c + d;
        e -= c + d;
        if(s <= now && now <= e)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S;
signed main() {
    cin >> S;
    rep(i, S.length()) { cout << "x"; }
    cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

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

    vector<int64_t> mCnt(n);
    rrep(i, n)
    {
        if (i == n - 1) {
            mCnt[i] = (s[i] == 'M' ? 1 : 0);
        } else {
            mCnt[i] = mCnt[i + 1] + (s[i] == 'M' ? 1 : 0);
        }
    }

    vector<int64_t> dCnt(n);
    rrep(i, n)
    {
        if (i == n - 1) {
            dCnt[i] = (s[i] == 'D' ? 1 : 0);
        } else {
            dCnt[i] = dCnt[i + 1] + (s[i] == 'D' ? 1 : 0);
        }
    }

    vector<int64_t> a(n);
    rrep(i, n)
    {
        if (i == n - 1) {
            a[i] = 0;
        } else {
            a[i] = a[i + 1] + (s[i] == 'D' ? mCnt[i + 1] : 0);
        }
    }

    int q;
    cin >> q;
    rep(i, q)
    {
        int k;
        cin >> k;

        int64_t result = 0;
        rep(j, n)
        {
            if (s[j] == 'C' && j >= 2) {
                int l = max(0L, j - k + 1);
                int64_t t = a[l] - a[j] - (dCnt[l] - dCnt[j]) * mCnt[j];
                result += t;
                // cout
                //     << "i=" << i << " j=" << j << " k=" << k << " l=" << l << " t=" << t << " " << (dCnt[l] - dCnt[j]) * mCnt[i] << endl;
            }
        }
        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 24836
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#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() {
  char s;
  cin >> s;
  if (isupper(s)) cout << "A" << endl;
  else cout << "a" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int rc[4010],gc[4010],bc[4010];
int main(void){
    int n,i,j,k,ans=0,dist=1;
    string rgb;
    cin>>n>>rgb;

    for(i=0;i<4010;i++){
        rc[i]=gc[i]=bc[i]=0;
    }

    while(1){
        if(2*dist>n)break;

        for(i=0;i<n-dist*2;i++){
            if(rgb[i]!=rgb[i+dist] && rgb[i+dist]!=rgb[i+dist*2] && rgb[i+dist*2]!=rgb[i]){
                ans++;
            }
        }

        dist++;
    }
    int rcount=0,gcount=0,bcount=0;
    for(i=n-1;i>=0;i--){
        rc[i]=rcount;
        gc[i]=gcount;
        bc[i]=bcount;
        if(rgb[i]=='R'){
            rcount++;
        }else if(rgb[i]=='G'){
            gcount++;
        }else{
            bcount++;
        }
    }

    long long ret=0;
    for(i=0;i<n;i++){
        if(rgb[i]=='R'){
            ret +=gc[i]*bc[i];
        }else if(rgb[i]=='G'){
            ret +=rc[i]*bc[i];
        }else{
            ret +=rc[i]*gc[i];
        }
    }

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


Measured memory_bytes: 3684
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
#define MAX 1000000000
int main(){
    int i,n,a,sum,min=MAX;
    cin>>n;
    for(i=0;i<n;i++){        
        sum=0;
        cin>>a;
        while(1){
            if(a%2==0){
                a/=2;
                sum++;
                if(sum>=min)break;
            }           
            else if(a%2==1){
                break;
            }            
        }
        if(sum<min)min=sum;
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .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 ; $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, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;

fn main() {
    input!{
        n:usize,
        xy: [[i64;2];n]
    }
    let mut h = HashSet::new();
    for i in 0..n {
        for j in 0..n {
            if i==j {
                continue;
            }
            let dx = xy[i][0] - xy[j][0];
            let dy = xy[i][1] - xy[j][1];
            h.insert((dx, dy));
        }
    }
    let mut ans = n;
    for &(dx, dy) in h.iter() {
        let mut cur = n;
        for i in 0..n {
            let nx = xy[i][0]+dx;
            let ny = xy[i][1]+dy;

            if xy.contains(&vec![nx, ny]) {
                cur -=1;
            }
        }
        ans = std::cmp::min(ans, cur);
    }
    println!("{}", ans);
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

ll n;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;

  vl d;
  for (ll i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      d.push_back(i);
      if (i != n / i) d.push_back(n/i);
    }
  }

  ll res = 0;
  for (ll v : d) {
    ll x = n / v - 1;
    if (x != 0 && n % x == n / x) res += x;
  }

  cout << res << endl;


  return 0;
}


Measured memory_bytes: 384
while 1:
    n = int(raw_input())
    if n == 0: break
    table = []
    index = {}
    for k in range(n):
        i, p, q = raw_input().split()
        record = index.get(i)
        if not record:
            record = [i, 0]
            table.append(record)
            index[i] = record
        record[1] += int(p) * int(q)
    found = False
    for record in table:
        if record[1] >= 1000000:
            print record[0]
            found = True
    if not found:
        print 'NA'

Measured memory_bytes: 4364
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 1000000007;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        String s = in.next();
        for (int i = 0; i < s.length(); i++) {
            out.print((char)((s.charAt(i) - 'A' + n) % 26 + 'A'));
        }
        out.println();
    }


}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const int MAX_N=120;

struct edge{
	ll to,cap,rev;
};

vector<edge> G[MAX_N];
vector<int> check(MAX_N,0);

ll dfs(int v,int t, int f){
	if(v==t){return f;}
	check[v]=1;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(check[e.to]==0 && e.cap > 0){
			ll ff =dfs(e.to,t,min((ll)f,e.cap));
			if(ff>0){
				e.cap -= ff;
				G[e.to][e.rev].cap += ff;
				return ff;
			}
		}
	}
	return 0;
}

void print_graph(int V){
	REP(i, V){
		cout << "from: " << i << endl;
		REP(j, G[i].size()){
			edge e = G[i][j];
			printf("to: %d, cap: %d, rev: %d\n", e.to, e.cap, e.rev);
		}
		cout << endl;
	}
}

ll maxflow(int s,int t){
	ll flow = 0;
	while(1){
		fill(check.begin(),check.end(),0);
		int f = dfs(s,t,INT_MAX);
		if(f==0){return flow;}
		flow += f;
	}
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    const ll INF = (1ll<<60);

    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    int s=0, t=N+1;
    REP(i, N){
    	if(a[i]>=0){
    		edge e = {t, a[i], (int)G[t].size()};
    		G[i+1].push_back(e);
    		edge f = {i+1, 0, (int)G[i+1].size()-1};
    		G[t].push_back(f);
    	}else{
    		edge e = {i+1, -a[i], (int)G[i+1].size()};
    		G[s].push_back(e);
    		edge f = {s, 0, (int)G[s].size()-1};
    		G[i+1].push_back(f);
    	}
    }

    for(int i=1;i<=N;i++){
    	for(int j=2*i;j<=N;j+=i){
    		edge e = {j, INF, (int)G[j].size()};
    		G[i].push_back(e);
    		edge f = {i, 0, (int)G[i].size()-1};
    		G[j].push_back(f);
    	}
    }

    //print_graph(N+2);

    ll flow = maxflow(s, t);
    ll res = 0;
    REP(i, N) res += max(0ll, a[i]);
    cout << res - flow << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int A, B;
  int tmp; 
  
  cin >> A >> B;
  tmp = A - 2*B;

  if(tmp>=0) printf("%d\n",tmp);
  else  printf("0\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int d[10][10];
void init(){
  for(int i = 0; i < 6; i++)for(int j = 0 ; j < 6; j++)d[i][j] = -1;
  d[0][0] = d[5][1] = d[2][0] = 1;
  d[0][1] = d[4][1] = d[5][0] = 2;
  d[1][1] = 3;
  d[3][0] = 4;
  d[3][1] = d[4][0] = 5;
}
string s;
void solve(){
  int p = 0;
  for(int i = 0; i < (int)s.size(); i++){
    int b = s[i] - '0';
    p = d[p][b];
    if(p == -1)break;
  }
  cout << (p==5?"Yes":"No") << endl;
}
int main(){
  init();
  while(cin >> s && s != "#"){
    solve();
  }
}

Measured memory_bytes: 1180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

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

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

int n, max_digit;
vector<string> expr;
int value[256];
bool first[256];
bool used[10];

int dfs(int digit = 0, int left_sum = 0, int idx = 0) {
	if(digit >= max_digit)
		return left_sum ? 0 : 1;

	if(digit >= expr[idx].size())
		return dfs(digit, left_sum, idx + 1);

	int res = 0;
	const char c = expr[idx][digit];
	if(idx == n - 1) {
		if(value[c] == -1) {
			const int tmp = left_sum % 10;
			if(!used[tmp] && (tmp != 0 || !first[c])) {
				used[tmp] = true;
				value[c] = tmp;
				res = dfs(digit + 1, left_sum / 10, 0);
				used[tmp] = false;
				value[c] = -1;
			}
		}
		else if(value[c] == left_sum % 10)
			res = dfs(digit + 1, left_sum / 10, 0);
	}
	else {
		if(value[c] == -1) {
			if(!first[c] && !used[0]) {
				used[0] = true;
				value[c] = 0;
				res = dfs(digit, left_sum, idx + 1);
				used[0] = false;
			}
			for(int i = 1; i < 10; ++i) {
				if(used[i])
					continue;

				used[i] = true;
				value[c] = i;
				res += dfs(digit, left_sum + i, idx + 1);
				used[i] = false;
			}
			value[c] = -1;
		}
		else
			res = dfs(digit, left_sum + value[c], idx + 1);
	}

	return res;
}

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

	while(cin >> n, n) {
		expr.clear();
		expr.resize(n);
		max_digit = 0;
		memset(first, false, sizeof(first));
		for(int i = 0; i < n; ++i) {
			cin >> expr[i];
			if(expr[i].size() > 1)
				first[expr[i][0]] = true;
			reverse(expr[i].begin(), expr[i].end());
			chmax<int>(max_digit, expr[i].size());
		}

		if(max_digit != expr[n - 1].size()) {
			cout << "0" << endl;
			continue;
		}

		memset(value, -1, sizeof(value));
		cout << dfs() << endl;
	}

	return EXIT_SUCCESS;
}

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

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

	int five = 0;
	five += (A == 5);
	five += (B == 5);
	five += (C == 5);

	int seven = 0;
	seven += (A == 7);
	seven += (B == 7);
	seven += (C == 7);

	cout << (five == 2 && seven == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
H , W = map(int,input().split())
while H != 0 and W != 0:
  for j in range (H):
    for i in range (W):
      if i % 2 == 1 and j % 2 == 1:
        print('#',end='')  
      elif i % 2 == 0 and j % 2 == 1:
        print('.',end='')
      if i % 2 == 0 and j % 2 == 0:
        print('#',end='')
      elif i % 2 == 1 and j % 2 == 0:
        print('.',end='')
    print()
    
  print()
        
  H , W = map(int,input().split())    


Measured memory_bytes: 7004
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p(int A,int B){
  if(!B)return 1;
  if(B&1)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
signed main(){
  int N;
  cin>>N;
  cout<<((p(10,N)-p(9,N)*2%mod+mod)%mod+p(8,N))%mod<<endl;
}

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

#define N 505
#define M 200005

int n,m,q,l,r,str[N],ender[N];
struct rang{
	int l,r;
}a[M];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(n);read(m);read(q);
	for(register int i=1;i<=m;i++){
		read(a[i].l);read(a[i].r);
	}
}

bool cmp(rang cmp1,rang cmp2){
	return (cmp1.l<cmp2.l)||(cmp1.l==cmp2.l&&cmp1.r<cmp2.r);
}

int main(){
	init();
	sort(a+1,a+m+1,cmp);
	memset(str,-1,sizeof str);
	a[0].l=0;
	for(register int i=1;i<=m;i++)
	if(a[i-1].l!=a[i].l){
		str[a[i].l]=i;ender[a[i-1].l]=i-1;
	}
	ender[a[m].l]=m;
	int Ans,p[10],L;
	p[0]=1;
	for(register int i=1;i<=9;i++)
	p[i]=p[i-1]*2;
	while(q--){
		read(l);read(r);
		Ans=0;
		for(register int i=l;i<=r;i++){
			if(str[i]==-1){
				continue;
			}
			L=str[i]-1;
			for(register int j=9;j>=0;j--)
			if(L+p[j]<=ender[i]&&a[L+p[j]].r<=r){
				L=L+p[j];
			}
			Ans+=L-str[i]+1;
		}
		writeln(Ans);
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M 1000000007
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m)%m;
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
            return (((((res%m)*a)%m)*res)%m);
    }
}
bool x[101];
int main()
{

    ll K,X;
    cin>>K>>X;
    if(500*K>=X)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    string ss;cin>>ss;
    int e=0,w=0,s=0,n=0;
    for(int i=0;i<ss.length();i++){
        if(ss[i]=='E')e++;
        else if(ss[i]=='W')w++;
        else if(ss[i]=='N')n++;
        else s++;
    }
    if(s){
        if(!n){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(n){
        if(!s){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(e){
        if(!w){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(w){
        if(!e){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------














































Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
ll N;
string A;
ll alphaCount[26];

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

  cin >> A;
  N = _size(A);

  ll ans = 1 + N*(N-1)/2;

  for (int i = 0; i < N; ++i) {
      ++alphaCount[A[i]-'a'];
  }

  for (int i = 0; i < 26; ++i) {
     ans -= alphaCount[i]*(alphaCount[i]-1)/2;
  }

  cout << ans << endl;

  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT12 istream& operator>>(istream &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 ostream& operator<<(ostream &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT istream& operator>>(istream &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT ostream& operator<<(ostream &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT ostream& operator<<(ostream &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT ostream& operator<<(ostream &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT ostream& operator<<(ostream &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT12 ostream& operator<<(ostream &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 ostream& operator<<(ostream &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT istream& operator>>(istream &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT ostream& operator<<(ostream &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;







void _main() {
        int n; cin >> n;
        vi vec(n); cin >> vec;
        if (count(all(vec), 0LL)) {
                cout << 0;
                return;
        }

        int ans = 1;
        for (int i = 0; i < vec.size(); i++) {
                if (vec[i ] >1000000000000000000/ ans) {
                        cout << -1;
                        return;
                }

                ans *= vec[i];
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3992
#include<iostream>
using namespace std;
int main()
{
  int n,ac = 0,wa = 0,tle = 0,re = 0;
  cin>>n;
  while(n--)
  {
    string s;
    cin>>s;
    if(s=="AC") ++ac;
    else if(s=="WA") ++wa;
    else if(s=="TLE") ++tle;
    else ++re;
  }
  cout<<"AC x "<<ac<<"\n"
      <<"WA x "<<wa<<"\n"
      <<"TLE x "<<tle<<"\n"
      <<"RE x "<<re;
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	int a,b,ans;	
	cin>>a>>b;
	ans = max(0,a-b*2);
	cout<<ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3656
x,n = map(int, input().split())
p = list(map(int, input().split()))

ans = -1
i = 1

if x not in p:
    print(x)
    exit()

while ans == -1:
    temp = x -i
    if temp not in p:
        ans = temp
        break
    temp = x + i
    if temp not in p:
        ans = temp
        break
    i += 1

print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;

int main() {

	int n, m;
	cin >> n >> m;
	vi p(m);
	vs s(m);

	rep(i, m) {
		cin >> p[i] >> s[i];
		p[i]--;
	}

	vi nac(n),nwa(n);
	rep(i, n) {
		nac[i] = 0;
		nwa[i] = 0;
	}

	rep(i, m) {
		if (nac[p[i]] == 1) continue;
		if (s[i] == "AC") nac[p[i]]++;
		if (s[i] == "WA") nwa[p[i]]++;
	}

	int ac = 0, wa = 0;

	rep(i, n) {
		ac += nac[i];
		if (nac[i] == 1)wa += nwa[i];
	}
		cout << ac << " " << wa << endl;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>

signed main()
{
	int n;
	std::cin >> n;
	std::vector<int> dp(100010);
	dp[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		dp[i] = dp[i - 1] + 1;
		for (int j = 6; j <= i; j *= 6)
			dp[i] = std::min(dp[i], dp[i - j] + 1);
		for (int j = 9; j <= i; j *= 9)
			dp[i] = std::min(dp[i], dp[i - j] + 1);
	}
	std::cout << dp[n] << std::endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a < b) {

			if (b < c) {
				System.out.printf("%d %d %d\n", a, b, c);
			}

			else if (c < a) {
				System.out.printf("%d %d %d\n", c, a, b);
			} else {

				System.out.printf("%d %d %d\n", a, c, b);
			}
		} else if (b < a) {
			if (a < c) {
				System.out.printf("%d %d %d\n", b, a, c);
			} else if (c < b) {
				System.out.printf("%d %d %d\n", c, b, a);
			} else {
				System.out.printf("%d %d %d\n", b, c, a);
			}
		}

	}

}

Measured memory_bytes: 26296
from collections import deque

n, m = map(int, input().split())
a = [[] for _ in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    a[x - 1].append(y - 1)
    a[y - 1].append(x - 1)
c = [0] * n
que = deque([])
que.append(0)
while len(que) > 0:
    e = que.popleft()
    for i in a[e]:
        if c[i] > 0:
            continue
        c[i] = e + 1
        que.append(i)
print("Yes")
for i in range(1, n):
    print(c[i])


Measured memory_bytes: 98516
use std::io::{stdin, Read};
use std::str::FromStr;
use std::cmp::Ordering;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}
 
fn main() {
    let n: usize = read().unwrap();
    let mut arr: Vec<i64> = Vec::new();
    for _i in 0..n {
        let a: i64 = read().unwrap();
        arr.push(a);
    }
    let avg: f64 = (arr.iter().sum::<i64>() as f64) / (n as f64);

    let mut avgdiff: Vec<(f64, usize)> = Vec::new();
    for i in 0..n {
        let diff: f64 = ((arr[i] as f64) - avg).abs();
        avgdiff.push((diff, i));
    }
    avgdiff.sort_by(|a, b| {
        match a.0.partial_cmp(&b.0).unwrap() {
            Ordering::Equal => a.1.cmp(&b.1),
            other => other,
        }
    });
    //for i in 0..n {
    //  println!("{} {}", avgdiff[i].0, avgdiff[i].1);
    //}
    println!("{}", avgdiff[0].1);
}

Measured memory_bytes: 2160
using System;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int ans = 0;
        for (var i = 1; i <= N; i++)
        {
            if (i < 10)
            {
                ans++;
            }
            else if (i < 100)
            {}
            else if (i < 1000)
            {
                ans++;
            }
            else if (i < 10000)
            {}
            else if (i < 100000)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;

    int l[q],r[q];

    rep(i,0,q){
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }
    int sum[n];
    rep(i,0,n) sum[i] = 0;
    int tmp = 0;
    rep(i,1,n){

        if(s[i-1] == 'A' && s[i] == 'C') tmp++;
        sum[i] = tmp;
        
    }
    rep(i,0,q){
        cout << sum[r[i]]-sum[l[i]] <<endl;
    }
    
}

Measured memory_bytes: 2176
def larger(x, y):
	if x > y:
		return x
	return y

N = int(input())
lst = []
for i in range(0, N):
	x, y, h = map(int, input().split())
	lst.append([x, y, h])
lst.sort(key = lambda v: v[2], reverse = True)
for i in range(0, 101):
	flag1 = False
	for j in range(0, 101):
		H = lst[0][2] + abs(lst[0][0]-i) + abs(lst[0][1]-j)
		flag2 = True
		for k in range(1, N):
			if larger(H-abs(lst[k][0]-i)-abs(lst[k][1]-j), 0) != lst[k][2]:
				flag2 = False
				break
		if flag2:
			print(str(i)+' '+str(j)+' '+str(H))
			flag1 = True
			break
	if flag1:
		break

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

int main()
{
    long long n, b, c, a;
    long long sum = 0;
    map<long long, long long> mp;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        sum += a;
        mp[a]++;
    }
    long long q;
    cin >> q;
    while (q--)
    {
        cin >> b >> c;
        if (mp.find(b) != mp.end())
        {
            sum -= (mp[b] * b);
            sum += (mp[b] * c);
            mp[c] += mp[b];
            mp[b] = 0;
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 8684
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;

signed main(){
	int n;
	cin >> n;
	int a[n];
	rep(i, n)cin >> a[i];
	sort(a, a + n);

	priority_queue <int> que;
	int cnt = 1;
	rep(i, n){
		if((i != n - 1 && a[i] != a[i + 1]) || i == n - 1){
			que.push(cnt);
			cnt = 1;
		}
		else
			cnt++;
	}

	while(que.top() != 1){
		int va = que.top();
		que.pop();
		if(va % 2){//きすーのとき
			que.push(1);
		} else {//ぐすーのとき
			int ri = que.top();
			que.pop();
			que.push(1);
			if(ri - 1 != 0)
				que.push(ri - 1);
		}
	}

	cout << que.size() << endl;

}


Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
int main(){
  string s; cin >> s;
  int ss = (int)s.size();
  rep(i,ss-2){
    if(s[i] == s[i+1] && s[i] == s[i+2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S1, S2; int n; char C[3] = ".#";
int Division = 2;
int main() {
	cin >> n; bool END = false;
	while (true) {
		string S3 = S1, S4 = S2;
		if (Division == 2) {
			bool OK = false;
			for (int j = 0; j < 4; j++) {
				S3 = S1; S4 = S2;
				S3 = S3 + C[j / 2];
				S4 = S4 + C[j % 2];
				cout << S3 << endl << S4 << endl;
				string D; cin >> D;
				if (D == "end")END = true;
				if (D == "T" || D == "end") { OK = true; S1 = S3; S2 = S4; break; }
			}
			if (OK == false)Division = 1;
		}
		if (Division == 1) {
			bool OK = false;
			for (int j = 0; j < 4; j++) {
				S3 = S1; S4 = S2;
				S3 = C[j / 2] + S3;
				S4 = C[j % 2] + S4;
				cout << S3 << endl << S4 << endl;
				string D; cin >> D;
				if (D == "end")END = true;
				if (D == "T" || D == "end") { OK = true; S1 = S3; S2 = S4; break; }
			}
		}
		if (END == true)break;
	}
	return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

int n;
ll ans;
vector<vector<int>> e(200000);

int dfs(int v,int p){
    int res=1;
    for(int u:e[v]){
        if(u!=p){
            int tmp=dfs(u,v);
            res+=tmp;
            ans+=1+modpow(2,n)-modpow(2,n-tmp)-modpow(2,tmp);
            ans%=MOD;
        }
    }
    return res;
}

int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int s,t;
        cin>>s>>t;
        --s,--t;
        e[s].push_back(t);
        e[t].push_back(s);
    }
    ans=((2-n)*modpow(2,n-1))-1;
    ans%=MOD;
    dfs(0,-1);
    ans=(ans+MOD)%MOD;
    ll x=modpow(2,n);
    ans*=modpow(x,MOD-2);
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 20096