akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
    int ans = 1000000000;
    
	int n, k;
	std::cin >> n >> k;
	
	int h[n];
	for (int i = 0; i < n; i++) {
	    std::cin >> h[i];
    }
    sort(h, h+n);
    
    for (int i = 0; i < n - k + 1; i++) {
        ans = min(ans, h[i + (k - 1)] - h[i]);
        //std::cout << "h[" << i << "]= " << h[i + (k - 1)] - h[i] << std::endl;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
using namespace std;
int main(){
    boost;
    ll a,b;
    ll c,d;
    ll f,g,h;
    cin>>a>>b>>c>>d;
    f=((b)/(c))-(((a-1)/(c)));
    //f/=2*c;

    g=((b)/(d))-(((a-1)/(d)));
    //g/=2*d;
    ll j=__gcd(c,d);
    j=(c*d)/j;
    h=((b)/(j))-(((a-1)/(j)));
    //h/=c*d;
    //debug(f<<" "<<g<<" "<<h);

    //debug(g);
    ll ans=b-a+1-f-g+h;
    cout<<ans;


    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

using namespace std;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, a[300000], dp[300000], k;
	cin >> n >> k;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	dp[0] = 0;
	for (int i=1; i<n; ++i) {
		dp[i] = 1e16;
		for (int j=1; j<=k && (i-j)>=0; ++j)
			dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 4864
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int W, H, N; cin >> W >> H >> N;

    int x_left = 0, x_right = W, y_top = H, y_bottom = 0;
    for (int i = 0; i < N; i++) {
        int x, y, a; cin >> x >> y >> a;
        if (a == 1) {
            x_left = max(x_left, x);
        } else if (a == 2) {
            x_right = min(x_right, x);
        } else if (a == 3) {
            y_bottom = max(y_bottom, y);
        } else if (a == 4) {
            y_top = min(y_top, y);
        }
    }

    
    cout << ((x_right-x_left < 0 || y_top-y_bottom < 0) ? 0 : (x_right-x_left)*(y_top-y_bottom)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <limits>
#include <stdlib.h> 
using namespace std;
 
int main(){
    string S;
    cin>>S;
    string t[4]={"dream","dreamer","erase","eraser"};

    reverse(S.begin(),S.end());
    for(int i=0;i<4;i++)reverse(t[i].begin(),t[i].end());

    bool can=true;
    for(int i=0;i<S.size();){
        bool can2=false;
        for(int j=0;j<4;j++){
            string d=t[j];
            if(S.substr(i,d.size())==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=false;
            break;
        }
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
}
    
    


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {

	int n, x;
	cin >> n >> x;
	vint a(n);
	vcin(a, n);
	sort(a);
	int cnt = 0;
	rep(i, n) {
		if (i == n - 1 && x != a[i]) {
			break;
		}
		if (x >= a[i]) {
			cnt++;
			x -= a[i];
		}
		else {
			cout << cnt << rt;
			return 0;
		}
	}
	cout << cnt << rt;

	please AC;
}
//参考：---;

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


signed main(){
	int q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;

	int multi = min({8 * q, 4 * h, 2 * s, d});
	int mono = min({4 * q, 2 * h, s});

	cout << (n % 2 ? n / 2 * multi + mono : n / 2 * multi) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdlib>
#include<cstring>

#define M 1000003 /* your task*/ // データの総数より大きい最小の素数
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
    if ( ch == 'A') return 1;
    else if ( ch == 'C') return 2;
    else if ( ch == 'G') return 3;
    else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    //printf("getKeyfunc\n"); //
    for ( i = 0; i < strlen(str); i++ ){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){
    return key % M;
}

int h2(int key){
    return 1 + key % M-1;
}

int find(char str[]){
    /* your task */
    int i,h;
    //printf("findfunc\n"); //
    for (i = 0; i < M; i++) {
         h = ( h1(getKey(str)) + i * h2(getKey(str)) ) % M; // ハッシュ値計算
        if(H[h][0] == '\0'){
            return 0;
        }else if(strcmp(H[h], str) == 0){
            return 1;
        }
    }
    
    return 0;
}

int insert(char str[]){
    /* your task */
    int i, h;
    //printf("insertfunc\n"); //
    for(i = 0; i < M; i++){
        h = ( h1(getKey(str)) + i * h2(getKey(str)) ) % M; // ハッシュ値計算
        //printf("i:%d h:%d\n",i,h); //
        if(H[h][0] == '\0'){
            strcpy(H[h], str);
            return 1;
        }
    }
    
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
#ifdef D
    scanf("%s",str);
    printf("key:%lld \n",getKey(str));
#else
    
    for ( i = 0; i < n; i++ ){
        scanf("%s %s", com, str);
        
        if ( com[0] == 'i' ){
            insert(str);
        } else {
            if (find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
        
    }
    
#endif
    
    return 0;
}



Measured memory_bytes: 16356
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	string s;
	cin >> s;
	if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string t;
    cin >> t;
    for (int i = 0;i < 19;i++)
    {
        if (t[i] == ',')
        {
            t[i] = ' ';
        }
    }
cout <<t<<endl;

    return 0;
}




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

using namespace std;

int main() {
  long long n,i,l=0,j;cin>>n;long long  a[n];j=0;
  for(i=0;i<n;i++)
  {
      cin>>a[i];
      if(i)
      {
         if(a[i]<=a[i-1])j++;
         else j=0;
         if(l<j)l=j;
      }
     
  }
  cout<<l;
  
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int n,A[4][13];
	int I,j,k;
	char i;

	for(I=0; I<4; I++)	for(j=0; j<14; j++) A[I][j]=0;

	scanf("%d",&n);
	for(k=0; k<n; k++) {
		scanf(" %c %d",&i,&j);
		if(i=='S')I=0; if(i=='H')I=1; if(i=='C')I=2; if(i=='D')I=3; A[I][j-1]=1;
	}

	for(I=0; I<4; I++)	for(j=0; j<13; j++) {
		if(I==0)i='S'; if(I==1)i='H'; if(I==2)i='C'; if(I==3)i='D'; if(A[I][j]==0) printf("%c %d\n",i,j+1);
	}

	return 0;
}

Measured memory_bytes: 596
import numpy as np
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
A=np.array(A)

n=int(input())
for i in range(n):
    b=int(input())
    if b in A:
        A=np.where(A==b,0,A)
cross=0
if A[0][0]+A[1][1]+A[2][2]==0 or A[2][0]+A[1][1]+A[0][2]==0:
    cross=1
print("NYoe s"[0 in np.sum(A,axis=0) or 0 in np.sum(A,axis=1) or cross ::2])

Measured memory_bytes: 27004
package main

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

func main() {
	_, M := ReadInt(), ReadInt()
	cities := make([]*City, M)
	prefectures := make(map[int][]*City)
	for i := 0; i < M; i++ {
		p, y := ReadInt(), ReadInt()
		city := &City{
			index:      i,
			year:       y,
			prefecture: p,
		}
		cities[i] = city
		prefectures[p] = append(prefectures[p], city)
	}

	for _, vals := range prefectures {
		sort.Slice(vals, func(i, j int) bool {
			return vals[i].year < vals[j].year
		})
		for i, val := range vals {
			val.rank = i + 1
		}
	}

	for i := 0; i < M; i++ {
		fmt.Printf("%06d%06d\n", cities[i].prefecture, cities[i].rank)
	}
}

type City struct {
	index      int
	prefecture int
	year       int
	rank       int
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 21876
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;

  if(k % 2 == 0) cout << a - b << endl;
  else cout << b - a << endl;
  return 0;
}


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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
		string ans = "NO";
		if (p[1] - p[0] == p[2] - p[1]) { ans = "YES"; }
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13268
n = int(input())
a = [int(i) for i in input().split()]
ans = [a[i] if (i % 2 == 0) else -1 * a[i] for i in range(n)]
b = []
ans0 = sum([a[i] if (i % 2 == 0) else -1 * a[i] for i in range(n)])
b.append(str(ans0))
temp = int(ans0 // 2)
for i in range(0, n-1):
    k = a[i] - temp
    b.append(str(k*2))
    temp = k
print(' '.join(b))

Measured memory_bytes: 19680
S = input()
if S.count("S") >= 1 and S.count("W") >= 1 and S.count("E") >= 1 and S.count("N") >= 1:
  print("Yes")
elif S.count("S") >= 1 and S.count("W") == 0 and S.count("E") == 0 and S.count("N") >= 1:
  print("Yes")
elif S.count("S") == 0 and S.count("W") >= 1 and S.count("E") >= 1 and S.count("N") == 0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9124
def main(): 
    
    switch_cnt,bulb_cnt = map(int, input().split())

    k = [list(map(int, input().split())) for _ in range(bulb_cnt)]

    p = list(map(int, input().split()))

    cnt = 0
    for i in range(2 ** switch_cnt):

        switch_status = [False for _ in range(switch_cnt)]

        j = 0
        while i > 0b0:
            if i & 0b1 == 0b1:
                switch_status[j] = True
            i = i >> 1
            j += 1

        for ki in range(len(k)):
            on_count = 0
            for kj in range(1,len(k[ki])):
                switch_no = k[ki][kj] - 1
                if switch_status[switch_no]:
                    on_count += 1
            if on_count % 2 != p[ki]:
                break
        else:
            cnt += 1
    print(cnt)          


if __name__ == "__main__":
    main() 

Measured memory_bytes: 3064
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    size_t four, two, other;
    four = two = other = 0;

    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        if (t % 4 == 0) {
            four++;
        }
        else if (t % 2 == 0) {
            two++;
        }
        else {
            other++;
        }
    }

    if (two == 0) {
        if (four + 1 >= other) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    else {
        other ++;
        if (four + 1 >= other) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    int N;
    cin>>N;
    vector<tuple<ll, ll, int> > arr1, arr2;
    ll x, y;
    for(int i=0;i<N;++i){
        cin>>x>>y;
        arr1.push_back(make_tuple(x, y, i));
        arr2.push_back(make_tuple(y, x, i));
    }
    sort(arr1.begin(), arr1.end());
    sort(arr2.begin(), arr2.end());
    vector<vector<pair<int, ll> > > edge(N);
    int town1, town2;
    ll x1, y1, x2, y2;
    for(int i=1;i<N;++i){
        town1 = get<2>(arr1[i]);
        town2 = get<2>(arr1[i-1]);
        x1 = get<0>(arr1[i]);
        x2 = get<0>(arr1[i-1]);
        edge[town1].push_back(make_pair(town2, x1-x2));
        edge[town2].push_back(make_pair(town1, x1-x2));
        
        town1 = get<2>(arr2[i]);
        town2 = get<2>(arr2[i-1]);
        y1 = get<0>(arr2[i]);
        y2 = get<0>(arr2[i-1]);
        edge[town1].push_back(make_pair(town2, y1-y2));
        edge[town2].push_back(make_pair(town1, y1-y2));
    }

    priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > que;
    que.push(make_pair(0, 0));

    ll DP[N];
    for(int i=0;i<N;++i){
        DP[i] = -1;
    }

    pair<ll, int> state;
    int town;
    ll cost;
    while(!que.empty()){
        state = que.top();que.pop();
        town = state.se;
        cost = state.fi;
        if(DP[town] != -1) continue;
        DP[town] = cost;
        for(int i=0;i<edge[town].size();++i){
            if(DP[edge[town][i].fi] != -1) continue;
            que.push(make_pair(edge[town][i].se, edge[town][i].fi));
        }
    }
    ll ans = 0;
    for(int i=0;i<N;++i){
        ans += DP[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 20900
n, w = map(int, input().split())
W, V = [], []
sum_v = 0
for i in range(n):
  wi, vi = map(int ,input().split())
  W.append(wi)
  V.append(vi)
  sum_v += vi

memo = [[10**9] * (sum_v + 1) for _ in range(n+1)]
memo[0][0] = 0

for i in range(n):
  for v_i in range(sum_v + 1):
    memo[i+1][v_i] = min(memo[i+1][v_i], memo[i][v_i])
    if v_i - V[i] >= 0:
      memo[i+1][v_i] = min(memo[i+1][v_i], memo[i][v_i-V[i]] + W[i])

ans = 0
for i in range(sum_v + 1):
  if memo[-1][i] <= w:
    ans = i
print(ans)

Measured memory_bytes: 152120
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={default_val and {__index=function()return default_val end}}for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local N, W = read.nn()
local w, v = {}, {}
for i=1,N do
    w[i], v[i] = read.nn()
end
local tbl = array(2, 10^10)
tbl[0][0] = 0
for i=0,N-1 do
    local nw, nv = w[i+1], v[i+1]
    for j=0,100000 do
        if tbl[i+1][j] > tbl[i][j] then
            tbl[i+1][j] = tbl[i][j]
        end
        if tbl[i+1][j+nv] > tbl[i][j] + nw then
            tbl[i+1][j+nv] = tbl[i][j] + nw
        end
    end
end
local ans = 0
for j=0,100000 do
    if tbl[N][j] <= W then
        ans = math.max(ans, j)
    end
end
print(ans)

Measured memory_bytes: 45848
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=1800000;

inline unsigned long xor128() {
	static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
	unsigned long t=(x^(x<<11));
	x=y; y=z; z=w;
	return (w=((w>>19)^t^(t>>8)));
}

int D,c[26],s[200000][26],t[200000],T[200000];
set<int>st[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		pair<int,int>mx={-1,-1};
		for(int j=0;j<26;j++){
			mx=max(mx,{s[i][j],j});
		}
		t[i]=mx.second;
		st[mx.second].insert(i);
	}
	for(int i=0;i<26;i++){
		st[i].insert(-1);
		st[i].insert(D);
	}
	for(int i=0;i<N;i++){
		int K=xor128()%D;
		pair<int,int>mx={-100000000,-1};
		auto it1=st[t[K]].find(K);
		auto it2=it1;
		it1--;
		auto it3=it2;
		it3++;
		int a=c[t[K]]*((*it3-*it1)*(*it3-*it1-1)/2-(*it3-*it2)*(*it3-*it2-1)/2-(*it2-*it1)*(*it2-*it1-1)/2);
		for(int j=0;j<26;j++){
			if(j==t[K])continue;
			auto it=st[j].lower_bound(K);
			auto jt=it;
			jt--;
			mx=max(mx,{s[K][j]-s[K][t[K]]+c[j]*((*it-*jt)*(*it-*jt-1)/2-(*it-K)*(*it-K-1)/2-(K-*jt)*(K-*jt-1)/2)-a,j});
		}
		if(mx.first>=0){
			st[t[K]].erase(it2);
			t[K]=mx.second;
			st[mx.second].insert(K);
		}
		else if(mx.first>=-(N-i)/300){
			st[t[K]].erase(it2);
			t[K]=mx.second;
			st[mx.second].insert(K);
		}
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void rotate(string grid[6], int x[8], int y[8]){
  string tmp[6];
  REP(i, 6) tmp[i] = grid[i];
  REP(i, 8) grid[y[i]][x[i]] = tmp[y[(i + 6) % 8]][x[(i + 6) % 8]];
}
void rotate2(string grid[6], int x[4], int y[4]){
  string tmp[6];
  REP(i, 6) tmp[i] = grid[i];
  REP(i, 4) grid[y[i]][x[i]] = tmp[y[(i + 3) % 4]][x[(i + 3) % 4]];
}

int main(){
  string s;
  while(cin >> s){
    string grid[6] = {
      "..rr....",
      "..rr....",
      "ggyybbww",
      "ggyybbww",
      "..oo....",
      "..oo...."
    };
    REP(i, s.size()){
      int bx, by;
      if(s[i] == 'R'){
        bx = 4, by = 2;
        int x[] = {6, 6, 3, 3, 3, 3, 3, 3};
        int y[] = {2, 3, 5, 4, 3, 2, 1, 0};
        rotate(grid, x, y);
      }
      if(s[i] == 'U'){
        bx = 2, by = 0;
        int x[] = {7, 6, 5, 4, 3, 2, 1, 0};
        int y[] = {2, 2, 2, 2, 2, 2, 2, 2};
        rotate(grid, x, y);
      }
      if(s[i] == 'L'){
        bx = 0, by = 2;
        int x[] = {2, 2, 2, 2, 2, 2, 7, 7};
        int y[] = {0, 1, 2, 3, 4, 5, 3, 2};
        rotate(grid, x, y);
      }
      if(s[i] == 'B'){
        bx = 6, by = 2;
        int x[] = {0, 0, 2, 3, 5, 5, 3, 2};
        int y[] = {2, 3, 5, 5, 3, 2, 0, 0};
        rotate(grid, x, y);
      }
      if(s[i] == 'F'){
        bx = 2, by = 2;
        int x[] = {1, 1, 2, 3, 4, 4, 3, 2};
        int y[] = {3, 2, 1, 1, 2, 3, 4, 4};
        rotate(grid, x, y);
      }
      if(s[i] == 'D'){
        bx = 2, by = 4;
        int x[] = {0, 1, 2, 3, 4, 5, 6, 7};
        int y[] = {3, 3, 3, 3, 3, 3, 3, 3};
        rotate(grid, x, y);
      }
      int x2[4], y2[4];
      int dx[4] = {0, 1, 1, 0};
      int dy[4] = {0, 0, 1, 1};
      REP(i, 4) x2[i] = bx + dx[i];
      REP(i, 4) y2[i] = by + dy[i];
      rotate2(grid, x2, y2);
    }
      REP(i, 6) cout << grid[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int WW[200];
ll V[200];
ll DP[200][100100];

int main(){
    int N, W;
    cin >> N >> W;
    REP(i,N){
        int w;
        ll v;
        cin >> w >> v;
        WW[i] = w;
        V[i] = v;
    }

    for(int j = 0; j <= W; j++){
        if(j - WW[0] < 0) continue;
        DP[0][j] = V[0];
    }

    for(int i = 1; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j - WW[i] < 0) DP[i][j] = DP[i-1][j];
            else DP[i][j] = max(DP[i-1][j-WW[i]] + V[i], DP[i-1][j]);
        }
    }

    //for(int i = 0; i < N; i++){
    //    for(int j = 0; j <= W; j++){
    //        printf("%lld ", DP[i][j]);
    //    }
    //    printf("\n");
    //}

    ll ans = 0;
    REP(i,W+1){
        ans = max(ans, DP[N-1][i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(void) {
    vector<long long> cookie(2);
    int K;
    cin >> cookie[0] >> cookie[1] >> K;
    for (int i = 0; i < K; i++) {
        if (cookie[i % 2] % 2 == 1) {
            cookie[i % 2] -= 1;
        }
        cookie[(i + 1) % 2] += cookie[i % 2] / 2;
        cookie[i % 2] /= 2;
    }
    cout << cookie[0] << " " << cookie[1] << endl;
    return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int a,b;
	cin >> a >> b;
	if(a <= 9 && b <= 9){
		cout << a*b << endl;
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int k ,a , b;
	cin >> k >> a >> b;
	bool ok = false;
	for(int i = a ; i <= b ; i++)
		if(i%k==0)
			ok = true;
	ok?cout<<"OK":cout<<"NG";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

		String n = sc.next();
		
		StringBuilder sb = new StringBuilder(n);
		
		for(int i = 0; i < n.length(); i++) {
			sb.setCharAt(i, n.charAt(i) == '1' ? '9' : '1');
		}
		
		System.out.println(sb.toString());
	}
}


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

int main(){
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)&&s.at(1)!=s.at(2)&&s.at(2)==s.at(3)){
    cout<<"Yes"<<endl;
  }else if(s.at(0)!=s.at(1)&&s.at(1)==s.at(2)&&s.at(0)==s.at(3)){
    cout<<"Yes"<<endl;
  }else if(s.at(0)==s.at(1)&&s.at(1)!=s.at(2)&&s.at(2)==s.at(3)){
    cout<<"Yes"<<endl;
  }else if(s.at(0)==s.at(2)&&s.at(1)!=s.at(0)&&s.at(1)==s.at(3)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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


int main(){
  int N,ans = 0;

  cin >> N;


  int cnt = 0;
  while(true){
    cnt = 0;
    ++ans;
    for(int i=1;i<=ans;++i){
      if(ans % i == 0){
	++cnt;
      }
    }
    if(cnt == N) break;
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 3092
//
// Created by yuu on 2019-04-29.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int A,B,K;

    cin>>A>>B>>K;

    if(A<B){
        swap(A,B);
    }


    vector<int> div;
    for (int i = 1; i <=B; ++i) {
        if(A%i==0 && B%i==0){
            div.push_back(i);
        }
    }


    cout<<div[div.size()-K]<<endl;
    return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  input = input.trim().split('\n')
  const nums = input[1].split(' ').map(Number)

  let ans = 0

  for (let i=0; i<nums.length-1; i++) {
    if (nums[i] > nums[i+1]) {
      ans += nums[i] - nums[i+1]
      nums[i+1] = nums[i]
    }
  }

  return console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 50512
def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    return a * b // gcd(a, b)

try:
 while True:
  a, b = map(int, raw_input().split(' '))
  print gcd(a, b), lcm(a, b)
except EOFError:
  pass

Measured memory_bytes: 6328
import operator
class SegmentTree:
    def __init__(self, size, default, op = operator.add):
        self.size = 2**size.bit_length()
        self.dat = [default]*(self.size*2)
        self.op = op

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.op(self.dat[i*2], self.dat[i*2+1])

    def add(self, i, x):
        i += self.size
        self.dat[i] = self.op(self.dat[i], x)
        while i > 0:
            i >>= 1
            self.dat[i] = self.op(self.dat[i], x)

    def get(self, a, b = None):
        if b is None:
            b = a + 1
        l, r = a + self.size, b + self.size
        res = None
        while l < r:
            if l & 1:
                if res is None:
                    res = self.dat[l]
                else:
                    res = self.op(res, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                if res is None:
                    res = self.dat[r]
                else:
                    res = self.op(res, self.dat[r])
            l >>= 1
            r >>= 1

        return res

def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    return gcd(b%a, a)

n = int(input())
a = list(map(int, input().split()))
seg = SegmentTree(n,0,gcd)
for i in range(n):
    seg.update(i,a[i])
ans = 1
for i in range(n):
    seg.update(i,0)
    ans = max(ans, seg.get(0,n))
    seg.update(i,a[i])
print(ans)


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

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

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double r = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    printf("%6f\n" , r);
    return 0;
}

Measured memory_bytes: 1236
def cal(d, i, k, total):
  if i == len(d):
    return total + int(k)
  return cal(d, i+1, d[i], total + int(k)) + cal(d, i+1, k + d[i], total)

d = [x for x in input()]
print(cal(d, 1, d[0], 0))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{int a,b,c;
while(cin>>a>>b>>c)
{
if((a==b&&a!=c)||(b==c&&a!=b)||(a==c&&b!=a))
printf("Yes\n");
else if(a==b&&b==c&&a==c)
printf("No\n");
else if(a!=b&&b!=c&&a!=c)
printf("No\n");}
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x)  (x).begin(),(x).end()

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
    }

    bool f = true;
    rep(i, n) {
        if(v[i] % 2 == 0){
            if(v[i] % 3 == 0 || v[i] % 5 == 0){
            }else{
                f = false;
            }
        }
    }

    cout << (f ? "APPROVED" : "DENIED") << endl;

    return 0;
}


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


n,m,x = mi()
C = [[] for _ in range(n)]

for i in range(n):
    c = li()
    for l in range(m+1):
        C[i].append(c[l])


anss = 10**9
for i in range(1<<n):
    alis = [0]*m
    ans = 0
    for k in range(n):
        if i>>k & 1:
            ans += C[k][0]
            for l in range(m):
                alis[l] += C[k][l+1]
    flag = 1
    for l in range(m):
        if alis[l] < x:
            flag = 0
    if flag:
        anss = min(anss,ans)

if anss == 10**9:
    print(-1)
    exit()
print(anss)


Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll 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;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, D; vll path;
//***********//
int main() {
	cin >> K;
	string S;
	cin >> S;
	if (S.length() <= K) cout << S;
	else {
		cout << S.substr(0, K) << "...";
	}
}

Measured memory_bytes: 3632
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	n := sc.getInt()
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		c := sc.getString()
		m[c]++
	}

	f := func(c string) {
		fmt.Fprintln(wr, c, "x", m[c])
	}

	f("AC")
	f("WA")
	f("TLE")
	f("RE")
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




bool comp(string a, string b) {
    if (sz(a) != sz(b)) return sz(a) < sz(b);
    return a < b;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    cin >> n;
    vector<int> a(n);
    int flg = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i] == 0) flg = 1;
    }
    if (flg == 0) {
        cout << 0 << endl;
        return 0;
    }
    
    set<string> s;
    rep(i, n) {
        string t;
        int flg = 0;
        rep3(j, i, n) {
            if (flg == 0 && a[j] == 0) continue;
            if (sz(t) > 10) break;
            flg = 1;
            t += a[j] + '0';
            s.insert(t);
        }
    }
    vector<string> v;
    
    for (auto e : s) {
        v.eb(e);
    }
    sort(all(v), comp);
    // for (string vi : v) cout << vi << endl;
    
    rep(i, sz(v) - 1) {
        ll a = stoi(v[i]);
        ll b = stoi(v[i + 1]);
        if (a + 1 == b) continue;
        cout << a + 1 << endl;
        return 0;
    }
}



Measured memory_bytes: 4124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

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


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N, Q;

int main() {
    cin >> N >> Q;
    vector<vector<int>> next_to(N);
    int a, b;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        a--; b--;
        next_to[a].push_back(b);
        next_to[b].push_back(a);
    }
    int p;
    long long x;
    vector<long long> ans(N);
    for (int i = 0; i < Q; i++) {
        cin >> p >> x; p--;
        ans[p] += x;
    }
    vector<bool> visit(N, false);
    queue<int> que;
    que.push(0);
    int temp, next;
    while(!que.empty()) {
        temp = que.front(); que.pop();
        if (visit[temp]) continue;
        visit[temp] = true;
        for (int i = 0; i < next_to[temp].size(); i++) {
            next = next_to[temp][i];
            if (visit[next]) continue;
            ans[next] += ans[temp];
            que.push(next);
        }
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] << ' ';
    }
    cout << endl;
}



Measured memory_bytes: 16372
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a_max = max(A)
table = [True for i in range(a_max+1)]
for a in A:
    i = 2
    k = a * 2
    while k <= a_max:
        table[k] = False
        k += a
count = 0
for i, a in enumerate(A):
    if i < N - 1 and A[i] == A[i+1]:
        table[a] = False
    if table[a]:
        count += 1
print(count)


Measured memory_bytes: 165192
using System;

class Task5
{
   public static void Main(string[] args)
   {
       string[] dist = Console.ReadLine().Split(' ');
       int N = int.Parse(dist[0]);
       int D = int.Parse(dist[1]);
       int[,] X = new int[N, D];
       int ans = 0;

       for (int i = 0; i < N; i++)
       {
           string[] dist2 = Console.ReadLine().Split(' ');
           for(int j = 0; j < D; j++)
           {
               X[i, j] = int.Parse(dist2[j]);
           }
       }
       for(int i = 0; i < N; i++)
       {
           for(int j = i + 1; j < N; j++)
           {
               int sum = 0;
               for(int a = 0; a < D; a++)
               {
                   sum += (X[i, a] - X[j, a]) * (X[i, a] - X[j, a]);
               }
               int sqrt = (int)Math.Sqrt(sum);
               if(sqrt * sqrt == sum)
               {
                   ans++;
               }
           }
       }
       Console.WriteLine(ans);
   }
}

Measured memory_bytes: 13140
using System;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;

class name
{

    static void Main()
    {
        int[] magic = Console.ReadLine().Split().Select(int.Parse).ToArray();
      int[] kaisu = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int and = 0;
       int ans =0;
      for(int k = 1; k <= kaisu[0]; k++)
        {
            if (magic[0] >= magic[1])
            {
                magic[1] = magic[1] * 2;
                and = k; 
            }
            else
            {
                and = k-1;
                break;

            }
                  

        }
        for(int h = 1; h <= kaisu[0]-and; h++)
       {
          
            if (magic[1] >= magic[2])
            {
                magic[2] = magic[2] * 2;
               
            }
            else {
          break;    
           
        }
}
        if (magic[0] < magic[1] && magic[1] < magic[2])
        {
            Console.WriteLine("Yes");
　　
        }

else{
            Console.WriteLine("No");

        }
    }



}

Measured memory_bytes: 28244
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    H, W, D = in_nn()
    A = [list(map(int, readline().split())) for _ in range(H)]
    Q = in_n()
    LR = [list(map(int, readline().split())) for _ in range(Q)]

    grid = [tuple()] * (H * W + 1)
    for y in range(H):
        for x in range(W):
            num = A[y][x]
            grid[num] = (x + 1, y + 1)

    move = [[] for _ in range(D)]
    for i in range(D):
        if i == 0:
            s = D
        else:
            s = i
        while s <= H * W:
            move[i].append(grid[s])
            s += D

    d = [[] for _ in range(D)]
    for i in range(D):
        d[i].append(0)
        for j in range(len(move[i]) - 1):
            x, y = move[i][j]
            nx, ny = move[i][j + 1]
            d[i].append(abs(nx - x) + abs(ny - y))

    for i in range(D):
        for j in range(len(d[i]) - 1):
            d[i][j + 1] += d[i][j]

    # print(d)

    ans = [0] * Q
    for i in range(Q):
        l, r = LR[i]
        q1, rr = divmod(l, D)
        q2, _ = divmod(r, D)
        if rr == 0:
            ans[i] = d[rr][q2 - 1] - d[rr][q1 - 1]
        else:
            ans[i] = d[rr][q2] - d[rr][q1]

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64652