akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> dw(N, 0);
    vector<int> de(N, 0);
    for (int i = 0; i < N-1; i++){
	if (s[i] == 'W'){
	    dw[i+1] = dw[i]+1;
	} else {
	    dw[i+1] = dw[i];
	}
    }
    for (int i = N-1; i > 0; i--){
	if (s[i] == 'E'){
	    de[i-1] = de[i]+1;
	} else {
	    de[i-1] = de[i];
	}
    }

    int res = 100000000;
    for (int i = 0; i < N; i++){
	int x = dw[i]+de[i];
	res = min(res, x);
    }

    cout << res << endl;

    return 0;
}


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


int main() {
    ll n; cin >> n;
    vector<pair<ll,ll>> c(n,pair<ll,ll>(0,0));
    rep(i,n) cin >> c.at(i).second >> c.at(i).first;
    
    sort(c.begin(),c.end());
    ll sum=0;
    rep(i,n){
        sum += c[i].second;
        if(sum>c[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <boost/algorithm/string/replace.hpp>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n)                                                             \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define LIST(a, n)                                                             \
  for (int i = 0; i < n; i++)                                                  \
    cout << "[" << i << "] " << a[i] << endl;

int main() {
  // input
  int N;
  IN(N);
  int H[N];
  PACK(H, N);

  if (N == 1) {
    OUT("Yes");
    return 0;
  }

  if (N == 2) {
    if (H[1] - H[0] < -1) {
      OUT("No");
    } else {
      OUT("Yes");
    }
    return 0;
  }

  // calculation
  int X[N - 1];
  int gap = 0;
  for (int i = 0; i < N - 1; i++) {
    X[i - gap] = H[i + 1] - H[i];
    if (X[i - gap] < -1) {
      OUT("No");
      return 0;
    } else if (X[i - gap] == 0) {
      gap += 1;
    }
  }

  for (int i = N - 1 - gap; i < N - 1; i++) {
    X[i] = 100001;
  }

  // LIST(X, N - 1);

  for (int i = 0; i < N - 1; i++) {
    if (X[i] < 0 && X[i + 1] < 0) {
      OUT("No");
      return 0;
    }
  }

  OUT("Yes");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n;
    string s;
    cin>>s;
    n=s.size();
    rep(i,n){
        cout<<"x";
    }
}

Measured memory_bytes: 3624
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <ctime>
#include <bitset>
#include <string>
#include <cstdio>
#include <vector>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 100000 + 100;
int A, B, C, X, Y;

void work() {
    cin >> A >> B >> C >> X >> Y;
    long long Ret = 1000000000000LL;
    for (int i = 0; i <= 200000; i += 2) {
        long long S = C * i;
        if (i / 2 < X) S += (X - i / 2) * A;
        if (i / 2 < Y) S += (Y - i / 2) * B;
        Ret = min(Ret, S);
    }
    cout << Ret << endl;
}

int main() {
    int TestCase = 1;
    //scanf("%d", &TestCase);
    while (TestCase --) {
        work();
    }
    return 0;
}


Measured memory_bytes: 384
a = input().split()
b = input().split()
c = input().split()
list_ans =(a,b,c)
N = int(input())
bingo_list=[]

for i in range(N):
    bingo = input()
    bingo_list.append(bingo)


#横ビンゴ判定
def bingo_row(p,q):
    row_total= 0
    #p 横のリスト　q 出た値のリスト
    for i in range(3):
        if p[i] in q:
            row_total +=1
        else:
            return False
    if row_total == 3:
        return True
#縦ビンゴ判定
def bingo_column(p,q,r,s):
    batu = 0
    #pqr横リスト　s bingo_list
    for i in range(3):
        
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
                break
            else:
                batu +=1 
        else:
            batu +=1
    if batu == 3:
        return False
#斜めビンゴ判定
def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2] in s:
            return True
        elif p[2] in s and r[0] in s:
            return True
        else:
            return False
    else:
        return False

    
total = 0
for i in list_ans:
    if bingo_row(i, bingo_list):
        print('Yes')
        break
    elif bingo_column(a,b,c,bingo_list):
        print('Yes')
        break
    elif bingo_slash(a,b,c,bingo_list):
        print('Yes')
        break
    else:
        total += 1
if total == 3:
    print('No')
                    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int K, X;
  cin >> K >>X;
  
  //vector<int> p(N); 
  cout<<((K * 500 >= X)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <set>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

class Unionfind{
    public:
    vector<int> par,rank;

    Unionfind(){

    }
    Unionfind(int n){
        init(n);
    }

    void init(int n){
        par.resize(n);
        rank.resize(n);
        rep(i,n){
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void unite(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;
    set<int> st;
    cin >> n >> m;
    Unionfind uf(n);

    int x,y,z;
    rep(i,m){
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x,y);
    }
    rep(i,n){
        st.insert(uf.find(i));
    }
    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,M,R,ANS=INF,rr;
    cin>>N>>M>>R;
    ll r[R],A[M],B[M],C[M];
    vector<vector<ll>> ans(N,vector<ll> (N,INF));
    for(ll i=0;i<R;i++) cin>>r[i];
    for(ll i=0;i<M;i++){
        cin>>A[i]>>B[i]>>C[i];
        ans[A[i]-1][B[i]-1]=C[i];
        ans[B[i]-1][A[i]-1]=C[i];
    }
    for(ll k=0;k<N;k++){
        for(ll i=0;i<N;i++){
            for(ll j=0;j<N;j++){
                chmin(ans[i][j],ans[i][k]+ans[k][j]);
            }
        }
    }
    
    sort(r,r+R);
    do{
        ll kotae=0;
        for(ll i=0;i<R-1;i++){
            kotae+=ans[r[i]-1][r[i+1]-1];
        }
        chmin(ANS,kotae);
    }while(next_permutation(r,r+R));
    cout<<ANS<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
using ll = long long;
ll M = 1e9 + 7;
ll C[1001][1001];

int main() {
  int N, K;
  cin >> N >> K;
  for (int n = 0; n <= K; ++n)
    C[n][0] = 1;
  for (int k = 1; k <= N; ++k)
    for (int n = k; n <= K; ++n)
      C[n][k] = (C[n - 1][k - 1] + C[n - 1][k]) % M;
  ll F = 1;
  for (int i = 1; i <= N; ++i)
    F = (F * i) % M;
  cout << ((F * C[K][N]) % M) << endl;
}


Measured memory_bytes: 9984
S = input()
if((S[-1] == '2') or (S[-1] == '4') or (S[-1] == '5') or (S[-1] == '7') or (S[-1] == '9')) :
  print("hon")
elif((S[-1] == '0') or (S[-1] == '1') or (S[-1] == '6') or (S[-1] == '8')) :
  print("pon")
else :
  print("bon")

Measured memory_bytes: 9008
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  if (s[0] == '3') {
    cout << "bon\n";
    return 0;
  }
  if (s[0] == '0' || s[0] == '1' || s[0] == '6' || s[0] == '8') {
    cout << "pon\n";
    return 0;
  }
  cout << "hon\n";
  return 0;
}


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

int main(void) {
  long long int X;
  long long int year = 0;

  long long int money = 100;

  scanf("%lld",&X);

  while(money < X){
    money += (money / 100);
    year++;
  }

    printf("%lld\n",year);

  return 0;
}


Measured memory_bytes: 1728
/*input
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#include <tuple>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 2e5+100;
typedef long long int lld;
typedef long long ll;

#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }


#define popcount __builtin_popcountll

ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

pair<ll,ll> intersection(ll a,ll b,ll c,ll d) {
    // Error(a,b,c,d);
    if(b<c or d<a) return make_pair(-1,-1);
    return make_pair(max(a,c),min(b,d));
}


vector<ll> V;
ll Array[lim], C[lim];

int main(){

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

    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>Array[i];
        if(i>k) {
            if(Array[i]>Array[i-k]) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5224
def recording(N: int, C: int, info: list) -> int:
    _, max_time, _ = max(info, key=lambda x: x[1])
    max_time = 2*max_time

    # 各チャンネルでのレコーダーの使用数を累積和として求める。
    # cum が累積和であり、S-0.5 を配列で表すために 2*(10**5)
    # のサイズにしている。
    cum = [[0] * C for _ in range(max_time + 1)]

    # スタート時間を +1 、終了時間を -1 とすることで、あとで
    # 累積和をとるときに、録画している時間帯が 1 、していない
    # 時間が 0 になるようにできる。
    for s, t, ch in info:
        cum[2*s-1][ch-1] += 1
        cum[2*t][ch-1] -= 1

    # 累積和をとる。
    for t in range(max_time):
        for ch in range(C):
            cum[t+1][ch] += cum[t][ch]

    # 各時間帯でのレコーダーの使用台数の最大値をとる。
    return max(sum(used > 0 for used in cum[t]) for t in range(max_time+1))


if __name__ == "__main__":
    N = 0
    N, C = map(int, input().split())
    info = [tuple(map(int, input().split())) for _ in range(N)]
    ans = recording(N, C, info)
    print(ans)


Measured memory_bytes: 81556
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;
long double arr[maxn];
int main(){
	migmig;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	for(int i=1;i<n;i++){
		arr[i]=arr[i-1]+arr[i];
		arr[i]/=2;
	}
	cout<<arr[n-1];
	return 0;
}



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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}

int main(void) 
{	
	int r, g, b, n; cin>> r >> g >> b >> n;
	
	int cont = 0;
	rep(x, 0, 3000){
		rep(y,0,3000){
			int z = (n - x*(r) - y*(g))/ b;
			
			if(z >= 0 && x*r + y*g + z*b == n)
				cont++;
		}
	}
	cout<<cont;
	return 0;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main(){
    int n;
    while(cin>>n){
        int dp[3][n];
        memset(dp, 0, sizeof dp);

        vvi act(3, vi(n));

        int a,b,c;
        for(int i=0; i<n; i++){
            cin>>act[0][i]>>act[1][i]>>act[2][i];
        }

        for(int i=0; i<3; i++)
            dp[i][0] = act[i][0];

        // for(int i=1; i<n; i++){
        //     for(int ac=0; ac<3; ac++){
        //         if(ac==0)
        //             dp[ac][i] = act[ac][i] + max(dp[1][i-1], dp[2][i-1]);
        //         else if(ac==1)
        //             dp[ac][i] = act[ac][i] + max(dp[0][i-1], dp[2][i-1]);
        //         else if(ac=2)
        //             dp[ac][i] = act[ac][i] + max(dp[0][i-1], dp[1][i-1]);
        //     }
        // }

        for(int i=1; i<n; i++){ //i: day
            for(int ac = 0; ac<3; ac++){ //ac: activity
                for(int oac = 0; oac <3; oac++){ //oac: other activity
                    if(ac!=oac){
                        dp[ac][i] = max(dp[ac][i], act[ac][i] + dp[oac][i-1]);
                    }
                }
            }
        }

        cout<<max({dp[0][n-1], dp[1][n-1], dp[2][n-1]})<<endl;
    }
    return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int r = 0;
		int D = 0;
		int x = 0;
		String s;
		Scanner sc = new Scanner(System.in);
		r = Integer.parseInt(sc.next());
		D = Integer.parseInt(sc.next());
		x = Integer.parseInt(sc.next());
		int i;
		for(i=0;i<10;i++){
			x=r*x-D;
			System.out.println(x);
		}

	}

}


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

/*#### modular_arithmetic */
class modular_arithmetic{
public:
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	void set_mod(int _mod){mod = _mod;}
	int add(int x,int y){return (x+y)%mod;}
	int sub(int x,int y){return (x-y+mod)%mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int sqr(int x){return mul(x,x);}

};
/*####*/
modular_arithmetic ma;

#define ran 101111
int s,t,n;
long long int ds[ran], dt[ran];
int cs[ran],ct[ran];
vector<pair<int,int> > e[ran];

void dij(int x,long long int*d,int*c){
	priority_queue<pair<long long int,int> > q;
	for(int i=1; i<=n; i++)d[i] = -1;
	d[x] = 0;
	c[x] = 1;
	q.push(make_pair(0LL, x));
	while(!q.empty()){
		x = q.top().second;
		long long int dis = -q.top().first;
		q.pop();
		if(dis != d[x])continue;
		for(auto p : e[x]){
			int y = p.first, z = p.second;
			if(d[y] == -1 || d[y] > d[x] + z){
				d[y] = d[x] + z;
				c[y] = c[x];
				q.push(make_pair(-d[y], y));
			}else
			if(d[y] == d[x] + z){
				c[y] = ma.add(c[y], c[x]);
			}
		}
	}
}

int main(){
	int m;
	scanf("%d%d%d%d",&n,&m,&s,&t);
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,z));
	}
	dij(s,ds,cs);
	dij(t,dt,ct);
	int res = ma.sqr(cs[t]);
	for(int i=1; i<=n; i++){
		if(ds[t] == ds[i] + dt[i] && ds[i] == dt[i]){
			res = ma.sub(res, ma.sqr(ma.mul(cs[i], ct[i])));
		}
		for(auto p : e[i]){
			int x = i, y = p.first, z = p.second;
			if(ds[t] == ds[x] + z + dt[y] && max(ds[x], dt[y]) < min(ds[x] + z, dt[y] + z)){
				res = ma.sub(res, ma.sqr(ma.mul(cs[x], ct[y])));
			}
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 14420
#include <iostream>
#include <math.h>
#include <map>
using namespace std;
map<int ,bool >q;
int main(int argc, char** argv) {
	int n;
	while(scanf("%d",&n)!=EOF)
	{int ans=0;
	 q.clear();
     for(int i=1;i<=n;i++)
      {int a;
       scanf("%d",&a);
       if(q[a])
        {ans--;
         q[a]=false; 
        } 
       else
       {
        q[a]=true;
        ans++;
       }
      }
      printf("%d\n",ans);
    }
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	
	n *= 2;
	int a[210];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	sort(a, a + n);
	
	long long ans = 0;
	for (int i = 0; i < n; i += 2) {
		int x = a[i];
		int y = a[i + 1];
		
		ans += x;
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


const int MAX_N = 100000;
vector<int> prime(MAX_N);
vector<bool> is_prime(MAX_N+1, true);
vector<int> like2017(MAX_N, 0);

void sieve(){
  int p=0;
  is_prime[0] = is_prime[1] = false;
  for (int i=2; i<=MAX_N; i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j=2*i; j<=MAX_N; j+=i) is_prime[j] = false;
    }
  }
}

bool is_2017like(int n){
  // nは2017に似た数か？
  if (n % 2 == 0) return false;
  if (is_prime[n] && is_prime[(n+1)/2]) return true;
  return false;
}

int main() {
  sieve();
  rep(i, MAX_N){
    int buf = is_2017like(i+1);
    like2017[i+1] = like2017[i] + buf;
  }
  int q; cin >>q;
  rep(qq, q){
    int l,r; cin >>l >>r; l--;
    cout <<like2017[r]-like2017[l] <<endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int x, y, smaller, bigger;

int main(){

	while (true){

		cin >> x >> y;

		if (x == 0 & y == 0){
			break;
		}

		if (x > y){

			bigger = x;
			smaller = y;
		}
		else{
			bigger = y;
			smaller = x;
		}

		cout << smaller << " " << bigger << endl;
	}

	return 0;
}






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

int main()
{
    int n;
    cin >> n;
    string s[n];
    vector<int> v(4, 0);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (s[i] == "AC") v[0]++;
        if (s[i] == "WA") v[1]++;
        if (s[i] == "TLE") v[2]++;
        if (s[i] == "RE") v[3]++;
    }
    cout << "AC x " << v[0] << "\n";
    cout << "WA x " << v[1] << "\n";
    cout << "TLE x " << v[2] << "\n";
    cout << "RE x " << v[3] << "\n";
    return 0;
}


Measured memory_bytes: 6752
import itertools
N = int(input())
N_str = []
for i in range(N):
    N_str.append(i+1)
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
a = sorted(list(itertools.permutations(N_str)))
for i in range(len(a)):
    if(P == a[i]):
        cnt_P = i
    if(Q == a[i]):
        cnt_Q = i
print(abs(cnt_Q-cnt_P))

Measured memory_bytes: 8308
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  long double T, A;
  cin >> N >> T >> A;
  vector<ll> H(N);
  vector<long double> C(N);
  int ans;
  long double min_res = 1000000.0;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
    C[i] = T - 0.006 * H[i];
    if (abs(C[i] - A) < min_res) {
      min_res = abs(C[i] - A);
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {

    int N;
    cin >> N;

    map<string, int> JudgeResult;
    JudgeResult["AC"] = 0;
    JudgeResult["WA"] = 0;
    JudgeResult["TLE"] = 0;
    JudgeResult["RE"] = 0;

    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        JudgeResult[S] += 1;
    }

    cout << "AC x " << JudgeResult["AC"] << '\n';
    cout << "WA x " << JudgeResult["WA"] << '\n';
    cout << "TLE x " << JudgeResult["TLE"] << '\n';
    cout << "RE x " << JudgeResult["RE"] << '\n';

}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    string s;
    cin>>s;
    int f[10],b[10]={};
    vector<vector<int>> mid(10);
    REP(i,10) f[i]=N;
    REP(i,N){
        f[s[i]-'0']=min(f[s[i]-'0'],i);
        mid[s[i]-'0'].push_back(i);
        b[s[i]-'0']=i;
    }
    int ans=0;
    REP(i,10) REP(j,10) REP(k,10){
        auto m=upper_bound(All(mid[j]),f[i]);
        if(m!=mid[j].end()&&*m<b[k]) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans=0;
    ans=a*c;
    if (ans<a*d) ans=a*d;
    if (ans<b*c) ans=b*c;
    if (ans<b*d) ans=b*d;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 3e5 + 10;
using namespace std;

int n, m, T, kase = 1;
int a[100], arr[maxn];

bool add(ll x) {
	bool flag = true;
	int t = 0;
	for( ; x; x >>= 1) {
		t++;
		if((x & 1) == 0) continue;
		a[t]++;
		if(a[t] > 1) flag = false;
	}
	return flag;
}

bool del(ll x) {
	bool flag = true;
	int t = 0;
	for( ; x; x >>= 1) {
		t++;
		if((x & 1) == 0) continue;
		a[t]--;
		if(a[t] > 1) flag = false;
	}
	for(int i = 0; i < 25; i++) if(a[i] > 1) return false;
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	ll ans = 0;
	int j = 1;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
		bool flag = add(arr[i]);
		while(!flag) {
			ans += i - j;
			flag = del(arr[j]);
			j++;
		}
	}
	while(j <= n) { ans += n + 1 - j; j++; }
	cout << ans << endl;
	return 0;
}

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

int main() {
  string c;
  std::cin >> c;
  if (c=="a" || c=="e" || c=="i" || c=="o" || c=="u") {
    /* code */std::cout << "vowel" << '\n';
  }
  
  else{
    std::cout << "consonant" << '\n';
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> B(N);
	for (int i = 0; i < N - 1; i++) {
		cin >> B[i];
	}
	long long int sum = 0;
	sum += B[0] + B[N - 2];
	for (int i = 0; i < N - 1; i++) {
		sum += min(B[i], B[i + 1]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 2e5 + 5;

int n,k,a[N];

bool check(int x){
	int cnt=0;
	for(int i=1;i<=n;i++){
		cnt+=(a[i]-1)/x;
	}
	return cnt<=k;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
   	cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    int L=1,R=1e9,mid;
    while(L<R){
    	mid=(L+R)/2;
    	if(check(mid))
    		R=mid;
    	else
    		L=mid+1;
    }
    cout<<R<<'\n';
    return 0;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
map<ll, ll> m;

int main(){
    cin >> n;
    rep(i,n) {
        ll a; cin >> a;
        m[a]++;
    }
    ll pre = 0;
    ll ans = 0;
    for(auto it = m.begin(); it != m.end(); it++) {
        if((*it).second >= 2) {
            ans = pre*(*it).first;
            pre = (*it).first;
        }
        if((*it).second >= 4) {
            ans = pre*pre;
        }
    }
    cout << ans << endl;
}
































Measured memory_bytes: 6528
N = gets.to_i
sa = N.times.map{ gets.chomp.chars.sort }.sort_by{|v| v.size}
sample = sa.first.clone
r = []
sample.each{|c|
  if sa.all?{|s| s.include?(c)}
    r << c
    sa.each{|s|
      s.delete_at(s.index(c))
    }
  end
}
puts r.join


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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {

   ll n;
   cin >>n;

   vector<ll> a(n+2);
   repn(i,n+1)cin >>a[i];

   map<ll,ll> mp;
   ll b;

    repn(i,n+1){
       mp[a[i]]++;
       if(mp[a[i]]==2){b=i;}
   }

   ll c;
   repn(i,n+1){
       if(a[i]==a[b]){c=i; break;}
   }

    COMinit();

    repn(i,n+1){
        ll ans=COM(n+1,i)-COM(c+n-b,i-1);
        ans=((ans%MOD)+MOD)%MOD;
        cout <<ans<<endl;
    }

 
	

}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int res = 0;
    for(int i=1;i<n-1;i++){
        int ma = max(a[i-1],max(a[i],a[i+1]));
        int mi = min(a[i-1],min(a[i],a[i+1]));
        if(a[i] != ma && a[i] != mi)res++;
    }
    cout << res << endl;
}


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

int main() {
  
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double kakudo;
  double kh,km,pi,unit;
  pi = 2.0 * asin(1.0); 
  unit  = pi / 180.0;
  kh = (h % 12)*30 + (double)m /2;
  km = (double)m * 6;
  
  if(fabs(kh - km) < 180){
    kakudo = fabs(kh - km) * unit;
    cout << setprecision(12) << sqrt(a *a +b * b - 2.000000000000000 * a * b * cos(kakudo)) << endl;
  }else if(fabs(kh - km) > 180){
    kakudo = (360 - fabs(kh - km)) * unit;
    cout << setprecision(12) << sqrt(a *a +b * b - 2.000000000000000 * a * b * cos(kakudo)) << endl;
  }else{
    cout << setprecision(12) << a + b << endl;
  }
  
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, k;
    cin >> n >> k;
    vi h(n); 
    rep(i,n) cin >> h[i];
    int ans = 0;
    rep(i,n) {
        if(h[i] >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		int count5 = 0;
		int count7 = 0;

		for(int i=0; i<list.length; i++){
			if(list[i].equals("5")){
				count5 = count5 + 1;
			}else if(list[i].equals("7")){
				count7 = count7 + 1;
			}
		}

		if(count5 == 2 && count7 == 1){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 8148
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

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

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
   int n; cin>>n;
   int a[n],b[n];
   rep(i,0,n) cin>>a[i];
   rep(i,0,n) cin>>b[i];
   ll neg=0,ans=0;
   vi pos;
   rep(i,0,n)
   {
     if(a[i]<b[i]) neg+=a[i]-b[i],ans++;
     if(a[i]>b[i]) pos.pb(a[i]-b[i]);
   }
   sort(pos.rbegin(),pos.rend());
   int sz=pos.size();
   rep(i,0,sz)
   {
     if(neg>=0) break;
     neg+=pos[i],ans++;
   }
   if(neg<0) ans=-1;
   cout<<ans; 
}  
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

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

#define ff first
#define ss second
#define ll long long
#define pq priority_queue
#define mii map<int,int>

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;

int n;
ll mod = (1e9) + 7;
ll tb[22][1<<22];
int calc[22][1<<22];
int mat[22][22];

ll dp(int i, int mask) {
    if(mask == (1<<n)-1) return 1;
    if(calc[i][mask]) return tb[i][mask];

    ll ans = 0;
    for(int j = 0; j < n; j++)
    {
        if(mask & (1 << j)) continue;

        if(mat[i][j]) ans += dp(i+1, mask | (1<<j)) ;
    }
    calc[i][mask] = 1;
    tb[i][mask] = ans%mod;
    return ans%mod;
}

int main() {
    cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            scanf("%d", &mat[i][j]);
        }
    }
    printf("%lld\n", dp(0, 0));

    
    return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int N;
    scanf("%d",&N);

    long name[5]={0};
    char c[6]="MARCH";

    for(int i=0;i<N;i++){
        char S[11];
        scanf("%s",S);
        for(int j=0;j<5;j++){
            if(S[0]==c[j]) name[j]++;
        }
    }

    long ans=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++) ans+=name[i]*name[j]*name[k];
        }
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
#include <string>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double l; cin >> l;
    double ans=l*l*l/3.0/3.0/3.0;
    printf("%.8f\n",ans);
}


Measured memory_bytes: 256
from collections import defaultdict, deque


def main():
    N, M = map(int, input().split())
    adj = defaultdict(lambda: defaultdict(lambda: 0))
    for _ in range(M):
        l, r, d = map(int, input().split())
        adj[l][r] = d
        adj[r][l] = -d
    q = deque()
    while len(adj.keys()):
        k = list(adj.keys())[0]
        pos = {k: 0}
        q.append((k, 0))
        while len(q):
            i, x = q.popleft()
            for j in adj[i]:
                if j in pos and pos[j] != x + adj[i][j]:
                    print("No")
                    return
                pos[j] = x + adj[i][j]
                q.append((j, pos[j]))
                del adj[j][i]
            del adj[i]
    print("Yes")


if __name__ == "__main__":
    main()


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

using PP = pair<long, long>;

int n, k;
PP p[100000];
vector<int> v[100000];
int used[100000];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    p[i] = PP(a, b);
    v[a].push_back(b);
  }
  
  sort(p, p + n, [](PP a, PP b) { return a.second > b.second; });
  for (int j = 0; j < n; ++j) {
    sort(v[j].begin(), v[j].end(), greater<int>());
  }
  
  long sum = 0;
  for (int i = 0; i < k; ++i) {
    sum += p[i].second;
    ++used[p[i].first];
  }
  
  long cnt = 0;
  for (int j = 0; j < n; ++j) {
    cnt += used[j] > 0;
  }
  
  vector<int> rem;
  for (int j = 0; j < n; ++j) {
    if (used[j]) continue;
    if (v[j].empty()) continue;
    rem.push_back(v[j].front());
  }
  sort(rem.begin(), rem.end(), greater<int>());
  
  long mx = sum + cnt * cnt;
  int idx = 0;
  for (int i = k - 1; i >= 0; --i) {
    if (idx >= rem.size()) break;
    int a = p[i].first;
    int b = p[i].second;
    if (used[a] == 1) continue;
    --used[a];
    
    sum -= b;
    sum += rem[idx];
    ++cnt;
    ++idx;
    mx = max(mx, sum + cnt * cnt);
  }
  cout << mx << endl;
}

Measured memory_bytes: 8064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
    n: usize,
    a: usize,
    }
    let mut n = n;
    n %= 500;
    let ans = if n <= a {"Yes"} else { "No"};
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
 
int main(void) {
int m,f,r;
 
while (1) {
scanf("%d %d %d", &m, &f, &r);
if (m == -1 && f == -1 && r == -1) break;
if (m == -1 || f == -1) printf("F\n");
else if (m+f >= 80) printf("A\n");
else if (m+f >= 65) printf("B\n");
else if (m+f >= 50) printf("C\n");
else if (m+f >= 30) {
if (r >= 50) printf("C\n");
else printf("D\n");
}
else printf("F\n");
}
 
return (0);
}

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

int N;
string s;
int main()
{
    cin >> N;
    int l = 0, r = N - 1;
    cout << 0 << endl;
    fflush(stdout);

    int sex;
    cin >> s;
    if(s == "Vacant")
        return 0;
    sex = (s == "Male" ? 0 : 1);

    while(l < r) {
        int m = (l + r + 1) / 2;
        cout << m << endl;
        fflush(stdout);
        cin >> s;
        if(s == "Vacant")
            return 0;
        int x = (s == "Male" ? 0 : 1);
        if((m - l) % 2 != abs(x - sex)) {
            r = m - 1;
        } else {
            l = m;
            sex = x; 
        }
    }
    return 0;
}


Measured memory_bytes: 852
#include <stdio.h>

#include <stdlib.h>


int main() {
	int n, i, j, flag, numbers, count = 0;

	scanf("%d", &numbers);

	for (j = 0; j != numbers; j++) {
		scanf("%d", &n);
		flag = 0;

		for (i = 2; i*i <= n; ++i) {

			// condition for non-prime
			if (n % i == 0) {
				flag = 1;
				break;
			}
		}

		if (n == 1) {
			count++;
		}
		if (flag == 0) {
			count++;
		}
	}

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



Measured memory_bytes: 2088
def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0

    for i in range(N - 1):
        for j in range(N-1, i, -1):
            if A[j - 1] > A[j]:
                A[j - 1], A[j] = A[j], A[j - 1]
                ans += 1

    print(" ".join(list(map(str, A))))
    print(ans)

main()


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d;
ll sum;

ll gcd(ll a,ll b)
{
   return b==0?a:gcd(b,a%b);
}
int main()
{
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    ll t=c/gcd(c,d)*d;
    ll x=(a-1)/c;
    ll y=(a-1)/d;
    ll z=(a-1)/t;
    ll x2=b/c;
    ll y2=b/d;
    ll z2=b/t;
    ll ans=b-(x2+y2-z2)-(a-1-(x+y-z));
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


bool solve(string s){
	char bef=s[0];
	for(int i=1;i<(int)s.size();i++){
		if(s[i]=='A')if( bef!='B' && bef!='D' )return false;
		if(s[i]=='B')if( bef!='A' && bef!='C' && bef!='E' )return false;
		if(s[i]=='C')if( bef!='B' && bef!='F' )return false;
		if(s[i]=='D')if( bef!='A' && bef!='E' && bef!='G' )return false;
		if(s[i]=='E')if( bef!='B' && bef!='D' && bef!='F' && bef!='H' )return false;
		if(s[i]=='F')if( bef!='C' && bef!='E' && bef!='I' )return false;
		if(s[i]=='G')if( bef!='D' && bef!='H' )return false;
		if(s[i]=='H')if( bef!='E' && bef!='G' && bef!='I' )return false;
		if(s[i]=='I')if( bef!='F' && bef!='H' )return false;
		bef=s[i];
	}
	return true;
}

int main(){
	rep(i,1000){
		string s;
		cin>>s;
		if( solve(s) )cout<<s<<endl;
	}
	return 0;

}

Measured memory_bytes: 1188
#include <iostream>
    #include <vector>
    #include <algorithm>
    #define SIZE 30
    using std::vector;
    using namespace std;
     
     
    int main() {
        std::cin.tie(0);std::ios::sync_with_stdio(false);
    	int a,b,c;
    	cin >> a >> b >> c;
    	if (a<=c && b>=c){
    		cout << "Yes" ;
    	}else {
    		cout << "No" ;
    	}
    return 0;
     
    }

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10 ** 6)

def main():
    n = int(input())
    adj_list = [[] for i in range(n)]
    for i in range(n - 1):
        a1, b1 = map(int, sys.stdin.readline().split())
        adj_list[a1 - 1].append(b1 - 1)
        adj_list[b1 - 1].append(a1 - 1)
    path = list(reversed(dfs(0, -1, adj_list, n)))
    assert len(path) >= 2
    fpath = len(path) - len(path) // 2
    cut = set(path[fpath - 1:fpath + 1])
    f = dfs2(0, -1, adj_list, n, cut)
    s = dfs2(n - 1, -1, adj_list, n, cut)
    assert f + s == n
    print("Fennec" if f > s else "Snuke")

def dfs(now, prev, adj_list, n):
    if now == n - 1:
        return [now]
    for next in adj_list[now]:
        if next == prev:
            continue
        p = dfs(next, now, adj_list, n)
        if p is not None:
            p.append(now)
            return p

def dfs2(now, prev, adj_list, n, cut):
    size = 1
    for next in adj_list[now]:
        if next == prev:
            continue
        if {now, next} == cut:
            continue
        s = dfs2(next, now, adj_list, n, cut)
        size += s
    return size

if __name__ == "__main__":
    main()


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  string s;
  cin >> s;
  int ans=700;
  REP(i,3)if(s.at(i)=='o')ans+=100;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	string s;
	cin >> s;
	for (int i = 0; i < N; i++) {
		if (s[i] > '9' || s[i] < '0') {
			cout << "No\n";
			return 0;
		}
	}
	if (s[N] != '-') {
		cout << "No\n";
		return 0;
	}
	for (int i = N + 1; i < 1 + N + M; i++) {
		if (s[i] > '9' || s[i] < '0') {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

int main(){
    string s;
    cin >> s;

    int cnt = 0,ans = 0;
    for (auto c : s){
        if (c == 'A' || c == 'G' || c == 'C' || c == 'T'){
            cnt++;
        }
        else {
            cnt = 0;
        }
        ans = max(ans,cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> py(m);
  for(int i=0;i<m;i++){
    cin >> py.at(i).first;
    cin >> py.at(i).second;
  }
  vector<vector<int>> ct_list(n+1,vector<int>(0));
  for(int i=0;i<m;i++){
    ct_list.at(py.at(i).first).push_back(py.at(i).second);
  }
  for(int i=0;i<n+1;i++){
    sort(ct_list.at(i).begin(),ct_list.at(i).end());
  }
  for(int i=0;i<m;i++){
    printf("%06d%06d\n",py.at(i).first,lower_bound(ct_list.at(py.at(i).first).begin(),ct_list.at(py.at(i).first).end(),py.at(i).second)-ct_list.at(py.at(i).first).begin() + 1);
  }
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if (a<=0 && b>=0) return cout<<"Zero",0;
	b=min(b,-1);
	if (a>b || (b-a+1)%2==0) return cout<<"Positive",0;
	cout<<"Negative";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main ()
{
    int i,y,x,N,K,L,R,D,s1[100];
    scanf("%d",&N);//5 10 2// 3
    for(i=1;i<=N;i++)
    {
        scanf("%d",&s1[i]);
    }
    for(i=1,y=0;i<=N;i=i+2)//1 100 1
    {
        x=s1[i]*s1[i];
      if(x%2!=0)
      {
          y++;
      }
    }
    printf("%d\n",y);
    return 0;
}


Measured memory_bytes: 1720