akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text; 
using System.Collections.Generic;
using System.Linq;

public class Remainder
{
    static public void Main ()
    {
        var LR= Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var L = LR[0];
        var R = LR[1];
        long min = 2019;
        var flag = false;
        
        for(long i = L;i < R ; i++){
            for(long j = i+1;j <= R ; j++){
                var L2 = i%2019;
                var R2 = j%2019;
                var com = (L2*R2)%2019;
                if(com<min){
                    min = com;
                }
                if(min == 0){
                    flag = true;
                    break;
                }                
            }
            if(flag){
                break;
            }
        }
        
        Console.WriteLine(min);

    }

}


Measured memory_bytes: 13268
n,m,k = map(int, input().split())

a = [0]+list(map(int, input().split()))
b = [0]+list(map(int, input().split()))

for i in range(1,n+1):
    a[i]+=a[i-1]
for i in range(1,m+1):
    b[i]+=b[i-1]

b_cnt=m
ans=0

for a_cnt in range(n+1):
    if a[a_cnt]>k:
        break
    while a[a_cnt]+b[b_cnt]>k:
         b_cnt-=1
    ans=max(ans,a_cnt+b_cnt)

print(ans)

Measured memory_bytes: 40016
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    int count = 0;
    for(int i = 0; i < n;){
        if(h[i] > 0){
            count++;
            for(int j = i; j < n; j++){
                if(h[j] == 0){
                    break;
                } else {
                    h[j]--;
                }
            }
        } else {
            i++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(void){
  int N,L;
  cin>>N>>L;
  string P[100]={};
  for(int i=0;i<N;i++){
      string S;
      cin>>S;
      P[i]=S;
  }
  sort(P,P+100);
  string answer;
  for (int i=0;i<100;i++){
      if(P[i]!=" "){
           answer+=P[i];
      }
  }
 cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long x, long long y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return gcd(y, x % y);
    }
}
long long lcm(long long x, long long y)
{
    return x / gcd(x, y) * y;
}

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    // b以下でcでもdでも割り切れないもの
    long long bb = b - b / c - b / d + b / lcm(c, d);
    long long aa = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d);
    cout << bb - aa << endl;
    return 0;
}


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

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout.tie(nullptr);
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    vector<int>v(4); for(auto&itr:v)cin>>itr;
    cout << max({v.at(0)*v.at(2) , v.at(0)*v.at(3) , v.at(1)*v.at(2), v.at(1)*v.at(3)}) << '\n'; 
    return 0;
}


Measured memory_bytes: 3648
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        k: i32,
        s: i32,
    }
    let mut ret = 0;
    for x in 0..=k {
        for y in 0..=k {
            let z = s - x - y;
            if z >= 0 && z <= k {
                ret += 1;
            }
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2096
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
using namespace std;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
 
int main() {
	//freopen("test.txt", "r", stdin);
	FASTER;
	int n; cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0 && i%5!=0) sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3196
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main()
{
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;

  if(N < K) {
    cout << N * X << endl;    
  } else {
    cout << K * X + (N - K) * Y << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";

int main() {
  ll n,a; cin>>n;
  ll m=pow(n,0.5);
  for(ll i=m; i>=1; i--){
    if(n%i==0){
      a=n/i;break;
    }
  }
  int k=0;
  while(a!=0){a/=10;k++;}
  cout<<k;
}




Measured memory_bytes: 3968
#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 A, B; cin >> A >> B;
    int ans = A+B;
    ans = max(ans, A-B);
    ans = max(ans, A*B);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
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! {
    h: usize,
    w: usize,
    k: usize,
    mut map: [Chars; h],
    }

    let mut h_it = vec![vec![]];
    for i in 1..=h {
        h_it.push((0..h).combinations(i).collect());
    }

    let mut w_it = vec![vec![]];
    for i in 1..=w {
        w_it.push((0..w).combinations(i).collect());
    }


    let mut cnt = 0;
    for h_rev in &h_it {
        if h_rev.len() == 0 {
            for w_rev in &w_it {
                if w_rev.len() == 0 {
                    if cntb(&vec![], &vec![], &map, w, h) == k {
                        cnt += 1;
                    }
                } else {
                    for w_rev2 in w_rev {
                        if cntb(&vec![], &w_rev2, &map, w, h) == k {
                            cnt += 1;
                        }
                    }
                }
            }
        } else {
            for h_rev2 in h_rev {
                for w_rev in &w_it {
                    if w_rev.len() == 0 {
                        if cntb(&h_rev2, &vec![], &map, w, h) == k {
                            cnt += 1;
                        }
                    } else {
                        for w_rev2 in w_rev {
                            if cntb(&h_rev2, &w_rev2, &map, w, h) == k {
                                cnt += 1;
                            }
                        }
                    }
                }
            }
        }
    }

    println!("{}", cnt);
}

fn cntb(vech: &Vec<usize>, vecw: &Vec<usize>, map: &Vec<Vec<char>>, w: usize, h: usize) -> usize {
    let mut cnt = 0;
    for hi in 0..h {
        if !vech.contains(&hi) {
            for wi in 0..w {
                if !vecw.contains(&wi) {
                    if map[hi][wi] == '#' {
                        cnt += 1;
                    }
                }
            }
        }
    }
    return cnt;
}


Measured memory_bytes: 2144
#include <iostream>

using namespace std;

int main()
{ string s,t,u;
   cin>>s>>t;
   int a,b;
   cin>>a>>b;
   cin>>u;
   if (a>=10||b>=10)
   {
       cin>>a>>b;
   }
       if(s==u)
        a--;
       else
        b--;

    cout <<a<<" "<<b;
    return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
#define f(c,d)for(c=d%2;c<d;c+=2)
p[2<<19],a,b,m,i,j,o;x(i,j){if(a)p[i]=60,p[i+1]=62,a--;}y(i,j){if(b)p[i]=94,p[i+m]=118,b--;}main(n){scanf("%d%d%d%d",&n,&m,&a,&b);if(n&1)f(j,m)x(j);if(m&1)f(i,n)y(i*m);if(n>2&m>2&n&m&a&a>0&b>0)a++,x(0),x(2*m+1),y(2);f(i,n)f(j,m)if(p[(o=i*m+j)+1]);else if(a)x(o),x(o+m);else y(o),y(o+1);puts(a|b?"NO":"YES");if(!a&!b)for(i=0;i<n*m;++i%m||puts(""))putchar(p[i]?:46);}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi d(n); rep(i, n) cin >> d[i];

  ll ans = 0;
  rep(i, n) rep(j, n) {
    if(i == j) continue;
    ans += d[i]*d[j];
  }

  std::cout << ans/2 << '\n';
}


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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#pragma GCC optimize("", on)
//#pragma GCC optimization_level 3

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [" << endl;                      \
        rep(i, h) {                                                            \
            rep(j, w) cerr << a[i][j] << space;                                \
            cerr << endl;                                                      \
        }                                                                      \
        cerr << "]" << endl;                                                   \
    }

#define lldump(a, n)                                                           \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [";                              \
        rep(i, n) if (i) cerr << space << a[i];                                \
        else cerr << a[i];                                                     \
        cerr << "]" << endl;                                                   \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

signed main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D, cout << min(A, B) + min(C, D) << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
 
int main(){
  long long n,ans, var;
  cin>>n;
  var = n%11;
  ans = n/11;
  ans *= 2;
  if(var>0) ans++;
  if(var>6) ans++;
  cout<<ans<<endl;
return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  for(int i=1;i<=1000;i++){
    if(((int)(i*(8.0/100))==A)&&((int)(i*(10/100.0))==B)){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
# Problem B - Five Dishes

from itertools import permutations
import math

# input
nums = [0]*5
for i in range(5):
    n = int(input())
    nums[i] = n

# initialization
pattern_moto = [i for i in range(5)]
patterns = permutations(pattern_moto)
min_time = 1000

# time count
for p in patterns:
    tmp = 0
    for i in range(4):
        tmp += nums[p[i]]
        tmp = math.ceil(tmp/10)*10
    tmp += nums[p[4]]
    min_time = min(min_time, tmp)

# output
print(min_time)


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

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 1010;

int xs, ys, xt, yt, n;
PII p[N];
int r[N];
vector<pair<int, double>> child[N];
double odl[N];

double dis(int i, int j)
{
	return sqrt((p[i].ST-p[j].ST)*(p[i].ST-p[j].ST)+(p[i].ND-p[j].ND)*(p[i].ND-p[j].ND));
}

void dijkstra() {
	set<pair<double, int>> s;
	for (int i = 0; i <= n+5; ++i)
		odl[i] = 1e15;
	odl[0] = 0;
	s.insert({odl[0], 0});
	while (!s.empty()) {
		auto p = *s.begin();
		s.erase(s.begin());
		for (auto c: child[p.ND]) {
			int v = c.ST;
			double waga = c.ND;
			if (odl[v] > odl[p.ND]+waga) {
				s.erase({odl[v], v});
				odl[v] = odl[p.ND]+waga;
				s.insert({odl[v], v});
			}
		}
	}
}

double max(double a, double b) {
	if (a >= b)
		return a;
	return b;
}

signed main()
{
	init_ios();
	cout<<fixed<<setprecision(10);	
	cin >> xs >> ys >> xt >> yt;
	cin >> n;
	p[0] = {xs, ys};
	p[n+1] = {xt, yt};
	for (int i = 1; i <= n; ++i) {
		cin >> p[i].ST >> p[i].ND >> r[i];
	}
	for (int i = 0; i <= n; ++i)
		for (int j = i+1; j <= n+1; ++j) {
			double d = max(0, dis(i, j)-r[i]-r[j]);
			child[i].PB({j, d});
			child[j].PB({i, d});
		}
	dijkstra();
	cout<<odl[n+1]<<"\n";
}

Measured memory_bytes: 16640
a = []
b = []

n,m,l = map(int,input().split())

for i in range(n):
    a.append(list(map(int,input().split())))
for j in range(m):
    b.append(list(map(int,input().split())))

B = []
for k in range(l):
    BB = []
    for i in b:
        BB.append(i[k])
    B.append(BB)

C = []

for i in range(n):
    CC = []
    for k in range(l):
        CCC = 0
        for j in range(m):
            CCC += a[i][j] * B[k][j]
        CC.append(CCC)
    C.append(CC)

for p in C:
    print(" ".join(map(str,p)))



Measured memory_bytes: 7024
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

X=one_int()

big = X//500

X=X%500
sma = X//5

print(big*1000+sma*5)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int N; cin >> N;
    int a_max;
    int b_min;
    for (int i=0;i<N;i++){
        int ai,bi; cin >> ai >> bi;
        if (i==0) {
            a_max = ai;
            b_min = bi;
        }
        else if (ai>a_max) {
            a_max = ai;
            b_min = bi;
        }
    }
    cout << a_max + b_min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	string s,t,u;
	cin>>s>>t>>a>>b>>u;
	for(int i=0;i<s.size();i++)if(s[i]!=u[i])c=1;
	for(int i=0;i<t.size();i++)if(t[i]!=u[i])c=0;
	if(c)cout<<a<<" "<<b-1;
	else cout<<a-1<<" "<<b;
}


Measured memory_bytes: 3548
n = input()
m = map(int, input().split())
d = {}
for i in m:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1
cnt = 0
for i in d.items():
    if i[0] > i[1]:
        cnt += i[1]
    elif i[0] < i[1]:
        cnt += i[1]-i[0]
print(cnt)

Measured memory_bytes: 23284
#include <stdio.h>

int main(){
  int x, y, z;
  
  while(scanf("%d %d",&x,&y) != EOF){
    if (x < y){
      z = x;
      x = y; y = z;
    }
    int koyaku = gojo(x, y);
    long int koubai = (x/koyaku)*y;

    printf("%d %d\n",koyaku,koubai);

  }
  return 0;
}

int gojo(int x, int y){
  int r;

  while((r = x % y) != 0){
      x = y;
      y = r;
      }
  return y;
}

Measured memory_bytes: 596
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define FIND(v,key) std::find(v.begin(), v.end(), key) != v.end() //FIND(vector,key) :v contains key

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}





//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	int N;
	cin>>N;
	vector<string> S(N);
	set<string> st;
	REP(i,N){
		cin>>S[i];
		st.insert(S[i]);
	}
	

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





}







Measured memory_bytes: 25112
#include<bits/stdc++.h>
using namespace std;
long long a[10],ans=1000000000000000;
long long n;
int main(){
    cin>>n;
    int pos;
    for(int i=1;i<=5;i++){
        cin>>a[i];
        if(ans>a[i]){
            ans=a[i];
            pos=i;
        }
    }
    long long res=0;
    if(n>=a[pos]){
        long long coun=n/a[pos];
        if(n%a[pos]!=0)
            coun++;
        res+=(coun-1);
    }

    res+=pos-1;
    res+=6-pos;

    cout<<res;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main()
{
    int n,i,j,k,a[10000];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int cnt=0,sum;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum=a[i]+a[j];
            for(int k=j+1;k<n;k++)
            {
                if(sum>a[k])
                cnt++;
                else break;
            }
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;

LL S(LL N, LL r)
{
	LL cap=N-r;
	LL b=r+1;
	LL m=cap/b;
	LL ans=0;
	while(m>0 && cap/m<N){
		ans+=(cap/m-b+1)*m;
		b=cap/m+1;
		m=cap/b;
	}
	ans+=(N-b+1)*m;
	ans+=N-r;
	return ans;
}

int main() {
	LL N,K,ans=0;
	cin>>N>>K;
	if(K==0){
		cout<<N*N<<endl;
		return 0;
	}
	for(LL r=K;r<N;r++){
		ans+=S(N,r);
		//printf("r=%lld %lld\n",r,S(N,r));
	}
	cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto&& x:a)cin >> x;
  sort(a.begin(), a.end());
  int ans = 0;
  for(auto it = a.begin();it!=a.end();){
    auto nt = upper_bound(it, a.end(), *it);
    ans += (distance(it, nt) & 1);
    it = nt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
from collections import defaultdict
N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]

path = defaultdict(int)
for i in range(N):
    path[i] = defaultdict(int)

for i in range(N):
    path[i][i] = []

for i in range(M):
    ABC[i][0] -= 1
    ABC[i][1] -= 1


edges = [list() for _ in range(N)]
for a,b,c in ABC:
    edges[a].append((b,c)) 
    edges[b].append((a,c)) 
inf = 100000000

for i in range(N):
    D = [inf for _ in range(N)]
    D[i] = 0
    stack = [i]
    while stack:
        vertex = stack.pop(-1)
        for b,c in edges[vertex]:
            cost = D[vertex] + c
            if cost < D[b]:
                if vertex > b:
                    path[i][b] = path[i][vertex] + [(vertex,b)]
                else:
                    path[i][b] = path[i][vertex] + [(b,vertex)]
                D[b] = cost
                stack.append(b)

counter = set()

for i in range(N):
    for j in range(N):
        for e in path[i][j]:
            counter.add(e)

print(M-len(counter))



        


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

int main(){
  int a;
  cin>>a;
  
  int b=a;
  int sum=0;
  while(a>0){
    sum +=a%10;
      a=a/10;

  }

  
  
  if(b%sum==0){
    cout<<"Yes"<<endl;}
  
  else 
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A, B, C, D = map(int, input().split())
AC = (A - 1) // C
AD = (A - 1) // D
BC = B // C
BD = B // D
BCD = B // lcm(C, D)
ACD = (A - 1) // lcm(C, D)
tmp = (BC + BD) - (AC + AD) - (BCD - ACD)
ans = (B - A + 1) - tmp
print(ans)

Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}
int dp[9]={};
int main(){
    fast_io
    
    
    string s;
    ll k;
    cin>>s>>k;
    if(s[0]!='1'){
        cout<<s[0]<<endl;
        return 0;
    }
    for(ll i=1;i<k;i++){
        if(s[i-1]=='1'&&s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,t;cin >> n >> t;
	vector<int> a(n);
	vector<int> b(n);
	rep(i,n) cin >> a.at(i) >> b.at(i);
	int ans=1000000;
	rep(i,n){
		if(b.at(i)<=t) ans=min(ans,a.at(i));
	}
	if(ans>10000) cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
	if (a > b) {
		swap(a, b);
	}

	if (a == 0) {
		return b;
	}

	return gcd(b%a, a);
}

int main() {
	int n;
	cin >> n;
	vector<ll> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

	ll lcm = t[0];

	for (int i = 1; i < n; i++) {
		
		ll g = gcd(lcm, t[i]);
		lcm = lcm / g * t[i];
	}

	cout << lcm << endl;
}

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

int main(){
  int N;
  cin >> N;
  int c = 0;

  for (int i = 1;i <= N;i++){
    int s = i;
      int n = 0;
    while (s!=0){
      s /= 10;
      n++;
    }
    if ((n % 2) == 1){
      c++;
    } 
  }
  cout << c << endl;
}

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

using namespace std;
typedef long long ll;

// union find tree
class UFT {
    private:
    vector<ll> r;
    vector<ll> p;

    public:
    UFT(ll n) {
        r.resize(n);
        p.resize(n);

        for (ll i = 0; i < n; ++i) {
            r[i] = 0;
            p[i] = i;
        }
    }

    void link(ll x, ll y) {
        if (r[x] > r[y]) {
            p[y] = x;
        } else {
            p[x] = y;

            if (r[x] == r[y]) {
                r[y]++;
            }
        }
    }

    ll find(ll x) {
        if (x != p[x]) {
            p[x] = find(p[x]);
        }
        return p[x];
    }

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

    void unite(ll x, ll y) {
        link(find(x), find(y));
    }
};

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

    vector< pair<ll, pair<ll, ll> > > M;

    cin >> W >> H;
    M.resize(W + H);

    for (ll i = 0; i < W; ++i) {
        ll e;

        cin >> e;
        M[i] = make_pair(e, make_pair(0, i));
    }

    for (ll i = 0; i < H; ++i) {
        ll e;

        cin >> e;
        M[W+i] = make_pair(e, make_pair(1, i));
    }

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

    ll ans = 0;
    ll w = W + 1;
    ll h = H + 1;

    for (ll i = 0; i < H + W; ++i) {
        ll e;
        ll b;

        e = M[i].first;
        b = M[i].second.first;

        if (b == 0) {
            ans += (h * e);
            w -= 1;
        } else {
            ans += (w * e);
            h -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int total =0;
            for (int i = 0; i < N; i++)
            {
               string[] s = Console.ReadLine().Split(' ');
               total += int.Parse(s[1]) - int.Parse(s[0]) + 1;
            }
            Console.WriteLine(total);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    a.insert(0,0)
    count=0
    for i in range(1,n+1,2):
        if a[i]%2==1:
            count+=1
    return count

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    REP(i, N) { cin >> a[i] >> b[i]; }

    RSORT(b);
    int a_max = *max_element(ALL(a));

    ll ans = 0;

    REP(i, N) {
        if (a_max < b[i]) {
            H -= b[i];
            ans++;
            if (H <= 0) {
                std::cout << ans << '\n';
                return 0;
            }
        } else
            break;
    }
    ans += (H + a_max - 1) / a_max;

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 102
#define INF 10000
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
int prim();
int n,W[MAX][MAX];
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&W[i][j]);
    }
  }
  printf("%d\n",prim());
  return 0;
}
int prim(){
  int i,u,mincost,color[MAX],d[MAX],pi[MAX],count=0;
  for(i=1;i<=n;i++){
    d[i]=INF;
    pi[i]=NIL;
    color[i]=WHITE;
  }
  d[1]=0;
  while(1){
    mincost=INF;
    for(i=1;i<=n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    }
    if(mincost==INF) break;
    color[u]=BLACK;
    for(i=1;i<=n;i++){
      if(W[u][i]!=NIL && color[i]!=BLACK && W[u][i]<d[i]){
	pi[i]=u;
	d[i]=W[u][i];
      }
    }
  }
  for(i=1;i<=n;i++){
    if(pi[i]!=NIL){
      count+=W[i][pi[i]];
    }
  }
  return count;
}



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

int main()
{
    int n,k;
    cin>>n>>k;
    double ans=0.0;
    for(int i=1;i<=n;i++)
    {
        int ii=i;
        double p=1.0;
        while(ii<k)
        {
            p/=2.0;
            ii*=2;
        }
        ans+=p/(double)n;
    }
    printf("%.10f\n",ans);
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string S; cin >> S;

	int N = S.length();
	int ans = 1 << 30;
	REP(i,N-2){
		ans = min(ans, abs(753-stoi(S.substr(i,3))));
	}

	cout << ans << endl;

	return 0;

}


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

int main() {

  long long X;
  cin >> X;

  long long current = 100;
  long long answer = 0;
  
  while (current < X) {
    answer++;
    current += floor((long double) current / 100);
  }

  cout << answer << endl;

  return 0;

}

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

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

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    string s;
    cin >> s;
    string ans;
    for (auto c:s) {
        if(c=='B') ans=ans.substr(0, ans.size()-1);
        else ans.push_back(c);
    }
    printf("%s\n", ans.c_str());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
    int a,b,c;cin >> a >> b >> c;
    int t = a + b + c;
    int m = 3*max(max(a,b),c);
    if(t%2 != m%2) m += 3;
    cout << (m-t)/2 << endl;
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, X, ans;
    scanf("%lld %lld", &N, &X);
    vector<ll> L(N);
    ll D=0;
    REP(int,i,0,N) scanf("%lld", &L.at(i));
    ans = 1;
    REP(int,i,0,N){
        D = D + L.at(i);
        if ( D <= X ) ans++;
    }
    printf("%lld\n",ans);
    return 0;
}

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

int c[100][100],ans;

int search(int x, int y){
	if(c[x][y] == 1){
		c[x][y] = 2;
		search(x-1, y-1);
		search(x-1, y);
		search(x-1, y+1);
		search(x, y-1);
		search(x, y+1);
		search(x+1, y-1);
		search(x+1, y);
		search(x+1, y+1);
	return 1;	
	}
	else return 0;
}

int main(){
	int w,h,i,j;
	while(cin >> w >> h && w > 0 && h >0){
		for(i = 1; i <= 99; i++){
			for(j = 1; j <= 99; j++){
				c[i][j] = 0;
			}
		}
		ans = 0;
		for(i = 1; i <= h; i++){
			for(j = 1; j <= w; j++){
				cin >> c[i][j];
			}
		}
		for(i = 1; i <= h; i++){
			for(j = 1; j <= w; j++){
				if(search(i, j) == 1){
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1304
#include<stdio.h>
int main(){
int n[28],i,a=0,b=0,j,flag;
for(i=0;i<28;i++){
scanf("%d\n",&n[i]);
}
for (i=1;i<=30;i++){

for (j=0;j<28;j++){
if(n[j]==i)flag=1;
}

if(flag==0){
if(a==0)a=i;else b=i;
}else{
flag=0;
}

}
printf("%d\n%d\n",a,b);
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

int N; cin >> N;
set<string> st;
rep(i,N) {
    string s;
    cin >> s;
    st.insert(s);
}
cout << SZ(st) << endl;
return 0;
}

Measured memory_bytes: 19196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  fo(i,n) for(ll i=0;i<n;i++)
#define rfo(i,n) for(ll i=n;i>=0;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
void solve()
{
	ll x;
	cin>>x;
	if(x == 0)
	{
		cout<<1;
	}
	else
	{
		cout<<0;
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3648
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(2, 27):
        if s[-i] <= s[-i + 1]:
            break
    s_ = sorted(s[-i + 1:])
    for j in s_:
        if j > s[-i]:
            break
    print(s[:-i] + j)

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,k,ans=1;
int main ()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		ans+=min(ans,k);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = set(list(input()))

print("Yes" if len(S) == 2 else "No")

Measured memory_bytes: 60268
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;


int main()
{
    int n;
    cin>>n;
    long long arr[n];
    unordered_map<long long,long long> mp;
    
    for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            mp[arr[i]]++;
        }
    long long ans=0ll;
    for(auto i=mp.begin();i!=mp.end();i++)
        {
          long long tmp=i->second;
          ans=ans+ (tmp*(tmp-1))/2;
        }
        
    for(int i=0;i<n;i++)
    {
        long long freq=mp[arr[i]];
        long long xx= ans-(freq*(freq-1))/2;    
        freq--;
        xx+=(freq*(freq-1))/2;
        cout<<xx<<endl;
    }
    
}


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

const int MAX=1010;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,ans;
    vector<int> sum(MAX,0);
    for (int i=1;i<MAX;++i) sum[i]+=sum[i-1]+i;
    while(cin >> N,N){
        ans=0;
        for (int i=0;i<MAX;++i){
            for (int j=i+2;j<MAX;++j){
                ans+=(sum[j]-sum[i]==N);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3032
n, k = map(int, input().split())
l = [1] * n
#print(l)
for _ in range(k):
  d = int(input())
  #print(d)
  a = list(map(int, input().split()))
  for c in a:
    #print(c)
    l[c-1] = 0
print(sum(l))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 200000
using namespace std;

typedef long long ll;

int bi_search(ll *arr, int size, ll val)
{
    int l = 0, r = size - 1, mid;

    while (r >= l)
    {
        mid = (l + r) / 2;
        if (arr[mid] == val)
            return mid;
        else if (arr[mid] > val)
            r = mid - 1;
        else
            l = mid + 1;
    }
    return r;
}

int main()
{
    int a, b, q, m, n;
    ll s[N] = {}, t[N] = {}, x = 0, res = 0;
    cin >> a >> b >> q;
    FOR(i, 1, a + 1)
    cin >> s[i];
    FOR(i, 1, b + 1)
    cin >> t[i];
    FOR(i, 0, q)
    {
        res = 20000000000;
        cin >> x;
        m = bi_search(s, a+1, x);
        if (m != 0)
        {
            n = bi_search(t, b+1, s[m]);
            if(n!=0)
                res = min(x - t[n],res);
            if(n!=b)
                res = min(x-s[m]+t[n+1]-s[m],res);
        }
        if(m !=a)
        {
            n = bi_search(t,b+1,s[m+1]);
            if(n!=0)
                res = min(s[m+1]-x + s[m+1] - t[n],res);
            if(n!=b)
                res = min(t[n+1]-x,res);
        }

        n = bi_search(t, b+1, x);
        if (n != 0)
        {
            m = bi_search(s, a+1, t[n]);
            if(m!=0)
                res = min(x - s[m],res);
            if(m!=a)
                res = min(x-t[n]+s[m+1]-t[n],res);
        }
        if(n !=b)
        {
            m = bi_search(s,a+1,t[n+1]);
            if(m!=0)
                res = min(t[n+1]-x + t[n+1] - s[m],res);
            if(m!=a)
                res = min(s[m+1]-x,res);
        }

        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#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) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
inline int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a , int b){
  if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
bool check(std::vector<int> &a){
  for(int i = 0 ; i < a.size(); i++) {
    if(a[i] != a.size()) return false; 
  }
  return true;
}
void cal(vector < int > &a){
  int n = a.size();
  vector < int > pre(a.size(),0);  
  for(int i = 0 ; i < n ; i++){
    if(a[i]+i+1 < n) pre[a[i]+i+1] += -1;
    pre[i]+=1;
   // cout << pre[i] << " " << pre[a[i]+i+1] << "**\n";
  }
  for(int i = 1 ; i < n ; i++) pre[i] = pre[i-1]+pre[i];
  vector < int > suff(n,0);
  for(int i = 0 ; i < n ; i++){
    if(i - a[i] - 1 >=0 && a[i] > 0 ) suff[i-a[i]-1] += -1;
    if(a[i] > 0 && i-1 >= 0 ) suff[i-1]+=1;
  }
  //for(int i = 0 ; i < n  ; i++) cout << suff[i] << " ** ";
  for(int i = n-2 ; i >=0 ; i--) suff[i] = suff[i+1]+suff[i];
  
  ///for(int i = 0 ; i < n  ; i++) cout << pre[i] << " ** ";
  cout << "\n";
  for(int i = 0 ; i < n ; i++) a[i] = pre[i]+suff[i];
}
int32_t main() 
{ 
  fast;
  int n,k;
  cin >> n >> k;
  vector <int > a(n);
  int cnt = 0;
  for(int i = 0 ; i < n ; i++) cin >> a[i];
  while(!check(a) && cnt <k){
      cal(a);
      cnt++;
  }
  for(int i = 0 ; i < n ; i++) cout << a[i] << " ";
    cout << "\n";
  return 0;
} 
/*
    x dia y shovels
  2*y + y = y emarald
  x + 2*x = x emarld
  2*y + x <=a 
  y+2*x <=b 
  500 + 250 
  2*a + b ~ x

  .322.. ....... ..... ... .... .... 
  a + 2*b ~ y
  max(a+b)
  2*x+y
  x+2*y
  1-2-3
  [ 1-2 2-3 ]

   
   
  1-2-3-4

*/
 

Measured memory_bytes: 7936
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N;
	cin >> N;
	vll A(3*N);
	for (int i = 0; i < 3*N; i++) {
		cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<ll>());

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += A[2 * i + 1];
	}

	cout << ans;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	int w,a,b;
	scanf("%d %d %d",&w,&a,&b);
	int c=abs(a-b)-w;
	if(c<0){
		printf("0\n");
	}
	else{
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n, m, a[100009], j = 1;
long long ans = 0;
struct rep
{
    int b, c;
};
rep d[100009];
bool tmp(rep x, rep y)
{
    return x.c > y.c;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    for(int i = 1; i <= m; ++ i)
    {
        cin >> d[i].b >> d[i].c;
    }
    sort(d + 1, d + 1 + m, tmp);
    for(int i = 1; i <= n; ++ i)
    {
        if(d[j].c > a[i] && j <= m)
        {
            ans += d[j].c;
            //cout << ans << endl;
            -- d[j].b;
            if(d[j].b == 0) ++ j;
        }
        else ans += a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408