akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int int_fast32_t
#define char int_fast8_t

using Pi = pair < int, int >;

bool solve()
{
        int N;
        cin >> N;
        if ( N == 0 ) return ( false );

        string S[20];
        int fact[11];
        fact[0] = 1;
        for ( int i = 1; i <= 10; i++ ) fact[i] = fact[i - 1] * i;

        vector < char > number[20];
        string chars;
        int cnt = 0;
        for ( int i = 0; i < N; i++ ) {
                cin >> S[i];
                for ( int j = 0; j < S[i].size(); j++ ) {
                        int pos;
                        if ( (pos = chars.find(S[i][j])) == string::npos ) {
                                number[i].push_back(chars.size());
                                chars += S[i][j];
                        } else {
                                number[i].push_back(pos);
                        }
                }
        }

        register vector < char > v(10);
        for ( int i = 0; i < v.size(); i++ ) v[i] = i;
        do {
                register char flag = 0;
                register int sum = 0;
                for ( register int i = 0; i < N; i++ ) {
                        register int k = 0;
                        register auto &numm = number[i];
                        if ( numm.size() != 1 && v[numm[0]] == 0 ) {
                                flag = 1;
                                break;
                        }
                        for ( register auto &x : numm ) {
                                k *= 10;
                                k += v[x];
                        }
                        sum += (i < N - 1 ? 1 : -1) * k;
                }
                if ( flag || sum ) continue;
                cnt++;
        } while ( next_permutation(begin(v), end(v)) );

        cout << cnt / fact[v.size() - chars.size()] << endl;

        return ( true );
}

signed main()
{
        while ( solve() );
        return ( 0 );
}



Measured memory_bytes: 3156
import bisect
import itertools

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

ans = 0
for ij in itertools.combinations(range(N), 2):
    i, j = ij
    a, b = L[i], L[j]

    cl = abs(a - b)
    cr = a + b
    l = bisect.bisect_right(L, cl)
    r = bisect.bisect_left(L, cr)
    l = max(l, j+1)
    if r - l > 0:
        ans += r - l
print(ans)

Measured memory_bytes: 50648
n = gets.chomp.to_i

b = gets.chomp.split.map{|a| a.to_i}

b << b.last

a = []

a << b[0]

n.times do |i|
  next if i == 0
  a << [b[i-1], b[i]].min
end

puts a.inject(&:+)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int n;
#define modp 998244353
#define Maxn 10000007
int power(int a,int b)
{
    int res=1,now=a,left=b;
    while (left>0)
    {
        if (left%2==1) res=(1LL*res*now)%modp;
        left/=2;
        now=(1LL*now*now)%modp;
    }
    return res;
}
int bin[Maxn],pre[Maxn],inv[Maxn];
int calc(int x,int y)
{
    int res=(1LL*pre[x]*inv[y])%modp;
    return (1LL*res*inv[x-y])%modp;
}
int main()
{
    scanf("%d",&n);
    int ans=0;
    bin[0]=1;
    for (int i=1;i<=n;i++)
        bin[i]=(2LL*bin[i-1])%modp;
    pre[0]=1;
    for (int i=1;i<=n;i++)
        pre[i]=(1LL*pre[i-1]*i)%modp;
    inv[n]=power(pre[n],modp-2);
    for (int i=n;i;i--)
        inv[i-1]=(1LL*inv[i]*i)%modp;
    for (int i=n/2+1;i<=n;i++)
        ans=(ans+1LL*calc(n,i)*bin[n-i])%modp;
    ans=(2LL*ans)%modp;
    ans=(power(3,n)+modp-ans)%modp;
    printf("%d\n",ans);
    return 0;
}


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

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

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


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

int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  
  for(int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> h(N+1);
    for ( int i = 1; i <= N; ++i){
        cin >> h.at(i);
    }
    
    vector<int> dp(N+1);
    dp[1] = 0;
    for ( int i = 2; i <= N; ++i){
        if ( i == 2 ) {
            dp[i] = dp[i-1] + abs( h.at(i) - h.at(i-1) );
        } else {
            dp[i] = min( dp[i-1] + abs( h.at(i) - h.at(i-1) ) , dp[i-2] + abs( h.at(i) - h.at(i-2) ) );
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
import itertools

def main():
    n, m, x = map(int, input().split())
    ca = [list(map(int, input().split())) for i in range(n)]
    INF = float('INF')
    res = INF
    for comb in itertools.chain(*(itertools.combinations(ca,r) for r in range(1,n+1))):
        c, *a = list(map(sum, zip(*comb)))
        if c < res and min(a) >= x:
            res = c
    if res == INF:
        print(-1)
    else:
        print(res)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9148
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

class UnionFind{
    vector<int> par;
    vector<int> rank;

public:
    UnionFind(int n): par(n), rank(n){
        REP(i, n){
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x){
        if(x == par[x]) return x;
        else return par[x] = find(par[x]);
    }

    void unit(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) ++rank[x];
        }
    }

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


int main(){
    int n, m; cin >> n >> m;
    // i=0,...,n-1: i+1が1, i=n,..,2n-1: i-n+1が0
    UnionFind uf(2*n);
    REP(i, m){
        int x, y, z; cin >> x >> y >> z;
        --x; --y;
        if(z%2){
            uf.unit(x, n+y); uf.unit(n+x, y);
        }else{
            uf.unit(x, y); uf.unit(n+x, n+y);
        }
    }
    
    set<int> par;
    REP(i, n){
        /*  矛盾があるとき
        if(uf.same(i, n+i)){
            cout << -1 << "\n";
            return 0;
        }
        */
        par.insert(uf.find(i));
        par.insert(uf.find(i+n));
    }
    cout << par.size() /2 << "\n";
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
const int N=1e2+5, M = 5e5+5, OO = 0x3f3f3f3f;
typedef long long ll;
#define PI 3.14159265358979323846
#define MOD 1000000007
int main()
{
     ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string move;
    cin >> move;
    ll c = 0;
    for(int i=0; i<n; ++i)
    {
        if (i < k || move[i - k] != move[i])
        {
            if (move[i] == 'r') c += p;
            else if (move[i] == 'p') c += s;
            else c += r;
        }
        else if (i >= k && move[i - k] == move[i]) move[i] = ' ';
    }
    cout << c << '\n';
   return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll x,ans=0;
	cin>>x;
	ans+=2*(x/11);
	x%=11;
	if(x>=7){
		ans+=2;
	}else if(x>0){
		ans+=1;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
n=int(input())
xy=[]
dist=[]
for i in range(n):
    x,y=map(int,input().split())
    xy.append((x,y))

for l in list(permutations(xy)):
    d=0.0
    for i in range(len(l)-1):
        d+=((l[i+1][0]-l[i][0])**2+(l[i+1][1]-l[i][1])**2)**0.5
    dist.append(d)
print(sum(dist)/len(dist))


Measured memory_bytes: 9204
#include <stdio.h>
const char WEEKDAYS[7][10] = {
	"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
	"Sunday"
};
const int MONTHS_1ST_WEEKDAY[] = {
	3, 6, 0, 3, 5, 1, 3, 6, 2, 4, 0, 2
};

int main() {
	int month, day;
	while (1) {
		scanf(" %d %d", &month, &day);
		if (month == 0 && day == 0)
			break;
		puts(WEEKDAYS[(MONTHS_1ST_WEEKDAY[month-1] + day - 1) % 7]);
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <numeric>
using namespace std;
using Int = long long;
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)
int main()
{
    char c;
    int odd = 0;
    while (cin >> c) {
        odd ^= 1 << (c - 'a');
    }
    cout << (odd ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
h,n = map(int, input().split())
abl = [tuple(map(int, input().split())) for _ in range(n)]

dp = [10**18]*(h+1)
dp[0] = 0
for i in range(h):
    for a,b in abl:
        next_h = min(h,i+a)
        dp[next_h] = min(dp[next_h], dp[i]+b)

print(dp[-1])

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

int main()
{
  vector<int> arr(3);
  cin>>arr[0]>>arr[1]>>arr[2];
  sort(arr.begin(),arr.end());
  double ans = (double)arr[0]*arr[1];
  ans = ans/2.0;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

struct ab{
	long long int a, b;
};

bool cmp(ab x, ab y) {
	if (x.a < y.a) { return true; }
	else return false;
}

int main() {
	//cout << fixed << setprecision(10);
	ab num[200050];
	long long int a[200500], b[200500], c, d, n, m,sum=0,cou=0;
	string str;
	cin >> n>>m;

	for (int i = 1; i <= n; i++) {
		cin >> num[i].a >> num[i].b;
	}
	sort(num + 1, num + n + 1, cmp);
	for (int i = 1; i <= n; i++) {
		if (m <= num[i].b) {
			cout << cou + m * num[i].a;
			return 0;
		}
		else {
			cou += num[i].a*num[i].b;
			m -= num[i].b;
		}
	}
}

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

signed main(){
	int n,ans = 0;
	map<int,bool> mp;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		mp[a] = !mp[a];
	}
	for(auto it = mp.begin();it != mp.end();it++){
		if(it->second) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#define abs(x) ((x>0)?x:(-(x)))
int H,W,D,A;
int Q,L,R;
int px[90001],py[90001];
int d[90001];
int main() {
    scanf("%d%d%d",&H,&W,&D);
    for(int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            scanf("%d",&A);
            px[A]=i,py[A]=j;
           }
         }
    for(int i=D+1;i<=H*W;i++)
        d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
    scanf("%d",&Q);
    while(Q--) {
        scanf("%d%d",&L,&R);
        printf("%d\n",d[R]-d[L]);
       }
    }

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

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define ll long long
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
     IOS
     int n,i,j,k,sum=0;

     cin>>n;
     int cnt=0;
     for(i = 1;i <= n;i++)
     {
          for(j = 1; j <= n; j++)
          {
               for(k = 1; k <= n; k++)
               {
                    sum+=gcd(gcd(i,j),gcd(j,k));
                    cnt++;
               }
          }
     }
     cout<<sum<<endl;
     return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;
  int length = S.size();
  if(length <= K) cout << S << endl;
  else{
    for(int i=0; i<K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, d, count = 0;
  cin >> n >> d;
  vector<double> sum(50, 0);
  vector<vector<int>> dot(10, vector<int>(10, 0));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> dot.at(i).at(j);
    }
  }
  int a = 0;
  
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){//点１と２、１と３・・・の距離を求める
        for(int l = 0; l < d; l++){
          sum.at(a) += (dot.at(i).at(l) - dot.at(j).at(l))*(dot.at(i).at(l) - dot.at(j).at(l));
        }
      a++;
    }
  }
  int b = 0;
  for(int i = 0; i < 50; i++){
    b = sqrt(sum.at(i));
    if(b * b == sum.at(i) && sum.at(i) != 0){
      count++;
  }
  }
    cout << count << endl;
  
}


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

// DAME: 考え方重視

/*
    反転部分の内部の幸福関係は変わらない
    幸福関係が変化するのは、反転部分と他の部分のつなぎ目のみ

    →　一回の反転では最大２つしか幸福関係が増えない
*/
int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int score = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            score++;
        }
    }
    int ans = min(score + 2*k, n-1);
    cout << ans << endl;
    return 0;
}

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


int main() {
    long long N,K;
    cin >> N >>K;

    long long Ans = 0;

    long long mod = 1000000007;

    for(int i = K-1; i < N+1; i++){
        Ans += (i + 1)*(N - i) + 1;
        Ans %= mod;
    }

    cout << Ans << endl;



}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))

if N%2==0:
    S = [0]*N
    s = 0
    for i in range(0, N, 2):
        s += A[i]
        S[i] = s

    ans = s = sum(A[1:N:2])
    for t in range(1, N, 2):
        s -= A[t]
        ans = max(ans, S[t-1]+s)
    print(ans)

else:
    S = [0]*N
    s = 0
    p = 0
    for t in range(2, N, 2):
        p += A[t-2]
        S[t] = max(S[t-2]+A[t-1], p)
    
    ans = s = sum(A[2:N:2])
    for t in range(2, N, 2):
        s -= A[t]
        ans = max(ans, S[t]+s)
    print(ans)
    


Measured memory_bytes: 32884
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vi a(26,INF);
  rep(i,n) {
    vi b(26);
    string s;
    cin>>s;
    for (char c : s) b[c-'a']++;
    rep(j,26) mins(a[j],b[j]);
  };
  string ans;
  rep(i,26)rep(j,a[i]) ans += 'a'+i;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int N = 3;
    vi a(N); REP(i,N) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = a[0] + a[1];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
        int ans_int = 0;
        String ans = "";
        int[] balls = new int [int1];
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;

        for(int i = 0;i<int1;i++){
            balls[i] =  Integer.parseInt(scan.next());
        }
        ans_int+=1;
        for(int i = 0;i<balls.length;i++){
            temp_int1 += balls[i];
            if(temp_int1 > int2){
                break;
            }else{
                ans_int+=1;
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}

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

int main() {
    int n,m;
    cin >> n >> m;
    map<int,int> mp;
    vector<int> hs(n);
    rep(i,n) {
        int h;
        cin >> h;
        hs[i] = h;
    }
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        if (hs[a] > hs[b]) {
            mp[b] = -1;
        } else if (hs[a] < hs[b]) {
            mp[a] = -1;
        } else {
            mp[a] = -1;
            mp[b] = -1;
        }
    }
    int ans = 0;
    rep(i,n) {
        if (mp[i] != -1) {
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 8416
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

//

int32_t main() {
  FAST_IO;
  str s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  rtn 0;
}


Measured memory_bytes: 256
from math import *

x = 0
y = 0
D = []
A = []
sum_a = -90
while True:
    d, a = map(int, input().split(","))
    if a == 0 and d == 0:
        break
    else:
        D.append(d)
        A.append(a)
for i in range(len(A)):
    x = x + D[i] * cos(sum_a * pi / 180)
    y = y - D[i] * sin(sum_a * pi / 180)
    if abs(x-round(x))<10**(-7):
        x=round(x)
    if abs(y - round(y)) < 10 ** (-7):
        y=round(y)
    sum_a += A[i]
if x >= 0:
    print(floor(x))
else:
    print(floor(x)+1)
if y >= 0:
    print(floor(y))
else:
    print(floor(y)+1)

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

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

    int ans = 0;
    int ano_N = N;
    while(N > 0) {
        ans += N%10;
        N /= 10;
    }
    int num = 1;
    for(int i = 0; i < 6; i++) {
        num *= 10;
        if(ano_N == num) {
            ans = 10;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2e5+250;
int n,i,a[N],b[N];
int main()
{
    cin>>n;
    for (i=1;i<=n;++i)
        cin>>a[i],b[i]=a[i];
    sort(a+1,a+n+1,greater<int>());
    for (i=1;i<=n;++i)
    {
        if (b[i]==a[1]) cout<<a[2]<<"\n";
        else cout<<a[1]<<"\n";
    }
}




Measured memory_bytes: 3200
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

double DP[3100][3100] = {};

int main(){
	
	int N;
	cin >> N;
	
	DP[0][0] = 1;
	
	for(int i = 1; i <= N; i++){
		double p;
		cin >> p;
		
		DP[i][0] = DP[i - 1][0] * (1 - p);
		for(int j = 1; j <= N; j++){
			DP[i][j] = DP[i - 1][j] * (1 - p) + DP[i - 1][j - 1] * p;
		}
	}
	
	double ans = 0;
	for(int i = (N + 1) / 2; i <= N; i++){
		ans += DP[N][i];
	}
	
	printf("%.10f\n", ans);
	
	return 0;
}


Measured memory_bytes: 73984
N, T = input().split()
N, T = int(N), int(T)
R = [input().split() for i in range(N)]
 
for i, r in enumerate(R):
  R[i] = [int(r[0]), int(r[1])]
 
R_sorted = sorted(R, key = lambda x: x[0])
 
List = []
answer = 'TLE'
 
for r in R_sorted:
  if r[1] <= T:
    List.append(r[0])

if List:
  answer = min(List)

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;

  if (N == 25) {
    COUT("Christmas");
    return 0;
  }
  if (N == 24) {
    COUT("Christmas Eve");
    return 0;
  }
  if (N == 23) {
    COUT("Christmas Eve Eve");
    return 0;
  }
  if (N == 22) {
    COUT("Christmas Eve Eve Eve");
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N,K=map(int, input().split())

ans = 0
for i in range(1,N+1):
    x = np.log2((K-1)/i)
    if x < 0:
        ans += 1
    else:
        x = np.floor(x) + 1
        ans += (1/2)**x
        
ans /= N
print(ans)

Measured memory_bytes: 12488
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

void solve() {

	int x, n;
	cin >> x >> n;

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

	for (int j = 0; j < 1000; j++) {
		for (int i = 0; i < 2; i++) {
			if (i == 0) {
				int y = x - j;
				bool check = true;
				for (int k = 0; k < n; k++) {
					if (arr[k] == y) {
						check = false;
						break;
					}
				}
				if (check) {
					cout << y << endl;
					return;
				}
			}
			if (i == 1) {
				int y = x + j;
				bool check = true;
				for (int k = 0; k < n; k++) {
					if (arr[k] == y) {
						check = false;
						break;
					}
				}
				if (check) {
					cout << y << endl;
					return;
				}
			}
		}
	}
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	// int t;
	// cin >> t;
	// while (t--)
	solve();

	return 0;
}

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

using namespace std;
#define ll long long int
#define X first
#define Y second
const int MAXN = 1e5 + 5;
ll n, W, w[MAXN], v[MAXN], dp[105][MAXN];

int main()
{
	cin >> n >> W;
	for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
	for (int i = 0; i < 105; i++) for (int j = 0; j < MAXN; j++) dp[i][j] = 1e11 + 5;

	for (int i = 0; i < n; i++)
	{
		dp[i][0] = 0;
		for (int j = 0; j < MAXN; j++)
		{
			dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
			if (~dp[i][j] && dp[i][j] + w[i + 1] <= W)
			{
				dp[i + 1][j + v[i + 1]] = min(dp[i + 1][j + v[i + 1]], dp[i][j] + w[i + 1]);
			}
		}
	}

	ll res = 0;
	for (int i = MAXN - 1; i >= 0; i--)
	{
		if (dp[n][i] != 1e11 + 5) { res = i; break; }
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 82304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		StringBuffer nsb = new StringBuffer(N);
		String N_reverse = nsb.reverse().toString();

		if (N.equals(N_reverse)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
    }

}

Measured memory_bytes: 20820
def left(i):
    s=cum[i]
    l,r=-1,i
    while(r-l>1):
        mid=(l+r)//2
        if cum[mid]>s/2:
            r=mid
        else:
            l=mid
    a,b=cum[r],cum[i]-cum[r]
    c,d=cum[l],cum[i]-cum[l]

    if (abs(b-a)<abs(c-d)):
        return a,b
    else:
        return c,d
def right(i):
    s=cum[N]-cum[i]
    l,r=i-1,N+1
    while(r-l>1):
        mid=(l+r)//2
        if cum[mid]-cum[i]>s/2:
            r=mid
        else:
            l=mid
    a,b=cum[r]-cum[i],cum[N]-cum[r]
    c,d=cum[l]-cum[i],cum[N]-cum[l]

    if (abs(b-a)<abs(c-d)):
        return a,b
    else:
        return c,d
        
N=int(input())
A=list(map(int,input().split()))
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=cum[i]+A[i]
ans=10**30
for i in range(2,N-1):
    a,b=left(i)
    c,d=right(i)
    ans=min(ans,max([a,b,c,d])-min([a,b,c,d]))
print(ans)

Measured memory_bytes: 93164
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b){
			if (b < c){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 25972
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for e in range(a+1):
  for f in range(b+1):
    for g in range(c+1):
      if (e*500+f*100+g*50)==x:
        count =count+1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
    int n, a, b;

    scanf("%d%d%d", &n, &a, &b);

    if (b >= (a*n)) {
        printf("%d\n", a*n);
    }
    else {
        printf("%d\n", b);
    }

    return 0;
}

Measured memory_bytes: 128
N = int(input())
XYH = [list(map(int, input().split())) for i in range(N)]

for i in range(101):
    for j in range(101):
        height = -1
        Z = []
        for x, y, h in XYH:
            hi = abs(x - i) + abs(y - j) + h
            if h == 0:
                Z.append([x, y])
                continue
            if height == -1:
                height = hi
            else:
                if height == hi:
                    pass
                else:
                    break
        else:
            for x, y in Z:
                if abs(x - i) + abs(y - j) >= height:
                    continue
                else:
                    break
            else:
                print(i, j, height)
                exit()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define fs first
#define ss second
bool ispalin(string s){
    int n = s.length();

    for(int i=0;i<n/2;i++){
        if(s[i] != s[n-i-1]) return false;
    }
    return true;
}


int main(){
   string s;
   cin >> s;
   
   int n = s.length();

   int k = n/2;

   if( s.substr(0,k) == s.substr(k+1)){
       
        int l = k/2;
        if(ispalin(s.substr(0,k))) cout <<"Yes"<<endl;
        else cout <<"No"<<endl;
   }
   else cout <<"No"<<endl;




}

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize
    }
    let mut ans:usize = 0;
    for i in 1..n {
        if n % i != 0 {
            ans += (n - n % i) / i;
        } else {
            ans += (n - 1) / i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2196
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int j = 0; j < n; j++){
      a[j] = sc.nextInt();
    }
    int am = 0;
    for(int j = 0; j < n; j++){
      am += a[j] - 1;
    }
    System.out.println(am);
  }
}

Measured memory_bytes: 26032
K=int(input())
L=[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]
print(L[K-1])

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	vector<pair<ld, string>> money(n);
	rep(i, n)
		cin >> money[i].first >> money[i].second;

	ld ans = 0;
	rep(i, n)
	{
		if(money[i].second == "JPY")
			ans += money[i].first;
		else
			ans += money[i].first * 380000.0;
	}

	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
	long long l, r, ans = 3000; cin >> l >> r;
	for (long long i = l; i <= min(r, l + 2019); ++i)
		for (long long j = i + 1; j <= min(r, l + 2019); ++j)
			ans = min(ans, (i * j) % 2019);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

const int L=1e6;
vector<P> ps[L];
vector<LL> us,vs,ss;
int st[L];
int lp=-1;
bool odd[L];
LL W[L];
void dfs(int i,LL v,bool f){
	st[i]=1;
	odd[i]=f;
	W[i]=v;
	for(auto p:ps[i]){
		int j=p.first;
		if(st[j]==0){
			dfs(j,p.second-v,!f);
		}
	}
}

int main() {
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int u,v,s;
		cin >> u >> v >> s;
		u--;
		v--;
		ps[u].push_back(P(v,s));
		ps[v].push_back(P(u,s));
		us.push_back(u);
		vs.push_back(v);
		ss.push_back(s);
	}

	memset(st,0,sizeof(st));
	dfs(0,0,false);
	bool hasOddCycle=false;
	for(int i=0;i<m;i++){
		if(odd[us[i]]==odd[vs[i]]){
			hasOddCycle=true;
			LL d=W[us[i]]+W[vs[i]]-ss[i];
			if(d%2){
				cout << 0 << endl;
				return 0;
			}
			memset(st,0,sizeof(st));
			//cerr << us[i] << ", " << W[us[i]]-d/2 << endl;
			dfs(us[i],W[us[i]]-d/2,false);
			break;
		}
		else{
			if(W[us[i]]+W[vs[i]]-ss[i]){
				cout << 0 << endl;
				return 0;
			}
		}
	}

	if(hasOddCycle){
		for(int i=0;i<m;i++){
			if(W[us[i]]+W[vs[i]]-ss[i]){
				cout << 0 << endl;
				return 0;
			}
		}
		for(int i=0;i<n;i++){
			if(W[i]<=0){
				cout << 0 << endl;
				return 0;
			}
		}
		cout << 1 << endl;
		return 0;
	}
	LL l=1;
	LL h=1LL<<60;
	for(int i=0;i<n;i++){
		//cerr << i+1 << ": " << odd[i] << ", " << W[i] << endl;
		if(odd[i]){
			h=min(h,W[i]-1);
			for(auto p:ps[i]){
				l=max(l,W[i]-p.second+1);
			}
		}
		else{
			l=max(l,1-W[i]);
			for(auto p:ps[i]){
				h=min(h,p.second-1-W[i]);
			}
		}
	//cerr << h << ", " << l << endl;
	}
	if(l>h){
		cout << 0 << endl;
		return 0;
	}
	cout << h-l+1 << endl;

	return 0;
}



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

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

  int n;
  cin >> n;

  set<int> uniq;
  for (int i = 0; i < n; i++) {
    int di;
    cin >> di;

    uniq.insert(di);
  }

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

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>

constexpr int SENTINEL = 1000000001;

int64_t Merge(std::vector<int>& A, int left, int mid, int right) {
    int64_t ret = 0;
    
    std::vector<int> L, R;
    for (int i=0; i<mid-left; i++) L.push_back(A[left+i]);
    for (int i=0; i<right-mid; i++) R.push_back(A[mid+i]);
    L.push_back(SENTINEL);
    R.push_back(SENTINEL);
    
    int l = 0;
    int r = 0;
    for (int i=left; i<right; i++) {
        if (L[l] <= R[r]) {
            A[i] = L[l];
            l++;
        } else {
            A[i] = R[r];
            r++;
            ret += (mid-left)-l;
        }
    }
    return ret;
}

int64_t mergeSort(std::vector<int>& A, int left, int right) {
    if (left+1 < right) {
        int mid = (left+right) / 2;
        int64_t ret1 = mergeSort(A, left, mid);
        int64_t ret2 = mergeSort(A, mid, right);
        int64_t ret3 = Merge(A, left, mid, right);
        return ret1 + ret2 + ret3;
    } else return 0;
}

int main() {
    int N, temp;
    std::cin >> N;
    
    std::vector<int> a;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        a.push_back(temp);
    }
    
    int64_t cnt = mergeSort(a, 0, N);
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 4888
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n; cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];

  ll ans = 0;
  for(ll i = n-1; 0 <= i; i--){
    ll cnt = (a[i]+ans)%b[i];
    if(cnt) ans += b[i]-cnt;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4804
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
  
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int k,n;
    cin >> n >> k;
    int a[n + 5];
    rep(i,n){
      cin >> a[i];
    }
    sort(a,a +n);
    int minv = INF;
    rep(i,n - k + 1){
      minv = min( minv , a[i + k - 1] - a[i] );
    }
    cout << minv << '\n';
   
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
  char s[10];
  int i;
  scanf("%s", s);
  if( s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


import java.util.*;
import java.util.LinkedList;
import java.util.Queue;

class Pair{
	public String key;
	public int value;
	public Pair(String name, int number) {
		this.key = name;
		this.value = number;
	}
}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		
		int n = Integer.parseInt(info[0]);
		int limit =Integer.parseInt(info[1]);
		int time = 0;
		
		Queue<Pair> q = new LinkedList<Pair>();
		String [] inputArrayS = new String[n];
		for (int i = 0; i < n; i += 1) {
			inputArrayS[i]  = sc.nextLine();
		}
		sc.close();
		
		for (int j = 0; j < n; j += 1) {
			
			int quantum = Integer.parseInt(inputArrayS[j].split(" ")[1]);
			String nameS = inputArrayS[j].split(" ")[0];
			Pair p = new Pair(nameS, quantum);
			q.offer(p);
			}

			while (q.size()>0) {
				
					if(q.peek().value > limit) {
						Pair cp = q.remove();
						time = time + limit;
						
					
					cp.value = cp.value - limit;
					cp.key = cp.key;	
					q.add(cp);
					
					
				}else{
					
					time = time + q.peek().value;				
					System.out.println(q.peek().key + " " + time);
					q.remove();
					
				}
			}
		}
	}


Measured memory_bytes: 106420
#include<stdio.h>
int main()
{
    int N,x,y,z;
    scanf("%d",&N);
    x=N/100;
    y=(N%100)/10;
    z=N%10;
    if((x==7)||(y==7)||(z==7)){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1728
N = int(input())
l = []
for i in range(N):
  s, p = input().split()
  l.append([s, int(p), i+1]) 

# まず点数で降順に並べる
l = sorted(l, key=lambda x:(x[1]), reverse=True)
# 次に地名で辞書順に並べる
l = sorted(l, key=lambda x:(x[0]))
for i in range(N):
  print(l[i][2])

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(){
  int S, s1, s2, s3;
  cin >> S;
  s1 = S / 100;
  s2 = (S- s1 * 100) / 10;
  s3 = S - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int A[100];

int SelectionSort(int a[], int n) {
    int count = 0;
    for (int i = 0; i < n; ++i) {
        int selector = i;
        for (int j = i; j < n; ++j) {
            if (A[selector] > A[j])selector = j;
        }
        if (selector != i) {
            count++;
            swap(A[i], A[selector]);
        }
    }
    return count;
}

void outputArray(int a[], int n) {
    cout << a[0];
    for (int i = 1; i < n; ++i) {
        cout << ' ' << a[i];
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];
    int count = SelectionSort(A, n);
    outputArray(A, n);
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3116
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];

    const list = [];
    for (var i = 1; i <= N; i++) {
        var info = input[i].split(' ');
        var S = info[0];
        var P = parseInt(info[1], 10);
        list.push({
            S: S,
            P: P,
            origIndex: i
        });
    }
    
    list.sort((a, b) => {
        if (a.S === b.S) {
            return b.P - a.P;
        }
        
        if (a.S > b.S) {
            return 1;
        }

        return -1;
    });

    list.forEach((info) => {
        console.log(info.origIndex);
    });
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
 
typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const ld PI = acos(-1.0);

struct point {
	ld x, y;
	point(ld x = 0, ld y = 0): x(x), y(y) {}
	point operator-(point a) {
		return point(x - a.x, y - a.y);
	}
};

point rotl(point a) {
	return point(-a.y, a.x);
}
point p[200];


int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.setf(ios::fixed), cout.precision(20);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> p[i].x >> p[i].y;
	for (int i = 0; i < n; ++i) {
		ld l = 0, r = 2 * PI;
		int fl = 0;
		for (int j = 0; j < n; ++j) {
			if (i == j)
				continue;
			point df = rotl(p[j] - p[i]);
			ld ang = atan2(df.y, df.x);
			while (ang < 0)
				ang += 2 * PI;
			if (fl == 0)
				l = ang, r = ang + PI;
			else {
				while (ang < l)
					ang += 2 * PI;
				if (ang >= r) {
					ang -= 2 * PI;
					r = min(r, ang + PI);
					r = max(l, r);
				}
				else {
					l = ang;
				}
			}
			fl = 1;
		}
		cout << (r - l) / (2 * PI) << "\n";
	}
	return 0;
}




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

int main() {
  int a,b,ans=0;
  cin >> a >> b;
  for (int i = a; i < b+1; i++) {
    /* code */
    if (i/10000 == i%10 && (i/1000)%10 == (i%100)/10) {
      /* code */
      ans += 1;
    }
  }
  std::cout << ans << '\n';
}


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

int main(){
    int a, b;
	cin >> a >> b;
	
	if ( a < b ) cout << "a < b" << endl;
	else if ( a > b ) cout << "a > b" << endl;
	else cout << "a == b" << endl;
	
	return 0;
}


Measured memory_bytes: 3060
fun main(args: Array<String>) = ABC160A.main()

object ABC160A {
    fun main() {
        val s = readString()
        println(s.isCoffeeLike().yesOrNo())
    }

    fun String.isCoffeeLike():Boolean {
        return this[2]==this[3] && this[4]==this[5]
    }

    /*####################################################################################*/

    fun readString() = readLine()!!
    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
}

Measured memory_bytes: 33780
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> Q;

const int inf1=1e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=2e3+9;
const ll maxx=1e12+9;



int main()
{
    char ch;
    cin>>ch;
    if(isupper(ch)) cout<<'A'<<endl;
    else cout<<'a'<<endl;
}


Measured memory_bytes: 3032
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long x = c / gcd(c, d) * d;
		long aCount = (a - 1) / c + (a - 1) / d - (a - 1) / x;
		long bCount = b / c + b / d - b / x;
		System.out.println(b - a + 1 - (bCount - aCount));
   }
   
   static long gcd(long x, long y) {
       if (x % y == 0) {
           return y;
       } else {
           return gcd(y, x % y);
       }
   }
}


Measured memory_bytes: 25300