akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int n = nextInt();
        n %= 1000;
        outln(n == 0 ? 0 : 1000 - n);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 32920
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(style))]
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet, VecDeque};

//{{{
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
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)*}
    };
}

#[doc(hidden)]
#[macro_export]
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)*}
    };
}

#[doc(hidden)]
#[macro_export]
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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        n: usize,
        a: [isize; n],
    }
    let mut a = a.clone();
    for i in 0..n {
        a[i] -= i as isize + 1;
    }
    a.sort();
    let b = a[n / 2];
    let ans: isize = a.iter().map(|&x| (x - b).abs()).sum();
    println!("{}", ans);
}


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

int main() {
 char a,b;
 cin >> a >> b;
 
 if (((a == 'H')&&(b == 'H'))||((a == 'D')&&(b == 'D')))
  cout << 'H' << endl;
 else 
  cout << 'D' << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct UnionFind {
  int parent[110000];
  void unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) { return; }
    parent[y] = x;
  }
  int findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
};

int n, q;
UnionFind ufind;
int parent[110000];
bool mark[110000];
int query[110000];

int main() {
  while (scanf("%d %d", &n, &q), n|q) {
    memset(&ufind, -1, sizeof(ufind));
    MEMSET(mark, false);
    parent[0] = 0;
    REP(i, n -1) {
      int p;
      scanf("%d", &p);
      parent[i + 1] = p - 1;
    }
    int m = 0;
    REP(i, q) {
      char c;
      int v;
      scanf(" %c %d", &c, &v);
      if (c == 'Q') {
        query[m++] = v;
      } else if (c == 'M' && !mark[v - 1]) {
        mark[v - 1] = true;
        query[m++] = -v;
      }
    }
    REP(i, n) {
      if (mark[i]) { continue; }
      ufind.unionSet(parent[i], i);
    }
    reverse(query, query + m);
    ll ans = 0;
    REP(i, m) {
      int index = abs(query[i]) - 1;
      if (query[i] > 0) {
        ans += ufind.root(index) + 1;
      } else {
        ufind.unionSet(parent[index], index);
      }
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 2168
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s1, s2;
        int l1, l2;
        cin >> s1 >> s2;
        l1 = s1.length();
        l2 = s2.length();
        if (l1>80 || l2 > 80)
            cout << "overflow";
        else
        {
            int result[100], r = 0, m = max(l1, l2), t;
            reverse(s1.begin(), s1.end());
            reverse(s2.begin(), s2.end());
            s1.resize(m + 1, '0');
            s2.resize(m + 1, '0');
            for (int j = 0; j < m; j++)
            {
                t = r + s1[j] + s2[j] - 48 * 2;
                result[j] = t % 10;
                r = t / 10;
            }
            if (r == 1)
                result[m++] = 1;
            if (m>80)
                cout << "overflow";
            else
                for (int j = m - 1; j >= 0; j--)
                    cout << result[j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
A, B = map(int, input().split())

index = 0
val_list = list(range(0, 1263))

is_exist = False
while len(val_list) > 0:
    mid = len(val_list) // 2
    av = int(val_list[mid] * 0.08)
    bv = int(val_list[mid] * 0.1)
    if av == A and bv == B:
        index = mid
        is_exist = True
        break
    else:
        if av > A or bv > B:
            val_list = val_list[:mid]
        else:
            val_list = val_list[mid+1:]

if is_exist:
    ans = 0
    for i in range(0, index+1):
        if int(val_list[i] * 0.08) == A and int(val_list[i] * 0.1) == B:
            ans = val_list[i]
            break
    print(ans)
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

void chmin(int *a,int *b){
    if(*a>*b+1){
        *a = *b+1;
    }
}

int main(void){
    int H,W;cin>>H>>W;
    vector<vector<bool>> S(H,vector<bool>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char a;cin >> a;
            if(a=='#'){
                S[i][j] = 0;
            }else{
                S[i][j] = 1;
            }
        }
    }
    int max = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            while(1){
                if(S[i][j]==0)break;
                vector<vector<int>> dp(H,vector<int>(W,1000000));
                dp[i][j] = 0;
                int count = 0;
                while(count<H*W){
                    for(int m=0;m<H;m++){
                        for(int n=0;n<W;n++){
                            if(m-1>=0&&S[m-1][n]==1){
                                chmin(&dp[m-1][n],&dp[m][n]);
                            }
                            if(m+1<H&&S[m+1][n]==1){
                                chmin(&dp[m+1][n],&dp[m][n]);
                            }
                            if(n-1>=0&&S[m][n-1]==1){
                                chmin(&dp[m][n-1],&dp[m][n]);
                            }
                            if(n+1<W&&S[m][n+1]==1){
                                chmin(&dp[m][n+1],&dp[m][n]);
                            }
                        }
                    }
                    count++;
                }
                for(int k=0;k<H;k++){
                    for(int l=0;l<W;l++){
                        if(max<dp[k][l]&&dp[k][l]!=1000000){
                            max = dp[k][l];
                        }
                    }
                } 
                break;
            }
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
#define MN 1000005
int A, B, C, M;
int rand() {
	A = 36969 * (A & M) + (A >> 16);
	B = 18000 * (B & M) + (B >> 16);
	return (C & ((A << 16) + B)) % 1000000;
}
struct data { int x, y, z, k; } d[MN];
int dyn[MN], Y;
inline bool cmp(data a, data b) {
	if (a.x != b.x) return a.x < b.x;
	if (a.y != b.y) return a.y < b.y;
	return a.z < b.z;
}
int ym[MN], yd[MN];
map <int, int> r[MN];
map<int,int>::iterator it, it2;
void upd(int x, int y, int v) {
	while (x < Y) {
		it = it2 = r[x].upper_bound(y);
		while (it2 != r[x].end() && it2->second <= v) it2++;
		r[x].erase(it, it2);
		it = r[x].upper_bound(y);
		if (it == r[x].begin() || (--it)->second < v) r[x][y] = v;
		x += x&(-x);
	}
}
int ret, val;
int f(int x, int y) {
	ret = -1;
	while (x > 0) {
		it = r[x].lower_bound(y);
		if (it != r[x].begin()) val = (--it)->second;
		else val = -1;
		if (ret < val) ret = val;
		x &= x-1;
	}
	return ret;
}
int main() {
	int i, j;
	int m, n, N;
	while (scanf("%d%d%d%d",&m,&n,&A,&B),m||n||A||B) {
		N = m+n; Y = 0;
		C = ~(1<<31); M = (1<<16)-1;
		for (i = 0; i < m; i++) scanf("%d%d%d",&d[i].x,&d[i].y,&d[i].z);
		for (i = m; i < m+n; i++) d[i].x = rand(), d[i].y = rand(), d[i].z = rand();
		ym[0] = -1;
		for (i = 0; i < N; i++) d[i].k = i, ym[++Y] = d[i].y;
		sort(d, d+N, cmp);
		sort(ym+1, ym+Y+1);
		Y = 0;
		for (i = 1; i <= N; i++) if (ym[i] != ym[i-1]) yd[ym[i]] = ++Y;
		for (i = 0; i < N; i++) d[i].y = yd[d[i].y];
		Y+=2;
		for (i = 0; i < Y; i++) r[i].clear();
		i = 0;
		do {
			for (j = i; j < N && d[i].x == d[j].x; j++) dyn[d[j].k] = max(1, f(d[j].y-1, d[j].z)+1);
			for (; i < j; i++) upd(d[i].y, d[i].z, dyn[d[i].k]);
		} while (i < N);
		printf("%d\n",f(Y-1, 3*MN));
		m = n = A = B = 0;
	}
}

Measured memory_bytes: 105776
#include<iostream>

using namespace std;

void print(int a[],int n)
{
    for(int i=0;i<n;i++)
        {
            cout<<a[i];
            if(i!=n-1)
                cout<<" ";
        }
    cout<<endl;
}

int main()
{
   int n,i,j,v=0;
   int a[100];
   int minx,flag;

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

   for(i=0;i<n;i++)
   {
       minx=i;
       flag=0;
       for(j=i+1;j<n;j++)
       {
           if(a[j]<a[minx])
            {
                minx=j;
                flag=1;
            }
       }
       if(flag==1)
       {
           swap(a[i],a[minx]);
           v++;
       }


   }
   print(a,n);
   cout<<v<<endl;
    return 0;

}

Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n)), b(n, vector<int>(n, 1));
	rep(i, n) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				if (k != i && k != j) {
					if (a[i][j] > a[i][k] + a[k][j]) {
						cout << -1 << endl;
						return 0;
					}
					else if(a[i][j] == a[i][k] + a[k][j]) {
						b[i][j] = 0;
					}
				}
			}
		}
	}
	ll ans = 0;
	rep(i, n) {
		rep(j, i) {
			if (b[i][j]) {
				ans += a[i][j];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}



void solve() {
	int x; cin >> x; x ^= 1;
	cout << x << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 11832
/*  ex9_1
    B30095    */
#include <stdio.h>
#include <stdlib.h>

// stack size
#define SIZE 1000

// definition of stack
typedef struct stack{
    int size;  // stack size
    int count; // number of data
    char data[SIZE];
    char *top;
} stack;

void print_stack_from_bottom(stack *stk);
void initialize_stack(stack *stk);
char pop(stack *stk);
void push(stack *stk, char elem);


int main(void){
    stack stk;
    char ch;

    initialize_stack(&stk);
    
    // process input with stack
    while(1){
        ch = getchar();
        if(ch == '\n' || ch == EOF || ch == '\0') break;  /// end loop if the end of input is reached

        if(ch == 'B'){
            if(stk.count > 0){
                pop(&stk);  // pop an element if backspace is entered and stack is not empty
            }
        }
        // push to stack if character other than backspace is entered
        else{
            push(&stk, ch);
        }
    }

    // print out the stack
    print_stack_from_bottom(&stk);

    return 0;
}


// print stack conetent in FIFO
void print_stack_from_bottom(stack *stk){
    int i;
    for(i = 0; i < stk->count; i++){
        putchar(stk->data[stk->size - i - 1]);
    }
}


// initialize a stack to be empty
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);  // top is at the end of the array
}


// stack push operation
void push(stack *stk, char elem){
    if(stk->count >= stk->size){  // stack overflow
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{  // push an element
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}


// stack pop operation
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){  // stack underflow
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{  // pop an element
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

Measured memory_bytes: 1472
s = input()[::-1]
while True:
    end_flg = False
    if s[:5] == "maerd":
        s = s.replace("maerd", "", 1)
        end_flg = True
    elif s[:5] == "esare":
        s = s.replace("esare", "", 1)
        end_flg = True
    elif s[:7] == "remaerd":
        s = s.replace("remaerd", "", 1)
        end_flg = True
    elif s[:6] == "resare":
        s = s.replace("resare", "", 1)
        end_flg = True    

    if end_flg == False:
        break
        
if s == "":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<class T>void prarr(vector<vector<T>>& a){
rep(i, a.size()){
rep(j, a[i].size()){
cout << a[i][j]; printf(" ");}
printf("\n");} printf("\n");}

int main()
{
    int h, w; cin >> h >> w;
    vector<string> p(h);
    rep(i, h) cin >> p[i];

    //行iにあるOrbの累積和
    arr<ll> orb(h, vector<ll>(w, 0)); 
    //列jにあるIngotの累積和
    arr<ll> ingot(h, vector<ll>(w, 0));

    rep(i, h){
        if(p[i][0]=='O') orb[i][0]++;
    } 
    FOR(i, 0, h) FOR(j, 1 ,w){
        orb[i][j] += orb[i][j-1];
        if(p[i][j]=='O') orb[i][j]++;
    }

    rep(i, w){
        if(p[0][i]=='I') ingot[0][i]++;
    } 
    FOR(i, 1, h) FOR(j, 0 ,w){
        ingot[i][j] += ingot[i-1][j];
        if(p[i][j]=='I') ingot[i][j]++;
    }

    // prarr(orb);
    // prarr(ingot);

    ll ans = 0;
    rep(i, h) rep(j, w){
        // printf("%d, %d, %lld\n", i, j, ans);
        if(p[i][j]!='J') continue;
        ans += (orb[i][w-1] - orb[i][j]) * (ingot[h-1][j] - ingot[i][j]);
    }
    pr(ans);
    return 0;}


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

int main() {
  int n;
  cin >> n;
  string temp;
  set<string> st;
  for(int i=0; i < n; i++)
  {
    cin >> temp;
    st.insert(temp);
  }
  cout << st.size();
  return 0;
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

ll lr[501][501];
ll sum[501][501];

ll dp( ll l, ll r ){
	if ( sum[l][r] == -1 ) {
		sum[l][r] = dp(l, r - 1) + dp(l - 1, r) - dp(l - 1, r - 1) + lr[l][r];
	}

	return sum[l][r];
}

int main( void )
{
	ll n, m, q;
	cin >> n >> m >> q;

	rep( i, m ) {
		ll l, r;
		cin >> l >> r;
		lr[l][r]++;
	}

	fill((ll *)sum, (ll *)(sum + 501), -1);

	rep( i, q ) {
		ll a, b;
		cin >> a >> b;

		cout << (dp(b, b) + dp(a - 1, a - 1) - dp(a - 1, b) - dp(b, a- 1)) << endl;
	}

	return 0;
}


Measured memory_bytes: 16640
import collections

n = int(input());
A = list(map(int, input().split()));

ans = [0] * n;

c = collections.Counter(A)
key = list(c.keys());
value = list(c.values());

for i in range(len(key)):
    ans[key[i]-1] = value[i];
  
for a in ans:
  print(a);

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
using ll = long long;


int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n)cin >> d.at(i);
  sort(d.begin(),d.end());
  cout<<d.at(n/2)-d.at(n/2-1)<<endl;
  return 0;
}


Measured memory_bytes: 640
#N, *a = map(int, open(0).read().split())
N = int(input())
a=[]
for i in range(N):
    a.append(int(input()))

def main():
    flag = 0
    tmp = a[-1]
    ans = 0
    
    for aa in reversed(a[:-1]):
        if aa >= tmp:
            ans += tmp
            tmp = aa
        elif aa +1 == tmp:
            ans += 1
            tmp = aa
        else:
            return -1

    if a[0] != 0:
        ans = -1
    return ans
            
print(main())


Measured memory_bytes: 12584
n = gets.to_i
b = gets.split.map &:to_i
a = Array.new(n,0)
a[0] = b[0]
a[n-1] = b[-1]
if b.size > 1
  (0..(b.size - 2)).each do |i|
    a[i+1] = [b[i],b[i+1]].min.to_i
  end
end
p a.inject(:+)

Measured memory_bytes: 1788
from heapq import *
class Node():
    def __init__(self, key, char=None):
        self.key = key
        self.char = char
        self.pare = None

st = input()
_st = list(set(st))

a = []
for i in _st:
    a  += [(st.count(i),i)] 
heapify(a)

node = {}
for i in range(len(a)):
    cnt, char = a[i]
    node[char] = Node(cnt, char)

while len(a) > 1:
    p1, p2 = heappop(a)
    q1, q2 = heappop(a)
    x = Node(p1+q1, p2+q2) 
    node[p2+q2] = x
    if len(a) == 0:
        root = x
        break
    node[p2].pare = x
    node[q2].pare = x
    heappush(a, (p1+q1,p2+q2))

def dfs(node, cnt=1):
    if node.pare == None:
        return cnt
    a = dfs(node.pare, cnt+1)
    return a

Sum = 0
for i in _st:
    no = node[i]
    depth = dfs(no)
    Sum += depth*no.key
    
print(Sum)

    




Measured memory_bytes: 5872
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int n;

double len(int r1,int r2)
{
    return sqrt((r1+r2)*(r1+r2) - (r1-r2)*(r1-r2));
}

int main()
{
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    vector<double> v(n);
    double ans = 0;
    rep(i,n){
        double mn = vec[i];
        for(int j=0;j<i;j++){
            mn = max(mn,len(vec[i],vec[j])+v[j]);
        }
        v[i] = mn;
        ans = max(ans,mn+vec[i]);
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 3224
import sys
input=sys.stdin.readline

N=int(input())
a=list(map(int,input().split()))

Alice=0
Bob=0
for i in range(N):
	if i%2==0:
		Alice+=max(a)
	else:
		Bob+=max(a)
	a.pop(a.index(max(a)))

print(Alice-Bob)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	vector<int> vec(N);
	for(int i=0; i<N; i++){
		cin>>vec.at(i);
	}
	sort(vec.begin(), vec.end());
	
	int a=1,b=0;
	for(int i=0; i<N-1; i++){
		if(vec.at(i)==vec.at(i+1)){
			a++;
		}
		else if((a%2)==1){
			b++;
			a=1;
		}
		else{
		    a=1;
		}
	}
	if((a%2)==1){
		b++;
	}
	cout<<b<<endl;
}

Measured memory_bytes: 640
H, W, N = map(int, input().split())


graph = {}
for _ in range(N):
    a, b = list(map(int, input().split()))
    for i in [-1, 0, 1]:
        for j in [-1, 0, 1]:
            na, nb = a-1+i, b-1+j
            if 1 <= na <= H-2 and 1 <= nb <= W-2:
                if not graph.get(na, False):
                    graph[na] = {nb: 1}
                elif not graph[na].get(nb, False):
                    graph[na][nb] = 1
                else:
                    graph[na][nb] += 1
#print(graph)
ans = [0 for _ in range(10)]
S = 0
for a, v_graph in graph.items():
    for b, v in v_graph.items():
        ans[v] += 1
        S += 1
ans[0] = (H-2)*(W-2) - S
for a in ans:
    print(a)

Measured memory_bytes: 142724
#include <cstdio>

typedef long long ll;
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))

inline ll read()
{
    char c = getchar();
    ll ret = 0;
    while (c < '0' || c > '9') c = getchar();
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
    return ret;
}

int N;
ll suml, l, maxl;
int main()
{
    N = read();
    int i;
    for (i = 1; i <= N; ++i) l = read(), maxl = max(maxl, l), suml += l;
    if (maxl >= suml - maxl) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 128
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    H, W = mi()
    S = [input() for i in range(H)]

    left = [[0]*W for _ in range(H)]
    right = [[0]*W for _ in range(H)]
    top = [[0]*W for _ in range(H)]
    bottom = [[0]*W for _ in range(H)]

    # left
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                left[i][j] = 0
                continue

            if j == 0 or S[i][j-1] == '#':
                left[i][j] = 1
            else:
                left[i][j] = left[i][j-1] + 1

    # right
    for i in range(H):
        for j in range(W-1, -1, -1):
            if S[i][j] == '#':
                right[i][j] = 0
                continue

            if j == W-1 or S[i][j+1] == '#':
                right[i][j] = 1
            else:
                right[i][j] = right[i][j+1] + 1

    # top
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                top[i][j] = 0
                continue

            if i == 0 or S[i-1][j] == '#':
                top[i][j] = 1
            else:
                top[i][j] = top[i-1][j] + 1

    # bottom
    for i in range(H-1, -1, -1):
        for j in range(W):
            if S[i][j] == '#':
                bottom[i][j] = 0
                continue

            if i == H-1 or S[i+1][j] == '#':
                bottom[i][j] = 1
            else:
                bottom[i][j] = bottom[i+1][j] + 1


    m = -math.inf

    for i in range(H):
        for j in range(W):
            m = max(left[i][j]+right[i][j]+top[i][j]+bottom[i][j]-3, m)

    print(m)



if __name__ == '__main__':
    main()


Measured memory_bytes: 200064
#include <string>
#include <iostream>
#include <algorithm>
#include <sstream>

using namespace::std;

void calc(int *A, int *B){
      if(*A%2 == 1)(*A)--;
      *B += *A/2;
      *A -= *A/2;
}

int main(void){
  int A,B,K;

  cin >> A >> B >> K;

  for (int i = 0; i < K; i++) {
    if(i%2 == 0){
      calc(&A,&B);
    }else{
      calc(&B,&A);
    }
  }

  cout << A << " " << B << endl;
  return 0;
}



Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(& mut buf).ok();
    let buf = buf.trim();
    let n: i32 = buf.trim().parse().ok().unwrap();
    //println!{"{}", n};

    let mut buf = String::new();
    std::io::stdin().read_line(& mut buf).ok();
    let buf = buf.trim();
    let mut v: Vec<i32> = buf.split_whitespace().map(|x| x.parse().ok().unwrap()).collect();

    let mut v1: Vec<i32> = Vec::new();
    let mut v2: Vec<i32> = Vec::new();
    for i in 0..v.len() {
        if i % 2 == 0 {v1.push(v[i]);}
        else {v2.push(v[i]);}
    }
    /*
    for i in 0..v.len() {
        println!{"{}", v[i]};
    }
    println!{"------------"};
    for i in 0..v1.len() {
        println!{"{}", v1[i]};
    }
    println!{"------------"};

    for i in 0..v2.len() {
        println!{"{}", v2[i]};
    }
    println!{"------------"};

    */
    let mut cnt1: Vec<(i32, i32)> = Vec::new();
    let mut cnt2: Vec<(i32, i32)> = Vec::new();
    for i in 0..100000+1 {
        cnt1.push((0, i));
        cnt2.push((0, i));
    }
    //println!{"{}", cnt1[100].0};
    //println!{"{}", cnt[100]};
    for i in  0..v1.len() {
        let idx1:usize = v1[i] as usize;
        let idx2:usize = v2[i] as usize;
        cnt1[idx1].0 += 1;
        cnt2[idx2].0 += 1;
    }
    //println!{"{}", cnt1[3].0};
    cnt1.sort_by_key(|&(a,b)| a);
    cnt1.reverse();
    //println!{"{} {}", cnt1[0].0, cnt1[0].1};
    cnt2.sort_by_key(|&(a,b)| a);
    cnt2.reverse();
    let ans;
    if cnt1[0].1 != cnt2[0].1 {
        ans = n - cnt1[0].0 - cnt2[0].0;
    }
    else {
        ans = std::cmp::min(n - cnt1[0].0 - cnt2[1].0, n - cnt1[1].0 - cnt2[0].0);
    }
    println!{"{}", ans};
}


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
int n;

int main(){
	io;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)ans+=(ll)(n-i+1)*(ll)(n-i+2)/2LL;
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		if(u>v)swap(u,v);
		ans-=(ll)u*(ll)(n-v+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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(){
	ll n;cin>>n;


    ll ans=0;
    rep(x,n+1){
        if(x==0) continue;
        vector<ll> howmany;
        ll ins=x;

        for(ll i=2;i*i<=x;i++){
            bool in=false;
            ll cnt=0;
	        while(ins % i== 0) {
  		        ins/=i;
                in=true;
                cnt++;
	        }

            if(in) howmany.push_back(cnt);
        }
 
        if(ins!=1){
	        howmany.push_back(1);
        }

        ll num=1;
        rep(i,howmany.size()){
            num*=(howmany[i]+1);
        }

        if(x%2==1 && num==8) ans++;
    }
    
    cout<<ans<<endl;    

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
   public static void main(String[] args) {
	    Scanner in = new Scanner(System.in);
	    ArrayList<String> result = new ArrayList<String>();
	    while(true){
	       int cardNum = Integer.parseInt(in.nextLine());
	       int[] aCard = new int[cardNum];
	       int[] bCard = new int[cardNum];
	    
	       if(cardNum == 0){
	    	   resultToString(result);
	    	   in.close();
	    	   break;
	       }
	    
	       for(int i=0; i<cardNum; i++){
	          String[] pCard = in.nextLine().split(" ");
	          aCard[i] = Integer.parseInt(pCard[0]);
	          bCard[i] = Integer.parseInt(pCard[1]);
	          //System.out.println(aCard[i] +  " " + bCard[i]);
	       }
	       result.add(match(cardNum,aCard,bCard));
	    }
   }
   
   public static String match(int n, int[] a, int[] b){
	   int aScore=0;
	   int bScore=0;
	   
	   for(int i = 0; i < n; i++){
		   if(a[i] > b[i]){
			   aScore = aScore + a[i] + b[i];
		   }else if(a[i] == b[i]){
			   aScore = aScore + a[i];
			   bScore = bScore + b[i];
		   }else{
			   bScore = bScore + a[i] + b[i];
		   }
	   }
	   
	   return aScore + " " + bScore; 
   }
   
   public static void resultToString(ArrayList<String> result){
	   for(int i=0; i<result.size(); i++){
		   System.out.println(result.get(i));
	   }
   }
}

Measured memory_bytes: 60236
#include<iostream>
using namespace std;
long long n;
int main()
{
	cin>>n;
	for(int i=1;;i++)
		for(int j=i;j<3501;j++)
		{
			long long a=n*i*j,b=4*i*j-n*(i+j);
			if(b>0&&a%b==0)
			{
				cout<<i<<' '<<j<<' '<<a/b<<endl;
				return 0;
			}
		}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

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

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

int s[1024];

int main(void){
  int n;
  reps(i,1,999){
    int sum = i;
    reps(j,i+1,1000){
      sum += j;
      if( sum > 1000)break;
      s[sum]++;
    }
  }

  while(cin >> n,n){
    cout << s[n] << endl;
  }


  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	vi a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	int sum=0;
	vi ans(n,0);
	rep(z,n){
		int i=n-z-1;
		int p=(sum+a[i]+b[i]-1)/b[i]*b[i];
		ans[i]=p-(sum+a[i]);
		sum+=ans[i];
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 5616
/*input
6
AC
TLE
AC
AC
WA
TLE
*/

// Nihesh Anderson - knandy

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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

map<string, int> m;

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int n; cin >> n;
	for(int i = 0; i < n; i++) {
		string s; cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3628
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // 入力をpush_back(d)やarray[d]に使う時に1行で書ける

// ------------------- include, typedef, define END. -------------------

const char table[8] = { '0', '1', '2', '3', '5', '7', '8', '9' };

void solve(int n){
	if (n >= 8)
		solve(n / 8);
	cout << table[n % 8];
}

int main(){
	fastIO;
	// 文字01235789を使う8進数として考える.
	// 参考リンク4つ
	// http://d.hatena.ne.jp/nanikaka/20111120/1321748152
	// http://refiute.hatenablog.com/entry/20110907/1315381210
	// http://program.pinemz.net/article/168162542.html
	// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=180052

	// 1. 数値 (= n) を 8 で割った余りをその位の値とする.
	// 2. n を 8 で割り, その答えを n として 1 に戻る.
	// (8進数に変換しているだけ. 8→5とかでもいけるはず.)

	// これは下位桁から求めている.再帰にして上位桁から出力する.

	int n;
	while (cin >> n, n){
		solve(n);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int mod = 1000000007;
		int n = s.length;
		long[][] dp = new long[n + 1][3];
		long b = 1;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'A') {
				dp[i + 1][0] = dp[i][0] + b;
				dp[i + 1][0] %= mod;
				dp[i + 1][1] = dp[i][1];
				dp[i + 1][2] = dp[i][2];

			} else if (s[i] == 'B') {
				dp[i + 1][0] = dp[i][0];
				dp[i + 1][1] = dp[i][0] + dp[i][1];
				dp[i + 1][1] %= mod;
				dp[i + 1][2] = dp[i][2];

			} else if (s[i] == 'C') {
				dp[i + 1][0] = dp[i][0];
				dp[i + 1][1] = dp[i][1];
				dp[i + 1][2] = dp[i][1] + dp[i][2];
				dp[i + 1][2] %= mod;

			} else {
				dp[i + 1][0] = dp[i][0] * 3 + b;
				dp[i + 1][0] %= mod;
				dp[i + 1][1] = dp[i][0] + dp[i][1] * 3;
				dp[i + 1][1] %= mod;
				dp[i + 1][2] = dp[i][1] + dp[i][2] * 3;
				dp[i + 1][2] %= mod;
				b = b * 3 % mod;
			}
		}
		System.out.println(dp[n][2]);
	}
}


Measured memory_bytes: 32984
n,m,c = list(map(int, input().split()))
b = list(map(int, input().split()))
a = []
for k in range(n):
    a.append(list(map(int, input().split())))

num = 0
for k in range(n):
    temp = 0
    for i in range(m):
        temp += a[k][i] * b[i]
#     print(temp)
    if temp > -c:
        num += 1
print(num)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 int N;
  int A;
  cin >>N>>A;
  int x=N%500;
  if(x<=A) {
cout <<"Yes" << endl;
  }
else {
cout << "No" << endl;
}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	rep(i, N) {
		cin >> s[i];	
	}

	int M;
	cin >> M;
	vector<string> t(M);
	rep(i, M) {
		cin >> t[i];
	}

	int ans = 0;
	rep(i, N) {
		int cntN = 0;
		rep(j, N) {			
			if (s[i] == s[j]) cntN++;
		}
		int cntM = 0;
		rep(j, M) {
			if (s[i] == t[j]) cntM++;		
		}
		ans = max(ans, cntN - cntM);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4"""
        output = """0.5000000000"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5"""
        output = """0.6000000000"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1"""
        output = """1.0000000000"""
        self.assertIO(input, output)
def resolve():
    n=int(input())
    if n%2==0:
        print(0.5)
    else:
        print((int(n/2)+1)/n)
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 51440
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	ans := 0
	for _, n := range S {
		if n == '1' {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int ans=0;
  rep(i,1000){
    int a,b,c;
    c=i%10;
    b=(i/10)%10;
    a=(i/100);
    char x='0'+a;
    char y='0'+b;
    char z='0'+c;
    bool inx=false;
    bool iny=false;
    bool inz=false;
    rep(j,n){
      if(!inx && s[j]==x) {
        inx=true;
      }
      else if(inx && !iny && s[j]==y) {
        iny=true;
      }
      else if(iny && !inz && s[j]==z) {
        inz=true;
        break;
      }
    }
    if(inz) ans++;
  }

  cout << ans << endl;
}

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

int main() {
    long long X, Y;
    cin >> X >> Y;
    int ans = 0;
    while (X <= Y) X *= 2, ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}

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

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

Measured memory_bytes: 256