akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MODNum 1000000007
#define WHITE  0
#define GRAY   1
#define BLACK  2
#define INFTY  2147483647
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, E, r;
    scanf("%lld %lld", &N, &E);
    r = 0;
    int u,v,k;
    //ll c[N][N];    /* 辺の重みを記録した隣接行列 */
    ll d[N];       /* 最短コストの記録 */
    priority_queue<pair<ll,ll>> pq;
    int p[N];       /* 最短経路木における頂点vの親 */
    int weight;
    vector< vector<pair<ll,ll>> > G(N);

    /* Initialization */
    for ( int i = 0; i < N; i++ ){
        d[i]     = INFTY;
        if ( r == i ){
            pq.push(make_pair(0,i));
            d[i] = 0;
        }
        else{
            pq.push(make_pair(-INFTY,i));
        }
        p[i]  =  -1;
        //for ( int j = 0; j < N; j++ ) c[i][j] = INFTY;
    }
    /* グラフを読み込み */
    for ( int i = 0; i < E; i++ ){
            scanf("%d %d", &u, &v);
            //c[u][v] = weight;
            weight = 1;
            u = u - 1;
            v = v - 1;
            G[u].push_back( make_pair(weight, v) );
            G[v].push_back( make_pair(weight, u) );
    }

    while ( !pq.empty() ){
        pair<ll,ll> edgepair  =  pq.top();
        pq.pop();
        u                       =  edgepair.second;
        if ( d[u] < -edgepair.first ) continue;
        //for ( v = 0; v < N; v++ ){
            for ( auto& e:G[u])
          //  if ( c[u][v] != INFTY ){
                if ( d[e.second]    > d[u] + e.first ){
                    d[e.second]     = d[u] + e.first;
                    p[e.second]     = u + 1;
                    pq.push(make_pair(-d[e.second],e.second));
                }
            //}
        //}
    }
    /*
    for ( int i = 0; i < N; i++ ){
        if ( d[i] != INFTY )
            printf("%d\n", d[i]);
        else printf("INF\n");
    }*/
    printf("Yes\n");
    for ( int i = 1; i < N; i++ ) cout << p[i] << endl;
    return 0;
}

Measured memory_bytes: 20768
#include<stdio.h>
    #include<string.h>
    int main()
    {
      char s[10000];
      scanf(" %[^\n]",s);
      printf("%c",s[0]);
      for(int i=0;i<strlen(s);i++){
        if(s[i]==' '){
            printf("%c",s[i+1]);
        }
      }

        return 0;
    }


Measured memory_bytes: 1652
#include <iostream>
#include <string.h>
#include <iomanip>
using namespace std;

int main()
{	
	int n;

	cin >> n;

	while (n > 0) {
		int a[15][15];

		memset(a, 0, sizeof(a));

		int p = n / 2 + 1, q = n / 2;

		a[p][q] = 1;

		for (int i = 2; i <= n * n; i++) {
			p = (p + 1) % n;
			q = (q + 1) % n;

			if(a[p][q] == 0)
				a[p][q] = i;
			else {
				p = (p + 1) % n;
				q = (q + n - 1) % n;
				a[p][q] = i;
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				cout << setw(4) << a[i][j];
			cout << endl;
		}

		cin >> n;
	}

	return 0;
}



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

int solve(int k, const vector< int >&bam, const vector< int >&dan) {
    int ans = INT_MAX;
    for (int i = 0; i <= bam.size() && i <= k; i++) {
        int j = k-i;
        if (j <= dan.size()) {
            int tmp = 0;
            if (i > 0) tmp += 2*bam[i-1];
            if (j > 0) tmp += dan[j-1];
            ans = min(ans, tmp);
        }
    }
    return ans;
}

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

    vector< int >side1;
    vector< int >side2;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < 0)      side1.push_back(-x);
        else if (x > 0) side2.push_back(x);
        else k--;
    }

    reverse(side1.begin(), side1.end());
    cout << min(solve(k, side1, side2), solve(k, side2, side1)) << "\n";


    return 0;
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200010;
int K,N;
int A[maxn];
int main(void)
{
    cin>>K>>N;
    int d = -1;
    for(int i = 1;i <=N;i ++)
    {
        cin>>A[i];
        if(i>1)
            d = max(d,A[i]-A[i-1]);
    }
    d = max(d,K-A[N]+A[1]);
    cout<<K-d<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb emplace_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
 
#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif
 
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
 
ll pwr(ll a,ll b, ll mod){
    a %= mod;
   	ll ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
 
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
void debug1(int a[], int l,int r) {
	#ifdef LOCAL
		vector<int> temp(a + l, a + r + 1);
		debug(temp);
	#endif
}

const int N = 1e5 + 5;

int t[N][2];
int depth[N];

string s[N];

int cnt = 1;

void add(string s) {
	int cur = 1, d = 0;
	fr(i, 0, sz(s) - 1) {
		d++;
		if(!t[cur][s[i] - '0'])
			t[cur][s[i] - '0'] = ++cnt, depth[cnt] = d;
		cur = t[cur][s[i] - '0'];
	}
}

int gg(int x) {
	int val = x - (x & (x - 1));
	return val;
}

void solve(){
	int n, l;
	cin >> n >> l;
	fr(i, 1, n) {
		cin >> s[i];
		add(s[i]);
	}
	int ans = 0;
	fr(i, 1, cnt) {
		int cc = (t[i][0] > 0);
		cc += (t[i][1] > 0);
		if(cc == 1) {
			ans ^= gg(l - depth[i]);
		}
	}
	cout << ((ans) ? "Alice" : "Bob");
}

signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
} 

Measured memory_bytes: 3664
a, b ,c , k = list( map ( int , input().split() )) 
ans =0
ans += min( a , k ) 
k -= min(a, k)
if ( k == 0 ):
  print(ans)
  exit(0)
k-= min(b , k)
if k == 0 :
  print( ans)
  exit(0)
ans -= min( c, k ) 
print( ans)

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int dp[100001];
    fill_n(dp, 100001, 1e9);

    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    rep(i, n){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            if(i-j < 0) break;
            dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]), dp[i]);
        }
    }

    ppp(dp[n-1]);

    return 0;
}


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

const int N = 1e5 + 10;

int n;

int main() {
  cin >> n;
  for(int i = 1;;i++) {
    if(n <= (long long)i * (i + 1) / 2) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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

#define X first
#define Y second
#define mp make_pair
#define sz(v) (int) v.size()
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

/*#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
                         tree_order_statistics_node_update>;*/

void solve() {
	int k;
	cin >> k;
	queue<string> Q;
	unordered_map<string, bool> used;
	for (int i = 1; i <= 9; ++i) {
		Q.push(string(1, char('0' + i)));
		used[string(1, char('0' + i))] = true;
	}
	while (k > (int) Q.size()) {
		string v = Q.front();
		Q.pop();
		--k;
		int last = v.back() - '0';
		for (int nxt = max(0, last - 1); nxt <= min(9, last + 1); ++nxt) {
			v.push_back(char('0' + nxt));
			if (!used[v]) {
				used[v] = true;
				Q.push(v);
			}
			v.pop_back();
		}
	}
	for (int i = 0; i < k - 1; ++i) {
		Q.pop();
	}
	cout << Q.front() << "\n";
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int tt = 1;
	// cin >> tt;
	while (tt--) solve();
	return 0;
}


Measured memory_bytes: 12324
/*  Name: Abu Hurayra
    Handle: HurayraIIT
    Institute: IIT_JU   */

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef string S;
typedef double D;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;

#define pi acos(-1.0)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define Fin freopen("input.txt","r",stdin)
#define Fout freopen("output.txt","w",stdout)

int main()
{
	off;
    int n,d,i,j;
    cin >> n ;
    int a[n] , b[n] ;
    int m1=0 , m2=0;
    for(i=0;i<n;i++)
    {
        cin >> a[i] ;
        b[i] = a[i] ;
        //if(m1<a[i]) m1 = a[i];
        
        
    }
    sort(b,b+n);
    reverse(b,b+n);
    m1 = b[0];
    m2 = b[1] ;
    j=0;
    for(i=0;i<n;i++)
    {
        if(a[i]==m1) cout << m2 << endl;
        else cout << m1 << endl;
    }
    
    


	return 0;

}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N; cin >> N;
	if (N == 1) cout << "Hello World" << endl;
	else {
		int A, B; cin >> A >> B;
		cout << A + B << endl;
	}
}



Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
	map <char,bool> cnt;
    string s;cin>>s;
    int n=sz(s);
    for (int i=0;i<n;i++) cnt[s[i]]=true;
    if (n<26){
    	cout << s;
    	for (char c='a';c<='z';c++){
    		if (!cnt[c]){
    			cout << c << endl;
    			return;
    		}
    	}
    }
    else {
    	for (int i=25;i>=0;i--){
    		for (char c=s[i];c<='z';c++){
    			if (cnt[c]==false){
    				for (int j=0;j<i;j++)
    					cout << s[j] ; 
    				cout << c<< endl;
    				return;
    			}
    		}
    		cnt[s[i]]=false;
    	}
    }
    cout << -1 << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}



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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	vector<int> A(N);
	for (int i=0; i<N; ++i) {
		cin >> A.at(i);
	}
	
	int alt_sum = 0;
	for (int i=0; i<N; ++i) {
		if (i % 2 == 0) {
			alt_sum += A.at(i);
		} else {
			alt_sum -= A.at(i);
		}
	}
	
	vector<int> rain(N);
	for (int i=0; i<N; ++i) {
		if (i == 0) {
			rain.at(i) = alt_sum / 2;
		} else {
			rain.at(i) = A.at(i-1) - rain.at(i-1);
		}
	}
	
	for (int i=0; i<N; ++i) {
		if (i == N-1) {
			cout << 2 * rain.at(i) << endl;
		} else {
			cout << 2 * rain.at(i) << " ";
		}
	}
	
	return 0;
}

Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = ReadLine();
        var s = ReadLine();

        WriteLine(s.Count(x => x == 'R') > s.Length - s.Count(x => x == 'R') ? "Yes" : "No");


    }
}


Measured memory_bytes: 13268
import Control.Monad
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B

query :: Int -> [Int] -> Int
query m = sum . map ((\n -> (n * (n-1)) `div` 2)) . M.elems
  . foldl (\m i -> M.insertWith (+) i 1 m) M.empty
  . scanl' (\x y -> (x + y) `mod` m) 0 

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  ais <- unfoldr (B.readInt . B.dropWhile (==' ')) <$> B.getLine
  putStrLn $ show $ query m ais


Measured memory_bytes: 15740
#n = int(input())
n, m = map(int, input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
dic = {i: 0 for i in range(1, n+1)}
for i in range(m):
    a, b = map(int, input().split())
    dic[a] = dic[a]+1
    dic[b] = dic[b]+1

for i in range(1, n+1):
    print(dic[i])


Measured memory_bytes: 9160
n = int(input())
a = list(map(int,input().split()))
odd,even = 0,0
for i in a:
    if i % 2 == 0:
        even += 1
    else:
        odd += 1
even += odd // 2
odd %= 2
if odd == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 14108
#include <stdio.h>

int main() {
  int a[5];
  int min=10;
  int sum=0;
  scanf("%d\n",&a[0]);
   scanf("%d\n",&a[1]);
   scanf("%d\n",&a[2]);
   scanf("%d\n",&a[3]);
   scanf("%d\n",&a[4]);
  for(int i=0;i<5;i++){
    sum+=(a[i]%10)?(a[i]/10+1)*10 : a[i];
    if(a[i]%10&&a[i]%10<min) min=a[i]%10;
  }
  if(min<10) sum=sum-10+min;
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
//============================================================================
// Name        : abc100.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
using namespace std;

inline int func001() {

	int a, b;

	cin >> a >> b;

	if ((a <= 8) && (b <= 8)) {
		cout << "Yay!";
	} else {
		cout << ":(";
	}

	return 0;

}

inline int func002() {

	long long int d, n;

	cin >> d >> n;

	if (n == 100)
		n += 1;

	cout << n * (long long int)pow(100, d);

	return 0;

}

inline int func003() {

	int n;
	int a;
	int i, j;
	int res = 0;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a;
		for (j = 0; j < 31; j++) {
			if ((a & 0x1) == 0x1) {
				res += j;
				break;
			} else {
				a >>= 1;
			}
		}

	}

	cout << res;

	return 0;

}

inline int func004() {

	int n, m;
	int **a;
	int i, j;
	int res = 0;

	cin >> n;

	cout << res;

	return 0;

}

//#define TEST 1

int main() {

#ifdef TEST
	while (1)
#endif
		func002();

	return 0;
}


Measured memory_bytes: 256
while true
    numbers = gets.split.map(&:to_i)
    count = 0
    if numbers[0] == 0 && numbers[1] == 0
        break
    else
        (1..numbers[0]).each do |t|
            (1..t-1).each do |t_micro|
                (1..t_micro-1).each do |t_micro_2|
                    if t+t_micro+t_micro_2 == numbers[1]
                        count += 1
                    end
                end
            end
        end
    end
    puts count
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int H,W,A,B; cin >> H >> W >> A >> B;
    rep(i,H) {
        rep(j,W) {
            if (i < B) {
                cout << ((j < A) ? 0 : 1);
            } else {
                cout << ((j < A) ? 1 : 0);
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3676
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll longinf=1LL<<60;
const int mod=1000000007;    
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
  int n;cin>>n;
  int a[n],ma=0,mi=inf;
  rep(i,n){
    cin>>a[i];
    ma=max(ma,a[i]);
    mi=min(mi,a[i]);
    }
  if(ma-mi>1){
    cout<<"No"<<endl;
    return 0;
    }
  if(ma==mi){
    if (ma==n-1||ma<=n/2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
    }
  int cnt=0;
  rep(i,n){
    if(a[i]==mi)cnt++;
    }
  if(cnt<ma&&ma<=cnt+(n-cnt)/2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
  }
    
  
 
       

Measured memory_bytes: 640
a,b,c,d,e,f=map(int,input().split())
ans1,ans2=0,0
Wat,Salt=set(),set()
for i in range(f//(100*a)+1):
  for j in range(f//(100*b)+1):
    w=a*i*100+b*j*100
    if w<=f:
      Wat.add(w)
for i in range(f//c+1):
  for j in range(f//d+1):
    s=c*i+d*j
    if s<=f:
      Salt.add(s)
Wat=list(Wat)
Salt=list(Salt)
for i in Wat:
  for j in Salt:
    if i+j<=f and j*(100+e)<=e*(i+j) and j*ans1>=ans2*(i+j):
      ans1,ans2=i+j,j
print(ans1,ans2)

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

int main(){
    int n;
    
    while(1){
        cin >> n;
        if(n == 0) return 0;
        int a[n];
        for (int i = 0; i < n; i++) cin >> a[i];
        int goukei = 0;
        for(int i = 0; i < n; i++) goukei = goukei + a[i];
        int heikin = goukei / n;
        int ans=0;
        for(int i = 0; i < n; i++){
            if(a[i] <= heikin) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define M 1000000007
string s[1001];
int dp[1001][1001];


int main(){

        int n, m; cin >> n >> m;
        for(int i = 1; i <= n; i++){
                cin >> s[i];
                s[i] = '#' + s[i];
        }

        memset(dp, 0, sizeof dp);
        dp[1][1] = 1;
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        if(s[i][j] == '.'){
                                dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % M;
                        }
                }
        }

        cout << dp[n][m] << endl;



        return 0;
}


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

int main() {
	int n, m, x, y;
	scanf("%d%d%d%d", &n, &m, &x, &y);
	int ma = -1000;
	rep(i, n) {
		int a;
		scanf("%d", &a);
		ma = max(ma, a);
	}
	ma = max(x, ma);
	ma ++;
	rep(i, m) {
		int a;
		scanf("%d", &a);
		if (a < ma) {
			puts("War");
			return 0;
		}
	}
	if (y < ma) {
		puts("War");
		return 0;
	}
	puts("No War");
        return 0;
}


Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int b,h=0;
	cin>>b;
	bool g=false;
	for(int i=0;i<b;i++){
		g=false;
		string c;
		cin>>c;
		string d=c+c;
		for(int j=0;j<10;j++){
			string e;
			e=d.substr(j,a.length());
			if(a==e) g=true;
		}
		if(g) h++;
	}
	cout<<h<<endl;
}

Measured memory_bytes: 3184
#include <iostream>
#include <cmath>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long double a,b,c,d,e,f,g;
    string A;
    cin>>a>>b>>c>>d;
    e=pow(a-c,2)+pow(b-d,2);
    //cout<<printf("%.10lf\n", sqrt(e))<<endl;
    e=sqrt(e);
    // cout << f << endl;
    std::cout << std::setprecision(20) << e;
    return 0;
}



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

int main() {
    int a, b;   
    cin >> a >> b;      // a,bを入力

    // 整数aをb回繰り返す文字作
    int A = 0;    
    for (int i = 0; i < b; i++) {
        A += pow(10, i) * a;
    }
    string aStr;
    aStr = to_string(A);
    
    // 整数bをa回繰り返す文字作成
    int B = 0;    
    for (int i = 0; i < a; i++) {
        B += pow(10, i) * b;
    }
    string bStr;
    bStr = to_string(B);

    if (aStr.at(0) <= bStr.at(0)){
        cout << aStr << endl;
    } else{
        cout << bStr << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define F first
#define S second
#define en "\n"
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;



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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	string s, t, u;
	cin >> s >> t;
	ll a, b;
	cin >> a >> b >> u;
	if (s == u) a--;
	if (t == u) b--;

	cout << a << " " << b << endl;

	return 0;
}


Measured memory_bytes: 256
n, d = gets.split.map(&:to_i)
coordinates = (1..n).map { gets.split.map(&:to_i) }

answer = coordinates.combination(2).count do |(y, z)|
  distance = Math.sqrt((0..(d - 1)).reduce(0) { |s, i| s += (y[i] - z[i]) ** 2 } )
  distance - distance.to_i == 0
end
puts answer

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

int main()
{
    int n, k, s;
    cin >> n >> k >> s;
    if(n == k){
        for(int i = 0; i < k; i++) cout << s << " ";
        cout << endl;
        return 0;
    }
    if(s == 1000000000){
        for(int i = 0; i < k; i++) cout << s << " ";
        for(int i = k; i < n; i++) cout << 1 << " ";
        cout << endl;
        return 0;
    }
    for(int i = 0; i < k; i++){
        cout << s << " ";
    }
    for(int i = k; i < n; i++) cout << 1000000000 << " ";
    cout << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n, k;
int a[MN];

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

    cin >> k >> n;
    F0R(i, n){
        cin >> a[i];
    }
    int mxd = 0;
    F0R(i, n-1){
        mxd = max(mxd, a[i+1]-a[i]);
    }
    mxd = max(mxd, a[0]+k-a[n-1]);

    cout << k-mxd << "\n";
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int i, n, a, b, max = 0, maxn;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d%d", &a ,&b);
    if(a > max) max = a, maxn = b;
  }
  printf("%d", max + maxn);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<ll> Z(N), W(N);
    rep(i, N){
        int x, y; cin >> x >> y;
        Z[i] = x + y;
        W[i] = x - y;
    }
    sort(all(Z));
    sort(all(W));
    cout << max(Z[N - 1] - Z[0], W[N - 1] - W[0]) << endl;
}

Measured memory_bytes: 6424
// to check whether testcodes correct
// copy from https://atcoder.jp/contests/abc163/submissions/13011784
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 2005;

int n;
pair<int, int> a[mxn];
ll memo[mxn][mxn];
bitset<mxn> vstd[mxn];
ll dp(int at, int l) {
    if (at == n+1) return 0;
    auto &ret = memo[at][l];
    if (vstd[at][l]) return ret;
    vstd[at][l] = 1;
    int r = n-(at-l);
    ret = max(abs(a[at].second-l)*ll(a[at].first)+dp(at+1, l+1), abs(a[at].second-r)*ll(a[at].first)+dp(at+1, l));
    return ret;
}

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first, a[i].second = i;
    }
    sort(a+1, a+1+n, greater<pair<int, int>> ());
    cout << dp(1, 1) << '\n';
}


Measured memory_bytes: 26888
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

type item struct{ v, w int }

func parseProblem() int {
	n, c := scanInt(sc), scanInt(sc)
	items := make([]item, n)
	for i := range loop0(n) {
		items[i] = item{
			v: scanInt(sc),
			w: scanInt(sc),
		}
	}
	dp := make([][]int, n+1) // max value of j<i, w
	dp[0] = make([]int, c+1)
	for i := 1; i <= n; i++ {
		dp[i] = make([]int, c+1)
		for w := 1; w <= c; w++ {
			dp[i][w] = dp[i-1][w]
			item := items[i-1]
			if pW := w - item.w; pW >= 0 {
				if cV := dp[i-1][pW] + item.v; dp[i][w] < cV {
					dp[i][w] = cV
				}
			}
		}
	}
	return dp[n][c]
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}



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

#define endl '\n'

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

    string s; cin >> s;
    if (s == "SUN") cout << 7;
    else if (s == "MON") cout << 6;
    else if (s == "TUE") cout << 5;
    else if (s == "WED") cout << 4;
    else if (s == "THU") cout << 3;
    else if (s == "FRI") cout << 2;
    else cout << 1;
    cout << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> AB(M);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a - 1 < M) AB[a - 1].emplace_back(b);
  }

  int res = 0;
  priority_queue<int> pq;
  for (int i = 0; i < M; i++) {
    for (int b : AB[i]) {
      pq.push(b);
    }

    if (!pq.empty()) {
      res += pq.top();
      pq.pop();
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 5632
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  map<char, int> m;
  for (auto &i : s) m[i]++;
  if (m.size() == 2 && m.begin()->sc == 2) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
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 stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll a, b;
  cin >> a >> b;
  for(ll i = 1; i <= 10000; i++){
    int c = i * 0.08, d = i * 0.1;
    if(c == a && d == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
const int N=20;
int a[N],n;
int f(int l,int r,int xl,int xr){
	if(r-l<=1)return 0;
	int res=inf;
	for(int i=l+1;i<r;i++){
		int x=f(l,i,xl,xl+xr)+f(i,r,xl+xr,xr)+(xl+xr)*a[i];
		res=min(res,x);
	}
	return res;
}
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	cout << f(0,n-1,1,1)+a[0]+a[n-1] << endl;
}

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

#define int long long
#define xxx int32_t
#define fuck_u return 0;

xxx main() {
    int n, w;
    scanf("%lld%lld", &n, &w);
    int dp[w+1] = {0};
    for(int item=0; item<n; ++item) {
		int weight, value;
		scanf("%lld%lld", &weight, &value);
		for (int w1=w-weight; w1>=0; --w1) {
			dp[w1+weight] = max(dp[w1+weight], dp[w1]+value);
		}
	}
	int maximum = 0;
	for(int i=0; i<w+1; ++i)
		maximum = max(maximum, dp[i]);
    printf("%lld", maximum);
    printf("\n");
	fuck_u
}


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

#define pb push_back

using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;

bool comp(pi a, pi b) {
    return b.second < b.first;
}
int main() {
    int a,b;
    cin >> a >> b;
    string s = to_string(a) + to_string(b);
    int x = stoi(s);
    a = sqrt(x);
    if(a*a == x) cout << "Yes";
    else  cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a[101][101],c,h,w,i,j,k;
	char b[101][101];
	cin>>h>>w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			a[i][j]=-1;
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>b[i][j];
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(b[i][j]=='c'){
				a[i][j]=0;
				for(k=1;k<w;k++){
					c=j+k;
					if(c==w || a[i][j]==-1){
						c=0;
						break;
					}
					a[i][c]=k;
				}
			}
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(j==w-1){
				cout<<a[i][j];
			}
			else{
				cout<<a[i][j]<<' ';
			}
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

struct Edge {
    int from, to;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<Edge> ed(m);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        auto e = (Edge){a, b};
        ed[i] = e;
    }

    int res = 0;

    // i: 使わない辺
    rep(i, m) {
        vvi g(n);
        rep(j, m) {
            if (i == j) continue;
            int a = ed[j].from, b = ed[j].to;
            g[a].push_back(b);
            g[b].push_back(a);
        }

        vi dist(n, INF);
        dist[0] = 0;

        queue<int> que;
        que.push(0);

        while (!que.empty()) {
            int node = que.front();
            que.pop();

            for (auto&& v : g[node]) {
                if (dist[v] == INF) {
                    dist[v] = dist[node] + 1;
                    que.push(v);
                }
            }
        }

        for (auto&& e : dist) {
            if (e == INF) {
                res++;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";

const main = arg => {
  arg = arg.trim().split("\n");
  const N = parseInt(arg[0]);
  
  let answer = Infinity;
  
  for(let i=1; i<=Math.sqrt(N); i++) {
      if(N % i === 0) {
          const f = Math.max(String(i).length, String(N / i).length);
          answer = Math.min(answer, f);
      }
  }
  
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8652
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <string>

using namespace std;


int main(){
	int n,x;
	cin >> n >> x;
	int q = n*2-1;
	if(n == 1 && x == 1){
		cout << "Yes" << endl;
		cout << 1 << endl;
	}
	else if(x == q || x == 1){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
		if(x == q-1){
			for(int i=1;i<q-1;i++){
				cout << i << endl;
				if(i == n-1){
					cout << x << endl;
					cout << q << endl;
				}
			}
		}
		else{
			for(int i=2;i<q-1;i++){
				if(i!=x)
					cout << i << endl;
				if(i == n-1){
					cout << q-1 << endl;
					cout << 1 << endl;
					cout << x << endl;
					cout << q << endl;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 1536
import sys
prime=[False]*1000000
for i in range(2,1001):
    for j in range(i*2,1000000,i):
        prime[j]=True

for n in sys.stdin:
    cnt=0
    for i in range(2,int(n)+1):
        if not prime[i]:
            cnt+=1
    print(cnt)

Measured memory_bytes: 14944
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
string s;

int main() {
  int n;cin >> n;
  int cnt=0;
  for(int i=0;i<n;++i){
    ll t;cin>>t;
    if(t%2==1) ++cnt;
  }
  string s="YES";
  if(cnt%2==1) s="NO";
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  x = c.get(i)
  while x:
    r = r * pow(p, x, M) % M
    i += 1; n -= x; p = x; x = c.get(i)
print((r, 0)[n > 1])


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

int main() {

    int N,K;
    cin >> N >> K;

    int d = N / K;
    int p = N % K;

    //cout << d << ' ' << p << endl;

    if (p == 0)
        cout << 0 << endl;
    else if (N < K)
        cout << 1 << endl;
    else
        //cout << abs(p+d-d) << endl;
        cout << 1 << endl;

    return 0;
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

long long arr[MAX] ;
int n , k ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	sort(arr , arr + n) ;
	long long ans = 0ll ;
	reverse(arr , arr + n) ;
	for(int i = k ; i < n ; ++i)
		ans += arr[i] ;
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int t[100000];
int n,m,a,b,ans=0,L,R,M;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    L=0;
    R=n;
    while(L<R){
      M=(L+R)/2;
      if(t[M]==a){
    break;
      }else if(t[M]<a){
    L=M+1;
      }else{
    R=M;
      }
    }
     
    if(L<R)ans++;
     
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1548
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main() {
    // input
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }

    // solve & output
    sort(S.begin(), S.end());
    for (int i = 0; i < N; ++i) {
        cout << S[i];
    }
    cout << endl;

    return 0;
}


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

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

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

typedef struct {
	int id, solved, penalty;
} Team;

int compare(const void *a, const void *b) {
	int t;

	t = ((Team *)b)->solved - ((Team *)a)->solved;
	if (t)
		return t;
	else {
		t = ((Team *)a)->penalty - ((Team *)b)->penalty;
		if (t)
			return t;
		else
			return ((Team *)a)->id - ((Team *)b)->id;
	}
}

int main(void) {
	int i;
	int t, p, r;

	while (scanf("%d %d %d", &t, &p, &r), t) {
		Team team[50] = {0};
		int wrong[50][10] = {0};

		for (i = 0; i < t; i++)
			team[i].id = i + 1;

		for (i = 0; i < r; i++) {
			int tid, pid, t;
			char mes[10];

			scanf("%d %d %d %s", &tid, &pid, &t, mes);
			tid--;
			pid--;

			if (mes[0] == 'C') {
				team[tid].solved++;
				team[tid].penalty += wrong[tid][pid] * 1200 + t;
			} else
				wrong[tid][pid]++;
		}

		qsort(team, t, sizeof(Team), &compare);

		for (i = 0; i < t; i++)
			printf("%d %d %d\n", team[i].id, team[i].solved, team[i].penalty);
	}

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<string, int> count;
    count["AC"] = 0;
    count["WA"] = 0;
    count["TLE"] = 0;
    count["RE"] = 0;
    rep(i,n){
        string str;
        cin >> str;
        count.at(str) += 1;
    }
    
    cout << "AC x " << count.at("AC") << endl;
    cout << "WA x " << count.at("WA") << endl;
    cout << "TLE x " << count.at("TLE") << endl;
    cout << "RE x " << count.at("RE") << endl;
        
    
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int n, m, rk[Maxn], p[Maxn],cnt;
struct str
{
	int cnt, id;
	bool operator<(str an) const{
		return cnt > an.cnt;
	}
};
priority_queue<str>q[Maxn];
bool cmp(str a, str b) { return a.cnt < b.cnt; }
int main()
{
	int a, b;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		scanf("%d%d", &p[i], &a);
		q[p[i]].push({a, i});
	}
	for (int i = 1; i <= n; i++)
	{
		cnt = 0;
		while(!q[i].empty())
		{
			rk[q[i].top().id] = ++cnt;
			q[i].pop();
		}
	}	
	for (int i = 1; i <= m; i++)
	{
		a = log10(p[i]) + 1;
		for (int j = 1; j <= 6 - a; j++)
			printf("0");
		printf("%d",p[i]);
		a = log10(rk[i]) + 1;
		for (int j = 1; j <= 6 - a; j++)
			printf("0");
		printf("%d",rk[i]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

vector<int> a[100001];

int main(){
    tezi;
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> v(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> v[i];
    }
    for(int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for(int i = 1; i <= n; ++i){
        int flag = 0;
        for(int j = 0; j < a[i].size(); ++j){
            if(v[i] <= v[a[i][j]]){
                flag = 1;
                break;
            }
        }
        if(flag == 0) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 8796
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"
struct Query
{
    int l, r, ans, ind;
};
int n, q;
vector<int> arr;
vector<Query> queries;

bool operator<(Query &q1, Query &q2)
{
    return q1.r < q2.r;
}

class SegmentTree
{
    // Update : Sum Point update
    // Query : Range Query
public:
    int n;
    vector<int> tree;
    SegmentTree(int sz)
    {
        n = sz;
        tree.assign(4 * n + 1, 0);
    }
    void update(int curr, int l, int r, int pos, int val)
    {
        if (l == r)
        {
            tree[curr] += val;
            return;
        }
        int mid = (l + r) / 2;
        if (pos <= mid)
        {
            update(curr << 1, l, mid, pos, val);
        }
        else
        {
            update(curr << 1 | 1, mid+1, r, pos, val);
        }
        tree[curr] = tree[curr << 1] + tree[curr << 1 | 1];
    }
    int query(int curr, int l, int r, int i, int j)
    {
        if (i > j || i > r || j < l)
        {
            return 0;
        }
        if (i <= l && r <= j)
        {
            return tree[curr];
        }
        int mid = (l + r) / 2;
        return query(curr << 1, l, mid, i, j) + query(curr << 1 | 1, mid + 1, r, i, j);
    }
};

void solve()
{
    SegmentTree st(n + 1);
    vector<int> lastSeen(1e6, -1);
    int queryNumber = 0;
    for (int i = 0; i < n; i++)
    {
        if (lastSeen[arr[i]] == -1)
        {
            st.update(1, 1, n, i + 1, 1);
        }
        else
        {
            st.update(1, 1, n, lastSeen[arr[i]] + 1, -1);
            st.update(1, 1, n, i + 1, 1);
        }
        lastSeen[arr[i]] = i;
        while (queryNumber < q && queries[queryNumber].r == i + 1)
        {
            int l = queries[queryNumber].l;
            int r = queries[queryNumber].r;
            queries[queryNumber].ans = st.query(1, 1, n, l, r);
            queryNumber++;
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    arr.resize(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    queries.resize(q);
    for (int i = 0; i < q; i++)
    {
        cin >> queries[i].l >> queries[i].r;
        queries[i].ind = i;
        queries[i].ans = -1;
    }
    sort(queries.begin(), queries.end());
    solve();
    vector<int> ans(q, 0);
    for (int i = 0; i < q; i++)
    {
        ans[queries[i].ind] = queries[i].ans;
    }
    for (auto i : ans)
    {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 46156
import java.util.*;
class Main
{
   public static void main (String[] args) 
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int note1=n/500;
        n= n-(500*note1);
        int note2= n/5;
       int answer= (note1*1000)+(note2*5);
       System.out.println(answer);
    }  
}




Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MAXN 200050
#define LL long long int
LL n,a,b;
LL revfrac[MAXN],ans,res;
LL quickpow(LL a,LL b)
{
    LL tmp=1;
    while(b)
    {
        if(b&1)tmp*=a;
        a=a*a%MOD;
        tmp=tmp%MOD;
        b>>=1;
    }
    return tmp;
}
LL getrevfrac()
{
    revfrac[1]=1;
    for(int i=2;i<MAXN;i++)
        revfrac[i]=revfrac[i-1]*i%MOD;
    revfrac[MAXN-1]=quickpow(revfrac[MAXN-1],MOD-2);
    for(int i=MAXN-2;i>1;i--)
    revfrac[i]=revfrac[i+1]*(i+1)%MOD;
}
int main()
{
    ios::sync_with_stdio(false);
    getrevfrac();
    cin>>n>>a>>b;
    ans=quickpow(2,n)-1;
    res=1;
    if(a>b)swap(a,b);
    for(int i=0;i<a;i++)
    {
        res=res*(n-i)%MOD;
    }
    LL res2=res*revfrac[a]%MOD;
    for(int i=a;i<b;i++)
    res=res*(n-i)%MOD;
    res=res*revfrac[b]%MOD;
    ans=((ans-res-res2)%MOD+MOD)%MOD;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<string> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  vector<int> num(n);
  sort(vec.begin(), vec.end());
  int m = 1;
  int M = 1;
  int i;
  for (i = 0; i < n - 1; i++) {
    if (vec[i] == vec[i+1]) {
      num[i] = m;
      m++;
      if (m > M) M = m;
    } else {
      num[i] = m;
      m = 1;
    }
  }
  num[i] = m;
  if (M < m) M = m;
  for (int i = 0; i < n; i++) {
    if (num[i] == M) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 15104