akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int t[] = new int[n+1];
      int x[] = new int[n+1];
      int y[] = new int[n+1];

      t[0]=0;
      x[0]=0;
      y[0]=0;
      
      for(int i=0;i<n;i++){
        t[i+1] = scan.nextInt();
        x[i+1] = scan.nextInt();
        y[i+1] = scan.nextInt();
      }

      boolean can = true;
      for(int i=0;i<n;i++){
        int dt = t[i+1]-t[i];
        int dist = Math.abs(x[i+1]-x[i])+Math.abs(y[i+1]-y[i]);
        if(dt<dist) can = false;
        if(dt%2!=dist%2) can = false;
      }

      String ans = can?"Yes":"No";
      System.out.println(ans);
      
    }
  }


Measured memory_bytes: 90936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    map<char, ll> cnt;
    rep(i, len(s)) cnt[s[i]]++;
    if (sz(cnt) != 2) {
        cout << "No" << endl;
        return 0;
    }
    if (cnt.begin()->second != 2) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);

string s;
cin>>s;
int a=static_cast<int>(s.at(0)) -48;
int b=static_cast<int>(s.at(1)) -48;
int c=static_cast<int>(s.at(2)) -48;
int d=static_cast<int>(s.at(3)) -48;

int first= (a*10)+b;
int second= (c*10)+d;
//cout<<first<<" "<<second;
if( (first>=1 && first<=12) && (second>=1 && second<=12) )
{
  cout<<"AMBIGUOUS";
}
else if( (first>=1 && first<=12)  )
{ 
  cout<<"MMYY";
 
}
else if( (second>=1 && second<=12) )
{
  cout<<"YYMM"; 
}
else cout<<"NA";

return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    int xmax=X,ymin=Y;
    int x[n];
    int y[m];
    for(int i=0;i<n;i++){
        cin>>x[i];
        if(x[i]>xmax){
            xmax=x[i];
        }
    }   
    for(int i=0;i<m;i++){
        cin>>y[i];
        if(y[i]<ymin){
            ymin=y[i];
        }
    }   
    if(xmax<ymin){
        cout<<"No War"<<endl;
    }else{
        cout<<"War"<<endl;
    }   
}


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

main()
{
long long int ar[100000],br[1000],cr[1000],n,a,b,c,aaa,k,i,r=0,rr=0,d1,dd=0,d2,d3,ck=0,m,j,aa,bb,cc;
//char cr[1000];
float aaf,bbf,ccf,rf,kf;
//scanf("%lld",&n);
cin>>n>>k;

a=n%k;
b=abs(k-a);
if(a<b){
    cout<<a;

}
else{
    cout<<b;
}




    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int bubbleSort(int A[],int N) {
	int sw = 0;
	bool flag = 1;
	for(int i=0; flag; i++) {
		flag = 0;
		for(int j=N-1; j>=i+1; j--) {
			if(A[j] < A[j-1]) {
				swap(A[j], A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void) {
	int A[100], N, sw;
	cin >> N;
	for(int i=0;i<N; i++) cin >> A[i];

	sw = bubbleSort(A,N);

	for(int i = 0; i < N; i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x,S[99],top=0,ans=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){

      ans=S[top-2]+S[top-1];
      top--;
      S[top-1]=ans;
  
    }
    else if ( s[0] == '-' ){
   
      ans=S[top-2]-S[top-1];
       top--;
       S[top-1]=ans;
  
    }
    else if ( s[0] == '*' ){
      
      ans=S[top-2]*S[top-1];
       top--;
       S[top-1]=ans;
    
    }
    else {
   
      x = atoi(s);
       S[top]=x;
       top++;
    }
  }
  printf("%d\n",S[top-1]);

  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define pii pair<int,int>
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
int inf_i = 1001001000;
ll inf_l = 1001001001001000;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	ll ans = 0;
	for (ll i = 1; i*i <= n; i++)
	{
		if (n % i == 0)
		{
			ll m = n / i - 1;
			if (i < m)ans += m;
		}
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

  int i, j, k, l, n, x[1000][2], m[1000][1000], dp[1000][1000], p[1000];

  scanf("%d", &n);

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

  p[0]=x[0][0];
  for(i=0; i<n; i++){
    p[i+1]=x[i][1];

  }
  for (i=0; i<n; i++)
    m[i][i]=0;

  for (l=2; l<=n; l++) {
    for (i=1; i<=n-l+1; i++) {
      j=i+l-1;
      m[i][j]=1000001;
      for (k=i; k<=j-1;k++) {
        m[i][j]=min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);

      }
    }
  }
  printf("%d\n", m[1][n]);


  return 0;
}

Measured memory_bytes: 2792
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int mod=1e9+7;
int n,x,y,z,f[45][1<<17][2],status;
signed main(){
	//freopen("a","r",stdin);
	n=read(),x=read(),y=read(),z=read();
	status=(1<<x+y+z-1)+(1<<y+z-1)+(1<<z-1);
	f[0][0][0]=1;
	rep(i,0,n-1)rep(s,0,(1<<x+y+z)-1)rep(opt,0,1)if(f[i][s][opt]){
		rep(j,1,10){
			int sta=((s<<j)+(1<<(j-1)))&((1<<x+y+z)-1),top=opt;
			if((sta&status)==status)top=1;
			f[i+1][sta][top]=(f[i+1][sta][top]+f[i][s][opt])%mod;
		}
	}
	int ans=0;rep(i,0,(1<<x+y+z)-1)ans=(ans+f[n][i][1])%mod;return cout<<ans,signed();
}

Measured memory_bytes: 40824
a,b,c,d = map(int,input().split())
mod = 998244353
dp = [[0]*(d+1) for _ in range(c+1)]
dp[a][b] = 1
for i in range(a,c+1):
    for j in range(b,d+1):
        dp[i][j] += dp[i][j-1]*i+dp[i-1][j]*j-dp[i-1][j-1]*(i-1)*(j-1)
        dp[i][j] %= mod
print(dp[c][d])

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

using namespace std;

int main() {
    int  A, B, A_B, X, Y;
    cin >> A >> B >> A_B >> X >> Y;
    int sum;

    if (A + B <= A_B * 2) {
        sum = X*A + Y*B;
    }

    else {
        if (A >= A_B * 2 && B >= A_B * 2) {
            sum = A_B * 2 * max(X, Y);
        }

        else if (A >= A_B * 2) {
            if (X >= Y) {
                sum = A_B * 2 * X;
            }
            else {
                sum = (A_B * 2)*X;
                sum += B*(Y - X);
            }
        }
        else if (B >= A_B * 2) {
            if (Y >= X) {
                sum = A_B * 2 * Y;
            }
            else {
                sum = (A_B * 2)*Y;
                sum += A*(X - Y);
            }
        }
        else {
            if (X >= Y) {
                sum = A_B * 2 * Y;
                sum += A*(X - Y);
            }
            else if (Y >= X) {
                sum = A_B * 2 * X;
                sum += B*(Y - X);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,x;
	scanf("%d %d",&a,&b);
	if(a>b)	x=a-1;
	else x=a;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100001
#define prob "DP_A"
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
int n,k,a[N],b[N],c[N];
int f[N][3];
void read()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
    f[1][0]=a[1];
    f[1][1]=b[1];
    f[1][2]=c[1];
    for(int i=2;i<=n;i++)
    {
        f[i][0]=max(f[i-1][1],f[i-1][2])+a[i];
        f[i][1]=max(f[i-1][0],f[i-1][2])+b[i];
        f[i][2]=max(f[i-1][1],f[i-1][0])+c[i];
    }
    cout<<max(max(f[n][0],f[n][1]),f[n][2]);
}
int main()
{
//    io
    read();
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

// 素因数分解を行う関数
map<int, int> PrimeFactor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

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

    int s = 0;
    int ans = 0;
    while (true) {
        s = s * 10 + 7;
        s %= k;
        ans++;
        if (s == 0) break;
        if (ans == k) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int d = in.nextInt();
        int g = in.nextInt();
        int[] P = new int[11];
        int[] C = new int[11];
        int[] S = new int[11];
        for(int i = 1; i <= d; i++) {
            P[i] = in.nextInt();
            C[i] = in.nextInt();
            S[i] = (P[i]*i*100) + C[i];
        }

        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < (1 << d); i++) {
            int pointSum = 0;
            int problemCnt = 0;
            for(int j = 0; j < d; j++) {
                if(((i>>j)&1) == 1) {
                    pointSum += S[j+1];
                    problemCnt += P[j+1];
                }
            }

            if(pointSum >= g) {
                ans = Math.min(ans, problemCnt);
            }else{
                int pointsToGo = g - pointSum;

                for(int j = 0; j < d; j++) {
                    if(((i>>j)&1) == 0){
                        if(pointsToGo > (P[j+1]-1) * (j+1)*100) {
                            continue;
                        }else{
                            problemCnt += pointsToGo / ((j+1)*100);
                            ans = Math.min(ans, problemCnt);
                        }
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    unordered_map<ll,ll> diff;
    ll d;
    rep(i,n){
        cin >> d;
        diff[d]++;
    }
    bool y = 1;
    ll m,t;
    cin >> m;
    rep(i,m){
        cin >> t;
        if (diff[t] > 0){
            diff[t]--;
        }
        else{
            y = 0;
            break;
        }
    }
    if (y) PRINT("YES");
    else PRINT("NO");
}


Measured memory_bytes: 11360
#include<cstdio>
#include<algorithm>
using namespace std;
char st[19];
int num[10];
int main()
{

	scanf("%s",st);
	num[st[0]-'a']++;
	num[st[1]-'a']++;
	num[st[2]-'a']++;
	if (num[0]&&num[1]&&num[2]) puts("Yes");
	else puts("No");
	return 0;
//	int a,b,c;
//	scanf("%d%d%d",&a,&b,&c)
 } 

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

int main(){
  int n,r;
  cin >> n >> r;
  if(n<10) cout << r+100*(10-n) << endl;
  else  cout << r <<endl;
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  string s;
  cin >>s;
  char u;
  int cnt=0;
  rep(i,n){
    if(u != s[i]){
      cnt += 1;
      u=s[i];
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int b = a.size();
  int min=b,max=0;
  for(int i=0;i<b;i++){
    if(a.at(i) == 'A' && i<min)
      min = i;
    if(a.at(i) == 'Z' && max<i)
      max = i;
  }
  cout << max - min + 1<< endl;
}

Measured memory_bytes: 640
#include<cstdio>

const int MAX_N = 1e5;
int n, m;
bool judge[30][MAX_N];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        int s, t, c;
        scanf("%d %d %d", &s, &t, &c);
        for (int j = s - 1; j < t; j++) judge[c - 1][j] = true;
    }
    
    int ans = 0;
    for (int i = 0; i < 100000; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (judge[j][i]) cnt++;
        }
        ans = (ans < cnt) ? cnt : ans;
    }
    
    printf("%d\n", ans);
    return 0;
} 


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
const int mod = 1e9 + 7;
inline int mul( int x , int y ){ return 1LL * x * y % mod ;}
int power_mod( int x , int y ){int ret = 1;while( y ){if( y & 1 ) ret = mul( ret , x );y >>= 1;x = mul( x , x );}return ret;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;
const int maxn = 1e5 + 50;

char s[maxn];
int n , pos[50];

int main(int argc,char *argv[]){
	scanf( "%s" , s + 1 );
	n = strlen( s + 1 );
	int opr = n - 2 - (s[1] == s[n]);
	if( opr & 1 )
		puts("First");
	else
		puts("Second");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
#define NUM_MAX 100000
#define DIVISOR 1000000007
int fget_array(char *map, int size) {
    int i;
    for(i = 0; i < size; i++) {
        int stairs;
        scanf("%d", &stairs);
        map[stairs] = 0;
    }
    return 0;
}

int main(void) {
    static int64_t dp[NUM_MAX+1];
    int num, s;
    get_int2(&num, &s);
    static char map[NUM_MAX+1];
    memset(map, 0x01, NUM_MAX+1);
    fget_array(map, s);

    int i;
    dp[0] = 1;
    for(i = 1; i <= num; i++) {
        if(!map[i]) continue;
        dp[i] += dp[i-1];
        if(i>=2) dp[i] = (dp[i] + dp[i-2])%DIVISOR;
    }
    printf("%d\n", (int)dp[num]);
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define ll long long
#define mod 924844033
#define maxn 2010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int mark[2*maxn],f[2*maxn][2*maxn][2];
ll fac[maxn];
int n,k;
int main()
{
	n=read(); k=read();
	int p=0;
	for(int i=1;i<=k;i++){
		mark[++p]=1;
		p+=(n-i)/k;
		mark[++p]=1;
		p+=(n-i)/k;
	}
	f[0][0][0]=1;
	for(int i=1;i<=2*n;i++)
		for(int j=0;j<=2*n;j++){
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mod;
			if(j)f[i][j][1]=(!mark[i])*f[i-1][j-1][0];
		}
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%mod;
	ll ans=0;
	for(int i=0;i<=n;i++)
		if(i&1)ans-=(f[2*n][i][0]+f[2*n][i][1])*fac[n-i]%mod;
		else ans+=(f[2*n][i][0]+f[2*n][i][1])*fac[n-i]%mod;
	writeln((ans%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 125824
#include<stdio.h>
int S[100000], n;

bool binarySearch(int key) {
    int left = 0;
    int right = n;
    while (left<right) {
        int mid = (left+right)/2;
        if (S[mid] == key) return true;
        if (key < S[mid]) right = mid;
        else left = mid + 1;
    }
    return false;
}

int main() {
    int i, T, q;
    int C=0;
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    for (i=0; i<q; i++) {
        scanf("%d", &T);
        if (binarySearch(T)) C++;
    }
    printf("%d\n", C);

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

const int MOD = 1e9+7;

signed main(){
    int N; cin >> N;
    vector<bitset<60>> A(N);
    rep(i,N){
        int t; cin >> t;
        A[i] = t;
    }
    
    int res = 0, bit = 1;
    rep(i, 60){
        int one = 0;
        rep(j, N){
            if(A[j][i]) one++;
        }
        int delta = ((N-one) * one) % MOD;
        delta *= bit;
        res += delta % MOD;
        bit <<= 1;
        bit %= MOD;
    }
    
    cout << res % MOD << endl;
    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int k, x;
  cin >> k >> x;
  int first = -1000000, last = 1000000;

  int a = x-k+1, b = x+k-1;

  for(int i = a; i <= b; i++){
    if(i >= first && i <= last)
        cout << i << " ";
    else
        break;
  }

  cout << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
	int n, m;
	int x, y, d, c;

	while(cin >> n >> m, n || m)
	{
		if(n >= m)
		{
			x = n;
			y = m;
		}
		else
		{
			x = m;
			y = n;
		}

		c = 0;
		while(y != 0)
		{
			d = x % y;
			x = y;
			y = d;
			c++;
		}

		cout << x << " " << c << endl;
	}

	return 0;
}

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


int main()
{
    string A,B;
    cin >> A >> B;
    int count=0; 

    for(int i=0; i<A.size(); i++)
    {
        if(!(A.at(i)==B.at(i)))
        {
            count++;
        }
    }
    cout << count << endl;
    
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// http://ronly.hatenablog.com/entry/2017/06/17/161641
struct edge {
    ll to, cost;
    edge(ll to_, ll cost_): to(to_), cost(cost_) {}
};
typedef vector<vector<edge> > AdjList;
AdjList graph[2];

typedef pair<ll, ll> P;

vector<ll> dist[2];
multiset<ll> distsum;
vector<ll> prever[2];

void dijkstra(ll n, ll s, ll mode){
    dist[mode] = vector<ll>(n,INF);
    prever[mode] = vector<ll>(n,-1);
    dist[mode][s] = 0;

    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        ll v = p.second;
        if(dist[mode][v] < p.first){
            continue;
        }
        for(ll i=0;i<SZ(graph[mode][v]);i++){
            edge e = graph[mode][v][i];
            if(dist[mode][e.to] > dist[mode][v] + e.cost){
                dist[mode][e.to] = dist[mode][v] + e.cost;
                prever[mode][e.to] = v;
                que.push(P(dist[mode][e.to],e.to));
            }
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    rep(i, 2) graph[i] = AdjList(n+1);
    vll u(m), v(m), a(m), b(m);
    rep(i, m){
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        graph[0][u[i]].emplace_back(v[i], a[i]);
        graph[0][v[i]].emplace_back(u[i], a[i]);
        graph[1][u[i]].emplace_back(v[i], b[i]);
        graph[1][v[i]].emplace_back(u[i], b[i]);
    }
    dijkstra(n+1, s, 0);
    dijkstra(n+1, t, 1);
    repr(i, 1, n+1){
        distsum.insert(dist[0][i] + dist[1][i]);
        //cerr << dist[0][i] + dist[1][i] << endl;
    }
    repr(i, 1, n+1){
        cout << 1000000000000000-*distsum.begin() << endl;
        distsum.erase(distsum.find(dist[0][i] + dist[1][i]));
    }
    return 0;
}

Measured memory_bytes: 27520
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n; int m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}


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



#define endl'\n'
#define mem(a,b) memset(a, b, sizeof(a) )
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int inf = 2000000000;



const int mx = 1e5+123;
int dp[mx], n, h[mx];

int solve ( int i )
{
  if ( i == n ) return 0;
  if ( dp[i] != -1 ) return dp[i];

  int ret2 = inf;
  int ret1 = abs ( h[i] - h[i+1] ) + solve ( i+1 );
  if ( i+2 <= n ) ret2 = abs ( h[i] - h[i+2] ) + solve ( i+2 );

  return dp[i] = min ( ret1, ret2 );
}

int main()
{
  optimize();

  cin >> n;
  for ( int i = 1; i <= n; i++ ) cin >> h[i];

  memset ( dp, -1, sizeof (dp) );
  cout << solve ( 1 ) << endl;


  return 0;
}

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;

int main()
{
    IO;
    int n,x,Max=INT_MIN,Min=INT_MAX;
    cin >> n;
    while(n--){
        cin >> x;
        Min=min(Min,x);
        Max=max(Max,x);
    }
    cout<<Max-Min<<endl;
    re 0;
}

Measured memory_bytes: 256
import numpy as np

L, R = map(int, input().split())

if L // 2019 == R // 2019:
    LIST = []
    for i in range(R%2019 - L%2019+1):
        LIST.append(i+L%2019)
    LIST = np.array(LIST)
    print((np.dot(LIST.reshape(-1,1), LIST.reshape(1,-1)) % 2019 + 2019*np.tri(len(LIST), dtype=int)).min())
else:
    print(0)

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

int main() 
{
	int data[10000];
	int input = 1;
	int i = 0;
	while (input!=0) {
		cin >> input;
		data[i] = input;
		i++;
	}
	int j = 0;
	while (data[j] != 0) {
		cout << "Case " << j + 1 << ": " << data[j] << endl;
		j++;
	}
 }


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

typedef struct node{
	int z,o;
}Node;

Node no[7] = { {1,2},{6,3},{1,6},{4,5},{5,2},{2,1},{6,6} };
string p;

bool ok(string str){
	int l = 0;
	for(int i = 0; i < str.size(); i++){
		if(str[i] == '0'){
			l = no[l].z;
		}
		else{
			l = no[l].o;
		}
	}
	return l == 5;
}

int main(){
	while(cin >> p && p != "#"){
		cout << (ok(p) ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const pi dir[4] = {{1,0}, {0,1}, {-1,0}, {0,-1}};


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

int n, m, a, b;
int c[3];

int main(){
    IOS;
    cin >> n >> m;
    F0R(i,3){
        c[i] = 10;
    }
    F0R(i,m){
        cin >> a >> b;
        a--;
        if(c[a] != 10 && c[a] != b){
            cout << -1; return 0;
        }
        c[a] = b;
    }
    if(n==1 && c[0] == 10){
        cout << 0;
        return 0;
    }
    if(c[0] == 0){
        if(n == 1){
            cout << 0;
            return 0;
        }
        cout << -1;
        return 0;
    }
    bool zeroPlaced = false;
    F0R(i,n){
        if(c[i] == 10){
            if(zeroPlaced) cout << 0;
            else{
                cout << 1;
                zeroPlaced = true;
            }
        }
        else{
            cout << c[i];
            zeroPlaced = true;
        }
    }
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

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


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

  int h,a;
  cin >> h >> a;
  if(h/a*a==h) cout << h/a << endl;
  else cout << h/a+1 << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=5005;
int dp[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),mod=read();
	dp[n]=1;
	int t=(n-1)/2;
	For(i,1,(n+1)/2){
		Rep(j,n-i,1)dp[j]=(dp[j]+dp[j+i])%mod;
	}
	For(i,1,n/2){
		Rep(j,n-i,1)dp[j]=(dp[j]+dp[j+i])%mod;
	}
	ll ans=0;
	For(i,1,n)ans+=dp[i];
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 256
n = int(input())
w = [input() for i in range(n)]

def is_shiritori():
  if len(set(w)) != n:
    return 'No'
  for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
      return 'No'
  return 'Yes'

print(is_shiritori())

Measured memory_bytes: 3060
n, k = map(int, input().split())
h = sorted(list([int(input()) for _ in range(n)]), reverse=True)

t = 0

for i in range(n - k + 1):
    _t = h[i] - h[i + k - 1]
    if _t == 0:
        print(0)
        exit()
    else:
        if t == 0 or _t < t:
            t = _t

print(t)

Measured memory_bytes: 8124
#include <iostream>
#include <string>

using namespace std;

string S;

int main() {
    int a, b;

    while (cin >> S) {
        a = atoi(S.substr(0, 2).c_str());
        b = atoi(S.substr(2, 2).c_str());

        if (1 <= a && a <= 12) {
            if (1 <= b && b <= 12) {
                cout << "AMBIGUOUS" << endl;
            } else {
                cout << "MMYY" << endl;
            }
        } else {
            if (1 <= b && b <= 12) {
                cout << "YYMM" << endl;
            } else {
                cout << "NA" << endl;
            }
        }
    }
    return 0;
}


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

vector<int> vec[100010];
bool used[100010];
bool used1[100010];
int dp[100010];
int ans=0;

int dfs(int x){
	if (!used[x]){
		used1[x]=1;
		return dp[x]=1;
	}
	if (used1[x]) return dp[x];
	int len=vec[x].size();
	for (int i=0;i<len;i++){
		dp[x]=max(dp[x],dfs(vec[x][i])+1);
	}
	used1[x]=1;
	return dp[x];
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int x,y;
	ans=0;
	for (int i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
		used[x]=1;
	}
	for (int i=1;i<=n;i++){
		dfs(i);
	}
	for (int i=1;i<=n;i++) ans=max(ans,dp[i]-1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8320
n, a, b = map(int, input().split())
mod = 10**9 + 7

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % mod
            x = x ** 2 % mod
            n = (n - 1) // 2
        else:
            x = x ** 2 % mod
            n = n // 2

    return K * x % mod# 指数を割り続け n が 1 に至ったら終了

def modc(a,b,m):
    c = 1
    for i in range(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

ans = pow_k(2, n) - 1
ans -= modc(n, a, mod) + modc(n, b, mod)
ans = ans % mod
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  float ans = (float)v.at(0);
  for (int i = 1; i < n; i++){
    ans = (ans + v.at(i)) / 2.0;
  }
  cout << setprecision(7) << ans << endl;
}

Measured memory_bytes: 256
//Code by Enderturtle
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define repe(i,a) for(register int i=head[a];i;i=e[i].nxt)
#define il inline
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
typedef long long ll;
using namespace std;
il void filejudge(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
il int read(){
	int x=0;bool f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=0;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
/*----- head end -----*/
int n,x,now=1;
int main(){
	n=read();x=read();
	if(x==1 || x==(2*n-1)) puts("No");
	else{
		puts("Yes");
		rep(i,1,n-2){
			while(now==x || now==x-1 || now==x+1) ++now;
			printf("%d\n",now);
			++now;
		}
		printf("%d\n%d\n%d\n",x-1,x,x+1);
		rep(i,1,n-2){
			while(now==x || now==x-1 || now==x+1) ++now;
			printf("%d\n",now);
			++now;			
		}
	}
	return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        if(i)
            v[i] += v[i-1];
    }
    int curr = v[k-1];
    for(int i=k;i<n;i++)
    {
        curr = max(curr, v[i] - v[i-k]);
    }
    long double ans = (long double) (curr+k);
    ans /= 2;
    cout << fixed << setprecision(10) <<  ans << "\n";

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	auto a = vector<int>(n);
	int total = 0;
	for(auto&& aa : a){
		cin >> aa;
		total += aa;
	}
	sort(a.begin(), a.end(), greater<int>());
	cout << (a[m - 1] * 4 * m < total ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  long long n, mod = 1e9+7, sum = 1;
  cin >> n;
  for(int i = 1; i <= n; i++) sum = ((sum % mod) * (i % mod)) % mod;
  cout << sum << endl;
  return 0;
}

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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c ,n, sum, A[500010], B[500000],rui[500000],  dp[5000];
str S;bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> A[0] >> A[1];
sort(A,A+2);
if(A[0] == 1){
	if(A[1] == 2)cout << 3 << endl;
		if(A[1] == 3)cout << 2 << endl;
}
if(A[0] == 2){
	if(A[1] == 1)cout << 3 << endl;
		if(A[1] == 3)cout << 1 << endl;
}
if(A[0] == 3){
	if(A[1] == 1)cout << 2 << endl;
		if(A[1] == 2)cout << 1 << endl;
}
	return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <iostream>
#include <vector>
 
int main() {
  std::ios_base::sync_with_stdio(false);
  long n, k;
  std::cin >> n >> k;
  long r = n % k;
  std::cout << std::min(r, k - r);
  return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

type Process struct {
	name string
	time int
}

func shift(q []Process) (Process, []Process) {
	return q[0], q[1:]
}

func main() {
	var n, q int
	fmt.Scan(&n, &q)

	queue := make([]Process, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&queue[i].name, &queue[i].time)
	}

	var p Process
	var t int
	for len(queue) > 0 {
		t += q
		queue[0].time -= q
		p, queue = shift(queue)
		if p.time <= 0 {
			t += p.time
			fmt.Println(p.name, t)
		} else {
			queue = append(queue, p)
		}
	}
}




Measured memory_bytes: 7772
#include <bits/stdc++.h>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
// constant
const double PI  = acos(-1.0);
const int    MOD = (int)(1e9 + 7);
// DO NOT set INFTY_XXXs constants. They may bring some BUG! Use MAX_XXXs in climit instead.
 
// clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    string s, t; cin >> s;
    if (s == "ABC") t = "ARC";
    else if (s == "ARC") t = "ABC";
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=1e6+3,du=1e9+7;
int n;
int a[mxn];
int seive[mxn];
int cnt[mxn];
int ok;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	for (int i=2;i<=1000;i++)
	if (!seive[i]) for (int j=i*i;j<=1000000;j+=i) seive[j]=i;
    cin>>n;
    ok=1;
    int gcd=0;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        int x=a[i];
        gcd=__gcd(gcd,x);
        while(seive[x])
        {
            int d=seive[x];
            if (!cnt[d]) cnt[d]=1;
            else
            {
                ok=2;
            }
            while(x%d==0) x/=d;
        }
        if (x>1)
        {
            if (!cnt[x]) cnt[x]=1;
            else ok=2;
        }
    }
    if (ok==1) cout<<"pairwise coprime";
    else if (ok==2&&gcd==1) cout<<"setwise coprime";
    else cout<<"not coprime";
	return 0;
}


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

int main() {
  int A, B, C;
  int tmp = 0;
  cin >> A >> B >> C;
  for (int i = 0; i < B; i++) {
    tmp = (tmp + A) % B;
    if (tmp == C) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

void chmin(int &a, int b){
    if(a > b)a = b;
}

int main(){
    int N;
    vector<int> ABC(3);
    cin >> N >> ABC[0] >> ABC[1] >> ABC[2];
    vector<int> L(N);
    for(int i = 0; i < N; i++)cin >> L[i];
    
    int ans = 1e9;
    
    for(int tmp = 0; tmp < pow(4, N); tmp++){
        vector<pair<int, int>> sum_num(4, pair<int, int>(0, 0));
        vector<int> th(N);
        int m = tmp;
        for(int i = 0; i < N; i++){
            th[i] = m % 4;
            m /= 4;
        }
        
        for(int i = 0; i < N; i++){
            sum_num[th[i]].first += L[i];
            sum_num[th[i]].second++;
        }
        
        if(sum_num[0].second == 0 || sum_num[1].second == 0 || sum_num[2].second == 0)continue;
        
        int res = 0;
        for(int i = 0; i < 3; i++){
            res += abs(ABC[i] - sum_num[i].first) + abs(10 * (sum_num[i].second - 1));
        }
        chmin(ans, res);
    }
    
    cout << ans << endl;
    return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

void solve(){
	int x;
	cin>>x;
	int res=0;
	res+=(x/500)*1000;
	x = x%500;
	res+=(x/5)*5;
	cout<<res<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll sum = mod_pow(2, n, MOD) - 1;
    ll x_a = 1, y_a = 1, x_b = 1, y_b = 1;
    for(int i = 0; i < a; i++){
        x_a = x_a * (n - i) % MOD;
        y_a = y_a * (i + 1) % MOD;
    }
    for(int i = 0; i < b; i++){
        x_b = x_b * (n - i) % MOD;
        y_b = y_b * (i + 1) % MOD;
    }
    sum = sum - x_a * mod_inv(y_a, MOD) % MOD - x_b * mod_inv(y_b, MOD) % MOD + 2 * MOD;
    sum %= MOD;
    cout << sum;
}

/*⠀⠀⠀⠀⠀⢀⣀⣀⣀    
⠀⠀⠀⠰⡿⠿⠛⠛⠻⠿⣷
⠀⠀⠀⠀⠀⠀⣀⣄⡀⠀⠀⠀⠀⢀⣀⣀⣤⣄⣀⡀
⠀⠀⠀⠀⠀⢸⣿⣿⣷⠀⠀⠀⠀⠛⠛⣿⣿⣿⡛⠿⠷
⠀⠀⠀⠀⠀⠘⠿⠿⠋⠀⠀⠀⠀⠀⠀⣿⣿⣿⠇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠁

⠀⠀⠀⠀⣿⣷⣄⠀⢶⣶⣷⣶⣶⣤⣀
⠀⠀⠀⠀⣿⣿⣿⠀⠀⠀⠀⠀⠈⠙⠻⠗
⠀⠀⠀⣰⣿⣿⣿⠀⠀⠀⠀⢀⣀⣠⣤⣴⣶⡄
⠀⣠⣾⣿⣿⣿⣥⣶⣶⣿⣿⣿⣿⣿⠿⠿⠛⠃
⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡁
⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁
⠀⠀⠛⢿⣿⣿⣿⣿⣿⣿⡿⠟
⠀⠀⠀⠀⠀⠉⠉⠉
*/

//library//
ll mod_fact(ll a, ll mod){
    ll ans = 1;
    while(a > 1){
        ans = ans * a % mod;
        a--;
    }
    return ans; 
}
ll mod_pow(ll a, ll b, ll mod){
    ll ans = 1;
    while(b > 0){
        if(b & 1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod - 2, mod);
}
ll gcd(ll a, ll b){
    while(a % b){
        return gcd(b, a % b);
    }
    return b;
}
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}


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

int main(){
  int n;
  cin >> n;
  
  if(n==7){
    cout << "YES" << endl;
  }else if(n==5){
    cout << "YES" << endl;
  }else if(n==3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256