akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

k, n = Is()
A = LI()

m = k - A[n-1] + A[0]
for i in range(1, n):
        m = max(m, A[i]-A[i-1])

print(k-m)

Measured memory_bytes: 102344
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	int o=0;
	cin>>s;
	for(int i=0;i<=s.size()-1;i++)
	{
		if(s[i]=='C') o=1;
		if(s[i]=='F'&&o==1)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; string s; cin >> n >> s;
  if(n>=3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    
    int a;
    char s[101];
    // 整数の入力
    scanf("%d", &a);
    // 文字列の入力
    scanf("%s",s);
  if(a %2 == 1){
	printf("No");
    return 0;
  }
  
  int i=0;
  int num = a /2;
  for(i=0;i<a/2;i++){
	if(s[i] != s[i+num]){
      	printf("No");
      	return 0;
    }
  }
  printf("Yes");
	
   
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int n,x=0,i;
    string s;
    cin>>s;
    n=s.length();
    if(s[0]=='A' && s[1]>90 && s[n-1]>90){
        for(i=2;i<n-1;i++){
            if(s[i]=='C'){
                x++;
            }
        }
    }
    if(x==1)
       cout<<"AC";
    else
       cout<<"WA";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 998244353;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, S;
  cin >> N >> S;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  vector<vector<lint>> dp(N+1, vector<lint>(S+1));
  dp[0][0] = 1;
  lint tmp = 0;
  REP(i, N) {
    dp[i+1][0] = dp[i][0] + 1;
    FOR(j, 1, S+1) {
      dp[i+1][j] = dp[i][j];
      if(j == S) dp[i+1][S] = (dp[i+1][S] + tmp) % MOD;
      if(j - A[i] >= 0) {
        dp[i+1][j] = (dp[i+1][j] + dp[i][j-A[i]]) % MOD;
        if(j == S) tmp = (tmp + dp[i][j-A[i]]) % MOD;
      }
    }
    //cout << dp[i+1][S] << endl;
  }
  cout << dp[N][S] << endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,h,m,i,j,k;
  cin>>a>>b>>h>>m;
  h=h*60;
  h=h+m;
  double r1=(3.14159265359)/360,r2=(3.14159265359)/30;
  double r=h*r1,r3=(h*r2);
  r1=sqrt(a*a+b*b-2*a*b*cos(abs(r-r3)));
  printf("%.20f",r1);
}

Measured memory_bytes: 4188
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
//AtCoderC++.cpp

using namespace std;

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}

void show(vector<int> a) {
	for (auto v : a)cout << v << " ";
	cout << endl;
}

int main() {
	int A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 0) {
		cout << (A + B) / 2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < 3; i++)
            a[i] = sc.nextInt();
        Arrays.sort(a);
        System.out.println(a[2] * 10 + a[1] + a[0]);
    }

}


Measured memory_bytes: 21588
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> count(1000001,0);
  int one_count=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    count[a[i]]++;
    if(a[i]==1){
      one_count++;
    }
  }
  if(one_count>=1){
    if(one_count==1){
      cout<<1<<endl;
      return 0;
    }else{
      cout<<0<<endl;
      return 0;
    }
  }
  int result=n;
  for(int i=0;i<n;i++){
    bool isok=true;
    if(count[a[i]]>=2){
      result--;
      continue;
    }
    for(int div=2;div*div<=a[i];div++){
      if(a[i]%div==0){
        if(count[a[i]/div]!=0){
          isok=false;
          break;
        }
        if(count[div]!=0){
          isok=false;
          break;
        }
      }

    }
    if(!isok){
      result--;
    }
  }
  cout<<result<<endl;



  return 0;
}




Measured memory_bytes: 7888
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	io_init;
	ll N, M, L;
	cin >> N >> M >> L;
	vector<vector<ll>> A(N + 1, vector<ll>(N + 1, INF)), B;
	for (int i = 0; i <= N; i++)A[i][i] = 0;
	B = A;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		A[a][b] = A[b][a] = c;
	}

	for (int k = 1; k <= N; k++)for (int i = 1; i <= N; i++)for (int j = 1; j <= N; j++) {
		A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
	}

	for (int i = 1; i <= N; i++)for (int j = 1; j <= N; j++) {
		if (A[i][j] <= L)B[i][j] = 1;
	}

	for (int k = 1; k <= N; k++)for (int i = 1; i <= N; i++)for (int j = 1; j <= N; j++) {
		B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		if (B[s][t] == INF)cout << -1 << endl;
		else cout << B[s][t] - 1 << endl;
	}
}

Measured memory_bytes: 2048
// A - 01 Matrix

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int grid[1000][1000];


int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			if ((i < B && j < A) || (i >= B && j >= A)) {
				grid[i][j] = 0;
			} else {
				grid[i][j] = 1;
			}
		}
	}

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			cout << grid[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
  long long x;
  cin >> x;
  if (x % 11 > 6)
    cout << x / 11 * 2 + 2 << endl;
  else if (x % 11 > 0 && x % 11 <= 6)
    cout << x / 11 * 2 + 1 << endl;
  else
    cout << x / 11 * 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		if(a >= b){
			System.out.println("No");
		}
		else if(b >= c){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
	}
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> L(Q), R(Q);
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        L[i] = l; R[i] = r;
    }

    vector<int> nums(N);
    nums[0] = 0;
    for (int i = 1; i < N; i++) {
        nums[i] = nums[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C')
            nums[i]++;
    }

    for (int i = 0; i < Q; i++) {
        cout << nums[R[i]] - nums[L[i]] << endl;
    }
    return 0;

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
string S;
ll cnt[26];

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

  cin>>N>>S;
  rep(i,N)cnt[S[i]-'a']++;
  ll res=1;
  rep(i,26)(res*=cnt[i]+1)%=mod;
  cout<<(res-1+mod)%mod<<endl;

  return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
L = [[] for _ in range(n)]

for i in range(m):
    p, s = input().split()
    L[int(p)-1].append(s)

AC, WA = 0, 0

for q in L:
    tmp_ac = 0
    tmp_wa = 0
    for a in q:
        if a == 'WA':
            tmp_wa += 1
        if a == 'AC':
            tmp_ac += 1
            break
    if tmp_ac == 1:
        AC += 1
        WA += tmp_wa

print(AC, WA)


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

int main(){
  long long N,D,x,y,count=0;
  cin >> N >> D;
  for(int i=0;i<N;i++){
    cin >> x >> y;
    if(x*x+y*y<=D*D) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

ll mpow(ll a, ll n)
{
	ll r = 1;
	while (n)
	{
		if (n&1) r = r*a % MOD;
		a = a*a % MOD;
		n >>= 1;
	}
	return r;
}


int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	ll x[n];
	ll dp[n+5], fac[n+5]; dp[1] = fac[1] = 1;
	for (int i = 2; i <= n; ++i)
	{
		fac[i] = 1LL * i * fac[i-1] % MOD;
		dp[i] = 1LL * (i) * dp[i-1] + fac[i-1]; dp[i] %= MOD;
	}
	ll falling[n+5];
	falling[1] = fac[n-1];
	for (int i = 2; i <= n-1; ++i)
		falling[i] = falling[i-1] * mpow(i, MOD-2) % MOD;

	ll coeff[n+5];
	for (int i = 1; i <= n-1; ++i)
		coeff[i] = dp[i] * falling[i] % MOD;
	vector<ll> dif;
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
		if (i) dif.pb(x[i] - x[i-1]);
	}
	ll ans = 0;
	for (int i = 1; i <= n-1; ++i)
		ans += coeff[i] * dif[i-1] % MOD; ans %= MOD;
	cout << ans;
}

Measured memory_bytes: 5112
#include <stdio.h>
int main(){
	int a,b,k[100001],i,sum=0;
	scanf ("%d%d",&a,&b);
	for (i=1;i<a+1;i++){
		scanf ("%d",&k[i]);
		sum=sum+k[i];
		if(sum>b){
			break;
			}
		}
		printf ("%d",i);
	return 0;
	}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N) {
    cin >> d.at(i);
  }
  int count = 0;
  vector<bool> searched(N, false);
  rep(i,N) {
    if ( searched.at(i) ) {
      continue;
    }
    searched.at(i) = true;
    count++;
    int cur_d = d.at(i);
    rep(j,N) {
      if ( searched.at(j) ) {
        continue;
      }
      if ( d.at(j) == cur_d ) {
        searched.at(j) = true;
      }
    }
  }
  
  cout << count << endl;  
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADuplexPrinting solver = new ADuplexPrinting();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADuplexPrinting {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int total = n % 2 == 0 ? n / 2 : n / 2 + 1;
            out.println(total);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



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

    int main()
    {
        int n,m,inp,sum=0;
        cin>>n>>m;

        for(int i=0;i<m;i++)
        {
            cin>>inp;
            sum = sum +inp;
        }
        if(sum<=n)
        {
            cout<<n-sum<<endl;
        }
        else
            cout<<"-1"<<endl;


        return 0;
    }


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> Vec;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;


int main() {
    int N,M;
    cin >> N >>M;
    vector<pair<ll,int>> AB(N);
    for(int i=0;i<N;i++){
        cin>>AB.at(i).first>>AB.at(i).second;
    }
    ll ans=0;
    sort(AB.begin(),AB.end());
    for(int i=0;i<N;i++){
        ll product=AB.at(i).first*AB.at(i).second;
        if(AB.at(i).second>=M){
            ans+=M*AB.at(i).first;
            break;
        }else{
            M-=AB.at(i).second;
            ans+=product;
        }
    }
    cout <<ans<<endl;
    return 0;
}

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

int island[12][13];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
string str1,str[11];
int ans;
void solve();
void dfs(int a,int b);

int main()
{
        while(cin >> str1){
                for(int i=0;i<11;i++){
                        cin >> str[i];
                }
                for(int i=0;i<12;i++) island[0][i] = (int)(str1[i] - '0');
                for(int i=1;i<12;i++){
                        for(int j=0;j<12;j++){
                                island[i][j] = (int)(str[i-1][j] - '0');
                        }
                }

                solve();
                cout << ans << endl;
        }

        return 0;
}

void solve()
{
        ans = 0;
        for(int k=0;k<12;k++){
                for(int j=0;j<12;j++){
                        if(island[k][j]==1){
                                dfs(k,j);
                                ans += 1;
                        }
                }
        }
        return;

}

void dfs(int a,int b)
{
        island[a][b] = 0;
        for(int i=0;i<4;i++){
                int nx = a + dx[i];
                int ny = b + dy[i];
                if(0<=nx && nx<12 && 0<=ny && ny<12 && island[nx][ny]==1) dfs(nx,ny);
        }
        return;
}

Measured memory_bytes: 1188
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextLong();
    }
    sc.close();
    
    long m = 1000000007;
    long ans = 0;
    for (int i = 0; i < 60; i++) {
      long c = 0;
      for (int j = 0; j < N; j++)
        if (((A[j] >>> i) & 1) == 1) c++;
      long a = (c * (N - c)) % m;
      for (int j = 0; j < i; j++) 
        a = (a * 2) % m;
      ans += a;
      ans %= m;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 100360
N, K = map(int, input().split()) 

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

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

S_possible = "POSSIBLE"
S_impossible = "IMPOSSIBLE"

b = 0

for a in A:
    b = gcd(a, b)

if K % b or K > max(A):
    print(S_impossible)
else:
    print(S_possible)


Measured memory_bytes: 14096
/*Lower_Rating*/
/*AGC035 number*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define MAXN 150
#define Pr pair<LL,LL>
#define PR pair<pair<int,int>,Pr>
#define X first
#define Y second
#define INF 2000000000000000000
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
LL MOD;
int add(int x,int y){return (x+y>=MOD)?x+y-MOD:x+y;}
int dec(int x,int y){return (x-y<0)?x-y+MOD:x-y;}
int mul(int x,int y){return 1LL*x*y%MOD;}

int n,k;
struct subtask1{
    int f[MAXN+5][MAXN+5];
    int cal(int n,int k){
        f[0][0]=1;
        for(int i=1;i<=n;i++){
            f[i][0]=f[i-1][0];
            for(int j=1;j<=k;j++){
                f[i][0]=add(f[i][0],f[i-1][j]);
                f[i][j]=f[i-1][j-1];
            }
        }int res=0;
        for(int j=0;j<=k;j++)res=add(res,f[n][j]);
        return res;
    }
    int process(){
        return mul(cal(n>>1,k>>1),cal((n+1)>>1,k>>1));
    }
}T1;

struct subtask2{
    int f[MAXN+5][MAXN+5][MAXN+5];
    int process(){
        f[0][0][0]=1;
        for(int i=1;i<=n;i++){
            int r=(i<<1),l=r-k;
            int cl=1<=l&&l<=n,cr=1<=r&&r<=n;
            for(int j=0;j<=n;j++)
                for(int p=0;p<=k+1;p++){
                    f[i][0][0]=add(f[i][0][0],f[i-1][j][p]);
                    if(cr)f[i][j+1][0]=add(f[i][j+1][0],f[i-1][j][p]);
                    if(cl&&p+1<k+2)f[i][0][p?p+1:p]=add(f[i][0][p?p+1:p],f[i-1][j][p]);
                    if(cl&&cr&&max(p+1,j+2)<k+2)f[i][j+1][max(p+1,j+2)]=add(f[i][j+1][max(p+1,j+2)],f[i-1][j][p]);
                }
        }int res=0;
        for(int j=0;j<=n;j++)
            for(int p=0;p<=k+1;p++)
            res=add(res,f[n][j][p]);
        return res;
    }
}T2;
int main()
{
    n=read(),k=read();MOD=read();
    if(k%2==0)printf("%d\n",T1.process());
    else printf("%d\n",T2.process());
}


Measured memory_bytes: 14464
n = int(input())
a = list(map(int, input().split()))

flag = True

for i in a:
  if i % 2 == 0:
    if i % 3 == 0 or i % 5 == 0:
      continue
    else:
      flag = False
      break
if flag:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int a,b,c,count=0,k;
  	cin >> a>>b>>c>>k;
  	if(b<=a){
    	while(b<=a){
        	b = b*2;
          	count++;
        }
    }
  if(c<=b){
    	while(c<=b){
        	c = c*2;
          	count++;
        }
    }
  if(count<=k){cout << "Yes"<<endl;}
  else cout << "No"<<endl;
}

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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code
	int a,b;
	cin >> a >> b;
	if(a+b==15) cout << "+";
	else if(a*b==15) cout << "*";
	else cout << "x";
	return 0;

}

Measured memory_bytes: 256
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;

int main() {

    cin >> N;

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i*j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct Circle
{
	double x, y, r;
};

int main()
{
	int n;
	cin >> n;
	
	rep(i, n)
	{
		Circle a, b;
		cin >> a.x >> a.y >> a.r >> b.x >> b.y >> b.r;

		double d = sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));

		if(a.r + b.r < d)
			cout << 0 << endl;
		else if(d < a.r - b.r)
			cout << 2 << endl;
		else if(d < b.r - a.r)
			cout << -2 << endl;
		else
			cout << 1 << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(ALL(a), greater<int>());
  ll ans = 0;
  if(n % 2 == 0){
    ans += a.front();
    rep2(i, 1, n/2){
      ans += 2*a.at(i);
    }
  }else{
    ans += a.front();
    rep2(i, 1, n/2){
      ans += 2*a.at(i);
    }
    ans += a.at(n/2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
int MAX_N=1001000;
vector<int> Par(MAX_N);
vector<int> Rank(MAX_N);

void init(int N){
    for(int i=0; i<N; i++){
        Par[i]=i;
        Rank[i]=0;
    }
}

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

void unite(int x, int y){
  	int fx=find(x);
  	int fy=find(y);
    if(fx==fy){
        return;
    }
    if(Rank[fx]<Rank[fy]){
        Par[fx]=fy;
    }
    else{
        Par[fy]=fx;
        if(Rank[fx]==Rank[fy]){
            Rank[fx]++;
        }
    }
}

int main(){
    int N, M;
    cin>>N>>M;
  	init(N);
    vector<int> X(M), Y(M), Z(M);
    for(int i=0; i<M; i++){
        cin>>X[i]>>Y[i]>>Z[i];
      	X[i]--;
      	Y[i]--;
    }
    for(int i=0; i<M; i++){
        unite(X[i], Y[i]);
    }
    set<ll> PP;
    for(int i=0; i<N; i++){
        PP.insert(find(i));
      	//cout<<find(i)<<endl;
    }
    cout<<PP.size()<<endl;
  	return 0;
}



Measured memory_bytes: 13824
#include<cstdio>
int m,k;
int main()
{
	scanf("%d %d",&m,&k);
	if(m==1&&k==0) printf("0 0 1 1");
	else if(m==1&&k==1) printf("-1");
	else if(k>(1<<m)-1) printf("-1");
	else
	{
		for(int i=(1<<m)-1;i>=0;i--)
		{
			if(i!=k) printf("%d ",i);
		}
		printf("%d ",k);
		for(int i=0;i<(1<<m);i++)
		{
			if(i!=k) printf("%d ",i);
		}
		printf("%d ",k);
	}
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); 
    int M = sc.nextInt();
    // int L[] = new int[M]; 
    // int R[] = new int[M]; 
    int min = sc.nextInt();
    int max = sc.nextInt();
    for(int i = 1; i < M; i++){
      int tmp_min = sc.nextInt();
      int tmp_max = sc.nextInt();
      if(min<=tmp_min){
        min = tmp_min; 
      }
      if(tmp_max<=max){
        max = tmp_max; 
      }
    }
    System.out.println(Math.max((max-min+1),0));    
  
  }
}




Measured memory_bytes: 63260
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        long x=sc.nextLong();
        int k=sc.nextInt();
        long[]r=new long[k+1];
        r[0]=0;
        for(int i=0;i<k;++i)r[i+1]=sc.nextInt();
        //precomp
        long[]d=new long[k+1],e=new long[k+1],f=new long[k+1];
        // max(d,min(f,a+e))
        d[0]=0;e[0]=0;f[0]=x;
        for(int i=0;i<k;++i){
            if(i%2==0){
                d[i+1]=Math.max(0,d[i]-(r[i+1]-r[i]));
                e[i+1]=e[i]-(r[i+1]-r[i]);
                f[i+1]=Math.max(0,f[i]-(r[i+1]-r[i]));
            }else{
                d[i+1]=Math.min(x,d[i]+(r[i+1]-r[i]));
                e[i+1]=e[i]+(r[i+1]-r[i]);
                f[i+1]=Math.min(x,f[i]+(r[i+1]-r[i]));
            }
        }
        int q=sc.nextInt();
        int cpos=0;
        for(int i=0;i<q;++i){
            long t=sc.nextInt();
            long a=sc.nextInt();
            while(cpos<k+1&&r[cpos]<=t)cpos++;
            cpos--;
            long dif=t-r[cpos];
            long st=Math.max(d[cpos],Math.min(f[cpos],a+e[cpos]));
            //System.err.println("max("+d[cpos]+",min("+f[cpos]+",a+"+e[cpos]+"))");
            //System.err.println("dif="+dif+" st="+st);
            if(cpos%2==0)st-=dif;
            else st+=dif;
            st=Math.max(0,Math.min(x,st));
            out.println(st);
        }
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 59912
#include<stdio.h>
int main( void )
{
	int x;
	scanf("%d",&x);
	if(x==7){ 
		printf("YES\n");
	}else if(x==5){
		printf("YES\n");
	}else if(x==3){ 
		printf("YES\n");
	}else{ 
		printf("NO\n");
	}
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;


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

    string c1[300], c2[300];;
    REP(i, N) cin >> c1[i];

    int ans = 0;
    REP(A, N) {
        REP(i, N) c2[i] = c1[(i - A + N) % N];

        bool flg = true;
        for (int j = 0; j < N; j++) {
            for (int i = 0; i < j; i++) {
                if(c2[i][j] != c2[j][i]) {
                    flg = false;
                    break;
                }
                if(!flg) break;
            }
        }
        if(flg) ans += N;
    } 

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c;
  cin>>a>>b>>c;
  a+b>=c ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

Measured memory_bytes: 256
void main()
{
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], k = tmp[1];

    writeln(k == 1 ? 0 : n - k);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val number: Int = sc.nextLine.toInt
    if (number < 105) println(0)
    else {
      println((105 to number).filter(_ % 2 == 1).map {
        n =>
          (1 to number).foldLeft(0) {
            case (acc, d) if n % d == 0 => acc + 1
            case (acc, _) => acc
          }
      }.count(_ == 8))
    }
  }
}


Measured memory_bytes: 27220
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ld,ld>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N) cin>>A[i]>>B[i];

    ll sum=0,ans=INF;

    rep(i,N){
        if(A[i]>B[i]){
            mini(ans,B[i]);
        }
        sum+=A[i];
    }
    if(ans==INF){
        cout<< 0 <<"\n"; return;
    }

    cout<< sum-ans <<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 640
fun main() = Thread(null, ::msolutions2020d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020d() {
    val n = readLine()!!.toInt()
    val prices = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val highestMoneys = LongArray(n)
    highestMoneys[0] = 1000

    for (dayToBuy in 0 until n) for (dayToSell in dayToBuy + 1 until n) {
        val stock = highestMoneys[dayToBuy] / prices[dayToBuy]
        highestMoneys[dayToSell] = maxOf(
            highestMoneys[dayToSell],
            highestMoneys[dayToBuy],
            highestMoneys[dayToBuy] + stock * (prices[dayToSell] - prices[dayToBuy])
        )
    }

    val answer = highestMoneys.last()

    println(answer)
}


Measured memory_bytes: 40528
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    ll n = abs(a - b), m = abs(v - w);
    if(v > w) {
        if(n <= m * t) cout << "YES" << endl;
        else cout << "NO" << endl;
    } else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3580
n = int(raw_input())
x = raw_input().strip()
def solve(b):
    if len(b) == 1:
        return 0
    m = 1001001001
    dp = [-m, -m, -m, 0]
    p = 0
    for x in b:
        ndp = [-m] * 4
        for j in (1, 2, 3):
            if dp[j] < dp[j-1]:
                dp[j] = dp[j-1]
        ndp[0] = dp[3]
        g = max(dp[0] + p, dp[1] + p - 1, dp[2] + 1)
        if x == 1:
            ndp[3] = g
        else:
            ndp[1] = g
            ndp[2] = dp[2] + x - 1
            ndp[3] = dp[2] + x
        dp = ndp
        p = x
    return max(dp)
a = []
p = ans = 0
c = x[0] == '1'
for i in xrange(1, n):
    if x[i-1] == x[i] == '0':
        if p < i - 1:
            ans += solve(a)
        a = []
        c = 0
        p = i
    elif x[i-1] != x[i] == '0':
        a.append(c)
        c = 0
    else:
        c += 1
if p < n - 1:
    if c:
        a.append(c)
    ans += solve(a)
print ans


Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string s;
	int a = 0;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		a += ((s[i] == '+')?1:-1);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N;
    cin >> N;
    int K;
    cin >> K;
    map<int, int> count;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        count[A]++;
    }
    int n = count.size();
    vector<pair<int, int>> v;
    for(auto p : count) v.emplace_back(p.second, p.first);
    sort(all(v));
    ll sum = 0;
    for(int i = 0; i < n - K; i++){
        sum += v[i].fi;
    }
    cout << sum << endl;
}

Measured memory_bytes: 11764
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a;
    int b;
    int c=0;
    int d=0;
    for (int i=0; i<n; i++) {
        cin>>a>>b;
        if(a>c){
            c=a;
            d=a+b;
        }
    }
    cout<<d<<endl;
    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  int n = s.size();
  rep(i, n) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << '\n';
  
  return 0;
}

Measured memory_bytes: 3916
using Yorukatsu032.Questions;
using Yorukatsu032.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu032.Questions
{
    /// <summary>
    /// ABC094 C
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var x = inputStream.ReadIntArray();
            var orderedX = new int[n];
            x.CopyTo(orderedX, 0);
            Array.Sort(orderedX);

            var left = orderedX[orderedX.Length / 2 - 1];
            var right = orderedX[orderedX.Length / 2];

            foreach (var xi in x)
            {
                if (xi <= left)
                {
                    yield return right;
                }
                else
                {
                    yield return left;
                }
            }
        }
    }
}


namespace Yorukatsu032
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu032.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu032.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 38712
#include<iostream>
using namespace std;
int main(void)
{
	int N,i,cnt=0;
	cin >> N;
	for (i = 1; i <= 1000; i *= 10) {
		if (N / i % 10 == 2) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] ary = new int[n];
        int[] nums = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            nums[i] = sc.nextInt();
            ary[nums[i]-1]++;
        }
        Arrays.sort(ary);
        for(int i = n-1; i >= n-k; i--){
            sum += ary[i];
        }
        System.out.println(n-sum);
    }
}


Measured memory_bytes: 86824
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int,input().split())
uf = UnionFind(N)
for _ in range(M):
  a,b = map(int,input().split())
  uf.union(a-1,b-1)
  
print(uf.group_count() - 1)

Measured memory_bytes: 75196
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint r, c, k; cin >> r >> c >> k;
  vector<vector<lint>> grid(r, vector<lint> (c, 0));
  for (int i = 0; i < k; i++) {
    lint x, y, v; cin >> x >> y >> v;
    x--;
    y--;
    grid[x][y] = v;
  }

  vector<vector<vector<lint>>> dp(r, vector<vector<lint>>(c, vector<lint>(4, -INF)));
  dp[0][0][0] = 0;
  dp[0][0][1] = grid[0][0];

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      for (int l = 0; l < 4; l++) {
        if (dp[i][j][l] == -INF) continue;

        // したに行く
        {
          int ni = i + 1;
          int nj = j;

          // 取らない
          if (ni < r) dp[ni][nj][0] = max(dp[ni][nj][0], dp[i][j][l]);

          // とる
          if (ni < r)
            dp[ni][nj][1] = max(dp[ni][nj][1], dp[i][j][l] + grid[ni][nj]);
        }

        // 右に行く
        {
          int ni = i;
          int nj = j + 1;

          // 取らない
          if (nj < c) dp[ni][nj][l] = max(dp[ni][nj][l], dp[i][j][l]);

          // とる
          if (nj < c and l < 3)
            dp[ni][nj][l + 1] = max(dp[ni][nj][l + 1], dp[i][j][l] + grid[ni][nj]);
        }
      }
    }
  }

  lint ans = -INF;
  for (int l = 0; l < 4; l++) {
    ans = max(ans, dp[r - 1][c - 1][l]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 706064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;
int N, M;
vector<vector<int>> G;

void dfs(int s, int x, int y, vector<bool> &vis){
    if(vis[s]) return;
    vis[s] = true;
    for(int t : G[s]){
        if((t == x && s == y) || (t == y && s == x)) continue;
        dfs(t, x, y, vis);
    }
}


bool check(int x, int y){
    vector<bool> vis(N, false);
    dfs(x, x, y, vis);
    for(auto z : vis)
        if(z == false)
            return true;
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    G.resize(N);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    for(int i=0; i<N; i++){
        for(int j : G[i]){
            if(check(i, j)) ans++;
        }
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 256