akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll k, a, b;
	cin >> k >> a >> b;

	ll ans = 0;

	if (b - a <= 2) {
		ans = k + 1;
	}
	else {
		ans = 1;
		ans += (b - a) * max(0LL, (k - (a - 1)) / 2);
		ans += k - 2 * max(0LL, (k - (a - 1)) / 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A, B + 1):
        if i % K == 0:
            print("OK")
            break
    else: print("NG")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t K;
  cin >> K;
  vector<int64_t> vec(K);
  for(int i=0; i<K; i++){
    cin >> vec.at(i);
  }
  int64_t dp[K+1][2]; //0が下限、1が上限とする
  for(int i=0; i<K; i++){
    for(int j=0; j<2; j++){
      dp[i][j] = 0;
    }
  }
  dp[K][0] = 2;
  dp[K][1] = 2;
  bool flag = true;
  
  for(int i=K-1; i>=0; i--){
    int64_t down = ((dp[i+1][0]-1) / vec.at(i)) * vec.at(i) + vec.at(i);
    int64_t up = (dp[i+1][1] / vec.at(i)) * vec.at(i);
    //cout << dp[i+1][0] << " " << vec.at(i) << endl; 
    if(down > dp[i+1][1]){
      flag = false;
    }
    dp[i][0] = down;
    dp[i][1] = up + vec.at(i)-1;
  }
  /*for(int i=0; i<K+1; i++){
    for(int j=0; j<2; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  
  if(flag){
    cout << dp[0][0] << " " << dp[0][1] << endl;
  }
  else{
    cout << -1 << endl;
  }
}

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


int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  int sum =0;
  rep(i,m){
    cin>>a.at(i);
    sum+=a.at(i);

  }
  if(n<sum){
    cout<<-1<<endl;

  }
  else{
    cout<<n-sum<<endl;
  }
  return 0;

}


Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<bool> good(N, true);
    
    for(int i = 0; i < N; ++i) cin >> H[i];
    
    REP(i, M){
        int a,b;
        cin >> a >> b;
        a--, b--;
        if(H[a] <= H[b]){
            good[a] = false;
        }
        if(H[a] >= H[b]){
            good[b] = false;
        }
    }
    
    int ans = 0;
    REP(i, N){
        ans += good[i];
    }
    
    cout << ans << endl;
    
    
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3396
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    int a = gi();
    int b = gi();
    int c = gi();

    c = MIN(c, a+b+1);
    printf("%d\n", b+c);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 505;

ll sum, ans[MN][MN];

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int H, W, h, w; cin >> H >> W >> h >> w;

    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            ans[i][j] = i%h == h-1 && j%w == w-1 ? -4000*h*w+3999 : 4000,
            sum += ans[i][j];

    if (sum > 0) {
        cout << "Yes";
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                cout << " \n"[!j] << ans[i][j];
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 5636
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var xy = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var xx = xy[0];
        var yy = xy[1];

        var rs = new [] { 0, (int)3e5, (int)2e5, (int)1e5 };
        var r = xx == 1 && yy == 1 ? (int)4e5 : 0;
        r += xy.Sum(x => x < 4 ? rs[x] : 0);
        Console.WriteLine(r);
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void) {
  int A,B,C,ans;
  scanf("%d %d %d",&A,&B,&C);
  if(A<B) {
    if(B<C) {
      ans=A+B+C*10;
    }else{
      ans=A+B*10+C;
    }
  }else{
    if(A<C) {
      ans=A+B+C*10;
    }else{
      ans=A*10+B+C;
    }
  }
  printf("%d",ans);
  return 0;
}

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

int a[100010];

int main() {
	int n, k; cin >> n >> k;
	int index = 0;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		if (a[i] == 1) index = i;
	}	
	int ans = n;
	for (int i = max(0,index-k+1); i < min(n, index+k); i ++) {
		int l = i / (k-1) + (i%(k-1)!=0);
		int r = (n-i-k) / (k-1) + ((n-i-k)%(k-1)!=0);
		ans = min(ans, l+r+1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
from collections import Counter

N = int(input())
balls = [int(i) for i in input().split()]

c = Counter(balls)

sum_ball_combinations = 0
for i in c.values():
    sum_ball_combinations += i*(i-1)//2

for b in balls:
    k = c[b]
    print(sum_ball_combinations- (k*(k-1)//2)+ (k-1)*(k-2)//2)

Measured memory_bytes: 26780
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>

using namespace std;

int main()
{
	long long N, K;
	cin >> N >> K;
	double ans = 0;

	vector<long long> B(18);
	B[0] = 1;

	for (int i = 1; i < 18; ++i)
	{
		B[i] = B[i - 1] * 2;
	}

	int b = 0;
	for (int i = N; i > 0; --i)
	{
		while(B[b] * i < K)
		{
			++b;
		}

		ans += 1.0 / N / B[b];
		
	}

	printf("%.10f",ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

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

    int n, c;
    cin >> n >> c;
    vector<int> x(n), v(n);
    REP(i, n){
        cin >> x[i] >> v[i];
    }
    vector<int> r(n), l(n);
    r[0] = v[0] - x[0];
    l[0] = v[n-1] - (c - x[n-1]);
    FOR(i, 1, n){
        r[i] = v[i] - (x[i] - x[i-1]);
        r[i] += r[i-1];
        l[i] = v[n-i-1] - (x[n-i] - x[n-i-1]);
        l[i] += l[i-1];
    }

    vector<int> r_max(n), l_max(n);
    int r_tmp = 0, l_tmp = 0;
    REP(i, n){
        if(r[r_tmp] < r[i]) r_tmp = i;
        r_max[i] = r_tmp;
        if(l[l_tmp] < l[i]) l_tmp = i;
        l_max[i] = l_tmp;
    }

    int ans = 0;
    ans = max(ans, r[r_max[n-1]]);
    ans = max(ans, l[l_max[n-1]]);
    REP(i, n-1){
        int j = n-i-2;
        ans = max(ans, r[r_max[i]] + l[l_max[j]] - min(x[r_max[i]], c-x[n-1-l_max[j]]));
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (10e9 + 7)

int main(void){
    ll N, K;
    cin >> N >> K;
    ll res = 0;
    FOR(i,K,N+2){
        ll min = i*(i-1)/2;
        ll max = (2*N+1-i)*i/2;
        res += (max - min) + 1;
        res %= 1000000007;
    }
    cout << res << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>

typedef long long ll;

using namespace std;

int main() {
	ll N;
	cin >> N;
	vector<ll>A(N);
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		A[x]++;
	}
	A[0]++;
	ll ans = 1;
	for (int i = 1-N%2; i < N; i+=2)
	{
		if (A[i] != 2) {
			cout << 0 << endl;
			return 0;
		}
	}

	ll tmp = 1e9 + 7;
	for (int i = 0; i < N/2; i++)
	{
		ans = ans*2 % tmp;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N; cin >> N;
	vector<ll> s(N); rep(i, N) cin >> s[i];

	ll mx = 0; rep(i, N) mx += s[i];

	sort(ALL(s));

	ll cnt = 0;
	while(1) {
		if (cnt == N) {
			cout << 0 << endl;
			return 0;
		}
		if(mx%10 == 0){
			if(s[cnt]%10 != 0)mx -= s[cnt];
			cnt++;
			continue;
		}
		else {
			cout << mx << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n=0,flag=1;
    char s[101]={},t1[51]={},t2[51]={};
    scanf("%d %s",&n,s);
    if(n%2==1) flag=0;
    else {
        for(int i=0;i<n/2;i++) t1[i]=s[i];
        t1[n/2]='\0';
        for(int i=0;i<n/2;i++) t2[i]=s[i+n/2];
        t2[n/2]='\0';
        if(strcmp(t1,t2)!=0) flag=0;
    }
    if(flag==1) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1728
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        if(s.length() == 2){
        	System.out.println(s);
        }else{
        	for(int i = s.length() - 1; i >= 0; i--){
            	System.out.print(s.charAt(i));
            }
        }
    }
}

Measured memory_bytes: 35648
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  set<int> st;
  rep(i,3){
    int a; cin>>a;
    st.insert(a);
  }
  cout << st.size() << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int X, Y, Z;
    cin >> X >> Y >> Z;

    swap(X, Y);
    swap(X, Z);

    cout << X << ' ' << Y << ' ' << Z << '\n';

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int ans = a * 100 + b * 10 + c;
	if (ans % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
long long f(long long a) {
     long long res[] = {a,1,a+1,0};
     return res[a%4];
}

long long getXor(long long a, long long b) {
     return f(b)^f(a-1);
}
int main(){
	ll a,b;
	cin>>a>>b;
	if(!a)a++;
	cout<<getXor(a,b)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    int ans = 0;
    for (auto & a : A) {
        if (a % 2 == 0) {
            //for (int i = 0; i < ans; i++) {
            //    a *= 3;
            //}

            while(a % 2 == 0) {
                a /= 2;
                ans++;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
      PROGRAM-ID. 082A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      01 A PIC 9(3).
      01 B PIC 9(3).
      01 WA PIC 9(3).
      01 X  PIC 9(3).
      01 XX PIC ZZ9.
      01 AMA PIC 9(1).
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      UNSTRING INP DELIMITED BY " "
      INTO A B.
      COMPUTE WA = A + B 
      DIVIDE WA BY 2 GIVING X REMAINDER AMA
      IF AMA = 0
      THEN
         CONTINUE
      ELSE
         COMPUTE X = X + 1
      END-IF.
      MOVE X TO XX.
      DISPLAY XX.
      STOP RUN.
      

Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	int a[3][3], b;
	bool f = false;
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			cin >> a[i][j];
		}
	}
	cin >> b;
	vector<int>c(b);
	for (int i = 0;i < b;i++) {
		cin >> c[i];	
	}
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			for (int k = 0;k < b;k++) {
				if (c[k] == a[i][j]) {
					a[i][j] = 0;
				}
			}
		}
	}
	int o=0;
	int p = 0;
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			o += a[i][j];
			p += a[j][i];
			if (j == 2) {
				
				if (o == 0||p==0) {
					f = true;
					goto A;
				}
				o = 0;
				p = 0;
			}
		}
	}
	if (a[0][0] + a[1][1] + a[2][2] == 0 || a[0][2] + a[1][1] + a[2][0] == 0) {
		f = true;
		goto A;
	}
	
	A:
	if (f == true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}


Measured memory_bytes: 256
import sys

#+++++
		
def main():
	s = input()
	t = input()
	ret=sum([1 for y,r in zip(s,t) if y == r])
	print(ret)
	
	
#+++++


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  int n; cin >> n;
  int ans = 0;
  reps(i, 1, n) {
    ans += i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

import sys
input = sys.stdin.readline
N, S = map(int, input().split())
X = list(map(int, input().split()))
if N > 1:
    D = gcd(abs(X[0] - S), abs(X[1] - S))
    for x in X[2:]:
        D = gcd(abs(S - x), D)
    print(D)
else:
    print(abs(S - X[0]))

Measured memory_bytes: 58608
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            //入力
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int sum = 0;

            string[] a = Console.ReadLine().Split(' ');
            for (int i = 0;i < m;i++)
            {
                sum += int.Parse(a[i]);
                if(sum > n)
                {
                    Console.WriteLine("-1");
                    return;
                }
                
            }

            //sの位置に応じて場合分けする
            Console.WriteLine(n - sum);
        }
    }

}


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

int N;
long int W;
long long int dp[102][100002]={};

int main() {
    cin >> N >> W;
    long long int w[N], v[N];
    for(int i=0; i<N; i++) {
        cin >> w[i] >> v[i];
    }
    
    for(long int sum_w=0; sum_w<=W; sum_w++) {
        for(int i=0; i<N; i++) {
            if(sum_w>=w[i]) {
                dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w[i]]+v[i]);
            } else {
                dp[i+1][sum_w] = dp[i][sum_w];
            }
        }
    }
    
    cout << dp[N][W] << endl;

    return 0;
    
}

Measured memory_bytes: 78336
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>
#include <climits>

using namespace std;

struct card {
  char suite;
  int num;
};

void BubbleSort(struct card *C,int N){
  for(int i=0;i<N;i++){
     for(int j=N-1;j>i;j--){
       if(C[j].num < C[j-1].num) {
         struct card tmp;
         memcpy(&tmp,&C[j],sizeof(card));
         memcpy(&C[j],&C[j-1],sizeof(card));
         memcpy(&C[j-1],&tmp,sizeof(card));
       }
     }
  }
}

void SelectionSort(struct card *C,int N){
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
       if(C[j].num < C[minj].num)
         minj = j;
    }
    if(minj != i){
    struct card tmp;
    memcpy(&tmp,&C[i],sizeof(card));
    memcpy(&C[i],&C[minj],sizeof(card));
    memcpy(&C[minj],&tmp,sizeof(card));
    }
  }
}

int main(){
  int n;
  struct card *bubble,*selection;

  scanf("%d\n",&n);
  
  bubble=(struct card*)malloc(n*sizeof(card));
  selection=(struct card*)malloc(n*sizeof(card));

  for(int i=0;i<n;i++){
    scanf("%c%d ",&bubble[i].suite,&bubble[i].num);
  }

  memcpy(selection,bubble,n*sizeof(card));
  
  BubbleSort(bubble,n);
  for(int i=0;i<n;i++){
    printf("%c%d",bubble[i].suite,bubble[i].num);
    if(i<n-1)
      putchar(' ');
  }
  puts("\nStable");

  SelectionSort(selection,n);
  for(int i=0;i<n;i++){
    printf("%c%d",selection[i].suite,selection[i].num);
    if(i<n-1)
      putchar(' ');
  }

  for(int i=0;i<n;i++){
    if(bubble[i].suite!=selection[i].suite || bubble[i].num != selection[i].num) {
      puts("\nNot stable");
      return 0;
    }
  }
  puts("\nStable");
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int used[500][500],n,m,k,tmp,tmpp,c,thien;
char a[500][500];
int main(){
    //freopen("dd.inp","r",stdin);
    //freopen("dd.out","w",stdout);
    cin>>n>>m>>k;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
        cin>>a[i][j];
    for (int i=1;i<=n;i++){
        tmp=0;
        tmpp=0;
        for (int j=1;j<=m;j++){
            if(a[i][j]=='#'){
                tmp=1;
                break;
            }
        }
        if(tmp==1){
            c++;
            for (int j=1;j<=m;j++){
                if(a[i][j]=='#'){
                    tmpp++;
                    if(tmpp>1)
                        c++;
                }
                used[i][j]=c;
            }
        }
        else
        if(tmp==0){
            for (int j=1;j<=m;j++)
                used[i][j]=used[i-1][j];
        }
    }
    tmp=0;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if (a[i][j]=='#'){
                tmp=1;
                break;
            }
        }
        if(tmp!=0){
            thien=i;
            break;
        }
    }
    if (thien!=1)
    for (int i=thien-1;i>=1;i--){
        for (int j=1;j<=m;j++){
            used[i][j]=used[i+1][j];
        }
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++)
            cout<<used[i][j]<<' ';
        cout<<endl;
    }
}


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

int main(int argc, char *argv[]) {
	int x1 = 0;
	int y1 = 0;

	int x2 = 0;
	int y2 = 0;

	int x3 = 0;
	int y3 = 0;

	int x4 = 0;
	int y4 = 0;

	int length = 0;

	std::cin >> x1 >> y1 >> x2 >> y2;

	if (x2 >= x1 && y2 >= y1) {
		x3 = x2 - (y2 - y1);
		y3 = y2 + (x2 - x1);
		x4 = x1 - (y2 - y1);
		y4 = y1 + (x2 - x1);
	}	
	if (x1 >= x2 && y2 >= y1) {
		x3 = x2 - (y2 - y1);
		y3 = y2 - (x1 - x2);
		x4 = x1 - (y2 - y1);
		y4 = y1 - (x1 - x2);
	}
	if (x1 >= x2 && y1 >= y2) {
		x3 = x2 + (y1 - y2);
		y3 = y2 - (x1 - x2);
		x4 = x1 + (y1 - y2);
		y4 = y1 - (x1 - x2);
	}
	if (x2 >= x1 && y1 >= y2) {
		x3 = x2 + (y1 - y2);
		y3 = y2 + (x2 - x1);
		x4 = x1 + (y1 - y2);
		y4 = y1 + (x2 - x1);
	}

	std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << std::endl;
	return 0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = input()
L = [[] for _ in range(K)]
for i in range(N):
    j = i % K
    L[j].append(T[i])
ans = 0
for i in range(K):
    for j in range(len(L[i])-1):
        if L[i][j] == L[i][j+1]:
            L[i][j+1] = 0
        if L[i][j] == 'r':
            L[i][j] = P
        if L[i][j] == 's':
            L[i][j] = R
        if L[i][j] == 'p':
            L[i][j] = S
    if L[i][-1] == 'r':
        L[i][-1] = P
    elif L[i][-1] == 's':
        L[i][-1] = R
    elif L[i][-1] == 'p':
        L[i][-1] = S
    ans += sum(L[i])
print(ans)

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

typedef long long ll;
using namespace std;

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

    for (int i = 1; i <= n; ++i) {
        if (floor(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
# import sys

s = input()

ans = "AC"
cnt = 0

if s[0] != "A":
    ans = "WA"

for i in range(1, len(s)):
    t = s[i]
    if t == "C":
        if 2 <= i < len(s) - 1:
            cnt += 1
    else:
        if t.isupper():
            ans = "WA"

if cnt != 1:
    ans = "WA"

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N),B(N,0);
  rep(i,N) cin >> A.at(i);
  queue<ll> Q;
  rep(i,N){
    ll k=2,x=0;
    while(k*(N-i)<=N){
      x+=B.at(k*(N-i)-1);
      k++;
    }
    if(x%2!=A.at(N-1-i)){
      B.at(N-1-i)=1;
      Q.push(N-i);
    }
  }
  cout << Q.size() << endl;
  while(!Q.empty()){
    cout << Q.front() << " ";
    Q.pop();
  }
  cout << endl;
}

Measured memory_bytes: 7100
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int main(void){
	int n;
	lli ys[55],xs[55];
	scanf("%d",&n);
	rep(i,n){
		scanf("%lld%lld",&ys[i],&xs[i]);
	}
	
	int ans=n;
	rep(i,n)rep(j,i){
		lli dy=ys[i]-ys[j],
			dx = xs[i]-xs[j];
		
		int s=0;
		rep(k,n){
			int nc=1;
			rep(t,n){
				if(ys[t]-ys[k]==dy && xs[t]-xs[k]==dx)nc=0;
			}
			s += nc;
		}
		ans = min(ans,s);
	}
	printf("%d\n",ans);
	
	return 0;
}






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

double culculate_1(double a, double b, double x){
    double s;
    
    s = (2*x) / (a*b);
    
    return atan2(b, s)*180/PI;
}

double culculate_2(double a, double b, double x){
    double y;
    
    y = (2*x) / (a*a) - b;
    
    return atan2(b-y, a)*180/PI;
}

int main(void){
    double a, b, x, result;
    
    cin >> a >> b >> x;
    
    if(a*a*b/2 >= x){
        result = culculate_1(a, b, x);
    } else {
        result = culculate_2(a, b, x);
    }
    
    printf("%.7lf", result);
    
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int first, end;
  bool finished1= false, finished2 = false;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'A') {
      first = i + 1;
      finished1= true;
    }
    if(finished1) {
      break;
    }
  }
  for(int i = s.size() + 1; i >= 0; i--) {
    if(s[i] == 'Z') {
      end = i;
      finished2= true;
    }
    if(finished2) {
      break;
    }
  }
  cout << end - first + 2 << endl;
}

Measured memory_bytes: 640
S = input()
n = len(S)

ans = 0
for bit in range(1 << (n-1)):
    tmp = S[0]
    for i in range(n-1):
        if bit & (1 << i):
            tmp += "+"
        tmp += S[i+1]
    
    ans += sum(map(int, tmp.split("+")))

print(ans)

Measured memory_bytes: 9056
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 == 7) {
			if (b == 5 && c == 5) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		} else if (a == 5) {
			if (b == 7 && c == 5) {
				System.out.println("YES");
			}else if (b == 5 && c == 7) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		} else {
			System.out.println("NO");
		}

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    vec d(N);
    rep(i,N) cin>>d[i];
    ll sum = 0;
    rep(i,N){
        reps(j, i + 1, N){
            sum += d[i]*d[j];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define p1(n) printf("showing %d\n",n)
#define p2(m,n) printf("showing %d %d\n",m,n)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
    int i,j,k,n,m,val,t=0,test;
    //freopen("000input.txt","r",stdin);
    cin>>n;
    int x=(1000-(n%1000))%1000;
    printf("%d\n",x);
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 3748
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

odd_most_common = Counter(v[:: 2]).most_common()[0]
even_most_common = Counter(v[1:: 2]).most_common()[0]

odd_most_cnt = odd_most_common[1]
even_most_cnt = even_most_common[1]

if odd_most_common[0] != even_most_common[0]:
	print(n - odd_most_cnt - even_most_cnt)
else:
	A = odd_most_cnt
	B = even_most_cnt
	if len(set(v[:: 2])) > 1:
		A = Counter(v[:: 2]).most_common()[1][1] + even_most_cnt
	if len(set(v[1:: 2])) > 1:
		B = odd_most_cnt + Counter(v[1:: 2]).most_common()[1][1]
	print(min(n - A, n - B))


Measured memory_bytes: 17116
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a % b)

def extgcd(a,b):
    if b == 0:
        x = 1
        y = 0
        return (x,y)
    r = a % b
    (y,x) = extgcd(b,r)
    y -= a//b * x
    return (x,y)

a,b = map(int,input().split())
x,y = extgcd(a,b)
print(x,y)


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>

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

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

	int N;
	cin >> N;
	vi ps(N+1, 0);
	ps[1] = 1;
	ll ans = 1;
	for(int i = 2; i <= N; ++i) {
		if(!ps[i]) {
			for(int j = i; j <= N; j += i) ps[j] = i;
			ps[i] = 2;
		} else {
			int p = ps[i];
			int j = i/p, c=1;
			while(j%p == 0) {
				++ c;
				j /= p;
			}
			ps[i] = ps[j] * (1+c);
		}
		ans += 1LL * ps[i] * i;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 42240
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {

  string s; cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  long long int cnt = 0;
  int w = 0;
  for(int i=0; i<n; i++){
    if(s[i] == 'W') w++;
    else cnt += w;
  }
  cout << cnt << endl;

  return 0;
}



///


Measured memory_bytes: 640
#include <iostream>

#include <algorithm>
using namespace std;
struct Point{
    long long int x;
    long long int lx, rx;
} points[100005];

bool cmp(Point a, Point b)
{
    return a.rx < b.rx;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 0 ; i < n;++i)
    {
        cin >> points[i].x;
        long long int l;
        cin >> l;
        points[i].lx = points[i].x - l;
        points[i].rx = points[i].x + l;
    }
    sort(points, points + n, cmp);
    long long int cur_rx = -2000000000;
    int sum = 0;
    for(int i = 0 ; i < n;++i)
    {
        if(i == 0)
        {
            cur_rx = points[i].rx;
            sum++;
        }
        else{
            if(points[i].lx >= cur_rx)
            {
                sum++;
                cur_rx = points[i].rx;
            }
        }
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

bool dual = 1;
int d[100020] = {};
vector<int> G[100010];
vector<bool> vis;

void dfs(int k, int dep) {
    vis[k] = 1;
    if (d[k] == 0) {
        if (dep % 2) d[k] = 1;
        else d[k] = 2;
    }
    for (auto &i : G[k]) {
        if (!vis[i]) {
            dfs(i, dep + 1);
        }
        else if (d[i] % 2 == dep % 2) {
            dual = 0;
            return;
        }
    }
}

int main() {
    ll n, m;
    cin >> n >> m;
    int x[m], y[m];
    vis.assign(n, 0);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        x[i]--;  y[i]--;
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }

    dfs(0, 0);
    if (dual) {
        ll p = 0, q = 0;
        for (int i = 0; i < n; i++) {
            if (d[i] == 1) p++;
            else q++;
        }
        ll ans = p * q;
        for (int i = 0; i < m; i++) {
            if (d[x[i]] != d[y[i]]) ans--;
        }
        cout << ans << endl;
    }
    else {
        cerr << 0 << endl;
        cout << n * (n - 1) / 2 - m << endl;
    }
}

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

bool graph[8][8];

int dfs(int v, int n, bool visited[8]){
  bool all_visited = true;
  for(int i=0; i<n; ++i){
    if(visited[i] == false){
      all_visited = false;
    }
  }
  if(all_visited){
    return 1;
  }
  int ret=0;
  for(int i=0; i<n; ++i){
    if(visited[i]){
      continue;
    }
    if(graph[v][i] == false){
      continue;
    }
    visited[i] = true;
    ret += dfs(i, n, visited);
    visited[i] = false;
  }
  return ret;
}

int main(){
  int n,m;
  cin >> n >> m;
  for(int i=0; i<m; ++i){
    int a, b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }
  bool visited[8];
  for(int i=0; i<n; ++i){
    visited[i] = false;
  }
  visited[0] = true;
  cout << dfs(0, n, visited) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int n,m,zekken[100],blank,i,j;

  scanf("%d %d",&n,&m);

  for(i = 0; i < n; i++){

    scanf("%d",&zekken[i]);

  }

  for(j = 0; j < m; j++){

    for(i = 0; i < n-1; i++){

      if(zekken[i]%(j+1) > zekken[i+1]%(j+1)){

	blank=zekken[i];
        zekken[i]=zekken[i+1];
        zekken[i+1]=blank;

      }

    }

  }

  for(i = 0; i < n; i++){

    printf("%d\n",zekken[i]);

  }

  return 0;

}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>

int n,m,i;
char s[10005];

int main(){
	while(scanf("%s",s)!=EOF){
		n=m=0;
		for(i=0;i<strlen(s)-2;i++){
			if(s[i]=='J' && s[i+1]=='O' && s[i+2]=='I')n++,i++;
			if(s[i]=='I' && s[i+1]=='O' && s[i+2]=='I')m++,i++;
		}
		printf("%d\n%d\n",n,m);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int c[200000];
const long long p = 1000000007;

long long powmod(long long b, long long x){
    long long t = 1;
    while(x){
        if (x & 1) t = (t * b) % p;
        b = (b * b) % p;
        x >>= 1;
    }
    return t;
}

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(c, c + n);
    for (int i = 0; i < n; i++) ans = (ans + (n+1-i) * ((long long) c[i])) % p;
    ans = (powmod(4, n-1) * ans) % p;
    cout << ans << '\n';
}


Measured memory_bytes: 1024
N,Ma,Mb = map(int,input().split())
abc = [ list(map(int,input().split())) for i in range(N)]

dp = [ [ [ float("inf") for i in range(401)] for j in range(401)] for k in range(N+1)]
dp[0][0][0] = 0
for i in range(N):
    for j in range(401):
        for k in range(401):
            if j - abc[i][0] >= 0 and k - abc[i][1] >= 0:
                dp[i+1][j][k] = min(dp[i][j][k],dp[i][j-abc[i][0]][k-abc[i][1]] + abc[i][2])

            else:
                dp[i+1][j][k] = dp[i][j][k]


ans = float("inf")
for i in range(1,401):
    for j in range(1,401):
        if (i / j ) == (Ma / Mb):
            ans = min(ans , dp[N][i][j])

if ans == float("inf"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 142044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
#define MAXN 120000
int n;
char s[MAXN+5],t[MAXN+5];
int maxx;
int main()
{
    scanf("%d",&n);
    scanf("%s%s",s+1,t+1);
    for(int p=1;p<=n;p++)
    {
        bool flag=0;
        for(int i=1;i<=p;i++)
        if(t[i]!=s[n-p+i])flag=1;
        if(flag==0)maxx=max(maxx,p);
	}
    printf("%d",n*2-maxx);
}

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

int main() {
  int N, K;
  int x;
  int y=0;
  cin >> N >> K;
  vector<int> vec(N);
  
  for (int i=0; i< N; i++) {
    cin >> x;
    if (x>=K) y++;
  }

  cout << y << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  int a, max = 1000;
  for (int i=0; i<N; i++) {
    int count = 0;
    cin >> a;
    while (a%2 == 0) {
      count++;
      a /= 2;
    }
    if (count < max) {
      max = count;
    }
  }
  
  cout << max << endl;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e3, mod = 1e9 + 7;
int n, k, dp[nsz + 5][nsz + 5], suf[nsz + 5][nsz + 5], ans;

int inline qpow(int a, int p) {
    int res = 1;
    for (; p > 0; p >>= 1) {
        (p & 1) && (res = (num) res * a % mod);
        a = (num) a * a % mod;
    }
    return res;
}

void inline upd(int &a, int b) {
    (a += b) && (a >= mod) && (a -= mod);
}

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> k;
    dp[0][n + 1] = 1;
    for (int j = n + 1; j >= 1; --j) {
        suf[0][j] = 1;
    }
    cont (i, k - 1) {
        cont (j, n) {
            dp[i][j] = suf[i - 1][j + 1];
            if (j + i - 1 <= n) {
                upd(dp[i][j], dp[i - 1][j]);
            }
        }
        for (int j = n; j >= 1; --j) {
            upd(suf[i][j], (suf[i][j + 1] + dp[i][j]) % mod);
        }
    }
    circ (j, 2, n + 1) {
        upd(ans, dp[k - 1][j]);
    }
    ans = (num) ans * qpow(2, n - k - 1) % mod;
    cout << ans << ln;
}


Measured memory_bytes: 31616
A, B = map(int, input().split())
a_cnt = 1
a_tmp = A
b_cnt = 1
b_tmp = B

while True:
    if a_tmp == b_tmp:
        print(a_tmp)
        exit(0)
    elif a_tmp > b_tmp:
        b_tmp = B*b_cnt
        b_cnt += 1
    else:
        a_tmp = A*a_cnt
        a_cnt += 1


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int dfs(int index,int M,int N,vi &p,vvi s,v(bool) on) {
  if(index == N) {
    v(bool) status(M,false);
    rep(i,N) {
      if(on[i]) {
        rep(j,M) {
          if(find(rng(s[j]),i+1) != s[j].end()) {
            status[j] = !status[j];
          }
        }
      }
      
    }
    bool flag = true;
    rep(i,M) {
      
      if(status[i] != p[i]) {
        flag = false;
      }
    }
    if(flag) return 1;
    return 0;
  }
  int ans = dfs(index+1,M,N,p,s,on);
  on[index] = true;
  ans += dfs(index+1,M,N,p,s,on);
  return ans;
}
  
int main() {
  int N,M;
  cin >> N >> M;
  vvi s(M);
  rep(i,M) {
    int k;
    cin >> k;
    s[i] = vi(k);
    rep(j,k) {
      cin >> s[i][j];
    }
  }
  vi p(M);
  rep(i,M) {
    cin >> p[i];
  }
  v(bool) on(N,false);
  cout << dfs(0,M,N,p,s,on) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll m,k;cin>>m>>k;
    if(k>=(ll)pow(2,m)){
        cout<<-1<<endl;
        return 0;
    }
    /*や～～～～～っとわかった．
    例えばk=110100とかだったら
    0~2^mまでで110100，110100，(111111,001011),(111111,001011)
    の4個のxorがkとなる部分を確実に作れる．
    で，0から2^m-1まで全部xorとったらこれって必ず0になる．絶対全桁偶数回1が出るから
    で0から2^m-1までのなかから110100，111111，001011を除いたやつをすべてxorとっても
    それは0になる．110100xor111111xor001011=0になるからxorの性質上それは明らか．

    だからk1=110100，k2=(111111,001011)とすると
    k1 abcd...k2...dcba  k1 k2(前のk2と前後逆)
    と構築すると満たせる．abcd...はk1,k2に使わなかったやつを1個ずつ並べたもので上述のようにすべてxorとると0

    あ，k=0の時は別でやらないとだめですね．失礼しやしんｗ
    あ，k=1111...のときもだめでしたね，死ぬか

    例外はm=1のときだけ1桁しかないから無理だからこれは別個処理
    */
   if(m==1){
       if(k!=0){
           cout<<-1<<endl;
       }
       else{
           cout<<"0 0 1 1"<<endl;
       }
       return 0;
   }

    //実際に構築すっぺ～～～
    
    ll M=(ll)pow(2,m)-1;

    if(k==0){
        for(ll i=M;i>=0;i--) cout<<i<<' ';
        for(ll i=0;i<M;i++) cout<<i<<' ';
        cout<<M<<endl;
        return 0;
    }
    if(k==M){
        for(ll i=0;i<M;i++) cout<<i<<' ';
        cout<<M<<' ';
        for(ll i=M-1;i>=0;i--) cout<<i<<' ';
        cout<<M<<endl;
        return 0;
    }



    cout<<k<<' ';
    //k2 = (M,M^k)である
    for(ll i=0;i<=M;i++){
        if(i==M||i==k||i==(M^k)) continue;
        cout<<i<<' ';
    }
    cout<<M<<' '<<(M^k)<<' ';
    for(ll i=M;i>=0;i--){
        if(i==M||i==k||i==(M^k)) continue;
        cout<<i<<' ';
    }
    cout<<k<<' '<<(M^k)<<' '<<M<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <string>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];

int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	vector <int> vx;
	for(int i=0;i<n;i++)
	{
		if(str[i]!='x')
		{
			vx.push_back(i);
		}
	}
	if(vx.size()==0)
	{
		puts("0");
		return 0;
	}
	for(int l=0,r=vx.size()-1;l<r;l++,r--)
	{
		if(str[vx[l]]!=str[vx[r]])
		{
			puts("-1");
			return 0;
		}
	}
	vector <int> len;
	int bef=0;
	for(int i=0;i<vx.size();i++)
	{
		len.push_back(vx[i]-bef);
		bef=vx[i]+1;
	}
	len.push_back(n-bef);
	int ret=0;
	for(int l=0,r=len.size()-1;l<r;l++,r--)
	{
		ret+=abs(len[l]-len[r]);
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 1528
import sys

N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

if X <= Y:
	Z = list(range(X+1,Y+1))
else:
	print('War')
	sys.exit()

Z_x = max(x)+1
Z_y = min(y)
if Z_x <= Z_y:
	Z_xy = list(range(Z_x,Z_y+1))
else:
	print('War')
	sys.exit()

for i in Z_xy:
	if i in Z:
		print('No War')
		sys.exit()
print('War')


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline


# 頂点数 v のグラフ d の頂点 i から頂点 j への最短路を求める (O|v^3|)
def warchall_floyd(d, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])


def main():
    N, M, L = map(int, input().split())
    inf = 10**10

    D = [[inf]*N for _ in range(N)]
    for i in range(N):
        D[i][i] = 0
    for _ in range(M):
        a, b, c = map(int, input().split())
        D[a-1][b-1] = c
        D[b-1][a-1] = c
    warchall_floyd(D, N)

    Q = int(input())

    F = [[inf]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if D[i][j] <= L:
                F[i][j] = 1
    warchall_floyd(F, N)

    ans = []
    for _ in range(Q):
        a, b = map(int, input().split())
        tmp = F[a-1][b-1]
        if tmp == inf:
            ans.append(-1)
        else:
            ans.append(tmp-1)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 54364