akhauriyash/Code-Regression huggingface dataset:
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)*}
    };
}

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)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

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

fn main() {
    input!{
        h: usize,
        w: usize,
        t: usize
    }
    let d = 1000000007;
    let gh = gcd(h, t);
    let gw = gcd(w, t);
    let h2 = h / gh;
    let w2 = w / gw;
    let mut ans = (pow_m(2, gcd(h2, w2), d) + pow_m(2, h2, d) + pow_m(2, w2, d) + d - 3) % d;
    ans = pow_m(ans, gh * gw, d);
    println!("{}", ans);
}

fn gcd(n: usize, m: usize) -> usize {
    let mut l = min(n, m);
    let mut r = max(n, m);
    while l > 0 {
        let t = l;
        l = r % l;
        r = t;
    }
    r
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>
int main(){
  int n,a,t=0,i=0;
  scanf("%d",&n);
  for(;i<n;i++){
    scanf("%d",&a);
    t+=1-a%2;
  }
  printf("%.f",pow(3,n)-pow(2,t));
}

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

C = [0]
for i in range(1, N + 1):
    C.append(C[-1] + A[i - 1])


def c_sum(right, left):
    return C[right] - C[left]


ans = float('inf')
l = 1
r = 2
for m in range(1, N):
    while abs(c_sum(m, l) - c_sum(l, 0)) > abs(c_sum(m, l + 1) - c_sum(l + 1, 0)):
        l += 1

    while abs(c_sum(N, r) - c_sum(r, m)) > abs(c_sum(N, r + 1) - c_sum(r + 1, m)):
        r += 1

    P = c_sum(l, 0)
    Q = c_sum(m, l)
    R = c_sum(r, m)
    S = c_sum(N, r)
    ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))

print(ans)

Measured memory_bytes: 25676
import Data.List
main=do
    ns<-map read.concat.f <$> getLine::IO[Int]
    print.sum $ ns

f ss =(:) [ss] $  concatMap (\(l,r)->g l r) $ map (flip splitAt ss) [1..(length ss)- 1]
g l r = map (\s->l:s) (f r)


Measured memory_bytes: 1020
#include<stdio.h>

void convert(char *str)
{
	int i=0;
	while(*(str+i)!='\0')
	{
		if(*(str+i)>'a'&&*(str+i)<='z')
		{
			*(str+i)-=1;
		}
		else if(*(str+i)=='a')
		{
			*(str+i)='z';
		}
		i++;
	}
}

int main()
{
	char str[81];
	int flg;
	int i;
	while(fgets(str,81,stdin)!=NULL)
	{
		flg=0;
		while(!flg)
		{
			convert(str);
			i=0;
			while(*(str+i+2)!='\0')
			{
				if(*(str+i)=='t')
				{
					if(*(str+i+1)=='h')
					{
						if(*(str+i+2)=='e')
						{
							flg=1;
						}
						else if(*(str+i+2)=='i')
						{
							if(*(str+i+3)=='s')
							{
								flg=1;
							}
						}
						else if(*(str+i+2)=='a')
						{
							if(*(str+i+3)=='t')
							{
								flg=1;
							}
						}
					}
				}
				i++;
			}
		}
		printf("%s",str);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline


# エラトステネスのふるい
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime_list = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime_list + data
        prime_list.append(p)
        data = [e for e in data if e % p != 0]


prime = get_sieve_of_eratosthenes(10 ** 5)
p = set(prime)
prime = [i for i in prime if (i + 1) // 2 in p]
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(bisect_right(prime, r) - bisect_left(prime, l))

Measured memory_bytes: 6024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
const int D_MAX_V=402;
const int D_v_size=402;
struct D_wolf{
	int t,c,r;
	D_wolf(){t=c=r=0;}
	D_wolf(int t1,int c1,int r1){
		t=t1;c=c1;r=r1;
	}
};
vector<D_wolf>D_G[D_MAX_V];
int D_level[D_MAX_V];
int D_iter[D_MAX_V];

void add_edge(int from,int to,int cap){
	D_G[from].push_back(D_wolf(to,cap,D_G[to].size()));
	D_G[to].push_back(D_wolf(from,0,D_G[from].size()-1));
}
void D_bfs(int s){
	for(int i=0;i<D_v_size;i++)D_level[i]=-1;
	queue<int> Q;
	D_level[s]=0;
	Q.push(s);
	while(Q.size()){
		int v=Q.front();
		Q.pop();
		for(int i=0;i<D_G[v].size();i++){
			if(D_G[v][i].c>0&&D_level[D_G[v][i].t]<0){
				D_level[D_G[v][i].t]=D_level[v]+1;
				Q.push(D_G[v][i].t);
			}
		}
	}
}
int D_dfs(int v,int t,int f){
	if(v==t)return f;
	for(;D_iter[v]<D_G[v].size();D_iter[v]++){
		int i=D_iter[v];
		if(D_G[v][i].c>0&&D_level[v]<D_level[D_G[v][i].t]){
			int d=D_dfs(D_G[v][i].t,t,min(f,D_G[v][i].c));
			if(d>0){
				D_G[v][i].c-=d;
				D_G[D_G[v][i].t][D_G[v][i].r].c+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	for(;;){
		D_bfs(s);
		if(D_level[t]<0)return flow;
		for(int i=0;i<D_v_size;i++)D_iter[i]=0;
		int f;
		while((f=D_dfs(s,t,99999999))>0){flow+=f;}
	}
	return 0;
}
char in[110][110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%s",in[i]);
	}
	int s=a+b;
	int t=a+b+1;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(in[i][j]=='S'){
			add_edge(s,i,9999999);
			add_edge(s,j+a,9999999);
		}
		if(in[i][j]=='T'){
			add_edge(i,t,9999999);
			add_edge(j+a,t,9999999);
		}
		if(in[i][j]=='o'){
			add_edge(i,j+a,1);
			add_edge(j+a,i,1);
		}
	}
	int ret=max_flow(s,t);
	if(ret>999999)ret=-1;
	printf("%d\n",ret);
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

const int  mod = 1e9+7;
int N, L;

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

  cin >> N >> L;
  vector<int> a(N);
  rep(i, N) {
    cin >> a.at(i);
  }
  int pos = -1;
  for(int i=0; i<N-1; i++) {
    if (a.at(i)+a.at(i+1) >= L) {
      pos = i+1;
      break;
    }
  }
  if (pos == -1) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << '\n';
  for(int i=1; i<pos; i++) {
    cout << i << '\n';
  }
  for(int i=N-1; i>pos; i--) {
    cout << i << '\n';
  }
  cout << pos << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll H, W;
    cin >> H >> W;

    vector<string> S(H); 
    rep(i,H){
        cin >> S[i];
    }

    vector<vector<int>> rows(H,vector<int>(W,0));
    vector<vector<int>> culs(H,vector<int>(W,0));

    rep(i,H){
        int j = 0;
        while(j < W){
            int count = 0;
            for(int k = j;k < W;k++){
                if(S[i][k] == '#'){
                    break;
                }
                count++;
            }

            for(int c = 0;c < count;c++){
                rows[i][j+c] = count;
            }

            j += count+1;
        }
    }


    rep(i,W){
        int j = 0;
        while(j < H){
            int count = 0;
            for(int k = j;k < H;k++){
                if(S[k][i] == '#'){
                    break;
                }
                count++;
            }

            for(int c = 0;c < count;c++){
                culs[j+c][i] = count;
            }

            j += count+1;
        }
    }

    // rep(i,H){
    //     rep(j,W){
    //         cout << rows[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    // rep(i,H){
    //     rep(j,W){
    //         cout << culs[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    ll maxVal = 0;

    rep(i,H){
        rep(j,W){
            maxVal = max(maxVal,(ll)rows[i][j]+culs[i][j]); 
        }
    }

    cout << maxVal - 1 << endl;


}

Measured memory_bytes: 35712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
			int c=0;
			while(true) {
				int a=scan.nextInt();
				String op=scan.next();
				int b=scan.nextInt();
			if(op.equals("+")) {
				c=a+b;
			}
			else if(op.equals("-")) {
				c=a-b;
			}
			else if(op.equals("*")) {
				c=a*b;
			}
			else if(op.equals("/")) {
				c=a/b;
			}
			else if(op.equals("?")) {
				break;
			}
			System.out.printf("%d\n",c);
			}
		scan.close();
}
}


Measured memory_bytes: 26352
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll A, B, C; cin >> A >> B >> C;
    //C基準
    if(C > (B + A)){
        cout << A + B + B + 1 << endl;
    }else if(C <= (B + A)){
        cout << C + B << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var s = ReadLine();

        var rCount = s.Count(c => c == 'R');
        var wCount = s.Count(c => c == 'W');

        var ans = s.Take(rCount).Count(c => c != 'R');

        WriteLine(ans);
    }
}


Measured memory_bytes: 28784
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		Set<Character>set=new HashSet<>();
		
		set.add(s.charAt(0));
		set.add(s.charAt(1));
		set.add(s.charAt(2));
		
		if(set.size()==3)System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int N;
	cin >> N;
	vector<ll> A;
	rep(i, 0, N) {
		ll a;
		cin >> a;
		A.push_back(a - i - 1);
	}

	vsort(A);

	int mid = 0;
	if(N % 2 == 0) {
		mid = N / 2;
	} else {
		mid = (N + 1) / 2 - 1;
	}

	ll tmp = A[mid];
	ll res = 0;
	rep(i, 0, N) {
		res += abs(A[i] - tmp);
	}

	cout << res << endl;


}


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

int countDigit(int n){
    return floor(log10(n) + 1);
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(countDigit(i) % 2)ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();

			int inf = 100000;
			int[,] d = new int[n, n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i != j) {
						d[i, j] = inf;
					}
				}
			}

			List<int>[] to = new List<int>[n];
			for (int i = 0; i < n; i++) {
				to[i] = new List<int>();
			}

			for (int i = 0; i < n; i++) {
				string t = cin.Next();
				for (int j = 0; j < n; j++) {
					if (t[j] == '1') {
						to[i].Add(j);
						d[i,j] = 1;
					}
				}
			}

			//わーシャルふろいど
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					for (int k = 0; k < n; k++) {
						d[j, k] = Math.Min(d[j, k], d[j, i] + d[i, k]);
					}
				}
			}

			int start = 0;
			int max = 0;
			for (int i = 0; i < n; i++) {
				int tempMax = 0;
				for (int j = 0; j < n; j++) {
					if (d[i, j] < inf) {
						tempMax = Math.Max(d[i, j], tempMax);
					}
				}

				if (tempMax > max) {
					max = tempMax;
					start = i;
				}
			}

			bool[] check = new bool[n];
			var q = new Queue<Tuple<int, int>>();
			check[start] = true;
			q.Enqueue(new Tuple<int, int>(start, 0));
			while(q.Count > 0){
				var target = q.Dequeue();
				foreach (int next in to[target.Item1]) {
					int dist = d[start, next];
					if (dist == target.Item2 + 1 || dist == target.Item2 - 1) {
						if (dist == target.Item2 + 1 && check[next] == false) {
							check[next] = true;
							q.Enqueue(new Tuple<int, int>(next, dist));
						}
					} else {
						Console.WriteLine(-1);
						return;
					}
				}
			}

			Console.WriteLine(max + 1);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13396
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] dishes = new int[5];
		int sum = 0;
		for(int i = 0; i < 5; i++) {
			dishes[i] = sc.nextInt();
			sum += dishes[i];
			dishes[i] = (10 - (dishes[i] % 10)) % 10;
		}
		Arrays.sort(dishes);
		for(int i = 0; i < 4; i++) {
			sum += dishes[i];
		}
		System.out.println(sum);
	}
}

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

int main() {
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    char v[3] = {'0'-1, '0'-1, '0'-1};

    rep(i, 10){
        if(v[0] == '9') v[0] = '0';
        else v[0]++;
        rep(j, 10){
            if(v[1] == '9') v[1] = '0';
            else v[1]++;
            rep(k, 10){
                if(v[2] == '9') v[2] = '0';
                else v[2]++;

                ll p[3] = {-1, -1, -1};
                for(ll l = 0; l < N; l++){
                    if(v[0] == S[l]){
                        p[0] = l;
                        break;
                    }
                }
                for(ll l = p[0]+1; l < N; l++){
                    if(v[1] == S[l]){
                        p[1] = l;
                        break;
                    }
                }
                for(ll l = p[1]+1; l < N; l++){
                    if(v[2] == S[l]){
                        p[2] = l;
                        break;
                    }
                }
                if(p[0] != -1 && p[1] != -1 && p[2] != -1){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


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

public class Main {
	Scanner sc = new Scanner(System.in);
	public void run(){
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			calc(n);
		}
	}
	public void calc(int n){
		String firs = "";
		String secs = "";
		int firn = 0;
		int secn = 0;
		int d = 0;
		
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		for(int i = 0; i < n; i++){
			String c = sc.next();
			d+=1;
			int cn = 1;

			if(map.containsKey(c)){
				cn = map.get(c)+1;
			}
			map.put(c, cn);
			
			if(cn > firn){
				if(!(firs.equals(c))){
					secs = firs;
					secn = firn;
				}
				firs = c;
				firn = cn;
			}
			else if(cn > secn){
				secs = c;
				secn = cn;
			}
			if(secn + n - d < firn){
				break;
			}
		}
		if(firn == secn){
			System.out.println("TIE");
		}
		else{
			System.out.print(firs);
			System.out.print(" ");
			System.out.println(d);
		}
		
		for(int i = d; i < n; i++){
			sc.next();
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 51820
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

LL POW_MOD(LL n, LL p, LL MOD) {
    LL ret = 1;
    while (p > 0) {
        if (p & 1) ret = (ret * n) % MOD;
        n = (n * n) % MOD;
        p >>= 1;
    }
    return ret;
}

LL ARITH_SUM_MOD(LL a, LL d, LL n, LL MOD) {
    return (2 * a + (n - 1) * d) % MOD * n % MOD * POW_MOD(2, MOD - 2, MOD) % MOD;
}

LL ARITH_SUM(LL a, LL d, LL n) {
    return (2 * a + (n - 1) * d) * n / 2;
}

constexpr LL mod = 1e9 + 7;

int main() {

    LL N, K;
    cin >> N >> K;

    vector<LL> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<LL> B(N, 0);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (A[i] < A[j]) {
                B[i]++;
            }
        }
    }

    LL ans = 0;
    for (int i = 0; i < N; i++) {
        LL cnt = 0;
        for (int j = 0; j < i; j++) {
            if (A[i] < A[j]) {
                cnt++;
            }
        }
        ans += ARITH_SUM_MOD(cnt, B[i], K, mod);
        ans %= mod;
    }

    cout << ans << endl;

}














Measured memory_bytes: 384
xs = [[int(x) for x in input().split()] for _ in range(3)]
ys = list(zip(*xs))

def check(row1, row2):
    return len(set(a-b for a,b in zip(row1, row2))) == 1

rowcheck = all(check(row1, row2) for row1, row2 in zip(xs, xs[1:]))
colcheck = all(check(col1, col2) for col1, col2 in zip(ys, ys[1:]))

print('Yes' if rowcheck and colcheck else 'No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
constexpr int MOD = 1e9+7;
const int N= 50000;
using namespace std;


ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 
ll lcm(int a, int b)  
 {  
    return a/gcd(a, b) *b;  
 }
  
int prime(int n)
{
	rep(i,2,n+1)
	{
		if(n%i==0)return i;
	}
	
}


void solve() 
{
int n, cnt = 0;
	cin >> n;
	double dist = 0;
	vector<int> id(n);
	vector<double> x(n), y(n);
	rep (i,0, n) cin >> x[i] >> y[i], id[i] = i;
	do {
	  rep (i,0, n - 1) {
		double p = (x[id[i]] - x[id[i + 1]]) * (x[id[i]] - x[id[i + 1]]) + (y[id[i]] - y[id[i + 1]]) * (y[id[i]] - y[id[i + 1]]);
		dist += sqrt(p);
	  }
	  cnt++;
	} while (next_permutation(id.begin(), id.end()));
	cout << fixed << setprecision(10) << dist / cnt << endl;

}

int main()
{
	hello777;
	int q=1;
//    cin>>q;
    while(q--)
    {   
      solve();
    }
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

modint<> nCr(int n,int r){
	modint<> ans = 1;
	for(int i = 1;i <= r;i++) ans = ans * modint<>(n - i + 1) / modint<>(i);
	return ans;
}

signed main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << modint<>(2).pow(n) - nCr(n,a) - nCr(n,b) - modint<>(1) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<unordered_map>
#include<utility>
#include<vector>

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

class UnionFind{
    using Weight = long long;

    int n;
    std::vector<int> par;
    std::vector<Weight> weight;
    int siz;

public:
    UnionFind(int n_ = 0){
        init(n_);
    }

    void init(int n_ = 0){
        n = n_;
        par.assign(n, -1);
        weight.assign(n, 0);
        siz = n;
        return;
    }

    int find(int x){
        if(par[x] < 0){
            return x;
        }
        int root = find(par[x]);
        weight[x] += weight[par[x]];
        return par[x] = root;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    Weight get_weight(int x){
        find(x);
        return weight[x];
    }

    bool unite(int x, int y, Weight w = 0){
        w += get_weight(x) - get_weight(y);

        x = find(x);
        y = find(y);

        if(x == y){
            return false;
        }

        if(par[x] < par[y]){
            std::swap(x, y);
            w = -w;
        }

        par[x] += par[y];
        par[y] = x;
        weight[y] = w;
        --siz;

        return true;
    }

    Weight diff(int x, int y){
        return get_weight(y) - get_weight(x);
    }

    int size_of_set(int x){
        return -par[find(x)];
    }

    int count_set(void){
        return siz;
    }
};

int main(){
    int n, m;
    std::cin >> n >> m;

    std::vector<int> l(m), r(m);
    std::vector<long long> d(m);
    for(int i = 0 ; i < m ; ++i){
        std::cin >> l[i] >> r[i] >> d[i];
        --l[i];
        --r[i];
    }

    UnionFind uf(n);
    for(int i = 0 ; i < m ; ++i){
        if(uf.same(l[i], r[i]) && uf.diff(l[i], r[i]) != d[i]){
            std::cout << "No" << std::endl;
            return 0;
        }
        uf.unite(l[i], r[i], d[i]);
    }

    std::cout << "Yes" << std::endl;

    return 0;
}

Measured memory_bytes: 7388
import java.util.Scanner
import kotlin.math.*

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val abc =IntArray(3){scn.nextInt()}
	val q = Array(n){scn.next().toCharArray().map{it-'A'}}
	val arr = mutableListOf<Char>()
	repeat(n){
		val s = q[it]
		if (max(abc[s[0]],abc[s[1]])==0) {
			println("No")
			return
		}
		if (abc[s[0]]<abc[s[1]]){
			abc[s[0]]++
			abc[s[1]]--
			arr.add('A'+s[0])
		}else if (abc[s[0]]==1 && abc[s[1]]==1 && it<n-1 && s[0] in q[it+1]){
			abc[s[0]]++
			abc[s[1]]--
			arr.add('A'+s[0])
		}else {
			abc[s[0]]--
			abc[s[1]]++
			arr.add('A'+s[1])
		}
	}
	println("Yes")
	arr.forEach(::println)
}

Measured memory_bytes: 66872
#include <bits/stdc++.h>
using namespace std;
const long long INF = 9999999999999999;

const long long MAX = 30000000;
const long long MOD = 1000000007;

int main(){
  int N;
  cin>>N;
  int a[N][2];
  for(int i = 0;i<N;i++){
    cin>>a[i][0] >> a[i][1];
  }
  double ans = 0;
  double temp;
  for(int i = 0;i<N;i++){
    for(int k = i+1;k<N;k++){
      temp = sqrt(pow((a[i][0]-a[k][0]),2)+pow((a[i][1]-a[k][1]),2));
      ans += temp;
    }
  }
  int p = 1;
  for(int i = 1;i<N;i++){
    p*=i;
  }
  cout << setprecision(10) << ans*2/N << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int solve(int, int);
int n;
int A[20];


int main(){

  int i,q;
  int mi[200];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

 scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&mi[i]);
  }

  for(i=0;i<q;i++){
    if(solve(0,mi[i])==1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i, int m){
  
  int res;
  
  if(m==0) return 1;
  if(i>=n) return 0;
  
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  
  return res;
}

Measured memory_bytes: 580
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto P = RDA(-1);
	auto cnt = new long[][](N, N);
	foreach (i; 0..N)
	{
		auto b = N-i-1;
		foreach (j; 0..N)
		{
			auto r = N-j-1;
			cnt[i][j] = min(i, j, b, r);
		}
	}
	auto use = new long[][](N, N);
	foreach (i; 0..N)
	{
		use[i][] = 1;
	}

	void visit(long y, long x)
	{
		auto cost = cnt[y][x] + use[y][x];
		if (y != 0)
		{
			if (cost < cnt[y-1][x])
			{
				cnt[y-1][x] = cost;
				visit(y-1, x);
			}
		}
		if (y != N-1)
		{
			if (cost < cnt[y+1][x])
			{
				cnt[y+1][x] = cost;
				visit(y+1, x);
			}
		}
		if (x != 0)
		{
			if (cost < cnt[y][x-1])
			{
				cnt[y][x-1] = cost;
				visit(y, x-1);
			}
		}
		if (x != N-1)
		{
			if (cost < cnt[y][x+1])
			{
				cnt[y][x+1] = cost;
				visit(y, x+1);
			}
		}
	}
	debug writeln(cnt);

	long ans;
	foreach (e; P)
	{
		auto y = e / N;
		auto x = e % N;
		visit(y, x);
		ans += cnt[y][x];
		use[y][x] = 0;
		visit(y, x);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


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

int main()
{
  int N;
  cin >> N;
  unordered_set<int> s;
  int fn = 0;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(1 <= a && a <= 399){
      s.insert(1);
    }else if(400 <= a && a <= 799){
      s.insert(2);
    }else if(800 <= a && a <= 1199){
      s.insert(3);
    }else if(1200 <= a && a <= 1599){
      s.insert(4);
    }else if(1600 <= a && a <= 1999){
      s.insert(5);
    }else if(2000 <= a && a <= 2399){
      s.insert(6);
    }else if(2400 <= a && a <= 2799){
      s.insert(7);
    }else if(2800 <= a && a <= 3199){
      s.insert(8);
    }else if(a >= 3200){
      fn++;
    }
  }
  if(s.size() != 0)
    cout << s.size() << " " << s.size()+fn << endl;
  else
    cout << "1 " << s.size()+fn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int a[100001];
  REP(i,n){
    cin>>a[i+1];
  }
  int fst=1;
  REP(i,n){
    fst=a[fst];
    if(fst==2){
      P(i+1);
      return 0;
    }
  }
  P(-1);
  return 0;
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code
vector<ll> v;
multiset<ll> s;
int main()
{
	int n;
	cin>>n;
	ll x;
	cin>>x;
	s.insert(x);
	s.insert(M);
	ll ans = 1;
	rep(i, 1, n)
	{
		cin>>x;
		auto itr = s.lower_bound(x);
		if(itr == s.begin())
		{
			ans++;
			s.insert(x);
		}
		else
		{
			itr--;
			s.erase(itr);
			s.insert(x);
		}
		// for(int x: s) cout<<x<<" ";
		// cout<<endl;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f;
int n,a[100010],dp[100010],k;
int main()
{
	memset(dp,INF,sizeof(dp));
	cin>>n>>k;
	for(int i=1;i<=n;++i)cin>>a[i];
	dp[1]=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			if(i-j>=1)dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
		
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
def abc127d():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    d = {}
    for item in a:
        if item in d:
            d[item] += 1
        else:
            d[item] = 1
    for _ in range(m):
        b, c = map(int, input().split())
        if c in d:
            d[c] += b
        else:
            d[c] = b
    cnt = n
    ans = 0
    for k in sorted(d.keys(), reverse=True):
        v = min(cnt, d[k])
        ans += k * v
        cnt -= v
    print(ans)
abc127d()

Measured memory_bytes: 105644
#include <iostream>
using namespace std;
int main() {
  int n,a,b;
  cin >> n >> a>>b;
  cout << ((a<b)?a:b) << " ";
  if(a+b<=n){
    cout << "0";
  }else{
    cout << a+b-n;
  }
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[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()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

fn main() {
    input!{
        k: usize,
        a: usize,
        b: usize,
    }
    let mut answer = false;
    let mut a = a;
    while a <= b {
        if a % k == 0 {
            answer = true;
            break;
        }
        a+=1;
    }
    println!("{}", if answer {"OK"} else {"NG"});
}


Measured memory_bytes: 2108
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(0<n&&n<10){cout<<"Yes"<<endl;
          return 0;
            }else{
  for(int i=0;i<8;i++){
    if(n/(i+2)<10&&n%(i+2)==0){
      cout<<"Yes"<<endl;
      return 0;
     }
    if(i==7){cout<<"No"<<endl;
             return 0;
            }

  }
  }

  }

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

int main()
{
  int n, ans = 1;
  cin >> n;
  vector<char> s;
  char c;
  cin >> c;
  s.push_back(c);
  for (int i = 1; i < n; i++)
  {
    cin >> c;
    if (c != s.at(i - 1))
    {
      ans++;
    }
    s.push_back(c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3696
#include <stdio.h>

int main(){
  char S[2*10*10*10*10*10+1];
  char T[2*10*10*10*10*10+1];
  int count = 0;
  int i=0;
  
  scanf("%s %s",S,T);
  
  while(S[i] != '\0'){
    if(S[i] != T[i]) count++;
    i++;
  }
  
  printf("%d\n",count);
  
  return 0;
  
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	ll v = V-W;
	if (v <= 0) {
		cout << "NO" << endl;
		return 0;
	}
	cout << (abs(A-B) <= v*T ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt();
        }

        boolean flag = true;
        while (flag) {
            K--;
            int[] A_imos = new int[N+1];
            for (int i=0;i<N;i++) {
                A_imos[Math.max(0, i-A[i])]++;
                A_imos[Math.min(N, i+A[i]+1)]--;
            }
            for (int i=0;i<N;i++) {
                A_imos[i+1] = A_imos[i+1]+A_imos[i];
            }

            boolean all_equal = true;
            for (int i=0;i<N;i++) {
                if (A[i] != A_imos[i]) all_equal = false;
                A[i] = A_imos[i];
            }
            if (all_equal) flag = false;
            if (K == 0) flag = false;
        }

        StringBuilder sb = new StringBuilder();
        for (int i=0;i<N;i++) {
            sb.append(A[i]);
            if (i != N-1) sb.append(" ");
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 61568
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> arr(n);
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        --x;
        ++arr[x];
    }

    for (int &x : arr) {
        if (k - (q - x) > 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define Nmax 100006
using namespace std;
int n,A[Nmax],B[Nmax],k,C[Nmax],fr[Nmax],nr;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin >> n >> k;

    cin >> s;
    for (int i=0;i<s.size();i++){
        if (s[i] == 'L' && (i > 0 && s[i-1] == 'L')) nr++;
        if (s[i] == 'R' && (i+1 != s.size() && s[i+1] == 'R')) nr++; 
    }

    cout << min(2*k+nr, n-1) << '\n';

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        if(a<b)
        	System.out.println("a < b");
        else if(a>b)
        	System.out.println("a > b");
        else
        	System.out.println("a == b");
    }
}

Measured memory_bytes: 26104
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
using namespace std;
using ull = unsigned long long;
using ll = long long;

int main() {
    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << ab * bc / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int A, B;
char S[20] = {};

int main() {
	cin >> A >> B;
	cin >> S;
	for (int i = 0; i < A + B + 1; i++) {
		if (i != A) {
			if (S[i] < '0' || S[i] > '9') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (S[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
#include <array>
#include <algorithm>

int main()
{
    int n;
    while (scanf("%d ", &n) && n > 0)
    {
        std::array<int, 26> d;
        for (int i = 0; i < 26; ++i)
        {
            d[i] = 0;
        }

        bool find = false;
        // printf("n = %d\n", n);
        for (int i = 1; i <= n; ++i)
        {
            // printf("i = %d\n", i);
            char c;
            scanf("%c ", &c);
            // printf("c = %c\n", c);
            d[c - 'A'] += 1;

            std::array<int, 26> temp = d;
            std::sort(temp.rbegin(), temp.rend());
            // printf("%d %d\n", temp[1] + n - i , temp[0]);
            if(find == false && temp[1] + n - i < temp[0])
            {
                c = std::distance(d.begin(), std::max_element(d.begin(), d.end())) + 'A';
                printf("%c %d\n", c, i);
                find = true;
            }
        }

        if(find == false)
        {
            printf("TIE\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2704
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict
INF = float("inf")
MOD = 10**9+7


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, f, t, w=1):
        self.E[f].append(t)
        self.E[t].append(f)


def make_order(g, v):
    seen = [False]*g.N
    last_order = [-1]*g.N
    parent = [-1]*g.N
    size = [1]*g.N
    counter = {"last": 0}

    def recur(v):
        seen[v] = True
        for to in g.E[v]:
            if seen[to] == True:
                continue
            parent[to] = v
            recur(to)
            size[v] += size[to]

        last_order[counter["last"]] = v
        counter["last"] += 1

    recur(v)
    return last_order, parent, size


def merge(d: dict, e: dict):
    if len(d) < len(e):
        d, e = e, d
    for k in e:
        d[k] += e[k]
    return d


N = int(input())
c = [x-1 for x in map(int, input().split())]
A = [None]*(N-1)
B = [None]*(N-1)
for i in range(N-1):
    A[i], B[i] = map(int, input().split())

g = Graph(N)
for a, b in zip(A, B):
    g.add_edge(a-1, b-1)

ans = [0]*N

ret = {}
last_order, parent, size = make_order(g, 0)
for curr in last_order:
    cn = c[curr]
    rrr = defaultdict(int)
    for dest in g.E[curr]:
        if dest == parent[curr]:
            continue
        child = ret.pop(dest)

        n = size[dest]-child[cn]
        ans[cn] += n*(n+1)//2

        # マージ
        rrr = merge(rrr, child)

    rrr[cn] = size[curr]
    ret[curr] = rrr


tot = N*(N+1)//2
for color in range(N):
    if color != c[0]:
        n = N-ret[0][color]
        ans[color] += n*(n+1)//2
    print(tot-ans[color])


Measured memory_bytes: 340348
#include <stdio.h>
typedef long long ll;

int main(){
    ll  n, sum=0, tmp;
    scanf("%lld", &n);

    tmp = n;
    while( tmp ){
        sum += tmp % 10;
        tmp /= 10;
    }
    if( n % sum == 0 ){ printf("Yes\n"); }
    else              { printf("No\n");  }

    return 0;
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
int gcd(long long a, long long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main(){
  long long a,b,c,d,i;
  cin>>a>>b>>c>>d;
  long long z=c*d/gcd(c,d);

  long long sum=b/c+b/d-b/z;
  long long x=(a-1)/c+(a-1)/d+-(a-1)/z;
  cout<<b-a+1-sum+x<<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll N;
  cin>>N;
  ll X[N],Y[N];
  for(int i=0; i<N; ++i){
  cin>>X[i];
  Y[i]=X[i];
  }
  sort(Y,Y+N);
  for(int i=0;i<N; i++){
    if(X[i]<Y[N/2])
      cout<<Y[N/2]<<endl;
    else 
      cout<< Y[N/2-1] <<endl;
  }
}
  

  
  

 


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

int main(){
    string s;
    cin >> s;
    int check =0;
    rep(i,s.size()){
        if ((i == 0)||  (i%2 ==0)){
            if (s.at(i) == 'L') check++;
        }
        if ( (i%2 !=0)){
            if (s.at(i) == 'R') check++;
        }
    }
    if (check ==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    } 
}

Measured memory_bytes: 256