akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;


int main(void) {
    long N, K, Q;
    cin >> N >> K >> Q;
    vector<long>A(Q);
    for(long i = 0; i < Q; i++) {
        cin >> A[i];
    }
    vector<long> score(N);
    for(long i = 0; i < N; i++) {
        score[i] = 0;
    }
    for(long i = 0; i < Q; i++) {
        score[A[i]-1]++;
    }
    for(long i = 0; i < N; i++) {
        if(K - Q + score[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2176
from math import ceil
A,B,C=map(int, input().split())
L=sorted([A,B,C])
n1=L[0]
n2=L[1]
n3=L[2]

fir=ceil((n2-n1)/2)
if n1+2*fir!=n2:
    sec=1
else:
    sec=0

ans=n3+sec-(n1+2*fir)+fir+sec
print(ans)
#print(fir, sec)
#6+1-(4)

Measured memory_bytes: 3060
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

ll GetDigit(ll num) {
    if(num == 0) {
        return 0;
    }
    ll digit = 0;
    while(num != 0) {
        num /= 10;
        digit++;
    }
    return digit;
}

P op(P a, P b) {
    return P((a.first + b.first) % MOD, (a.second + b.second) % MOD);
}
P e() { return P(0, 0); }
P mapping(ll f, P x) {
    if(f == 0) {
        return x;
    }
    return P(x.first, f * x.first % MOD);
}
// ll mapping(ll f, ll x) { return f + x; }
ll composition(ll f, ll g) {
    if(f == 0)
        return g;
    return f;
}
ll id() { return 0; }

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> a(n);
    ll p = 1;
    lazy_segtree<P, op, e, ll, mapping, composition, id> seg(n);
    rep(i, n) {
        seg.set(n - i - 1, P(p, p));
        p = p * 10 % MOD;
    }
    rep(i, q) {
        int l, r;
        ll d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << (seg.all_prod()).second << endl;
    }
    return 0;
}


Measured memory_bytes: 18336
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll ten ,five,two;
ll count(ll n) 
{ 
    // Initialize result 
    ll count = 0; 
  
    // Keep dividing n by powers of  
    // 5 and update count 
    for (ll i = 5; n / i >= 1; i *= 5) 
        count += n / (i*2); 
  
    return count; 
} 

int main() 
{
ll n;
cin>>n;
ll x=count(n);
if(n%2==1)
{
	cout<<0;
	return 0;
}
cout<<x;	
	
	}
 
 

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	unsigned long int a[5], b, c;
	int i;

	for (i = 0; i < 5; i++) {
		scanf("%ld", &a[i]);
	}

	for (i = 0; i < 5; i++) {
		if (a[i] == 0) {

			printf("%d", i + 1);
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

ll pow(ll x, int n) {
    if (n == 0) {
        return 1;
    } else {
        return x * pow(x, n - 1);
    }
}

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

    if (n % 2) {
        cout << 0 << endl;
    } else {
        ll cnt = 0, m = 10;
        
        while (n >= m) {
            cnt += n / m;
            m *= 5;
        }

        cout << cnt << endl;
    }

    return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = 100;
		int[][] m = new int[N][];
		for(int i=0;i<N;i++) m[i] = new int[N];
		
		int N2 = N / 2;
		
		for(int i=0;i<N;i++) for(int j=0;j<N2;j++) m[i][j] = 1;
		
		for(int i=1;i<N;i+=2) for(int j=1;j<N2-1;j+=2) if(A > 1) { m[i][j] = 0; A--; }
		for(int i=1;i<N;i+=2) for(int j=N2+1;j<N-1;j+=2) if(B > 1) { m[i][j] = 1; B--; }
		
		Console.WriteLine("{0} {1}", N, N);
		Console.WriteLine(String.Join("\n",m.Select(ar => String.Join("", ar.Select(n => n == 0 ? "." : "#")))));
		
		
	}
	int A, B;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13464
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>

int main()
{
	int N, M, C;
	std::cin >> N >> M >> C;
	std::vector<int> B(M);
	for (int i = 0; i < M; i++) {
		std::cin >> B[i];
	}
	std::vector<int> A(M);
	int cnt =0;
	for (int i = 0; i < N; i++) {

		int sum = C;
		for (int j = 0; j < M; j++) {
			std::cin >> A[j];
			sum += B[j] * A[j];
		}
		if(sum > 0) cnt++;
	}
	std::cout << cnt;
	return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n, W; cin >> n >> W;
    ll w[n], v[n];
    rep(i,n) cin >> w[i] >> v[i];

    int max_v = 100100;

    ll dp[n+1][max_v];
    rep(i,n+1) rep(j,max_v) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i,n){
        rep(j,max_v){
            if(j-v[i]>=0) dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    int res = 0;
    for(int j=max_v-1; j>=0; j--){
        if(dp[n][j]<=W){
            res = j;
            break;
        }
    }
    

    cout << res << endl;
}

Measured memory_bytes: 82572
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
signed main() {
    ll n,m;
    string s,s2;
    while(true){
        cin>>s;
        if(s[0]=='-')break;
        cin>>n;
        rep(i,n){
          cin>>m;
          FOR(i,m,s.length()){
              s2+=s.at(i);
          }
          FOR(i,0,m){
              s2+=s.at(i);
          }
          s=s2;
          s2="";
        }
        cout<<s<<endl;
    }
}


Measured memory_bytes: 3148
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;in(k);
  out(a[k-1]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#AtCoder

import sys
import math
import itertools

A, B = map(int, input().split())

if A+B >= A-B:
	if A+B >= A*B:
		print(A+B)
	else:
		print(A*B)
else:
	if A-B >= A*B:
		print(A-B)
	else:
		print(A*B)


"""

"""


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys

line = input()
N, M = map(int, line.split())

from_to = {}
for i in range(M):
    line = input()
    line = line.rstrip()
    ai, bi = map(int, line.split())

    l = from_to.get(ai, list())
    l.append(bi)
    from_to[ai] = l

#print(from_to)

next_lands = from_to.get(1, list())
if not next_lands:
    print('IMPOSSIBLE')

for n in next_lands:
    goals = from_to.get(n, list())
    if N in goals:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 31724
s = input()
alphabets = [0] * 26
for i in range(len(s)):
  a = ord(s[i])
  alphabets[a-97] += 1
flag = True
for x in alphabets:
  if x % 2 != 0:
    flag = False
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9116
n=int(input())
h=list(map(int, input().split()))
ans=0
while max(h)!=0:
  l=0 
  for i, hi in enumerate(h):
    if hi==0 and l!=i:
      r=i
      n=min(h[l:r])
      h=[hi-n if i>=l and i<r else hi for i, hi in enumerate(h) ]
      ans+=n
      l=min(i+1,len(h)-1)

    elif hi==0 and l==i and i!=len(h)-1:
      l+=1

  else:
    r=i+1
    n=min(h[l:r])
    h=[hi-n if i>=l and i<=r else hi for i, hi in enumerate(h) ]
    ans+=n
    l=i+1

print(ans)

Measured memory_bytes: 3064
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int X;
    cin>>X;
    if(X>=400&&X<=599){
        cout<<8<<endl;
    }else if(X>=600&&X<=799){
        cout<<7<<endl;
    }else if(X>=800&&X<=999){
        cout<<6<<endl;
    }else if(X>=1000&&X<=1199){
        cout<<5<<endl;
    }else if(X>=1200&&X<=1399){
        cout<<4<<endl;
    }else if(X>=1400&&X<=1599){
        cout<<3<<endl;
    }else if(X>=1600&&X<=1799){
        cout<<2<<endl;
    }else if(X>=1800&&X<=1999){
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int A, B, C, D;

int main() {
    cin >> A >> B >> C >> D;
	int ret = max( min(B, D) - max(A, C), 0);
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) cin >> L[i];

    sort(L.begin(), L.end());
    ll ans = 0;
    REP(i, N) REP(j, i){
        auto iter1 = lower_bound(L.begin(), L.end(), abs(L[i] - L[j] + 1));
        auto iter2 = upper_bound(L.begin(), L.end(), L[i] +L[j] - 1);
        int tmp = 0;
        if (iter1 - L.begin() <= i && i < iter2 - L.begin()) tmp++;
        if (iter1 - L.begin() <= j && j < iter2 - L.begin()) tmp++;
        ans += iter2 - iter1 - tmp;
        //cout << to_string(i) + " " + to_string(j) + " :" << (iter1 - L.begin()) << " " << (iter2 - L.begin()) << " " << tmp << endl;
    }
    ans /= 3;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void Solve(int n){
  std::vector<int> key(n);
  for(int i=0;i<n;i++){
    cin>>key[i];
  }
  std::string s;
  cin>>s;
  std::string result;
  int key_itr=0;
  for(int i=0;i<s.size();i++){
    char target=s[i];
    for(int i=0;i<key[key_itr];i++){
      target--;
      if(target<'A'){
        target='z';
      }
      else if('Z'<target&&target<'a'){
        target='Z';
      }
    }
    result+=target;
    key_itr++;
    if(key_itr>=n){
      key_itr=0;
    }
  }
  cout<<result<<endl;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  while(1){
    int n;
    cin>>n;
    if(n==0){
      return 0;
    }else{
      Solve(n);
    }
  }


  return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=200010;
int n,a[N],d;
ll ans=0;
int main(){
	scanf("%d%d",&n,&d);
	ans=1ll*(n-1)*d;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),ans+=a[i];
	for(int i=2;i<=n;++i)a[i]=min(a[i-1]+d,a[i]);
	for(int i=n-1;i;--i)a[i]=min(a[i+1]+d,a[i]);
	for(int i=2;i<n;++i)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void){
  char n[200001];
  scanf("%s",n);
  int i=strlen(n);
  int s=0;
  for(int j=0;j<i;j++){
    s+=n[j]-48;
  }
  if(s%9==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 1808
import java.lang.Exception
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem169b(n, a))
}

fun problem169b(n: Int, a: List<Long>): Long {
    if(a.contains(0)) return 0
    var multi = 1L
    for (i in 0 until n) {
        try {
            multi = Math.multiplyExact(multi, a[i])
        } catch (e : Exception) {
            return -1
        }
    }
    return if (multi > 1000000000000000000L) -1 else multi.toLong()
}

Measured memory_bytes: 63268
N,M,C = map(int,input().split())
b = list(map(int,input().split()))
a = [input().split() for l in range(N)]
ai = C
count = 0
num = []
for i in range (N):
  for j in range (M):
    ai = ai + int(a[i][j])*b[j]
  num.append(ai)
  ai = C
for k in range (N):
  if num[k] > 0:
    count = count + 1
  else:
    count = count
    
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		int n, m;
		Scanner input = new Scanner(System.in);
		n = input.nextInt();
		m = input.nextInt();
		System.out.println(n*m + " " + 2*(n+m));
	}
}

Measured memory_bytes: 26232
#include<stdio.h>
#include<math.h>

typedef unsigned long long int INT;
int main()
{
	while(1)
	{
		int i,n;
		INT sum=0;
		if(1!=scanf("%d",&n))break;
		if(n<=0)break;
		for(i=0;i<n;++i){
			int t;
			scanf("%d",&t);
			sum+=t;
		}
		printf("%u\n",(int)floor(sum/(double)n));
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    for (int i = 0; i < 3000; i++){
        int x, y;
            cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        if (x < y)
            cout << x << " " << y << endl;
        else
            cout << y << " " << x << endl;
    }
}



Measured memory_bytes: 3088
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ct0=[0]*64
ct1=[0]*64
for i in range(n):
  x=format(a[i],'0'+str(64)+'b')
  for j in range(64):
    if x[j]=='0':
      ct0[j]+=1
    else:
      ct1[j]+=1
ct0.reverse()
ct1.reverse()
ans=0
for i in range(64):
  x=(ct0[i]*ct1[i])%mod
  ans+=x*(2**i)
  ans%=mod
print(ans)

Measured memory_bytes: 125624
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    nL = [i for i in range(1, n+1)]
    m = 0
    for a in nL:
        nL_1 = nL[a:]
        for b in nL_1:
            nL_2 = nL[b:]
            for c in nL_2:
                if a + b + c == x:
                    m += 1
    print(m)


Measured memory_bytes: 5600
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int[] x = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int ans = 0;
        for (int i = 0; i < x.Length; i++)
        {
            ans += Math.Min(x[i], k - x[i]);
        }
        Console.WriteLine(ans*2);
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, M;
  	scanf("%d",&N);
  		getchar();
  	scanf("%d",&M);
	  	getchar();
			
  if (N == M) {
    		printf("Yes");
  }
  else if (N > M) {
    	printf("No");
  }
 
  return 0;
}

Measured memory_bytes: 1712
n,k = map(int,input().split())
s = list(input())
if s[k-1] == "A":
         s[k-1] = "a"
elif s[k-1] == "B":
         s[k-1] = "b"
else:
         s[k-1] = "c"
answer = ''.join(s)
print(answer)


Measured memory_bytes: 3060
n = int(input())

k = len(str(n))
if k%2 == 0:
  count = 0
  for i in range(1,k,2):
    count += 10**i - 10**(i-1)
else:
  count = 0
  for i in range(1,k+1,2):
    count += 10**i - 10**(i-1)
  count -= 10**k-1-n
print(count)


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

int main() 
{ 
 ll n,k;
 cin>>n>>k;
 ll ans=0;
 for(int i=0;i<n;i++){ ll a; cin>>a; if(a>=k) ans++;}
 cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

using ll = long long;

ll N, M;
ll A[100010];

ll gcd(ll a, ll b)
{
    if (a < b) {
        b -= b / a * a;
    }
    
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

bool any_div2() {
    for (ll i = 0; i < N; i++) {
        if (A[i] % 2 == 0) return true;
    }
    return false;
}

bool all_div2() {
    for (ll i = 0; i < N; i++) {
        if (A[i] % 2 != 0) return false;
    }
    return true;
}

void div2() {
    for (ll i = 0; i < N; i++) {
        A[i] /= 2;
    }
}

int main() {
    cin >> N >> M;

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

    ll count2 = 0;

    while (all_div2()) {
        div2();
        count2++;
    }

    if (any_div2()) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 0; i < count2 - 1; i++) M /= 2;

    ll LCM = 1;

    for (int i = 0; i < N; i++) {
        LCM = lcm(LCM, A[i]);
        if (LCM > M) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (M / LCM + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 1024
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N =1e5 + 6;
void solve(){

	int k,a,b;
	cin>>k>>a>>b;
	ll val=a/k;
	val=val*k;
	if ( val==a||(val+k>=a&&val+k<=b))
		cout<<"OK\n";
	else
		cout<<"NG\n";


}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// 	freopen ("INPUT.txt" , "r" , stdin);
	// 	freopen ("OUTPUT.txt", "w" , stdout);
	// #endif	
    ll t=1;
	//cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

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

int main(void) {
  long N;
  cin >> N;

  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  long ans = 0;
  for (long t = 5; t <= N; t *= 5) {
    ans += (N / t) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    x,y=map(int,input().split())
    cnt=0
    while True:
        x*=2
        cnt+=1
        if x>y:
            break
    print(cnt)

    
resolve()

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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,c,L[100],ps[100],Cnt,Ans;
int F[310][40];
inline int solve()
{
	memset(F,0,sizeof F); F[n*L[n-1]][0]=1;
	for(int i=0;i<n*c;i++) for(int j=i;j<=n*c;j++)
		for(int k=0;k<(1<<(n-1));k++) if(i%n&&!((k>>ps[i%n-1])&1))
			F[min(c*n,max(j,i+n*L[ps[i%n-1]]))][k|(1<<ps[i%n-1])]+=F[j][k];
	return F[n*c][(1<<(n-1))-1];
}
signed main()
{
	n=read(); c=read();
	for(int i=0;i<n;i++) 
		L[i]=read(),ps[i]=i;
	sort(L,L+n);
	while(1)
	{
		Cnt++; Ans+=solve();
		if(!next_permutation(ps,ps+n-1))
			break;
	}
	for(int i=1;i<n;i++) Cnt*=c;
	printf("%.12Lf",(long double)1.0*Ans/(Cnt*1.0)); puts("");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define lint long long int

void solve()
{
    int n;cin >> n;
    lint umin = 1e18,umax = -1 * 1e18 , vmin = 1e18 , vmax = -1*1e18; 
    lint ret = LONG_LONG_MIN;
    for(int i=0;i<n;++i)
    {
        lint x,y;cin >> x >> y;
        lint u = x + y;
        lint v = x - y;

        ret = max(ret,u - umin);
        ret = max(ret,umax - u);
        ret = max(ret,v - vmin);
        ret = max(ret,vmax - v);

        umin = min(u,umin);
        umax = max(u,umax);
        vmin = min(v,vmin);
        vmax = max(v,vmax);
    }

    cout << ret << '\n';
}
 
signed main()
{
     int test_cases;test_cases=1;
     //cin >> test_cases;
     while(test_cases --> 0) solve();
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> p(n),q(n),a(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    rep(i,n) a[i] = i+1;
    int now = 0;
    int A,B;
    do {
        now++;
        if(a == p) A = now;
        if(a == q) B = now;
    } while(next_permutation(all(a)));
    cout << abs(A-B) << endl;
}

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

int main(){
  int N; cin >> N;
  vector<long long> A(N,0); 
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long long dp = 0;
  for (int i = 0; i < N-1; i++) {
    if (A.at(i) > A.at(i+1)){
      dp += A.at(i) - A.at(i+1);
      A.at(i+1) = A.at(i);
    }
  }
  cout << dp << endl;
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vec;

#define vecc vector<vector<ll>>
#define LM LLONG_MAX
 
#define ff first
#define ss second
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define M 1000020
#define MOD 1000000007

signed main()
{
        FAST;
        
        ll n,ball=0;
        cin>>n;
        
        vec a(n+1),b(n+1,0);
        
        for(int i=1;i<=n;i++)    cin>>a[i];
        
        for(int i=n;i>n/2;i--)   b[i]=a[i];
        
        for(int i=n/2;i>0;i--)
        {
                ll sum=0;
                for(int j=i;j<=n;j+=i)        sum+=b[j];
                sum+=a[i];
                sum%=2;
                if(sum==a[i])    b[i]=a[i];
                else             b[i]=1^a[i];
        }
        
        ball=0;
        for(int i=1;i<=n;i++)   ball+=b[i];
        
        cout<<ball<<endl;
        
        for(int i=1;i<=n;i++)
        {
                if(b[i])   cout<<i<<" ";
        }
        
}

Measured memory_bytes: 3968
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;

    vector<ll> v(n);
    for (auto &it: v) {
        cin >> it;
    }

    ll ans = 0;
    for (int i=1; i<n; i++) {
        ans += max(0LL, v[i-1]-v[i]);
        v[i] = max(v[i], v[i-1]);
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 4740
import sys
input = sys.stdin.readline
from collections import deque

INF = float('inf')


if __name__ == '__main__':
    K = int(input())
    q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

    if K < 10:
        print(K)
        exit()

    counter = 0
    while True:
        counter += 1
        x = q.popleft()
        amari = x % 10
        if counter != K:
            if amari == 0:
                q.append(x * 10 + amari)
                q.append(x * 10 + (amari + 1))
            elif amari == 9:
                q.append(x * 10 + (amari - 1))
                q.append(x * 10 + amari)
            else:
                q.append(x * 10 + (amari - 1))
                q.append(x * 10 + amari)
                q.append(x * 10 + (amari + 1))
        else:
            print(x)
            exit()


Measured memory_bytes: 40944
#include <bits/stdc++.h>
using namespace std;
long long n, h[100020], dp[100020];
long long fun(long long n)
{
    if (n <= 1)
        return 0;
    if (n == 2)
        return dp[n] = abs(h[2] - h[1]);
    if (dp[n] != -1)
        return dp[n];
    return dp[n] = min(fun(n - 1) + abs(h[n] - h[n - 1]), fun(n - 2) + abs(h[n] - h[n - 2]));
}
int main()
{
    long long x, y, z, i, j;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for (x = 1; x <= n; x++)
        cin >> h[x];
    long long ans = fun(n);
    cout << ans << endl;
}

Measured memory_bytes: 3328
//建立26棵线段树进行操作,统计不同的数量区间不同字符的数量
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn=5e5+5;
typedef long long ll;
char str[maxn];
struct node{
    int l,r;
    int num;
}tree[28][maxn<<2];
void pushup(int i,int m){
     tree[i][m].num=(tree[i][m<<1].num+tree[i][m<<1|1].num);
     return ;
}
void build(int m,int l,int r,int i){
     tree[i][m].l=l;
     tree[i][m].r=r;
     tree[i][m].num=0;
     if(l==r){
        return ;
     }
     int mid=(l+r)>>1;
     build(m<<1,l,mid,i);
     build(m<<1|1,mid+1,r,i);
     pushup(i,m);
}
void update(int m,int pos,int val,int i){
     if(tree[i][m].l==tree[i][m].r&&tree[i][m].r==pos){
         tree[i][m].num=val;
         return ;
     }
     int mid=(tree[i][m].l+tree[i][m].r)>>1;
     if(pos<=mid){
         update(m<<1,pos,val,i);
     }
     else{
         update(m<<1|1,pos,val,i);
     }
     pushup(i,m);
}
int query(int m,int l,int r,int i){
    if(tree[i][m].l==l&&tree[i][m].r==r){
        return tree[i][m].num;
    }
    int mid=(tree[i][m].l+tree[i][m].r)>>1;
    if(r<=mid){
        return query(m<<1,l,r,i);
    }
    else if(l>mid){
        return query(m<<1|1,l,r,i);
    }
    else{
        return query(m<<1,l,mid,i)+query(m<<1|1,mid+1,r,i);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",str+1);
    int len=strlen(str+1);
    for(int t=1;t<=26;t++){
        build(1,1,len,t);
    }
    for(int t=1;t<=len;t++){
        update(1,t,1,str[t]-'a'+1);
    }
    int q;
    scanf("%d",&q);
    int op;
    char tmp[2];
    int pos,l,r;
    while(q--){
         scanf("%d",&op);
         if(op==1){
             scanf("%d%s",&pos,tmp);
             update(1,pos,0,str[pos]-'a'+1);
             update(1,pos,1,tmp[0]-'a'+1);
             str[pos]=tmp[0];
         }
         else{
             scanf("%d%d",&l,&r);
             int ans=0;
             for(int t=1;t<=26;t++){
               // cout<<tmp1<<" "<<query(1,l,r,t)<<endl;
                if(query(1,l,r,t)>0){
                   ans++;
                }
               
             }
             printf("%d\n",ans);
         }
    }
    return 0;
}

Measured memory_bytes: 373504
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int K, A, B;
  cin >> K >> A >> B;

  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3084
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

n, k = map(int, input().split())
cnt = [0] * (k + 1)
for i in range(1, k+1):
    cnt[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):
    div = divisors(i)
    base = cnt[i]
    for d in div[1:]:
        cnt[d] -= base
ans = 0
for i, item in enumerate(cnt):
    ans += i * item
    ans %= MOD
print(ans)

Measured memory_bytes: 70176
import sys

# import numba as nb
import numpy as np

input = sys.stdin.readline


# @nb.njit("i8(i8[:],i8,i8)", cache=True)
def solve(N, K, L):
    dp = np.zeros(shape=(L + 1, 2, K + 1), dtype=np.int64)
    dp[0][0][0] = 1
    for i in range(L):
        D = N[i]
        for j in range(2):
            d_max = 9 if j == 1 else D
            for k in range(K + 1):
                if k < K:
                    for d in range(d_max + 1):
                        dp[i + 1][int(j or (d < D))][k + int(d > 0)] += dp[i][j][k]
                else:
                    dp[i + 1][j][k] += dp[i][j][k]

    return dp[L][0][K] + dp[L][1][K]


def main():
    N = np.array(list(input().rstrip()), dtype=np.int64)
    K = int(input())

    L = N.shape[0]
    ans = solve(N, K, L)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi vec(n);
    cin>>vec;
    multiset<int> se;
    REP(i,n){
        auto itr=se.lower_bound(vec[i]);
        if(itr==se.begin()){
            se.insert(vec[i]);
        }else{
            se.erase(--itr);
            se.insert(vec[i]);
        }
    }
    cout<<se.size()<<endl;
    return 0;
}

Measured memory_bytes: 5376
from operator import itemgetter
N = int(input())
A = [None] * N
for i in range(N):
  A[i] = list(map(int,input().split()))

s = sorted(A, key=itemgetter(0),reverse=True)
t = sorted(s, key=itemgetter(1))

time = 0
for i in range(N):
  if t[i][0] + time <= t[i][1]:
    time += t[i][0]
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 56644
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
    cout<<nl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

ans = make_divisors(N)
ans.sort()


while len(ans)>2:
    ans = ans[1:-1]
if len(ans)==1:
    n = ans[0]
    print((n-1)*2)
else:
    a = ans[0]
    b = ans[1]
    print(a+b-2)


Measured memory_bytes: 3296
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, m, s;
vector<edge> G[200005];
llint dist[200005];

void dijkstra(vector<edge> G[], llint S, llint dist[])
{
	for(int i = 0; i < 200005; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

llint get(llint v, llint c)
{
	return v * 2600 + c;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> s;
	s = min(s, 2500LL);
	
	llint u, v, a, b;
	for(int i = 1; i <= m; i++){
		cin >> u >> v >> a >> b;
		for(int j = 2500; j >= a; j--){
			G[get(u, j)].push_back(edge(get(v, j-a), b));
			G[get(v, j)].push_back(edge(get(u, j-a), b));
		}
	}
	llint c, d;
	for(int i = 1; i <= n; i++){
		cin >> c >> d;
		for(int j = 0; j <= 2500; j++){
			G[get(i, j)].push_back(edge(get(i, min(j+c, 2500LL)), d));
		}
	}
	dijkstra(G, get(1, s), dist);
	
	for(int i = 2; i <= n; i++){
		llint ans = inf;
		for(int j = 0; j <= 2500; j++) ans = min(ans, dist[get(i, j)]);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 26116
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
if a[0][0]==0 and a[0][1]==0 and a[0][2]==0:
    f=True
elif a[1][0]==0 and a[1][1]==0 and a[1][2]==0:
    f= True
elif a[2][0]==0 and a[2][1]==0  and a[2][2]==0:
    f= True
elif a[0][0]==0 and a[1][0]==0 and a[2][0]==0:
    f= True
elif a[0][1]==0 and a[1][1]==0 and a[2][1]==0:
    f= True
elif a[0][2]==0 and a[1][2]==0 and a[2][2]==0:
    f= True
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    f= True
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    f= True
else:
    f= False

if f == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
// AOJ 0224: Bicycle Diet
// 2017.10.27 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 0x77777777
int c[7];
int g[110][110], a[110][64];
int m, N;

int id(char *s)
{
	if (*s == 'H') return 0;
	if (*s == 'D') return N-1;
	if (*s == 'C') return atoi(s+1);
	return atoi(s+1) + m;
}

int bellman()
{
	int i, j, u, v, chg, lim, ans;

	memset(a, INF, sizeof(a));
	a[0][0] = 0;
	lim = 1 << m;
	for (i = 0; i < N*lim; i++) {
		chg = 0;
		for (u = 0; u < N; u++) for (v = 0; v < N; v++) {
			if (u == v || g[u][v] == INF) continue;
			for (j = 0; j < lim; j++) {
				if (1 <= v && v <= m && (j & (1<<(v-1)))) continue;
				if (1 <= v && v <= m) {
					if (a[u][j] + g[u][v] - c[v] < a[v][j|(1<<(v-1))]) {
						a[v][j|(1<<(v-1))] = a[u][j] + g[u][v] - c[v];
						chg = 1;
					}
				} else {
					if (a[u][j] + g[u][v] < a[v][j]) {
						a[v][j] = a[u][j] + g[u][v];
						chg = 1;
					}
				}
			}
		}
		if (!chg) break;
	}
	ans = INF;
	for (i = 0; i < lim; i++) if (a[N-1][i] < ans) ans = a[N-1][i];
	return ans;
}

int main()
{
	int n, k, d, i;

	while (scanf("%d%d%d%d", &m, &n, &k, &d) && m > 0) {
		N = 2 + m + n;
		for (i = 1; i <= m; i++) scanf("%d", c+i);
		memset(g, INF, sizeof(g));

		for (i = 0; i < d; i++) {
			char b1[10], b2[10]; int s, t, e;
			scanf("%s%s%d", b1, b2, &e);
			s = id(b1), t = id(b2);
			if (k * e < g[s][t]) g[s][t] = g[t][s] = k * e;
		}
		printf("%d\n", bellman());
	}
	return 0;
}

Measured memory_bytes: 1796
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<map>
#include<iostream>
#include<stack>
using namespace std;
const int N = 1e5+10;
char num[N];
int main()
{
	scanf("%s",num);
	int len = strlen(num);
	int ans = len;
	for(int i=1;i<len;++i)
		if(num[i] != num[i-1])
			ans = min(ans,max(i,len-i));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<(N); i++)
typedef long long ll;
const ll mod=1e9+7;

ll N;
ll A[100005];
ll a[100005],b[100005];
ll ans;

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

rep(i,N){
	cin>>A[i];
}
ans++;
ll n=0;
//a[n]=A[0]; 
b[n]=-A[0];
n++;

rep(i,N){
	if(i==0) continue;
	ll in=upper_bound(b,b+n,-A[i])-b;
	if(in==0){
		//a[in]=A[i];
		b[in]=-A[i]; 
	}else if(in==n){
		//a[in]=A[i]; 
		b[in]=-A[i];
		ans++;
		n++;
	}
	else{
		//a[in+1]=A[i];
		b[in]=-A[i];
	}
}

cout<<ans<<endl;

}


Measured memory_bytes: 1792
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut x: i64,
        mut k: i64,
        d: i64,
    };
    if x < 0 {
        x *= -1;
    };
    let alpha = x / d;
    // let beta = x % d;
    let beta = x - alpha * d;
    println!(
        "{}",
        if k <= alpha {
            x - k * d
        } else {
            if (k - alpha) % 2 == 0 {
                beta
            } else {
                d - beta
            }
        }
    )
}


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

int main() {
  int N = 3;
  vector<vector<int>> c(N, vector<int>(N));
  vector<int> b(N);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> c.at(i).at(j);
      if (i == 0) b.at(j) = c.at(i).at(j);
    }
  }

  for (int i = 0; i < N; i++) {
    int a = 0;
    for (int j = 0; j < N; j++) {
      int num_diff = b.at(j) - c.at(i).at(j);
      if (j == 0) {
        a = num_diff;
      } else if (a != num_diff) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    f(i,0,n-1)
      cin>>a[i];
      
    sort(a,a+n);
    cout<<abs(a[0]-a[n-1]);
} 


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		long sum = 0;
		
		for(int i = 1; i <= n; i++) {
			if(i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

#define nax 100009
#define FOR(i,n,m) for(ll i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
#define sz(v) int(v.size())
#define all(v) v.begin() , v.end()

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int main(){
	long long n; cin>>n;

	cout<<n*(n-1)/2;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String s1 = s.replaceAll(s.substring(0,1), "");
		String s2;
		if(s1.length() != 0) {
			s2 = s1.replaceAll(s1.substring(0, 1), "");
		}else {
			s2 = "AAAAA";
		}
		
		if(s1.length() == 2 && s2.length() ==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
				
		sc.close();	
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
int main()
{
  int a,b,i,j,n,k,x[500][500]; 
  scanf("%d",&k); 
  for(i=0;i<k;i++){
    scanf("%d%d",&a,&n);
    for(j=0;j<n;j++){
      scanf("%d",&b);
      x[a][b]=1;
    }
  }
  for(i=1;i<=k;i++){
    for(j=1;j<=k;j++){
      printf("%d",x[i][j]);
      if(j!=k) printf(" ");
    }
    printf("\n");
  }     
  return 0;
}

Measured memory_bytes: 804
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<bitset>
#include<map>
#include<algorithm>
using namespace std ;
#define ll  long long int 
int main(){
    ll a , b ; 
    cin >> a >> b ;
    if (a > b)
    {
        cout << "safe" << endl ;

    }
    else
    {
        cout << "unsafe" << endl ;
    }
    
    
    return 0 ; 
} 


Measured memory_bytes: 3636