akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

// aye tatti kya dekh raha hai ?

void merge(int arr[],int pos[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    int L[n1], R[n2],lt[n1],rt[n2];

    for (i = 0; i < n1; i++)
    {
        L[i] = arr[l + i];
        lt[i] = pos[l+i];
    }
    for (j = 0; j < n2; j++)
    {
        R[j] = arr[m + 1+ j];
        rt[j] = pos[m+1+j];
    }

    i = 0;j = 0;k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            pos[k]=lt[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            pos[k]=rt[j];
            j++;
        }
        k++;
    }


    while (i < n1)
    {
        arr[k] = L[i];
        pos[k]=lt[i];
        i++;
        k++;
    }


    while (j < n2)
    {
        arr[k] = R[j];
        pos[k]=rt[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[],int pos[], int l, int r)
{
    if (l < r)
    {
        int m = l+(r-l)/2;

        mergeSort(arr,pos, l, m);
        mergeSort(arr,pos, m+1, r);

        merge(arr,pos, l, m, r);
    }
}
bool isPower(unsigned int n)
{

    if (n <= 1) return true;

    for (int x=2; x<=sqrt(n); x++)
    {
        unsigned  p = x;

        while (p <= n)
        {
            p *= x;
            if (p == n)
                return true;
        }
    }
    return false;
}
int main()
{
//    int ttt;cin>>ttt;
//    while(ttt--)
//    {
//        int n,k,r;
//        cin>>n>>k>>r;
//
//    }

    unsigned x;
    cin>>x;
    while(x)
    {
        if(isPower(x))
        {
            cout<<x<<endl;
            break;
        }
        x--;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {
    int n; ll d; cin >> n >> d;
    vector<ll> x(n), y(n);
    rep(i, n) {
        cin >> x[i];
        cin >> y[i];
    }
    d *= d;
    int ans = 0;
    rep (i, n) {
        if (x[i] * x[i] + y[i] * y[i] <= d) ans++;
    }   
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 6420
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: usize,
    k: usize,
    s: Chars,
    }

    let mut nums = vec![];
    let mut now = 1;
    let mut cnt = 0;

    for i in 0..n {
        if s[i] == (b'0' + now as u8) as char {
            cnt += 1;
        } else {
            nums.push(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if cnt != 0 {nums.push(cnt);}

    if nums.len() % 2 == 0 {nums.push(0);}

    let add = 2 * k + 1;
    let mut  ans = 0;

    let mut left =0;
    let mut right = 0;
    let mut tmp = 0;

    debug!(nums);

    let mut i = 0;
    for _ in 0..nums.len() {

        let nextleft = i;
        let nextright = min!(i + add, nums.len());

        while nextleft > left {
            tmp -= nums[left];
            left +=1;
        }

        while nextright > right {
            tmp += nums[right];
            right+=1;
        }

        ans = max!(tmp, ans);
        i +=2;
        if i >= nums.len() {
            break;
        }
    }
    println!("{}", ans);;
}


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

int main() {
	int n, m;
	while (cin >> n >> m && n != 0 && m != 0) {
		int list[501][501];
		for (int i = 0; i <= n; ++i) {
			for (int i2 = 0; i2 <= n; ++i2) {
				list[i][i2] = 0;
			}
		}
		int L[501];
		for (int i = 0; i <= n; ++i) {
			L[i] = 0;
		}
		int cnt = 0;
		for (int i = 0; i < m; ++i) {
			int a, b;
			cin >> a >> b;
			list[a][b] = 1;
			list[b][a] = 1;
		}

		for (int i = 1; i <= n; ++i) {
			if (list[1][i] == 1) {
				L[i] = 1;
				for (int j = 1; j <= n; ++j) {
					if (list[i][j] == 1) {
						L[j] = 1;
					}
				}
			}
		}

		for (int i = 2; i <= n; ++i) {
			if (L[i] == 1) {
				++cnt;
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 4048
ABCD=list(map(int, list(input())))
for i in range(1<<3):
    tmp=list(map(int, list(str(bin(i))[2:].zfill(3))))
    a=ABCD[0]
    for j in range(3):
        if tmp[j]:
            a+=ABCD[j+1]
        else:
            a-=ABCD[j+1]
    if a==7:
        print(ABCD[0], end="")
        for j in range(3):
            print("+" if tmp[j] else "-", end="")
            print(ABCD[j+1], end="")
        print("=7")
        exit(0)


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

int get_dir(int x1, int y1, int x2, int y2) {
  if (x1 == x2) {
    return y2 > y1 ? 0 : 2;
  } else {
    return x2 > x1 ? 1 : 3;
  }
}

Vi make_line(int t, int *X, int *Y) {
  Vi ret;
  int x0 = X[0], y0 = Y[0], px = X[1], py = Y[1];
  ret.push_back(abs(x0-px)+abs(y0-py));
  int pd = get_dir(x0, y0, px, py);
  FOR(i, 2, t) {
    int x = X[i], y = Y[i];
    int d = get_dir(px, py, x, y);
    ret.push_back((d+1)%4 == pd ? 1 : -1);
    ret.push_back(abs(x-px)+abs(y-py));
    px = x, py = y, pd = d;
  }
  return ret;
}  

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

  while (1) {
    int N;
    cin >> N;
    if (N == 0) break;

    int t, x[16], y[16];
    cin >> t;
    REP(i, t) cin >> x[i] >> y[i];
    Vi target = make_line(t, x, y);
    int T = target.size();
    REP(n, N) {
      int m, mx[16], my[16];
      cin >> m;
      REP(i, m) cin >> mx[i] >> my[i];
      Vi line = make_line(m, mx, my);
      if (T != (int)line.size()) continue;
      bool flag = true;
      REP(i, T) {
	if (target[i] != line[i]) {
	  flag = false;
	  break;
	}
      }
      if (flag) {
	cout << n+1 << endl;
	continue;
      }
      REP(i, m/2) {
	swap(mx[i], mx[m-i-1]);
	swap(my[i], my[m-i-1]);
      }
      Vi line_ = make_line(m, mx, my);
      if (T != (int)line_.size()) continue;
      flag = true;
      REP(i, T) {
	if (target[i] != line_[i]) {
	  flag = false;
	  break;
	}
      }
      if (flag) {
	cout << n+1 << endl;
	continue;
      }      
    }
    cout << "+++++" << endl;
  }  

  return 0;
}

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

void Main()
{
    char a;
    cin >> a;

    if (a >= 'a' && a <= 'z')
    {
        cout << "a" << endl;
    }
    else
    {
        cout << "A" << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
ll cnt[27];
char s[111];
int main(void)
{
	scanf("%s",&s[1]);
	int n=strlen(&s[1]);
	int i;
	for(i=1 ; i<=n ; i++)
	{
		cnt[s[i]-'a'+1]++;
	}
	bool ok=true;
	for(i=1 ; i<=26 ; i++)
	{
		if(cnt[i]%2==1)
		{
			ok=false;
		}
	}
	if(ok)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>
#include<array>
#include<stdio.h>
#include<cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 1e15;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {1,0,-1,0,1,1,-1,-1};
int row[] = {0,1,0,-1,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios::sync_with_stdio(0);
    //cin.tie(0);


    int n, k;
    scanf("%d %d", &n, &k);

    vb dp(k+1,0);
    vi stns(n);

    for(int i = 0 ; i < n; ++i)
        scanf("%d", &stns[i]);

    for(int i = 1; i <= k; ++i)
        for(int j = 0; j < n ; ++j)
    {
        if(stns[j] <= i)
        {
            if(!dp[i-stns[j]])
                dp[i] = 1;
        }
    }

    if(dp[k])
        cout << "First" ;
    else
        cout << "Second" ;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef vector<P> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  V a(x),b(y),c(z);
  rep(i,x)cin>>a[i];
  rep(i,y)cin>>b[i];
  rep(i,z)cin>>c[i];
  RSORT(a);
  RSORT(b);
  RSORT(c);

  V ab;
  rep(i,x)rep(j,y)ab.pb(a[i]+b[j]);
  RSORT(ab);
  if(ab.size()>k+1)ab.erase(ab.begin()+k,ab.end());
  
  V abc;
  rep(i,ab.size())rep(j,z)abc.pb(ab[i]+c[j]);
  RSORT(abc);

  rep(i,k)cout<<abc[i]<<"\n";

  
  return 0;
}


Measured memory_bytes: 43112
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += in.nextInt() - 1;
		}
		System.out.println(ans);
	}
}

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

const int N = 1e5 + 5;
typedef long long ll;

int n;
ll a[N], l, r;

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++) cin>>a[i];
	l = r = 2; 
    for(int i = n; i; i--) {
    	r = r - r%a[i];
    	l = l + (a[i] - l%a[i])%a[i];
    	if(r < l) {
    		cout<<-1<<endl;
    		return 0;
    	}
    	r = r + a[i] - 1;
    }
    cout<<l<<" "<<r;
	return 0;
}

Measured memory_bytes: 1024
### coding: UTF-8

#import math
#import random as rd
#import numpy as np

line=[]
line.append(int(input()))
line.append(int(input()))
line.append(int(input()))
X=int(input())

count=0

for i in range(line[0]+1):
    for j in range(line[1]+1):
        for k in range(line[2]+1):
            if 500*i+100*j+50*k == X:
                count+=1

print(count)


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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N; cin >> N;
    int B[N-1];
    rep(i, N-1){
        cin >> B[i];
    }
    int ans = B[0] + B[N-2];
    rep(i, N-2) ans += min(B[i], B[i+1]);
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut seqs = vec![(0, 0); n];
    for i in 0..n {
        seqs[i].1 = read::<usize>() - 1;
        seqs[i].0 = read::<usize>();
    }
    seqs.sort();
    seqs.reverse();
    let mut cnts = vec![0; n];
    let mut sum = 0;
    let mut type_cnt = 0;
    for i in 0..k {
        sum += seqs[i].0;
        if cnts[seqs[i].1] == 0 {
            type_cnt += 1;
        }
        cnts[seqs[i].1] += 1;
    }
    let mut ans = sum + type_cnt * type_cnt;
    let mut pos = k as i32 - 1;
    for i in k..n {
        if cnts[seqs[i].1] != 0 {
            continue;
        }
        while pos >= 0 {
            if cnts[seqs[pos as usize].1] > 1 {
                cnts[seqs[pos as usize].1] -= 1;
                sum -= seqs[pos as usize].0;
                pos -= 1;
                type_cnt += 1;
                cnts[seqs[i].1] += 1;
                sum += seqs[i].0;
                ans = std::cmp::max(ans, sum + type_cnt * type_cnt);
                break;
            } else {
                pos -= 1;
            }
        }
        if pos == -1 {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
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")
    };
}

macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        a: chars,
        b: chars,
        c: chars,
    }
    let mut a = a; a.reverse();
    let mut b = b; b.reverse();
    let mut c = c; c.reverse();
    let mut t = 'a';
    loop {
        match t {
            'a' => if let Some(y) = a.pop() { t = y } else { break },
            'b' => if let Some(y) = b.pop() { t = y } else { break },
            'c' => if let Some(y) = c.pop() { t = y } else { break },
            _ => { panic!(); }
        };
    }
    println!("{}", t.to_uppercase().next().unwrap());
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll b18=1000000000000000000;

    ll ans=1;
    rep(i,n){
        if(a[i]>b18/ans){
            repa(j,i+1,n){
                if(a[j]==0){
                    cout<<0<<"\n";
                    return 0;
                }
            }
            cout<<-1<<"\n";
            return 0;
        }
        ans*=a[i];
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 4052
let fdr (cnt1, cnt2) x =
  if x = '0' then (cnt1+1, cnt2) else (cnt1, cnt2+1)

stdin.ReadLine()
|> Seq.fold fdr (0,0)
|> fun (a,b) -> 2 * (List.min [a;b])
|> printfn "%d"

Measured memory_bytes: 18520
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
//using ll = long long;
typedef long double ld;
const ll INF = 1e18 + 10;
#if defined(ONLINE_JUDGE)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define push_back pb
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
    speed;
    s ss , dd , currl="";
    cin >> ss >> dd;
    if(ss==dd){
    	cout<<"Yes"<<endl;
    	return 0;
    }
    bool ok = false;
    int n = (int)ss.size();
    for( int i = 0 ; i < n ; i++ ){
    	s curr="";
    	char x = ss[n-1];
    	currl+=x;
    	ss.pop_back();
    	ss=x+ss;
    	if(ss==dd){
    		ok = true;
    		break;
    	}
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



























return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/




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

p_list = []
s_list = []
for i in range(M):
    p, s = input().split()
    p_list.append(int(p))
    s_list.append(s)

p_state = [0 for i in range(N)]
pena_list = [0 for i in range(N)]
ans = 0
pena = 0

for i in range(M):
    if p_state[p_list[i]-1] == 0 and s_list[i] == "WA":
        pena_list[p_list[i]-1] += 1
    elif p_state[p_list[i]-1] == 0 and s_list[i] == "AC":
        p_state[p_list[i]-1] = 1
        ans += 1
        pena += pena_list[p_list[i]-1]
    else:
        continue

print(ans, pena)


Measured memory_bytes: 100208
def main():
    S = list(input())
    dp = [[0] * 13 for _ in range(10 ** 5 + 1)]
    dp[0][0] = 1
    n = len(S)
    for i in range(n):
        c = 0
        if S[i] == '?':
            c = -1
        else:
            c = int(S[i])
        for si in range(10):
            if c != -1 and c != si:
                continue
            for j in range(13):
                dp[i + 1][(j * 10 + si) % 13] += dp[i][j]
        for j in range(13):
            dp[i + 1][j] %= 10 ** 9 + 7
    print(dp[n][5])


main()


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

int main(){
                                                                     

    int n, k, i;

    
    cin >> n >> k;

    int a = k;


    for( i = 1 ; n > a ; i = i + 1 ){

         a += k - 1;

         }


    cout << i << endl;


    return 0;

    }

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

using namespace std;
const int N = 1e6+100;
vector<int> G[N];
int depth[N];
const int mod = 1e9+7;
long long ans=1;
int n,k;
void dfs1(int x,int fa){
	depth[x]=depth[fa]+1;
	for(auto v:G[x]){
		if(v==fa) continue;
		dfs1(fa,x);
	}
}
void dfs(int u,int fa){
	if(depth[u]==1){
		int cnt=1;
		for(auto v:G[u]){
			if(v==fa) continue;
			if(k<=cnt) ans=0;
			else ans=(ans%mod*(k-cnt)%mod)%mod;
			cnt++;
			dfs(v,u);
		}
	}
	else{
		int cnt=2;
		for(auto v:G[u]){
			if(v==fa) continue;
			if(k<=cnt) ans=0;
			else ans=(ans%mod*(k-cnt)%mod)%mod;
			cnt++;
			dfs(v,u);
		}	
	}
}
int main(){
	cin>>n>>k;
	int u,v;
	for(int i=1;i<=n-1;i++){
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	depth[1]=1;
	dfs1(1,0);
	dfs(1,0);
	cout<<(ans%mod*k%mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 33408
#include <iostream>
 
int main()
{
  int A,B,C;
  std::cin >> A >> B >> C;
  if((A !=5 && A != 7) || (B !=5 && B != 7) || (C !=5 && C != 7) || A + B + C != 17)
    std::cout<<"NO"<<std::endl;
  else
    std::cout<<"YES"<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m;
  scanf("%d",&n);
  scanf("%d",&m);

  int A[n][m],b[m];

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

  // Init b
  for(int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }

  long c[n];
  long sum = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++) sum += A[i][j]*b[j];
    c[i] = sum;
    sum = 0;
  }

  for(int i=0; i<n;i++){
    printf("%ld\n",c[i]);
  }

  return 0;
}


Measured memory_bytes: 2760
import java.io.*;
import java.util.Scanner;

class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        int s = ReadInt();
        System.out.print(s / 3600 + ":" + s / 60 % 60 + ":" + s % 60 + "\n");
    }
    static int ReadInt() throws IOException {
        return Integer.parseInt(sc.next());
    }
}

Measured memory_bytes: 26152
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    int[] a = new int[4];
    for (int i = 0; i < 4; i++) a[i] = s[i] - '0';
    char[] c = new char[4];
    for (int i = -1; i < 2; i += 2) {
      c[0] = i == -1 ? '-' : '+';
      for (int j = -1; j < 2; j += 2) {
        c[1] = j == -1 ? '-' : '+';
        for (int k = -1; k < 2; k += 2) {
          c[2] = k == -1 ? '-' : '+';
          if (a[0] + i * a[1] + j * a[2] + k * a[3] == 7) {
            System.out.printf("%d%s%d%s%d%s%d=7\n",a[0],c[0],a[1],c[1],a[2],c[2],a[3]);
            return;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j,k;
    vector<long>vec;
    vector<long>::iterator ii;
    cin>>n;
    long o,a,b,c;
    for(i=0;i<n;i++){
        cin>>o;
        vec.push_back(o);
    }
    sort(vec.begin(),vec.end());
    int cnt=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            if(vec[j]!=vec[i]){
                for(k=j+1;k<n;k++){
                    if(vec[k]!=vec[j] && vec[k]!=vec[i]){
                        a=vec[i];
                        b=vec[j];
                        c=vec[k];
                        if(a+b>c && b+c>a && c+a>b){
                            cnt++;
                        }
                    }
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		char[] c = S.toCharArray();
		
		boolean[] alp = new boolean[26];
		Arrays.fill(alp, false);
		
		for(int i = 0; i < S.length(); i++) {
			alp[c[i] - 'a'] = true;
		}
		
		for(int i = 0; i < 26; i++) {
			if(alp[i] == false) {
				System.out.println((char)(i+'a'));
				System.exit(0);
			}
		}
		System.out.println("None");

	}

}

Measured memory_bytes: 27172
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0&&W==0) break;
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if((i+j)%2==0) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println("");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33384
from sys import stdin
def g(n):
 if n=='1':
  return 14
 return int(n)
a,b = stdin.readline().strip().split()
a = g(a)
b = g(b)
if a > b:
 print 'Alice'
elif a<b:
 print 'Bob'
else:
 print 'Draw'

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int cnt=1;
    int ans=0;
    while(cnt<b){
        cnt+=(a-1);
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
var
 k,a,b,s,x:int64;
begin
 read(k,a,b);
 if a>=k then begin writeln(1);halt;end;
 if b>=a then begin writeln('-1');halt;end;
 x:=k-a;
 s:=x div (a-b);
 if x mod (a-b)<>0 then inc(s);
 writeln(s*2+1);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int a[60],b[60],sum;
int mn;
int main(){
    for(int i=0;i<5;i++){
        cin>>a[i];
        b[i] = a[i];
        int pl = 10 - a[i]% 10;
        if(pl==10)pl=0;
        b[i]+=pl;
        sum += b[i];
    }
    mn = 1000;
    for(int i=0;i<5;i++){
        int temp;
        temp = sum-b[i]+a[i];
        mn = min(mn,temp);
    }
    cout<<mn<<endl;

}


Measured memory_bytes: 256
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int T[100005];
int32_t main()
{
    speed
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>T[i];
    }
    sort(T+1,T+n+1);
    ll suma=0;
    for(int i=1;i<=k;i++)
        suma+=T[i];
    cout<<suma;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){

  int n;
  int t, a;
  ll vote, x = 1, y = 1;

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t >> a;
    vote = max((x + t - 1) / t, (y + a - 1) / a);
    x = vote * t;
    y = vote * a;
  }
  cout << x + y << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int W[N];
  for (int i = 0; i < N; i++) {
    cin >> W[i];
  }
  
  int answer = 100;
  for (int t = 0; t < N; t++) {
    int S1 = 0, S2 = 0;
    for (int i = 0; i < N; i++) {
      if (i <= t) {
        S1 += W[i];
      } else {
        S2 += W[i];
      }
    }
    answer = min(answer, abs(S1 - S2));
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,b,c=0,o,e,d=1,i,t,j,n,x,y,k,m,l,r=0;
    scanf("%lld%lld",&a,&b);
    if(a>b){printf("safe\n");}
    else{printf("unsafe\n");}


}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,T;
    cin >> N >> T;
    vector<int> A;
    rep(i,N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    vector<pair<int,int>> B;
    int nmax = 0;
    int idx = 0;
    rep(i,N) {
        if (A[N-1-i]>nmax) {
            nmax = A[N-1-i];
            idx = N-1-i;
        }
        B.push_back(make_pair(nmax,idx));
    }
    reverse(B.begin(),B.end());
    int ans = 0;
    map<int,int> M;
    int diff_max = 0;
    rep(i,N-1) {
        int n = B[i+1].first;
        int d = B[i+1].second;
        int a = A[i];
        int diff = n-a;
        M[diff]++;
        if (diff>diff_max) {
            diff_max = diff;
        }
    }
    ans = M[diff_max];
    cout << ans << endl;
}


Measured memory_bytes: 9196
char a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;s=a[c+i&1][p+p]-50,c<m&&!s|n+~p;)p+=p<n&&s?~s|a[c+i&1][p+p+2]-49?++c,2:1:-1;}

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

int main(){

  int r,d,xx;
  cin>>r>>d>>xx;

  vector<long long> x(10);
  int i;
  for(i=0;i<10;i++){
    if(i==0)
    x.at(i)=r*xx-d;
    else
    x.at(i)=r*x.at(i-1)-d;
  }
  for(i=0;i<10;i++)
  cout<<x.at(i)<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N]; // ?????¢??§?¨??????¶???(color)???????????????

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; ++i) {
        d[i] = INFTY;
    }
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; ++v) {
            if (M[u][v] == 0)
                continue;
            if (d[v] != INFTY)
                continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {
    int u, k, v;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}

Measured memory_bytes: 3100
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from math import gcd
    from functools import reduce

    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    a.sort()

    if a[-1] < k:
        return print("IMPOSSIBLE")

    if n == 1:
        if a[0] == k:
            return print("POSSIBLE")
        else:
            return print("IMPOSSIBLE")
    else:
        g = reduce(gcd, a)
        if k % g == 0:
            return print("POSSIBLE")
        else:
            return print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 92324
#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() {
	ll n, k;
	cin >> n >> k;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	map<int, ll> mp;
	rep(i, n) {
		mp[a[i]] += b[i];
	}
	ll cnt = 0;
	for (auto& c : mp) {
		cnt += c.second;
		if (cnt >= k) {
			cout << c.first << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 4992
l=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
if b.count(l[0][0])>0 and b.count(l[0][1])>0 and b.count(l[0][2])>0:
    print("Yes")
    exit()
if b.count(l[1][0])>0 and b.count(l[1][1])>0 and b.count(l[1][2])>0:
    print("Yes")
    exit()
if b.count(l[2][0])>0 and b.count(l[2][1])>0 and b.count(l[2][2])>0:
    print("Yes")
    exit()
if b.count(l[0][0])>0 and b.count(l[1][0])>0 and b.count(l[2][0])>0:
    print("Yes")
    exit()
if b.count(l[0][1])>0 and b.count(l[1][1])>0 and b.count(l[2][1])>0:
    print("Yes")
    exit()
if b.count(l[0][2])>0 and b.count(l[1][2])>0 and b.count(l[2][2])>0:
    print("Yes")
    exit()
if b.count(l[0][0])>0 and b.count(l[1][1])>0 and b.count(l[2][2])>0:
    print("Yes")
    exit()
if b.count(l[0][2])>0 and b.count(l[1][1])>0 and b.count(l[2][0])>0:
    print("Yes")
    exit()
else:
    print("No")

    




Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _0588
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            long a = 0;
            while (true)
            {
                if (n == 0)
                {
                    a = long.Parse(Console.ReadLine());
                }
                string s = Console.ReadLine();
                if (s == "=") { Console.WriteLine(a); break; }
                long d = long.Parse(Console.ReadLine());
                if (s == "-") { a -= d; }
                if (s == "+") { a += d; }
                if (s == "*") { a = a * d; }
                if (s == "/") { a /= d; }
               
                n++;
            }
        }
    }
}

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    vector< int > ans(s.size(), 0);
    for (int i = 0; i < s.size(); i++) {
        if (i < s.size() - 1 && s[i] == 'R' && s[i + 1] == 'L') {
            for (int j = i; j >= 0; j--) {
                if (s[j] == 'L')
                    break;
                if ((i - j) % 2 == 0) {
                    ans[i]++;
                } else {
                    ans[i + 1]++;
                }
            }
            for (int j = i + 1; j < s.size(); j++) {
                if (s[j] == 'R')
                    break;
                if ((j - i) % 2 == 0)
                    ans[i]++;
                else
                    ans[i + 1]++;
            }
            i++;
        }
    }
    for (int i = 0; i < s.size() - 1; i++) {
        cout << ans[i] << " ";
    }
    cout << ans[s.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
int main()
{
  LL n,x,y,sum=0;
  LL a[100005],b[100005];

  cin>>n;

  for(LL i=0; i<n+1; i++){
    cin>>a[i];
  }

  for(LL i=0; i<n; i++){
    cin>>b[i];
  }

  for(LL i=0; i<n; i++){
    x=min(a[i],b[i]);
    y=min(a[i+1],b[i]-x);
    a[i+1]-=y;
    sum+=x+y;
  }
  
  cout<<sum<<'\n';
  return 0;
}





Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int rate = sc.nextInt();
        sc.close();
        int res = rate;

        if(n < 10)
            res += 100 * (10 - n);
        // 出力
        System.out.println(res);
    }
}

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

ll gcd(ll n, ll m) {
    if(n % m== 0) {
        return m;
    }
    return gcd(m, n%m);
}
int main() 
{
    ll N, X, ans;
    cin >> N >> X;
    ans = 3*(N - gcd(N, X));
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := getInt()
	hs := make([]int, n)
	for i := range hs {
		hs[i] = getInt()
	}

	ans := 0
	cnt := 0
	now := hs[0]
	for i := 1; i < n; i++ {
		if now < hs[i] {
			cnt = 0
			now = hs[i]
		} else {
			cnt++
			now = hs[i]
		}
		ans = max(ans, cnt)
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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: 3072
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        boolean[] dp = new boolean[n+1];
        dp[0] = true;

        for (int i = 1; i <= n; i++) {
            if (((i - 4 >= 0) && dp[i-4]) || ((i - 7 >= 0) && dp[i-7])) {
                dp[i] = true;
            }
        }

        System.out.println(dp[n] ? "Yes" : "No");
    }
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int N,M;

	scanf("%d %d",&N,&M);

	if(N == 1){
		printf("%d\n",M);
		return 0;
	}

	if(N%2 == 0){
		printf("0");
		for(int i = 1; i < N/2+1;i++)printf(" 0");
		for(int i = 1; i < N/2; i++)printf(" %d",M);
		printf("\n");
	}else{
		printf("0");
		for(int i = 1; i < (N+1)/2;i++){
			printf(" 0");
		}
		for(int i = 0; i < N/2; i++)printf(" %d",M);
		printf("\n");
	}

	 return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
#include<iomanip>
// #define int long long
#define ll long long
#define FOR(P,Q) for(P=0;P<Q;P++)
#define FORR(P,Q) for(P=1;P<=Q;P++)
#define FORS(i,s) for(i=0;s[i]!='\0';i++)
#define pb push_back
using namespace std;

/*std::cout << std::fixed;
    std::cout << std::setprecision(14);
    std::cout << d;
*/
    
int main()
{
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif

	int n;
  int i,a[100005];
  cin>>n;
  FORR(i,n){
    cin>>a[i];
  }
  sort(a+1,a+n+1);
  int q=n/2;
  int w=a[q+1]-a[q];
  cout<<w;
	  
return 0;
}

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

int main() {
  int W,a,b,sum;
  cin >> W >> a >> b;
  if(a>b){
    sum =a-(b+W);
    if(sum <=0){
      cout << '0' << endl;
    }else{
      cout << sum << endl;
    }
  }else{
    sum = b-(a+W);
    if(sum <= 0){
      cout << '0' << endl;
    }else{
      cout << sum << endl;
    }
  }
}

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

vector<bool> visited;
vector<vi> g;
vi dp;

int dfs(int root){
    if(dp[root] != -1){
        return dp[root];
    }
    int down = 0;
    for(auto child : g[root]){
        down = max(down, dfs(child));
    }
    return dp[root] = 1 + down;
}

void solve(){
    int n, m;
    cin >> n >> m;
    g.resize(n);
    visited.resize(n, false);
    dp.resize(n, -1);
    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].pb(y);
    }
    int ans = 0;
    rep(i, n){
        if(dp[i] == -1){
            dfs(i);
        }
        error(i, dp[i]);
        ans = max(ans, dp[i] - 1);
    }

    cout << ans << endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 8576
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		card[] c = new card[200000];
		long sum = 0;

		for(int i = 0; i < 200000; i++) {
			c[i] = new card(0, 0);
		}

		for(int i = 0; i < n; i++) {
			c[i] = new card(sc.nextInt(), 1);
		}

		for(int i = 0; i < m; i++) {
			int num = sc.nextInt();
			int val = sc.nextInt();
			c[n+i] = new card(val, num);
		}

		Arrays.sort(c, new Comparator<card>() {
			public int compare(card c1, card c2) {
				return c2.val - c1.val;
			}
		});

		for(card i : c) {
			for(int j = i.num; j > 0 && n > 0; j--) {
				sum += i.val;
				n--;
			}
		}

		System.out.println(sum);
		sc.close();
	}

	private static class card{
		int val; int num;
		card(int a, int b){
			this.val = a;
			this.num = b;
		}
	}
}

Measured memory_bytes: 104356
#include<stdio.h>
int main() {
	int W=0, H=0, x=0, y=0, r=0;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if (W >= x + r &&   x-r >= 0 && H >= y+r && y-r >= 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 2112
INF = 10 ** 20

def minimum_cost(rest, dp, tlst, tord, end, n):
  if rest in dp:
    return dp[rest]
  if rest == end:
    return 0
  
  ret = INF
  for ind, to in enumerate(rest):
    if to == "0":
      tmp = minimum_cost(rest[:ind] + "1" + rest[ind + 1:], dp, tlst, tord, end, n) + cost(ind, rest, tlst, tord, n)
      if tmp < ret:
        ret = tmp
  dp[rest] = ret
  return ret

def cost(ind, rest, tlst, tord, n):
  order = tord[ind - 1]
  for i in order:
    if rest[i] == "1":
      return tlst[ind - 1][i]


def main():
  while True:
    n = int(input())
    if n == 0:
      break
    tlst = [list(map(int, input().split())) for _ in range(n)]
    tord = []
    for lst in tlst:
      tmp = sorted(zip(lst, range(n + 1)))
      tord.append([i for _, i in tmp])
    dp = {}
    end = "1" * (n + 1)
    ans = minimum_cost("1" + "0" * n, dp, tlst, tord, end, n)
    print(ans)

main()


Measured memory_bytes: 17268
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll D;
    cin >> D;

    vector<ll> c(26);
    ll sum_c = 0;
    rep(0, i, 26)
    {
        cin >> c.at(i);
        sum_c += c.at(i);
    }

    vector<vector<ll>> s(D, vector<ll>(26, 0));
    rep(0, i, D)
    {
        rep(0, j, 26)
        {
            cin >> s.at(i).at(j);
        }
    }

    ll score = 0, dec = 0; // i日目のスコア、スコアの減少量
    vector<vector<ll>> d(D + 1, vector<ll>(26, 0));
    vector<ll> t(D), ans(D, 0);
    rep(0, i, D)
    {
        // 今日開くコンテスト
        ll today_i = 0;
        ll today_score = 0;
        ll sum;
        // i日目に各コンテストを開催したと仮定して満足度を求める
        rep(0, j, 26)
        {
            sum = s.at(i).at(j);
            sum = sum - (dec + sum_c - (c.at(j) * (d.at(i).at(j) + 1)));
            if (score + today_score < score + sum)
            {
                today_i = j;
                today_score = sum;
            }
        }

        // ループが終了したら今日開くコンテストが決まるので、last(d,i)を更新する
        rep(0, j, 26)
        {
            d.at(i + 1).at(j) = d.at(i).at(j) + 1;
        }
        d.at(i + 1).at(today_i) = 0;

        // decの更新
        dec = 0;
        rep(0, j, 26)
        {
            dec += c.at(j) * d.at(i + 1).at(j);
        }

        // scoreの更新
        score += today_score;

        // 答え
        t.at(i) = today_i + 1;
        ans.at(i) = score;
    }

    rep(0, i, D)
    {
        cout << t.at(i) << endl;
    }
}

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

int main() {
    int a, b,count = 0, tap=1;
    cin >> a >> b;
    while(1){
        if(tap >= b){
            cout << count << endl;
            return 0;
        }
        tap = tap - 1 + a;
        count ++;
    }
}

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

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));

    rep(i, N) rep(j, D) cin >> X[i][j];

    int ans = 0;
    rep(i, N) rep(j, i)
    {
        int sq = 0;
        rep(k, D)
        {
            int s = X[i][k] - X[j][k];
            sq += s * s;
        }
        int s = sqrt(sq) + 0.5;
        if (s * s == sq){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256