akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1e+7;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
char c[510][510];
int vis[510][510];//(i,j)まで到達できる白の個数
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int h,w;cin>>h>>w;
    for(int i=0;i<h;i++)cin>>c[i];
    ll ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(c[i][j]=='.'&&vis[i][j]==0){
                queue<P> q;
                q.push(P(i,j));
                vis[i][j]=1;
                ll c1=0,c2=0;
                while(!q.empty()){
                    P p=q.front();q.pop();int x=p.second,y=p.first;
                    if(c[y][x]=='#'){
                        c1++;
                    }else{
                        c2++;
                    }
                    for(int k=0;k<4;k++){
                        int nx=x+dx[k];
                        int ny=y+dy[k];
                        if(nx<0||ny<0||nx>=w||ny>=h)continue;
                        if(vis[ny][nx])continue;
                        if(c[y][x]=='.'){
                            if(c[ny][nx]=='#'){
                                vis[ny][nx]=1;q.push(P(ny,nx));
                            }
                        }else{
                            if(c[ny][nx]=='.'){
                                vis[ny][nx]=1;
                                q.push(P(ny,nx));
                            }
                        }
                    }
                }
                ans+=c1*c2;
            }
        }
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int k,ans=0;
signed main(){
	cin>>k;
	if(k%2==0||k%5==0){cout<<-1<<endl;return 0;
	}
	ll calc=0;
	while(ans<=k){
		ans++;
		calc*=10;calc+=7;
		calc%=k;
		if(calc%k==0){cout<<ans<<endl;return 0;
		}
		
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define P pair<ll,ll>
#define F first
#define S second
#define vll vector<ll>
#define pb push_back
#define M 1000000007
#define for1(i,n) for(ll i=1;i<=n;i++)
#define for0(i,n) for(ll i=0;i<n;i++)
#define forab(i,a,b,c) for(ll i=a;i<=b;i+=c)
using namespace std;
int main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll a[n], b[n];
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	ll xo = a[0];
	for (ll i = 1; i < n; i++)
	{
		xo = xo ^ a[i];
	}
	for (ll i = 0; i < n; i++)
	{
		b[i] = xo ^ a[i];
	}
	for (ll i = 0; i < n; i++)
	{
		cout << b[i] << " ";
	}
	//cout << "\n";
	return 0;
}

Measured memory_bytes: 6720
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::fmt;
#[allow(unused_imports)]
use std::io::{stdin, stdout, Read, Write};
use std::str::FromStr;

#[derive(Default)]
struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }

    fn scan<T: FromStr>(&mut self) -> Option<T> {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok()
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.scan() {
            s
        } else {
            std::process::exit(1);
        }
    }
}

#[derive(Default)]
struct Node {
    id: usize,
    parent: usize,
    depth: usize,
    children: Vec<usize>,
}

impl fmt::Display for Node {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let t = if self.depth == 0 {
            "root"
        } else if self.children.len() == 0 {
            "leaf"
        } else {
            "internal node"
        };

        let mut p = self.parent as i32;
        if self.parent == self.id {
            p = -1;
        }

        write!(
            f,
            "node {}: parent = {}, depth = {}, {}, {:?}",
            self.id, p, self.depth, t, self.children
        )
    }
}

/*
fn dfs(i: usize, d: usize, n: &mut [Node]) {
    n[i].depth = d;
    for &j in n[i].children.iter() {
        dfs(j, d+1, n);
    }
}
*/
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let out = stdout();
    let mut out = out.lock();

    let n = sc.next();
    let mut node = Vec::<Node>::new();
    for i in 0..n {
        node.push(Node {
            id: i,
            parent: i,
            depth: 0,
            children: Vec::new(),
        })
    }
    for _ in 0..n {
        let id: usize = sc.next();
        let k = sc.next();
        for _ in 0..k {
            let c = sc.next();
            node[id].children.push(c);
            node[c].parent = id;
        }
    }

    let mut root = 0;
    for x in node.iter() {
        if x.parent == x.id {
            root = x.id;
            break;
        }
    }

    let mut stack = vec![(root, 0)];
    while !stack.is_empty() {
        let (i, d) = stack.pop().unwrap();
        node[i].depth = d;
        for &c in node[i].children.iter() {
            stack.push((c, d+1));
        }
    }

    for x in node.iter() {
        writeln!(out, "{}", x).ok();
    }
}



Measured memory_bytes: 14708
#include <stdio.h>

int
main(){
int n; char s[101];
scanf("%d", &n);
scanf("%s", s);

int ans = 0; int x = 0;
for(int i = 0; i < n; i++){
if(s[i] == 'I')  x++;
else x--;
ans = (ans > x ? ans : x);
}
printf("%d\n", ans);
return 0;
}

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

const int64_t MOD = 1e9 + 7;
struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

void solve(string L)
{
    vector<mint> dp0(L.size() + 1);
    vector<mint> dp1(L.size() + 1);
    dp1.at(0) = 1;
    for (int i = 0; i < (int)L.size(); i++)
    {
        if (L.at(i) == '0')
        {
            dp0.at(i + 1) = dp0.at(i) * 3;
            dp1.at(i + 1) = dp1.at(i);
        }
        else
        {
            dp0.at(i + 1) = dp0.at(i) * 3 + dp1.at(i);
            dp1.at(i + 1) = dp1.at(i) * 2;
        }
    }
    cout << (dp0.at(L.size()) + dp1.at(L.size())) << endl;
}

int main()
{
    string L;
    cin >> L;
    solve(move(L));
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)

int main(){
  long long h;
  cin>>h;
  long long base=1,acum=0;
  while(h>0){
    acum+=base;
    base*=2;
    h/=2;
  }
  cout<<acum<<endl;

  return 0;
}

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

using namespace std;

int main() {

	long long n;

	cin >> n;

	vector<long> a(n + 3);
	vector<long> b(n + 3);

	for (int i = 2; i <= n; i++) {
		cin >> a[i];
		b[a[i]]++;
	}

	for (int i = 1; i <= n; i++) {

		cout << b[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 6376
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int x,h,m,s;

	scanf("%d",&x);

	s=x%60;
	x=x/60;
	m=x%60;
	h=x/60;

	printf("%d:%d:%d\n",h,m,s);

	return EXIT_SUCCESS;
}


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int K = in.nextInt();
			
			long a = N / K;
			long b = K % 2 == 0 ? (N + K / 2) / K : 0;
			
			long ans = (long)(Math.pow(a, 3) + Math.pow(b, 3));
			
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 073_arc_b / Link: https://arc073.contest.atcoder.jp/tasks/arc073_b?lang=en  ----- */
/* ------問題------

あなたは N 個の物と、強度 W のバッグを持っています。 i 個目の物は、重さが wi で価値が vi です。
あなたは、物のうちいくつかを選び、バッグに入れます。 ただし、選んだ物の重さの和は W 以下でなくてはいけません。
あなたは、バッグに入れた物の価値の総和を最大化したいです。

-----問題ここまで----- */
/* -----解説等-----

昔はDPを気合で解いていた

----解説ここまで---- */

LL N, W;

LL ans = 0LL;

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

	cin >> N >> W;
	VL w(N), v(N);

	VVL s(4,VL());
	LL baseW;
	FOR(i, 0, N) {
		cin >> w[i] >> v[i];
		if (i == 0)baseW = w[i];
		int id = w[i] - baseW;
		s[id].push_back(v[i]);
	}
	FOR(i, 0, 4)RSORT(s[i]);


	FOR(i, 0, SZ(s[0])+1) {
		FOR(j, 0, SZ(s[1])+1) {
			FOR(k, 0, SZ(s[2])+1) {
				FOR(l, 0, SZ(s[3])+1) {

					LL Vs = 0;
					LL Ws = 0;
					FOR(a, 0, i) {
						Ws += baseW;
						Vs += s[0][a];
					}FOR(a, 0, j) {
						Ws += baseW+1;
						Vs += s[1][a];
					}FOR(a, 0, k) {
						Ws += baseW+2;
						Vs += s[2][a];
					}FOR(a, 0, l) {
						Ws += baseW+3;
						Vs += s[3][a];
					}
					if (W >= Ws) {
						ans = max(ans, Vs);
					}

				}
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
/*
First solve the problem,then write the code.
Author-Manas Singh(@manassingh557)
*/

// #pragma GCC optimize ("Ofast")
// #pragma GCC optimization("O3")
// #pragma GCC optimization("unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
// #pragma GCC optimize ("-ffloat-store")

#include<bits/stdc++.h>

#define ll long long
#define ld long double

#define mod 1000000007
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define endl "\n"

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<<ll,ll>
#define vii vector<int>
#define vll vector<ll>

#define rep(i,end) for(int i=0;i<end;i++)
#define repi(i,start,end) for(int i=start;i<=end;i++)
#define repd(i,start,end) for(int i=start;i>=end;i--)

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;

int main()
{
	fast;
	int n;
	string s;
	cin>>s;
	n=s.size();
	int a=-1,z=-1;
	rep(i,n)
	    if(s[i]=='A')
	    {
	        a=i;
	        break;
	    }
	repd(i,n-1,0)
	    if(s[i]=='Z')
	    {
	        z=i;
	        break;
	    }
	cout<<z-a+1<<endl;
	return 0;
}

Measured memory_bytes: 720
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }

    if s.contains("RRR") {
        println!("3");
    } else if s.contains("RR") {
        println!("2");
    } else if s.contains("R") {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2116
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    var a = "NG"
    for (i in 0 until 1000) {
        if (n * i in x..y) {
            a = "OK"
        }
    }
    println(a)
}


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

int main(void)
{
	int N;
	cin >> N;
	long long *a = new long long[3 * N];
	for (int i = 0; i < 3 * N; ++i) {
		cin >> a[i];
	}

	sort(a, a + 3 * N);
	reverse(a, a + 3 * N);

	long long sum = 0;
	int cnt = 0;
	for (int i = 1; cnt < N; i += 2) {
		sum += a[i];
		++cnt;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 2560
N = int(input())
S = input()
noCount = {'R': 0, 'G': 0, 'B': 0}
minusCount = 0
for i in S:
    if i == 'R':
        noCount['R'] += 1
    elif i == 'G':
        noCount['G'] += 1
    elif i == 'B':
        noCount['B'] += 1
RGB = noCount['R']*noCount['G']*noCount['B']

for step in range(1, (N+1)//2):
    for cenPos in range(step, N-step):
        if S[cenPos - step] != S[cenPos] and S[cenPos] != S[cenPos + step] and S[cenPos - step] != S[cenPos + step]:
            minusCount += 1
print(RGB - minusCount)

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

int main()
{
 	int n;
  	cin>>n;
	int arr[n];
  	for(int i=0;i<n;i++)
      cin>>arr[i];
    int count=0;
  	for(int i=0;i<n-1;i++)
    {
      if(arr[i]==(i+1))
      {  
        count++;
        int temp=arr[i];
        arr[i+1]=arr[i];
        arr[i]=temp;
      }
    }
  	if(arr[n-1]==n)
  		count++;
  
  	cout<<count<<endl;
}
  

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

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

fn main() {
  input! {
    n: usize,
    pp: [usize1; n],
  }
  let mut aa = vec![0i64; n];
  for (i, x) in aa.iter_mut().enumerate() {
    *x = 30000 * (i as i64 + 1);
  }
  for (i, &p) in pp.iter().enumerate() {
    aa[p] += i as i64;
  }
  for &a in aa.iter() {
    print!("{} ", a);
  }
  println!("");
  for i in 0 .. n {
    print!("{} ", 1e9 as i64 - 30000 * i as i64);
  }
  println!("");
}


Measured memory_bytes: 4732
a=input()
b=0
if (len(a))%2==0:
  for i in range(int(len(a)/2)):
    if a[2*i]=="R" or a[2*i]=="U" or a[2*i]=="D":
      b=b+1
    if a[2*i+1]=="L" or a[2*i+1]=="U" or a[2*i+1]=="D":
      b=b+1
  if b==len(a):
    print("Yes")
  else:
    print("No")
if (len(a))%2==1:
  for i in range(int(len(a)/2)+1):
    if a[2*i]=="R" or a[2*i]=="U" or a[2*i]=="D":
      b=b+1
  for i in range(int(len(a)/2)):
    if a[2*i+1]=="L" or a[2*i+1]=="U" or a[2*i+1]=="D":
      b=b+1
  if b==len(a):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
    cin>>a>>b>>c;
    for(int s=1;s<=1000;s++)//暴力循环
    {
        if((a*s)%b==c)
        {
            cout<<"YES"<<endl;//成功，找到了
            return 0;
        }
    }
    cout<<"NO"<<endl;//没有找到
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll K;
  scanf("%lld",&K);
  ll X;
  scanf("%lld",&X);
  ll Y;
  scanf("%lld",&Y);
  cout << min(N,K)*X+max(0LL,N-K)*Y << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(void)
{
	map<string, string> mp;

	mp["Sunny"] = "Cloudy";
	mp["Cloudy"] = "Rainy";
	mp["Rainy"] = "Sunny";

	string S;
	cin >> S;
	cout << mp[S] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{    long long int n,a,p;
    cin>>n;
    map<int,int>mp;
    vector<int>v;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        mp[a]++;
        if(mp[a]==2){v.push_back(a);mp[a]=0;}
    }
    sort(v.begin(),v.end());
    p=(int)v.size();
    if(p<2) cout<<"0"<<endl;
    else cout <<((long long int)v[p-1]*v[p-2])<<endl;
    return 0;
}


Measured memory_bytes: 4992
N = int(input())
x = list(0 for i in range(N))
y = list(0 for i in range(N))
h = list(0 for i in range(N))
for i in range(N):
    x[i],y[i],h[i] = (int(i) for i in input().split())


for cx in range(101): 
    for cy in range(101):
        H = -1
        for i in range(N):
            if h[i] > 0:
                tmp = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
                if H == -1:
                    H = tmp
                elif H != tmp:
                    H = -2
                    break
        if H == -2:
            continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i]-cx)+abs(y[i]-cy)
                if H > dist:
                    H = -2
                    break
        if H == -2:
            continue
        print(cx,cy,H)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    if(c%__gcd(a,b)==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d.at(i);

  sort(d.begin(), d.end());

  int hanbun = (n/2) -1;
  int ans = (d.at(hanbun+1)) - d.at(hanbun);

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>

int main(){
    
    int w, a, b;
    std::cin >> w >> a >> b;

    if(b >= a - w && b <= a + w){
        std::cout << 0 << std::endl;
    }else if(b < a - w){
        std::cout << a - (b + w) << std::endl;
    }else{
        std::cout << b - (a + w) << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  enum CONTESTS = 26;
  const days = scan!int;
  const dec = scan!long(CONTESTS);
  const inc = days.iota.map!(x => scan!long(CONTESTS)).array;
  const contests = scan!int(days).map!(x => x - 1).array;

  long solve() {
    long[26] lastDay;
    lastDay[] = -1;

    long ans;
    foreach(i, c; contests) {
      lastDay[c] = i;
      ans += inc[i][c];
      foreach(o; 0..CONTESTS) {
        if (c != o) ans -= (i - lastDay[o]) * dec[o];
      }
      
      ans.writeln;
    }
    
    return ans;
  }

  solve();
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 3292
package main

import (
	"fmt"
	"os"
)

func run() int {
	var n int
	var s string
	fmt.Scanln(&n)
	fmt.Scanln(&s)
	if len(s) != n {
		fmt.Println("No")
		return 0
	}

	if len(s) == 1 {
		fmt.Println("No")
		return 0
	}

	if len(s)%2 != 0 {
		fmt.Println("No")
		return 0
	}

	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)/2+i] {
			fmt.Println("No")
			return 0
		}
	}

	fmt.Println("Yes")
	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    i64 N, A, B, ans = 1e17;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    } else {
        cout << min(A - 1 + (B - A) / 2 + 1,
                    N - B + (B - A) / 2 + 1) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    m,d = map(int, input().split())
    res = 0
    for i in range(1, m+1):
        for j in range(1, d+1):
            a = j // 10
            b = j % 10
            if a>=2 and b>=2:
                if a*b == i:
                    res += 1
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll mat[105][105],mark[105][105];
int n,m;
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            mat[i][j]=1e9;
    for(int i=0; i<m; i++)
    {
        int u,v,c;
        cin>>u>>v>>c;
        mat[u][v]=c;
        mat[v][u]=c;
        mark[u][v]=c;
        mark[v][u]=c;

    }
    int ans=0;
    for(int k=1; k<=n; k++)
        for(int i=1; i<=n; i++)
            for(int j=1; j<=n; j++)
            {
                if(mat[i][j]>mat[i][k]+mat[k][j])
                {
                    mat[i][j]=mat[i][k]+mat[k][j];
                    if(mark[i][j])
                    {
                        ans++;
                        mark[i][j]=0;
                        mark[j][i]=0;
                    }
                }
            }


    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3760
function alphabet(index, upper = false) {
    if (upper) {
        return String.fromCharCode('A'.charCodeAt(0) + index)
    }
    else {
        return String.fromCharCode('a'.charCodeAt(0) + index)
    }
}

function g(N) {
    if (N < 26) {
        return alphabet(N)
    }
    else {
        return g(Math.floor(N / 26) - 1) + alphabet(N % 26)
    }
}

function main(lines) {
    const [N] = parseNumberLine(lines[0])

    console.log(g(N - 1))
}

function parseNumberLine(line, radix = 10) {
    return line.split(/\s+/).map(_ => parseInt(_, radix))
}


main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"))


Measured memory_bytes: 29640
'use strict';

const main = input => {
  const [[N, T], ...costAndTime] = input.filter(x => x).map(str => str.split(' ').map(x => Number(x)));

  const temp = costAndTime.filter(arr => arr[1] <= T);
  const ans = temp.length >= 1 ? temp.reduce((acc, cur) => acc[0] < cur[0] ? acc : cur)[0] : 'TLE';

  console.log(ans);
};

main(require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/));

Measured memory_bytes: 7500
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
const int mo=1e9+7;
const int N=100000+10;
vector<int> has;
vector<pair<int,int>> p;
int x[N],y[N],t[N],NM;
void add(int &x,int y){
	if((x+=y)>=mo)
		x-=mo;
}
void Modify(int x,int v){
	for(;x<=NM;x+=x&-x)
		add(t[x],v);
}
int Query(int x){
	int res=0;
	for(;x;x-=x&-x)
		add(res,t[x]);
	return res;
}
int main(){
	// freopen("in.txt","r",stdin);
	int n,m;read(n),read(m);
	for(int i=1;i<=n;++i){
		read(x[i]);
	}
	for(int i=1;i<=m;++i){
		read(y[i]);
	}
	int i=1;
	for(;i<=n&&x[i]<y[1];++i);
	for(int j=1;j<m;++j){
		for(;i<=n&&x[i]>y[j]&&x[i]<y[j+1];++i){
			int xx=x[i]-y[j],yy=y[j+1]-x[i];
			p.push_back({xx,yy});
			has.push_back(yy);
		}
	}
	sort(p.begin(),p.end(),[](const pair<int,int> &A,const pair<int,int> &B)->bool{
		if(A.first!=B.first)
			return A.first<B.first;
		return A.second>B.second;
	});
	p.erase(unique(p.begin(),p.end()),p.end());
	sort(has.begin(),has.end());
	has.erase(unique(has.begin(),has.end()),has.end());
	NM=has.size();
	int ans=1;
	for(auto pp:p){
		int pos=lower_bound(has.begin(),has.end(),pp.second)-has.begin()+1;
		int tmp=Query(pos-1)+1;
		add(ans,tmp);
		Modify(pos,tmp);
	}
	write(ans),putchar('\n');
	return 0;
}

Measured memory_bytes: 2804
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	vector <int> v, bit;
	int n, k, c, sum = 0, ans = 0;
	cin >> n >> k;
	string s;
	cin >> s;
	c = 1;
	for (int i = 1; i < n; ++i)
	{
		if(s[i] == s[i - 1])
		{
			c++;
		}
		else
		{
			v.push_back(c);
			bit.push_back(s[i - 1] - '0');
			c = 1;
		}
	}
	if(c > 0)
	{
		v.push_back(c);
		bit.push_back(s.back() - '0');
	}
	int r = 0, cnt = 0;
	for (int i = 0; i < (int) v.size(); ++i)
	{
		while(r < (int) v.size() && cnt <= k)
		{
			if(bit[r] == 0 && cnt == k)
				break;
			if(bit[r] == 0)
				cnt++;
			sum = sum + v[r];
			r++;
		}
		// cout << i << ' ' << sum << "\n";
		ans = max(ans, sum);
		if(bit[i] == 0)
			cnt--;
		sum = sum - v[i];
	}
	cout << ans;
}



Measured memory_bytes: 1404
#include <stdio.h>
int main(void)
{
    int N, a, b, c = 0;
    scanf("%d", &N);
    for (int a = 9; a > 0; a--)
    {
        b = N / a;
        if (b < 10&&N%a==0)
            c = 1;
    }
    if (c)
        printf("Yes");
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
const ll mod = 1000000007;
int n, p1, p2;
int a[N];
ll cnt[N], inv[N], fac[N];
ll power(ll x, ll t)
{
	ll ret = 1;
	for(; t; t >>= 1, x = x * x % mod) if(t & 1) ret = ret * x % mod;
	return ret;
}
ll calc(int a, int b)
{
	if(a < b) return 0;
	return fac[a] * inv[b] % mod * inv[a - b] % mod; 
}
int main()
{
	scanf("%d", &n);
	++n;
	inv[0] = inv[1] = fac[0] = fac[1] = 1ll;
	for(int i = 2; i <= n; ++i)
	{
		fac[i] = fac[i - 1] * (ll)(i) % mod;
		inv[i] = mod - inv[mod % i] * (ll)(mod / (ll)i) % mod;
	}
	for(int i = 2; i <= n; ++i) inv[i] = inv[i] * inv[i - 1] % mod;
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		++cnt[a[i]];
		if(cnt[a[i]] == 2) p2 = i;
	}
	for(int i = 1; i < p2; ++i) if(a[i] == a[p2])
	{
		p1 = i; 
		break;
	}
	for(int i = 1; i <= n; ++i)
		printf("%lld\n", (((calc(n, i) - calc(n - p2 + p1 - 1, i - 1)) % mod) + mod) % mod);
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main() {
	int n;cin >> n;
    string s;cin >> s;
    int r=0,b=0;
    for(int i=0;i<n;i++){
        if(s.at(i) == 'R'){
            r++;
        }else{
            b++;
        }
    }
    cout << (r > b ? "Yes" : "No") << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i= 0; i < m; i++) {
    cin >> a.at(i);
  }
  
  int sum = 0;
  for (int i= 0; i < m; i++) {
    sum += a.at(i);
  }
  
  int k = n -sum;
  if (k >= 0)
    cout << k << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 3672
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto h = readln.chomp.to!long;
  long c = 1;
  long num;
  while (h != 0) {
    num += c;
    h /= 2;
    c *= 2;
  }
  writeln(num);
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    let mut v = {
        input!{
            v: [u8; 3],
        }
        v
    };
    v.sort();
    println!("{}", if v[0] != v[2] && (v[0] == v[1] || v[1] == v[2]) {"Yes"} else {"No"});
}


Measured memory_bytes: 4476
package main

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

func main() {
	n, k := getInt(), getInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		x := getInt()
		m[x]++
	}

	xs := make([]int, 0, len(m))
	for _, v := range m {
		xs = append(xs, v)
	}
	sort.Ints(xs)

	ans := 0
	diff := len(xs) - k
	for i := 0; i < diff; i++ {
		ans += xs[i]
	}

	fmt.Println(ans)
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 12672
#include<cstdio>
using namespace std;
int n,m,cnt,e[100005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,a,b;i<=m;i++){scanf("%d%d",&a,&b);e[a]++;e[b]++;}
	for(int i=1;i<=n;i++){if(e[i]%2!=0){printf("NO");return 0;}}
	printf("YES");
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
string toString(int n) {
    ostringstream os;
    os << n;
    return os.str();
}
string add(string a, string b) {
    if (a.size() > 80 || b.size() > 80) {
        return "overflow";
    }

    int siz = max(a.size(), b.size());
    vector<int> s1(siz, 0);
    for (int i=a.size()-1; i>=0; --i) {
        s1[a.size()-1-i] = a[i] - '0';
    }
    vector<int> s2(siz, 0);
    for (int i=b.size()-1; i>=0; --i) {
        s2[b.size()-1-i] = b[i] - '0';
    }

    string res = "";
    int carry = 0;
    for (int i=0; i<siz; ++i) {
        res = toString((s1[i] + s2[i] + carry) % 10) + res;
        carry = (s1[i] + s2[i] + carry >= 10);
    }
    if (carry) {
        res = '1' + res;
    }

    if (res.size() > 80) {
        return "overflow";
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i=0; i<n; ++i) {
        string a, b;
        cin >> a >> b;
        cout << add(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

object Solve {

  private val br = BufferedReader(InputStreamReader(System.`in`))
  private val out = PrintWriter(System.out)

  fun solve() {

    var n = br.readLine()!!.toInt()
    var a = br.readLine()!!.split(' ').map { it.toLong() }

    var maxA = 0L
    var ans = 0L
    for (len in a) {
      if(len < maxA) {
        ans += maxA - len
      }
      maxA = max(maxA, len)
    }

    out.println(ans)
    out.flush()
  }
}

fun main(args: Array<String>) {
  Solve.solve()
}

Measured memory_bytes: 64088
#include <bits/stdc++.h>
using namespace std;
int main() { 
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(), a.end()); 
  int b=0;
  for(int i=0;i<k;i++){
    b+=a.at(i);
  }
  cout<<b;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m;
vector<int> adj[100100];
vector<int> inc[100100];
bool vis[100100];
vector<int> ord;
void topo (int x) {
	vis[x] = true;
	for (auto i: adj[x]) {
		if (vis[i]) continue;
		topo(i);
	}
	ord.push_back(x);
}
int dp[100100];
int o = 0;
int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	int ai, bi;
	for (int i=0; i<m; i++) {
		cin >> ai >> bi;
		ai--; bi--;
		adj[ai].push_back(bi);
		inc[bi].push_back(ai);
	}
	for (int i=0; i<n; i++) {
		if (!vis[i]) topo(i);
	}
	reverse(ord.begin(), ord.end());
	for (auto &i: ord) {
		for (auto &j: inc[i]) {
			dp[i] = max(dp[i], dp[j]+1);
		}
		o = max(o, dp[i]);
	}
	cout << o << endl;
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 405
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007; 
int N;
int C,A[MAXN],B[MAXN];
int num[MAXN][MAXN],sum[MAXN][MAXN];
int dp[2][MAXN];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);read(C);
    for(int i = 1 ; i <= N ; ++i) read(A[i]);
    for(int i = 1 ; i <= N ; ++i) read(B[i]);
    for(int i = 1 ; i <= 400 ; ++i) {
	num[i][0] = 1;
	for(int j = 1 ; j <= 400 ; ++j) {
	    num[i][j] = mul(num[i][j - 1],i);
	}
    }
    for(int j = 0 ; j <= 400 ; ++j) {
	for(int i = 1 ; i <= 400 ; ++i) {
	    sum[i][j] = inc(sum[i - 1][j],num[i][j]);
	}
    }
    int cur = 0;dp[cur][0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	memset(dp[cur ^ 1],0,sizeof(dp[cur ^ 1]));
	for(int j = 0 ; j <= C ; ++j) {
	    for(int h = 0 ; h <= C - j ; ++h) {
		update(dp[cur ^ 1][j + h],mul(dp[cur][j],inc(sum[B[i]][h],MOD - sum[A[i] - 1][h])));
	    }
	}
	cur ^= 1;
    }
    out(dp[cur][C]);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

int main()
{
    int n, a;
    cin >> n >> a;
    int xxx = n % 500;
    if (xxx <= a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define mem(a) memset(a,0,sizeof(a))
#define reg register 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int MAX=10;
int p[MAX],q[MAX],jc[MAX];
int f(int c){
	if(c==1)
		return jc[c]=1;
	int d=1;
	FOR(i,1,c)
		d*=i;
	return jc[c]=d;		
}
int F(int*a,int n){
	int ans=0;
	for(int i=n;i>=1;i--){
		int b=0;
		for(int j=i-1;j>=1;j--)
			if(a[i]>a[j])
				b++;
		ans+=b*jc[i-1];		
	}
	return ++ans;
}
int main(){
	fio
	int n;
	cin>>n;
	for(int i=n;i>=1;i--)
		cin>>p[i];
	for(int i=n;i>=1;i--)
		cin>>q[i];
	FOR(i,0,n)
		f(i);			
	int a=F(p,n),b=F(q,n);
	cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int[] month = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    String[] days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
 
    void run(){
	while(sc.hasNext()){
	    int m = sc.nextInt();
	    int d = sc.nextInt();
	    if(m!=0 && d!=0)
		solve(m, d);
	}
    }

    void solve(int m, int d){
	int nowMonth = 1;
	int nowDay = 1;
	int now = 3;

	while(m!=nowMonth || d!=nowDay){
	    nowDay++;
	    now = (now+1)%7;
	    if(nowDay > month[nowMonth-1]){
		nowDay = 1;
		nowMonth++;
	    }
	}

	System.out.println(days[now]);
    }
}

Measured memory_bytes: 17228
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
UDLR = [[-1, 0], [1, 0], [0, -1], [0, 1]]

for i in range(H):
    for j in range(W):
        here = grid[i][j]
        if here == '.':
            continue
        ng = True
        for direction in UDLR:
            side_h = i + direction[0]
            side_w = j + direction[1]
            if 0 <= side_h < H and 0 <= side_w < W:
                side = grid[side_h][side_w]
                if side == '#':
                    ng = False
        if ng:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
N, A, B = map(int,input().split())

#M1 = float("inf")
#M2 = B-1
#M3 = N-A
if (B-A)%2==0:
	M1 = (B-A)//2
else:
	M1 = min(A-1,N-B) + (B-A+1)//2

#print(min(M1,M2,M3))
print(M1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ll n,x;
    cin >> n >> x;
    ll a[n];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum == x){
        cout << n << endl;
        return 0;
    }else if (sum < x){
        cout << n-1 << endl;
        return 0;
    }
    sort(a,a+n);
    int count = 0;
    for(int i = 0; i < n; i++){
        x -= a[i];
        if(x >= 0) count++;
        else break;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	vector<int> A;

	llint fmax=0LL;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		fmax+=a-1;
	}
	cout << fmax << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b||b==c||c==a){
    if(!(a==b&&b==c)){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <limits.h>
//# DEFINE ll as long long int;

using namespace std;

long long int check(long long int a, long long int b,long long int c,long long int d) {
  return b + c;
}




long long int foo(long long int n, string S) {
  long long int east = 0, west = 0;
  for (auto s : S) {
    if (s == 'W') {
      west++;
    }
    else {
      east++;
    }
  }
  long long int l_e = 0, l_w = 0, r_e = east, r_w = west;
  long long int minn = LLONG_MAX;
  for (int i = 0; i < n; i++) {
    if (S[i] == 'E') {
      r_e--;
      minn = min(minn,check(l_e, l_w, r_e, r_w));
      l_e++;
    }
    else {
      r_w--;
      minn = min(minn, check(l_e, l_w, r_e, r_w));
      l_w++;
    }
  }
  return minn;
}


int main() {
  long long int N;
  string s;
  cin>>N;
  cin>>s;
  cout<<foo(N, s);
  return 0;
    
}

Measured memory_bytes: 900
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
ans=0
1.upto(N) do|i|
  ans+=1 if i.to_s.split("").size.odd?
end
puts ans

Measured memory_bytes: 14260
/* ex3_4
   KKOO  */

#include <stdio.h>

int main(void) {
    int num,i,j,result;
    //整数の入力
    scanf("%d",&num);

    //九九の計算
    i = 0;
    j = 0;
    result=0;
    for(i=1; i < 10; i++){
        for(j=1; j < 10; j++){
            //九九が一致したらresultを1にする
            if(i*j == num){
                result = 1;
            }
        }
    }

    //resultが1ならYes
    if(result == 1){
        printf("Yes\n");
    }
    //resultが0ならYes
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); ++i)

using namespace std;

int main(){
  int A, B, C, D;
  ll N, M, K, l, sum, tmp, ans, ok = false;
  vector<int> X(5), Y(5);

  cin >> X[0];
  rep(i, 4){
    Y[i] = pow(10, 3-i);
    X[i+1] = X[i] % Y[i];
    X[i] /= pow(10, 3-i);
  }

  rep(i, 8) {
    if(ok) break;
    sum = X[0];
    rep(j, 3) {
      if (i&1<<j) sum += X[j+1];
      else sum -= X[j+1];
    }
    if(sum == 7){
      cout << X[0];
      rep(j, 3) {
        if (i&1<<j) cout << "+" << X[j+1];
        else cout << "-" << X[j+1];
      }
      cout << "=7" << endl;
      ok = true;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
long long int ans=0;
#define  ll long long
//最大公約数
long long int getgcd(long long n, long long m)
{
  int r;
  if (n > m) {
    long long t = m;
    m = n;
    n = t;
  }
  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }
return n;
}

//nの階乗を計算
long long factorial(long long n){
    long long int answer = 1;
while(n > 1){
  answer *= n;
  n--;
}
    return answer;
}

//組み合わせの数nCrを計算
long long calcNumOfCombination(long long  n, long long r){
    return factorial(n) / (factorial(r) * factorial(n-r));
}
 void yes(){
   printf("Yes\n");
 }

 void no(){
   printf("No\n");
 }

int main(int argc, char* argv[]){
	ll a = 0, b = 0,c=0,e=0;
  char h[1000];
	scanf("%s",h);
  if (h[1]=='B') {
    printf("ARC\n" );
  }else{
    printf("ABC\n" );
  }
  return 0;
}


Measured memory_bytes: 1620