akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <queue>
#include <cstdlib>
using namespace std;

int H, W, N;
char field[1000][1000];
int d[1000][1000];
pair<int, int> start;
pair<int, int> cheese;
int INF = 1000000;
int result = 0;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void bfs()
{
    for (int n = 1; n < N + 1; n++)
    {
        queue<pair<int, int>> que;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                d[i][j] = INF;
            }
        }
        que.push(start);
        d[start.first][start.second] = 0;

        while (que.size())
        {
            pair<int, int> p = que.front();
            que.pop();
            if (field[p.first][p.second] == '0' + (char)n)
            {
                cheese = p;
                break;
            }

            for (int i = 0; i < 4; i++)
            {
                int nx = p.first + dx[i];
                int ny = p.second + dy[i];

                if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] != 'X' && d[nx][ny] == INF)
                {
                    que.push(pair<int, int>(nx, ny));
                    d[nx][ny] = d[p.first][p.second] + 1;
                }
            }
        }
        result += d[cheese.first][cheese.second];
        start = cheese;
    }
}

int main() {
    scanf(" %d %d %d", &H, &W, &N);
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            scanf(" %c", &field[i][j]);
            if (field[i][j] == 'S')
            {
                start.first = i;
                start.second = j;
            }
        }
    }
    bfs();
    printf("%d\n", result);
}


Measured memory_bytes: 7548
#include <stdio.h>

int main(void){
	int a,b;
	int c;
	int digit;
	while(scanf("%d %d",&a,&b) != EOF){
		digit = 0;
		c = a + b;
		while(c>0){
			c /= 10;
			digit++;
		}
		printf("%d\n",digit);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
d = [int(i) for i in input().split()]
Visit = [[False for j in range(N)]for i in range(N) ]
ans = 0

for i in range(N):
    for j in range(N):
        if i==j:
            continue
        if Visit[i][j] and Visit[j][i]:
            continue
        else:
            ans += d[i]*d[j]
            Visit[i][j] = True
            Visit[j][i] = True
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;

int n,a[300],s;
//dp[i][x] := i番目までで最長でない二辺の和がxとなる場合の数
ll dp[300][90001];
ll dp1[300][90001];

void calc_dp(){

    dp[0][a[0]] = 2;
    for(int i = 0;i < n-1;i ++){
        dp[i][0] = 1;
        for(int x = 0;x <= 90000;x ++){
            dp[i+1][x] = (x-a[i+1]>=0?2*dp[i][x-a[i+1]]:0)+dp[i][x];
            dp[i+1][x] %= mod;
        }
    }

    dp1[0][a[0]] = 1;
    for(int i = 0;i < n-1;i ++){
        dp1[i][0] = 1;
        for(int x = 0;x <= 90000;x ++){
            dp1[i+1][x] = (x-a[i+1]>=0?dp1[i][x-a[i+1]]:0)+dp1[i][x];
            dp1[i+1][x] %= mod;
        }
    }    
}

ll mpow(ll x,ll n){
    ll res = 1;
    while(n != 0){
        if(n&1) res = res*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return res;
}

ll solve(){
    ll res=0,cnt=0;
    calc_dp();
    for(int x = 0;x <= s/2;x ++){
        cnt += dp[n-1][x];
        cnt %= mod;
    }
    res = (mpow(3,n) - cnt*3%mod) % mod;
    if(s%2==0) res += dp1[n-1][s/2]*3,res %= mod;
    if(res<0) res = mod + res;
    return res%mod;
}

int main(){
    cin >> n;
    for(int i = 0;i < n;i ++){
        cin >> a[i];
        s += a[i];
    }

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 421504
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
}rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

const int N(1e5 + 5), n(rd), P(rd);

inline void inc(int &x, int y) { if ((x += y) >= P) x-= P; }

std::vector<int> g[N];

int f[N], h[N];

void dfs1(int x, int fa) {
	f[x] = 1;
	for(int y : g[x]) if(y != fa)
		dfs1(y, x), f[x] = 1ll * f[x] * (f[y] + 1) % P;
	
}
void dfs2(int x, int fa) {
	static int son[N], a[N], b[N], nw, p;
	nw = 1, p = 0;
	for(int y : g[x]) if(y != fa) son[++p] = y, a[p] = nw = 1ll * nw * (f[y] + 1) % P;
	nw = 1;
	for(int i = p; i; --i) b[i] = nw = 1ll * nw * (f[son[i]] + 1) % P;
	a[0] = b[p + 1] = 1;
	REP(i, 1, p) h[son[i]] = (1ll * a[i - 1] * b[i + 1] % P * h[x] + 1) % P;	
	for(int y : g[x]) if(y != fa) dfs2(y, x);
}
int main() {
	REP(i, 2, n) {
		int x = rd, y = rd;
		g[x].push_back(y), g[y].push_back(x);
	}
	h[1] = 1;
	dfs1(1, 0), dfs2(1, 0);
	
	REP(i, 1, n) printf("%lld\n", 1ll * h[i] * f[i] % P);
	return 0;
}



Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int i,j;
	int tmp;
	int counter=0;
	ll X;
	ll answer=0;
	vector<int> given;

	cin >> X;

	answer+=(X/500)*1000;
	X-=(X/500)*500;
	answer+=(X/5)*5;
	
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n;
    cin>>n;
    vi v1,v2;
    rep(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        v1.pb(x+y);
        v2.pb(x-y);
    }
    sort(all(v1));
    sort(all(v2));
    ll ans=max(v1[n-1]-v1[0],v2[n-1]-v2[0]);
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 6696
import math
N, K = map(int, input().split())
mod = 10**9+7

ans = 0
for k in range(K, N+2):
    #個数が異なると合計も変わるので毎度計算する
    #数列の小さい方からk個選ぶ
    min_part = (k-1)*k//2
    #数列の大きい方からk個選ぶ
    max_part = (N*(N+1)-(N-k)*(N-k+1))//2
    #差分を足す
    ans += max_part-min_part+1
    
    ans %= mod


print(ans)




Measured memory_bytes: 9160
import java.util.*;

public class Main {
	int n, cnt;
	int[][] c;
	char[] list = new char[]{'R','Y','B','M','G','C'};
	
	void up(int m){
		int tmp = c[m][0];
		c[m][0] = c[m][1];
		c[m][1] = c[m][5];
		c[m][5] = c[m][4];
		c[m][4] = tmp;
	}
	
	void right(int m){
		int tmp = c[m][1];
		c[m][1] = c[m][3];
		c[m][3] = c[m][4];
		c[m][4] = c[m][2];
		c[m][2] = tmp;
	}
	
	boolean check(int m){
		for(int i=m-1;i>=0;i--){
			int cc = 0;
			for(int j=0;j<6;j++) if(c[i][j]==c[m][j]) cc++;
			if(cc==6) return true;
		}
		return false;
	}
	
	void func(int m){
		for(int i=0;i<6;i++){
			if(i==4) right(m);
			if(i>=4) up(m);
			for(int j=0;j<4;j++){
				if(check(m)) return;
				right(m);
			}
			if(i!=5) up(m);
		}
		cnt++;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			n = sc.nextInt();
			if(n==0) break;
			
			c = new int[n][6];
			cnt = 1;
			for(int i=0;i<n;i++){
				for(int j=0;j<6;j++){
					char a = sc.next().charAt(0);
					for(int k=0;k<6;k++){
						if(a==list[k]){
							c[i][j] = k;
							break;
						}
					}
				}
				if(i!=0) func(i);
			}
			System.out.println(n-cnt);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26868
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
D=0
for i in range(0,len(A)-1):
    if A[i+1]==A[i]+1:
        D+=C[A[i]-1]
D+=sum(B)
print(D)

Measured memory_bytes: 9168
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		sc.close();
		boolean ans = false;
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				if (i * 4 + j * 7 == a) {
					ans = true;
					break;
				}
			}
		}
		System.out.println(ans ? "Yes" : "No");
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n;
  int l,r;
  int ans=0;
  
  cin>>n;
  rep(i,n){
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    int a; cin >> a;
    n-=a;
  }
  cout << (n<=0? "Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            var n = long.Parse(ReadLine());
            var a = long.Parse(ReadLine());
            var b = long.Parse(ReadLine());
            var c = long.Parse(ReadLine());
            var d = long.Parse(ReadLine());
            var e = long.Parse(ReadLine());

            var min = Min(Min(Min(Min(
                a,
                b),
                c),
                d),
                e);

            WriteLine(ceil(n, min) + 4);

        }

        static long ceil(long a, long b)
        {
            return (a + b - 1) / b;
        }
    }
}


Measured memory_bytes: 11092
N=int(input())
A = list(map(int,input().split()))
sum_=[A[0]]
ans =float('inf')
for i in range(1,N):
    sum_.append(sum_[i-1]+A[i])

midL=0
midR=2
for i in range(1,N-2):
    minL=float('inf')
    minR=float('inf')
    for j in range(midL,i):
        if abs(sum_[i]-2*sum_[j]) > minL:
            break
        else:
            midL=j
            minL=abs(sum_[i]-2*sum_[j])
        
    for k in range(midR,N-1):
        if abs(sum_[-1]-2*sum_[k]+sum_[i]) > minR:
            break
        else:
            midR=k
            minR=abs(sum_[-1]-2*sum_[k]+sum_[i])
    tmp =  max(sum_[midL],sum_[i]-sum_[midL],sum_[midR]-sum_[i],sum_[-1]-sum_[midR]) -min(sum_[midL],sum_[i]-sum_[midL],sum_[midR]-sum_[i],sum_[-1]-sum_[midR])
    if ans >tmp:
        ans =tmp
print(ans)

Measured memory_bytes: 25676
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

const int N = 200001;
int i, j, k, m, n;
string s;
int a[N], x, y;

void solve() {
    CL(0, a);
    a[x]++; a[y]++;
    cin >> x >> y; a[x]++; a[y]++;
    cin >> x >> y; a[x]++; a[y]++;
    if (a[1] == 3 || a[2] == 3 || a[3] == 3 || a[4] == 3) cout << "NO"; else cout << "YES";
    cout << endl;
}

int main() {
    //freopen("x.in", "r", stdin);
    while (cin >> x >> y) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5 * 1e6 + 10;

int X, Y;

// int dp[N], dp2[N];
// int solve(int x){
//    if(x > X)
//       return 0;
//    if(x == X)
//       return 1;
//    int &ans = dp[x];
//    if(ans != -1)
//       return ans;
//    ans = 0;
//    ans += solve(x+1);
//    ans %= mod;
//    return ans;
// }

// int solve2(int x){
//    if(x > X)
//       return 0;
//    if(x == X)
//       return 1;
//    int &ans = dp2[x];
//    if(ans != -1)
//       return ans;
//    ans = 0;
//    ans += solve2(x+2);
//    ans %= mod;
//    return ans;
// }

// #define ll int
// ll power(ll a, ll b, ll m = mod){if(b < 0)b += m-1; ll r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

// int fact[N+10], ifact[N+10];
// void pre(int N){
//    fact[0] = 1;
//    for (int i = 1; i <= N; ++i)
//    {
//       fact[i] = (i*fact[i-1])%mod;
//    }
//    ifact[N] = power(fact[N], -1);
//    for (int i = N-1; i >= 0; --i)
//    {
//       ifact[i] = ((i+1)*ifact[i+1])%mod;
//    }
// }

int power(int a, int b, int m = mod){a %= m; if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}
int nCr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    int ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans %= mod;
        ans *= power(i, -1);
        ans %= mod;
    }

    return ans;
}

int32_t main(){_

   // pre(N);
   int x, y;
   cin >> x >> y;

   if ((x+y) % 3){
      cout<<0;
      exit(0);
   }

   if(x > y)
      swap(x, y);

   if(y > 2*x){
      cout<<0;
      return 0;
   }

   int a = (2 * y - x) / 3;
   int b = y - 2 * a;

   int nr = a+b;

   int f1 = 1, f2 = 1;// f3 = 1;
   for (int i = 1; i <= nr; ++i)
   {
      f1 *= i;
      f1 %= mod;
   }

   for (int i = 1; i <= b; ++i)
   {
      f2 *= i;
      f2 %= mod;
   }

   for (int i = 1; i <= a; ++i)
   {
      f2 *= i;
      f2 %= mod;
   }

   int ans = f1 * power(f2, -1) % mod;
   cout<<ans;

   // int t = 1;
   // while(t--){
   //    memset(dp, -1, sizeof dp);
   //    memset(dp2, -1, sizeof dp2);
   //    cin >> X >> Y;
   //    int a1 = solve(0);
   //    int a2 = solve2(0);

   //    X = Y;
   //    int b1 = solve(0);
   //    int b2 = solve2(0);

   //    int ans = (a1 * b2 % mod + a2 * b1 % mod) % mod;
   //    cout<<ans;
   // }

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    string s;
    cin >> s;
    if((s[0] >= '1' && s[1] >= '3') || (s[0] == '0' && s[1] == '0')){
        if((s[2] == '0' && s[3] == '0') || (s[2] >= '1' && s[3] >= '3')){
            cout << "NA" << endl;
            exit(0);
        }else{
            cout << "YYMM" << endl;
        }
    }else{
        if((s[2] >= '1' && s[3] >= '3') || (s[2] == '0' && s[3] == '0')){
            cout << "MMYY" << endl;
        }else{
            cout << "AMBIGUOUS" << endl;
        }
    }
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k = LI()
    if n == k:
        return 1
    a = LI()
    r = (n - k + k - 2) // (k-1) + 1

    return r


print(main())



Measured memory_bytes: 16280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = ReadInt();
            if (X >= 30)
                WriteLine("Yes");
            
            else
                WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27492
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        long a, b, c; {int[] d = in.ii(); a = d[0]; b = d[1]; c = d[2];}
        String ans;
        if(a + b < c){
            if ( 4 * a * b < (c - a - b) * (c - a - b)) {
                ans = "Yes";
            }
            else {
                ans = "No";
            }
        } else {
            ans = "No";
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

int p(int n, int m)
{
    if (m == 0) return 1;

    return n * p(n, m - 1);
}
int main()
{
    int x;
    cin >> x;

    int ans = 1;
    for (int i = 1; i <= x; i++) {
        for (int j = 2; j <= x; j++) {
            int t = p(i, j);
            if (t > x) continue;
            ans = max(ans, t);
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, s, t, x, y, ds[100100], dt[100100], dsn[100100], dtn[100100];
vi e[100100];

void dijkstra(int *d, int s) {
	priority_queue<pii, vector<pii>, greater<pii> > que;
	fill(d, d+n, inf), d[s] = 0;
	que.push({0,s});
	while(!que.empty()) {
		pii p = que.top(); que.pop();
		int v = p.se, dis = p.fi;
		if (d[v] < dis) continue;
		for (int i = 0; i < e[v].size(); ++i) {
			int u = e[v][i];
			if (d[u] > d[v] + 1) {
				d[u] = d[v] + 1;
				que.push({d[u],u});
			}
		}
	}
}

signed main() {
	cin >> n >> m >> s >> t;
	s--, t--;
	rep(i,m) {
		cin >> x >> y;
		x--, y--;
		e[x].pb(y), e[y].pb(x);
	}
	dijkstra(ds,s), dijkstra(dt,t);
	rep(i,n) {
		if (ds[i]!=inf) dsn[ds[i]]++;
		if (dt[i]!=inf) dtn[dt[i]]++;
	}
	int m = ds[t]-2, res = 0;
	rept(i,m) res += dsn[i]*dtn[m-i];
	cout << res << ln;
}


Measured memory_bytes: 13324
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int age;
    cin >> age;
    if(age == 1) cout << "Hello World" << endl;
    else{
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


k = I()
cost = [INF] * k
cost[1] = 1
que = deque([1])
while que:
    cur = que.popleft()
    nxt = (cur * 10) % k
    if cost[cur] < cost[nxt]:
        cost[nxt] = cost[cur]
        que.appendleft(nxt)
    nxt = (cur + 1) % k
    if cost[cur] + 1 < cost[nxt]:
        cost[nxt] = cost[cur] + 1
        que.append(nxt)



print(cost[0])


Measured memory_bytes: 46304
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());

        while (a > 0 && c > 0) {
            c -= b;
            if (c <= 0) {
                System.out.println("Yes");
                break;
            }
            a -= d;
            if (a <= 0) {
                System.out.println("No");
                break;
            }
        }

    }
}


Measured memory_bytes: 35680
import java.util.*;

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

    int n = sc.nextInt();
    int count = 0;
    for (int i = 0; i < n; i++) {
      String s = sc.next();
      if (s.equals("A")) count++;
      else count--;
      if (count < 0) {
        System.out.println("NO");
        return;
      }
    }
    if (count == 0)
      System.out.println("YES");
    else
      System.out.println("NO");
  }
}



Measured memory_bytes: 26424
import statistics
n = int(input())
d_ls = [int(i) for i in input().split()] 

med_low = statistics.median_low(d_ls)
med_high = statistics.median_high(d_ls)
if med_low == med_high and d_ls.count(med_low)==1:
    ans = 1
else:
    ans = med_high - med_low
    
print(ans)

Measured memory_bytes: 16536
#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 = 9999999999;
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; }

vector<vector<vector<vector<vector<vector<int>>>>>> dp(11, vector<vector<vector<vector<vector<int>>>>>(2, vector<vector<vector<vector<int>>>>(2, vector<vector<vector<int>>>(2, vector<vector<int>>(2, vector<int>(2, 0))))));

int main() {
  string s; cin >>s;
  int L = s.size();

  dp[0][0][0][0][0][0] = 1;

  for (int i=0; i<L; i++){
    int D = s.at(i) - '0';
    for (int j=0; j<2; j++){
      for (int not0=0; not0<2; not0++){
        for (int f7=0; f7<2; f7++){
          for (int f5=0; f5<2; f5++){
            for (int f3=0; f3<2; f3++){
              for (int d=0; d <= (j ? 9 : D); d++){
                if (d == 3 || d == 5 || d == 7){
                  dp[i+1][j || (d < D)][1][f7 || (d==7)][f5 || (d==5)][f3 || (d==3)] += dp[i][j][not0][f7][f5][f3];
                }else if (d == 0){
                  if (not0 == 0){
                    dp[i+1][j || (d < D)][not0][f7][f5][f3] += dp[i][j][not0][f7][f5][f3];
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  // dp[digit][smaller][notonlyzero][7][5][3]...何個？

  int ans = 0;
  ans += dp[L][0][1][1][1][1] + dp[L][1][1][1][1][1];
  cout <<ans <<endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

#define int long long

pii get(ll x) {
    pii ans = {0, 0};
    while (x % 2 == 0) {
        ans.fs++;
        x /= 2;
    }
    while (x % 5 == 0) {
        ans.sc++;
        x /= 5;
    }
    return ans;
}

main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    map <pair <pii, pii>, int> cnt;
    forn (i, 0, n) {
        string s;
        cin >> s;
        int point = sz(s);
        forn (j, 0, sz(s))
            if (s[j] == '.')
                point = j;
        string before_point;
        forn (j, 0, point)
            before_point += s[j];
        ll denominator = 1;
        string after_point;
        forn (j, point + 1, sz(s)) {
            after_point += s[j];
            denominator *= 10;
        }
        ll numerator;
        if (after_point.empty())
            numerator = 0;
        else
            numerator = stoll(after_point);
        numerator = stoll(before_point) * denominator + numerator;
        pii num = get(numerator), den = get(denominator);
        int t = min(num.fs, den.fs), f = min(num.sc, den.sc);
        num.fs -= t, den.fs -= t;
        num.sc -= f, den.sc -= f;
        cnt[{num, den}]++;
        cerr << numerator << " " << denominator << "\n";
    }
    vector <pair <pair <pii, pii>, int>> c;
    for (auto i : cnt)
        c.pb(i);
    ll ans = 0;
    forn (i, 0, sz(c)) {
        forn (j, i + 1, sz(c)) {
            auto x = c[i].fs;
            auto y = c[j].fs;
            int a = c[i].sc;
            int b = c[j].sc;
            if (x.fs.fs + y.fs.fs >= x.sc.fs + y.sc.fs &&
                x.fs.sc + y.fs.sc >= x.sc.sc + y.sc.sc)
                ans += 1LL * a * b;
        }
    }
    forn (i, 0, sz(c)) {
        auto x = c[i].fs;
        auto y = x;
        int a = c[i].sc;
        int b = a;
        if (x.fs.fs + y.fs.fs >= x.sc.fs + y.sc.fs &&
            x.fs.sc + y.fs.sc >= x.sc.sc + y.sc.sc)
            ans += 1LL * (a - 1) * a / 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3704
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int anc = 0;
        int seiseki[] = new int[L];
        for(int i = 0;i < L;i++){
            int a = sc.nextInt();
            seiseki [i] = a;
            if(i == 0 || i%2 == 0){
                if(a%2 != 0){
                    anc++;
                }
            }
        }
        
      
        System.out.println(anc);
    }
}


Measured memory_bytes: 35788
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

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

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)


    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9736
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   string s;
           cin>>s;
           if(s.size()==2)cout<<s<<endl;
           else{
            reverse(all(s));
             cout<<s<<endl;
           }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;


int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<ll> T(N, -1);

    REP(i,N){
        ll a;
        cin >> a;
        a--;
        A[i] = a;
    }

    ll now = 0;
    T[0] = 0;
    ll num = 1;
    map<ll, ll> visit;
    visit[0] = 0;
    ll period = -1;
    ll first = 0;
    while(num <= K){
        ll a = A[now];
        if(visit.find(a) == visit.end()){
            T[num] = a;
            now = a;
            visit[a] = num;
            num++;
        }
        else{
            first = visit[a];
            period = num - first;
            break;
        }
    }

    ll k;
    if(period != -1){
        k = (K - first) % period;
        k += first;
        //cout << period << endl;
        //cout << k << endl;
    }
    else{
        k = num-1;
    }

    ll ans = T[k] + 1;

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


Measured memory_bytes: 16372
N, M = [int(i) for i in input().split()]
Ai = [int(i) for i in input().split()]

min_voted_num = 1 / (4 * M) * sum(Ai)
num_selected = sum(A >= min_voted_num for A in Ai)
if num_selected >= M:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
nii=lambda:map(int,input().split())
lnii=lambda:list(map(int,input().split()))

x,n=nii()
p=lnii()

dist=1000
ans=1000
for i in range(101,-1,-1):
  if i not in p:
    t_dist=abs(x-i)
    if t_dist<=dist:
      dist=t_dist
      ans=i
print(ans)

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

int main() {
    int n;
    cin >> n;
    int h = n / 2;
    if (n % 2) {
        cout << h * (h + 1) << endl;
    } else {
        cout << h * h << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll n, k;
	cin >> n >> k;
	if (n == 2 && k == 0) { cout << 1 << endl; cout << 1 << " " << 2 << endl; }
	else {
		ll p = n * (n - 1) / 2 - k;
		ll memo = (n - 1) * (n - 2) / 2;
		if (k > memo)cout << -1 << endl;
		else {
			cout << n * (n - 1) / 2 - k << endl;
			cout << 1 << " " << 2 << endl;
			cout << 2 << " " << 3 << endl;
			rep(i, n - 3)cout << 2 << " " << i + 4 << endl;
			ll ans = n - 1;
			for (int i = 3; i <= n; i++) {
				if (p == ans)break;
				cout << i << " " << 1 << endl;
				ans++;
			}
			for (int i = 4; i <= n; i++) {
				if (p == ans)break;
				cout << i << " " << 3 << endl;
				ans++;
			}
			for (int i = 4; i <= n - 1; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (p == ans)break;
					cout << i << " " << j << endl;
					ans++;
				}
			}
		}
	}
	ggr
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct fint
{
    long long greutate,price;
};
const long long nm=100000;
long long dp[nm+5],aux[nm+5];
fint v[5005];
long long n,gmax;
int main()
{
    cin>>n>>gmax;
    for(long long i=1;i<=n;i++)
        cin>>v[i].greutate>>v[i].price;
    dp[0]=1;
    for(long long i=1;i<=n;i++)
    {
        for(long long j=0;j+v[i].greutate<=gmax;j++)
            if(dp[j])
                aux[j+v[i].greutate]=max(aux[j+v[i].greutate],dp[j]+v[i].price);
        for(long long j=1;j<=gmax;j++)
            dp[j]=aux[j];
    }
    long long sol=0;
    for(long long i=1;i<=gmax;i++)
        sol=max(sol,dp[i]-1);
    cout<<sol;
    return 0;
}
/**
**/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    cout << 180 * (n-2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll n,W;
 cin>>n>>W;
 ll w[n],v[n];
 for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
 ll dp[n+1][W+1];
 for(ll i=0;i<=W;i++) dp[0][i]=0;
 for(ll i=1;i<=n;i++){
  for(ll j=0;j<=W;j++){
   if(j>=w[i-1]) dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
   else dp[i][j]=dp[i-1][j];
  }
 }
 cout<<dp[n][W]<<endl;
 return 0;
}

Measured memory_bytes: 79104
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	if x < 4 {
		fmt.Println(1)
		return
	}

	minDiff := 9999
	for i := 0; i < x; i++ {
		b := i + 2
		for bb := b * b; bb <= x; bb *= b {
			if x-bb < minDiff {
				minDiff = x - bb
			}
		}
	}
	fmt.Println(x - minDiff)
}


Measured memory_bytes: 512
#include <stdio.h>
#define N 1000001

int binarySearch(int A[], int n, int key)
{
  int left=0, right=n, mid;

  while(left < right){
    mid = (left+right) / 2;
    if(A[mid] == key){
      return mid;
    } else if(key < A[mid]){
      right =  mid;
    } else if (key > A[mid]){
      left = mid + 1;
    }
  }
    return 0;
}

int main(){

  int i, n, q, key, count=0;
  int A[N];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);

  for(i=0; i<q; i++){
    scanf("%d", &key);
    if(binarySearch(A, n, key)){
        count++;
      }
  }

    printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  vector<int> dp(s.size()+1);
  dp[0] = 1;
  
  for(int i=0; i<s.size(); i++){
    if(dp[i] == 0){
      continue;
    }else{
      string s5 = s.substr(i,5);
      string s6 = s.substr(i,6);
      string s7 = s.substr(i,7);
      if(s5 == "dream"|| s5 == "erase"){
        dp[i+5] = 1;
      }
      if(s6 == "eraser"){
        dp[i+6] = 1;
      }
      if(s7 == "dreamer"){
        dp[i+7] = 1;
      }
    }
  }
  if(dp[s.size()] == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 896
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
 
typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
 
const int maxn = 500005;
const ll mod = 998244353;
const double PI = acos(-1.0);
 
struct no
{
	int le;
	int ri;
	int max_v;
}node[4 * maxn];
 
void build(int root, int le, int ri, int v)
{
	if (le == ri)
	{
		node[root].le = le;
		node[root].ri = ri;
		node[root].max_v = v;
		return;
	}
	int mid = (le + ri) >> 1;
	build(root << 1, le, mid, v);
	build((root << 1) | 1, mid + 1, ri, v);
	node[root].le = le;
	node[root].ri = ri;
	node[root].max_v = v;
}
 
int query(int root, int le, int ri)
{
	if (node[root].le == le&&node[root].ri == ri)
	{
		return node[root].max_v;
	}
	int mid = (node[root].le + node[root].ri) >> 1;
	if (mid >= ri)
	{
		return query(root << 1, le, ri);
	}
	else if (mid + 1 <= le)
	{
		return query(root << 1 | 1, le, ri);
	}
	else
	{
		return max(query(root << 1, le, mid), query(root << 1 | 1, mid + 1, ri));
	}
}
 
void update(int root, int k, int v)
{
	if (node[root].le == k&&node[root].ri == k)
	{
		node[root].max_v = v;
		return;
	}
	int mid = (node[root].le + node[root].ri) >> 1;
	if (k <= mid)
	{
		update(root << 1, k, v);
	}
	else
	{
		update(root << 1 | 1, k, v);
	}
	node[root].max_v = max(node[root << 1].max_v, node[root << 1 | 1].max_v);
}
 
int n, k;
int pos[maxn], out[maxn], res[maxn];
vector<int>ed[maxn];
priority_queue<int>que;
 
void solve()
{
	int i, j, m;
	sa(n), sa(k);
	for(i=1;i<=n;i++)
	{
		sa(m);
		pos[m] = i;
	}
	
	build(1, 1, n, -INF);
	for(i=1;i<=n;i++)
	{
		m = query(1, pos[i], min(n, pos[i] + k - 1));
		if (m != -INF)
		{
			int x = m;
			out[pos[x]]++;
			ed[pos[i]].push_back(pos[x]);
		}
		update(1, pos[i], i);
	}
 
	build(1, 1, n, -INF);
	for (i = n; i >= 1; i--)
	{
		m = query(1, pos[i], min(n, pos[i] + k - 1));
		if (m != -INF)
		{
			int x = -m;
			out[pos[i]]++;
			ed[pos[x]].push_back(pos[i]);
		}
		update(1, pos[i], -i);
	}
	
	for(i=1;i<=n;i++)
	{
		if (out[i] == 0)
		{
			que.push(i);
		}
	}
	for (i = n; i >= 1;i--)
	{
		int v = que.top();
		que.pop();
		res[v] = i;
		
		for(j=0;j<ed[v].size();j++)
		{
			out[ed[v][j]]--;
			if (out[ed[v][j]] == 0)
			{
				que.push(ed[v][j]);
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		printf("%d\n", res[i]);
	}
}
 
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 50560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 2019;




int main(){
    ll N; cin >> N;
    if(N/10 == 9 || N % 10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
#include<stdio.h>

#define N 250
#define NIL -1

typedef struct{
  int left,right,parent;
}heap;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int n,i,j,H[250];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&H[i]);
  }

  for(i=0;i<n;i++){
    printf("node %d: key = %d, ",i+1,H[i]);

    if(parent(i+1)!=0) printf("parent key = %d, ",H[parent(i+1)-1]);

    if(left(i+1)<=n) printf("left key = %d, ",H[left(i+1)-1]);

    if(right(i+1)<=n) printf("right key = %d, ",H[right(i+1)-1]);

    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>

int main(void)
{
	long int   i, j, k , a[100][100], b[100][100], c[100][100], n, m, l, sum, tem ;
	
	scanf("%d %d %d", &n, &m, &l);

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			c[i][j] = 0;
		}
	}


	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) {
			scanf("%d", &b[i][j]);
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			for (k = 0; k < m; k++) {
				c[i][j] = a[i][k] * b[k][j] + c[i][j];
			}
			
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
                       if( j == l -1 )
                        printf("%ld", c[i][j]);
else
			printf("%ld ", c[i][j]);
		}
		printf("\n");
	}

	
		
	return 0;
}


Measured memory_bytes: 2924
object Main {
  def before_tax(price: Int, rate: Int): Int = {
    val numerator = price * 100
    val denominator = 100 + rate
    val temp = numerator / denominator
    if(numerator % denominator == 0) temp
    else {
      if((temp + 1) * (100 + rate) / 100 != price) -1
      else temp + 1
    }
  }
  def solve(old_rate: Int, new_rate: Int, s: Int): Int = {
    var max = 0
    for(a <- 1 to s - 1) {
      val price1 = before_tax(a, old_rate)
      val price2 = before_tax(s - a, old_rate)
      if(price1 != -1 && price2 != -1) {
        val after_tax = price1 * (100 + new_rate) / 100 + 
                        price2 * (100 + new_rate) / 100
        if(max < after_tax) max = after_tax
      }
    }
    max
  }
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var x, y, s = sc.nextInt
    while(x != 0 || y != 0 || s != 0) {
      println(solve(x, y, s))
      x = sc.nextInt; y = sc.nextInt; s = sc.nextInt
    }
  }
}

Measured memory_bytes: 47496
a,b = gets.chomp.split(" ").map(&:to_i);
s = gets.chomp
i = 0

a.times do
  if !(s[i]>="0" && s[i]<="9")
    puts "No" 
    exit
  end
  i += 1 
end

if !(s[i]=="-")
  puts "No" 
  exit
end
i += 1

b.times do
  if !(s[i]>="0" && s[i]<="9")
    puts "No" 
    exit
  end
  i += 1 
end

puts "Yes"

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  string s;
  cin >> s;
  for(int i=0; i<3; i++) {
    if(s[i]=='1') {
      s[i]='9';
    }
    else {
      s[i]='1';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256