akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

const int INF = 1e9;


// code
// ------------------------------------------------
int main() {
  string s;
  cin >> s;

  bool b = false;
  if(s[2] == s[3])
  {
    if (s[4] == s[5])
    {
      b = true;
    }
  }
  
  if(b) cout << "Yes";
  else cout << "No";

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll k=((ll)sqrt(1+8*n)+1)/2, r=k*(k+1)/2-n;
    for(ll i=1; i<=k; i++){
        if(i==r) continue;
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

struct UnionFind
{
    vector<int> par, rank;
    
    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int find(int i){
        if(i == par[i]) return i;
        return par[i] = find(par[i]);
    }
    
    bool same(int i, int j){
        return find(i) == find(j);
    }
    
    void unite(int i, int j){
        if(same(i, j)) return;
        i = find(i), j = find(j);
        if(rank[i] < rank[j]) par[i] = j;
        else{
            par[j] = i;
            if(rank[i] == rank[j]) rank[i]++;
        }
    }
};

int main()
{
    int n;
    cin >> n;
    P px[100005], py[100005];
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        px[i] = P(x, i);
        py[i] = P(y, i);
    }
    sort(px, px + n);
    sort(py, py + n);
    PP p[200005];
    for(int i = 0; i < n - 1; i++) p[i] = PP(px[i + 1].first - px[i].first, P(px[i + 1].second, px[i].second));
    for(int i = 0; i < n - 1; i++) p[i + n - 1] = PP(py[i + 1].first - py[i].first, P(py[i + 1].second, py[i].second));
    sort(p, p + n * 2 - 2);
    UnionFind uf(n);
    ll ans = 0;
    for(int i = 0; i < n * 2 - 2; i++){
        P q = p[i].second;
        if(!uf.same(q.first, q.second)){
            ans += p[i].first;
            uf.unite(q.first, q.second);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11924
#include <cstdio>
#include <cstring>
typedef long long LL;
LL ans[200010], cnt[200010];
LL n, b[200010], c = 0, a[200010];
int main() {
    ans[1] = 0;
    for(LL i = 2; i < 200000; i++) {
        ans[i] = i - 1 + ans[i-1];
    }

    scanf("%lld", &n);
    for(LL i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        cnt[a[i]]++;
        if(cnt[a[i]] == 1) {
            b[c++] = a[i];
        }
    }
    LL sum = 0;
    for(int i = 0; i < c; i++) {
        sum += ans[cnt[b[i]]];
    }
    for(int i = 0; i < n; i++) {
        printf("%lld\n", sum - ans[cnt[a[i]]] + ans[cnt[a[i]]-1]);
    }
    return 0;
}


Measured memory_bytes: 8320
#include<iostream>

using namespace std;

int main() {
	int n;
	long long d;
	int ans = 0;
	cin >> n >> d;
	long long x, y;
	for (int i = 0;i < n;i++) {
		cin >> x >> y;
		if ((x * x + y * y) <= d*d) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3144
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int A[101];
        rep(i, n){
            cin >> A[i];
        }
        rep(i, n){
            int num = A[i];
            int j = i - 1;
            while(j >= 0 && A[j] > num){
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = num;
            rep(i, n){
                if(i == 0){
                    cout << A[i];
                }else{
                    cout << ' ' << A[i];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1164
fun main(args:Array<String>):Unit {
    var n = readLine()!!.toInt()
    while (n != 0){
        readLine()!!.toInt()
        val s = readLine()!!.trim()
        val memo = Array(s.length){0}
        for (i in 2 until memo.size){
            if (s[i - 2] == 'I' && s[i - 1] == 'O' && s[i] == 'I'){
                memo[i] = memo[i - 2] + 1
            }
        }
        println(memo.count{it >= n})
        n = readLine()!!.toInt()
    }
}



Measured memory_bytes: 48524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  string s;
  cin>>n>>s;
  n*=2;
  int a[200009];
  if(s[0]=='W'||s[n-1]=='W'){
    cout<<0<<endl;
    return(0);
  }
  a[0]=1;
  for(int i=1;i<n;i++){
    if(s[i-1]==s[i]){
      a[i]=!a[i-1];
    }
    else{
      a[i]=a[i-1];
    }
  }
  int k=0;
  rep(i,n){
    if(a[i])k++;
  }
  if(k!=n/2){
    cout<<0<<endl;
    return(0);
  }
  int cnt=0;
  mint ans=1;
  for(int i=n-1;i>=0;i--){
    if(a[i]==0)cnt++;
    else{
      if(cnt<0){
        cout<<0<<endl;
        return(0);
      }
      ans*=cnt;
      cnt--;
    }
  }
  for(int i=1;i<=n/2;i++){
    ans*=i;
  }
  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 1412
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 1000000007;


int main() {
  int N;
  cin >> N;
  int a[N];
  int cou[100001];
  for(int i = 0; i < 100001; i++) {
    cou[i] = 0;
  }
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < N; i++) {
    cou[a[i]]++;
  }
  int ma = 0;
  for(int i = 0; i < 100001; i++) {
    if(i == 0) {
      ma = max(ma,cou[i+1] + cou[i]);
    }
    else if(i == 100000) {
      ma = max(ma,cou[i-1] + cou[i]);
    }
    else {
      ma = max(ma,cou[i-1] + cou[i] + cou[i+1]);
    }
  }
  cout << ma << endl;

}


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

int main(void)
{
  int a,b,c = 0;
  cin >> a >> b >> c;
  int d1,d2,d3;
  d1 = abs(a-b);
  d2 = abs(b-c);
  d3 = abs(a-c);
  int max = d1;
  if(max<d2)
  max = d2;
  if(max<d3)
  max = d3;
  int ans = d1 + d2 + d3 -max;
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,a[100005],x[100005],y[100005];
struct uf{
    int par[100005],ran[100005];
    void init(){
        rep(i,100005) par[i] = i,ran[i] = 0;
    }
    int find(int x){
        if(x == par[x]) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(ran[x] < ran[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(ran[x] == ran[y]) ran[x]++;
        }
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
}u;
vector<int>num[100005],num2[100005];
int main(){
    cin>>n>>m; u.init();
    repn(i,n) cin>>a[i];
    repn(i,m){
        cin>>x[i]>>y[i];
        u.unite(x[i],y[i]);
    }
    repn(i,n){
        num[u.find(i)].pb(i);
        num2[u.find(i)].pb(a[i]);
    }
    int ans = 0;
    repn(i,n) SORT(num[i]),SORT(num2[i]);
    repn(i,n){
        rep(j,num2[i].size()){
            int a = num2[i][j];
            if(POSL(num[i],a) != num[i].size() && num[i][POSL(num[i],a)] == a){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2019nic2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();

            int count = 0;

            for(int i =0;i<N;i++)
            {
                if(A[i] != B[i] && A[i] != C[i] && B[i] != C[i])
                {
                    count += 2;
                }
                else
                {
                    if(A[i] != B[i] || A[i] != C[i] || B[i] != C[i])
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, ans[100100], chk[100100];
vector<int> v[100100];
queue<int> q;
int main(){
    scanf("%d %d",&n,&m);

    for(int i=1;i<=m;i++){
        int a, b; scanf("%d %d",&a,&b);
        v[a].push_back(b), v[b].push_back(a);
    }

    q.push(1);
    chk[1] = 1;
    while(!q.empty()){
        int u = q.front(); q.pop();

        for(auto x : v[u]) if(!chk[x]){
            chk[x] = 1;
            ans[x] = u;
            q.push(x);
        }
    }
    for(int i=2;i<=n;i++) if(!chk[i]) return !printf("No");

    puts("Yes");
    for(int i=2;i<=n;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 10916
import sys


def input():
    return sys.stdin.readline()[:-1]


N, M = map(int, input().split())

red = [0]*N
red[0] = 1
box = [1]*N
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1

    if red[x] == 1 and box[x] == 1:
        # 箱Xには赤玉がある可能性があって、全ボール数が1個のみがある場合
        red[x] -= 1
        red[y] = 1
    elif red[x] == 1 and box[x] >= 2:
        # 箱Xには赤玉がある可能性があって、全ボール数が2個以上ある場合
        red[y] = 1
    box[x] -= 1
    box[y] += 1

print(red.count(1))


Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i;
	string s;
	map<string, int> mp;
	cin >> num;
	rep(i, num) {
		cin >> s;
		mp[s]++;
	}
	printf("AC x %d\n", mp["AC"]);
	printf("WA x %d\n", mp["WA"]);
	printf("TLE x %d\n", mp["TLE"]);
	printf("RE x %d\n", mp["RE"]);
	return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  vi f(n);
  REP(i,n){
    REP(j,10){
      int x; cin>>x;
      f[i] += (x<<j);
    }
  }
  vector<vi> p(n,vi(11));
  REP(i,n)REP(j,11)cin>>p[i][j];
  int ans = -1e9;
  FOR(m,1,1024){
    int tmp = 0;
    REP(i,n)tmp += p[i][__builtin_popcount(f[i] & m)];
    CHMAX(ans, tmp);
  }
  cout<<ans<<endl;
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,k; cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  int ans=0;
  rep(i,n) if(h[i]>=k) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>

int main(){
  int n, a[1010], i, j, sa;
  while(1){
    scanf("%d", &n);
    if(n==0){
      break;
    }

    int  min=1000000;
    for(i=0;i<n;i++){
      scanf("%d", &a[i]);
    }
    for(i=0;i<n-1;i++){
      for(j=i+1;j<n;j++){
	sa=a[i]-a[j];
	if(sa<0){
	  sa*=-1;
	}
	if(min>sa){
	  min=sa;
	}
      }
    }
    printf("%d\n", min);
  }
  return 0;
}

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

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    int count = 0;
    int button = 1;


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

    for(int i = 0; i < n; i++){
        count += 1;
        button = a[button - 1];

        if(button == 2){
            cout << count;
            break;
        }

    }

    if(button != 2) cout << -1;


}

Measured memory_bytes: 640
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();

		if (a < b) {
			System.out.println("a < b");
		}

		else if (a > b) {
			System.out.println("a > b");
		}

		else {
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 26148
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>t;
    int cnt=1;
    ll d=t;
    while(d<=n)
    {
        cnt++;
        d*=t;
    }
    cout<<cnt;
    return 0;
}



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

using namespace std;

int n;
long long m[112123];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> m[i];
    sort(m, m + n);
    long long sum = 0;
    for (int i = 0; i < n/2 - 1; i++) {
        sum += 2*(m[n-i-1] - m[i]);
    }
    if (n % 2 == 0) {
        sum += (m[n/2] - m[n/2-1]);
    } else {
        sum += max(2*m[n/2+1] - m[n/2] - m[n/2-1],
                m[n/2+1] + m[n/2] - 2*m[n/2-1]);
    }
    cout << sum << '\n';
    return 0;
}


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

int main()
{
    int x,counter=0;
    string S,T,tempp;
    deque <char> temp;
    cin >> S >> T;
    tempp=S;
    if (S.length()!=T.length()){
        cout << "No";
    }
    if (S==T){
        cout << "Yes";
    }
    else {
        for (int i=0; i<S.length(); i++){
            temp.push_back(S[i]);
        }
        x=S.length()-1;
        for (int i=0; i<S.length()-1; i++){
            temp.push_front(S[x]);
            temp.pop_back();
            x-=1;
            for (int j=0; j<S.length(); j++){
                tempp[j]=temp[j];
            }
            if (tempp==T){
                counter=1;
                break;
            }
           }
           if (counter==1){
            cout << "Yes";
           }
           else cout << "No";
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  map<int,int>m;
  int n,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
  	int x;
  	cin>>x;
  	m[x]++;
  }
  for(auto& p:m)
  {
  	if(p.second&1)
  	cnt++;
  }
  cout<<cnt;
 return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    long long n,k;
    cin >> n >> k;
    long long ans = n % k;
    if(ans < abs(ans - k)){
        cout << ans << endl;
    }else{
        cout << abs(ans - k) << endl;
    }
}

Measured memory_bytes: 3604
use proconio::input;
use proconio::marker::Usize1;

fn main()
{
    input! {
    n:usize,
    m:i32,
    arr:[(Usize1,Usize1);m],
    }

    let mut v: Vec<i32> = vec![0; n + 1];
    for a in arr {
        v[a.0] += 1;
        v[a.1 + 1] -= 1;
    }

    for i in 0..n {
        v[i + 1] += v[i];
    }

    let ans = v.into_iter().filter(|&x| x == m).count();
    println!("{}", ans);
}

Measured memory_bytes: 5176
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

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

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

bool compareP(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int w, h;
int mp[50][50];

void dfs(int h2, int w2) {
    mp[h2][w2] = 0;
    rep(i, 8) {
        int nw = w2 + ddx[i];
        int nh = h2 + ddy[i];
        if (nw >= 0 && nw < w && nh >= 0 && nh < h && mp[nh][nw] == 1)
            dfs(nh, nw);
    }
}

int main() {
    while (true) {
        cin >> w >> h;
        int ans = 0;
        if (w == 0 && h == 0)
            break;
        rep(i, h) rep(j, w) cin >> mp[i][j];
        rep(i, h) rep(j, w) {
            if (mp[i][j] == 1) {
                dfs(i, j);
                ans += 1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
# define ll long long 
#define for(a,b) for(auto i=(a);i<(b);i++) 
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum =0,modo = 1e9 + 7;
    for(0,n){
        cin>>a[i];
        sum += a[i];
        sum %= modo;
    }
    ll ans =0;
    for(0,n){
        sum -= a[i];
        if(sum < 0){
            sum += modo;
        }
        ans += a[i]*sum;
        ans %= modo;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, d, x;
  cin >> n >> d >> x;
  ll a[n];
  ll ans = x;
  REP(i, n){
    cin >> a[i];
    ans += (d - 1) / a[i] + 1;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,k,cnt=0; cin>>n>>k;
	while(n>0){
		n/=k;
		++cnt;
	}
	cout<<cnt<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		final int[] list = getList();
		final int diff = getMaxDiff(list);
		
		System.out.println(diff);
	}
	
	public static int getMaxDiff(int[] list) {
        int maxDiff = list[1] - list[0];
        int min = list[0];
        
        int diff;
        for (int i = 2; i < list.length; i++) {
        	if (list[i-1] < min) min = list[i-1];
        	diff = list[i] - min;
        	if (maxDiff < diff) maxDiff = diff;
        }
         
        return maxDiff;
    }
	
	public static int[] getList() {
		int[] list = null;
		
		try {
			final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			final int n = Integer.parseInt(reader.readLine());
			list = new int[n];
			for (int i = 0; i < n; i++) {
				list[i] = Integer.parseInt(reader.readLine());
			}
			reader.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return list;
	}
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> n;

    bool f = true;
    REP(i, n) {
        int x;
        cin >> x;
        if (x%2 == 0) {
            if (!(x%3 == 0 || x%5 == 0)) {
                f = false;
                break;
            }
        }
    }
    if (f) {
        std::cout << "APPROVED" << '\n';
    } else {
        std::cout << "DENIED" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
map<long long,long long>Map;
long long A, B, C, D, P[6];
long long DP(long long n){
    if(!n)return 0ll;
    if(n==1)return D;
    if(Map.count(n))return Map[n];
    int i;
    long long r=1e18;
    for(i=2;i<=5;i++){
        if(i==4)continue;
        long long x = n/i;
        long long u = DP(x);
        long long t1 = (n-x*i)*D +P[i];
        if(t1/D >= (n-x))t1 = (n-x)*D;
        r=min(r,t1+u);
        if(x+1!=n){
            long long t2 = ((x+1)*i-n)*D +P[i];
            if(t2/D >= (n-x-1))t2 = (n-x-1)*D;
            long long v = DP(x+1);
            r=min(r,t2+v);
        }
    }
    Map[n]=r;
    return r;
}
void Solve(){
    long long n;
    scanf("%lld%lld%lld%lld%lld",&n,&P[2],&P[3],&P[5],&D);
    Map.clear();
    printf("%lld\n",DP(n));
}
int main(){
    int TC;
    scanf("%d",&TC);
    while(TC--){
        Solve();
    }
}


Measured memory_bytes: 4500
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int N, K,now = 1;
	cin >> N >> K;

	rep(i, N) now = min(now+K,now*2);
	cout << now << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[101010];
int main()
{
	int num, g;
	scanf("%d%d", &num, &g);
	for (int i = 0; i < num; i++)scanf("%d", &d[i]);
	int maxi = 0;
	int maxd = 0;
	int t = 0;
	for (int i = num - 1; i >= 0; i--)
	{
		maxi = max(maxi, d[i]);
		if (maxd < maxi - d[i])maxd = maxi - d[i], t = 1;
		else if (maxd == maxi - d[i])t++;
	}
	printf("%d\n", t);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int ok(string s){
	int n = s.size();
	int i;
	rep(i, n/2){
		if(s[i] != s[i+n/2]) return 0;
	}
	return 1;
}

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s;
	n = s.size();
	m = 0;
	while(n > 0){
		s.pop_back();
		s.pop_back();
		n = s.size();
		if(ok(s) > 0){
			m = n;
			break;
		}
	}

	cout << m << endl;
}

Measured memory_bytes: 256
N = int(input())
D = []
E = []
clear = 0
for i in range(N):
    x, y = map(int, input().split())
    D.append(x)
    E.append(y)

for i in range(N - 2):
    if D[i] == E[i] and D[i + 1] == E[i + 1] and D[i + 2] == E[i + 2]:
        clear = 1
        break

if clear == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9152
using System;

namespace ALDS1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int N = int.Parse(input);
            input = Console.ReadLine();
            string[] ref_st = input.Split(' ');
            int[] reference = new int[N];

            for (int i = 0; i < N; i++)
            {
                reference[i] = int.Parse(ref_st[i]);
            }

            input = Console.ReadLine();
            int q = int.Parse(input);
            input = Console.ReadLine();
            string[] ana_st = input.Split(' ');
            int[] analyte = new int[q];

            for (int i = 0; i < q; i++)
            {
                analyte[i] = int.Parse(ana_st[i]);
            }

            int left, right, middle;
            int count = 0;

            for (int i = 0; i < q; i++)
            {
                left = 0; right = N; 

                while (left < right)
                {
                    middle = (left + right) / 2;
                    if (reference[middle] == analyte[i])
                    {
                        count++;
                        break;
                    } else
                    {
                        if (reference[middle] < analyte[i])
                        {
                            left = middle + 1;
                        } else
                        {
                            right = middle;
                        }
                    }
                }
            }

            Console.WriteLine(count);

            
        }
    }
}

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

int main()
{
    string S, T;

    cin >> S;
    cin >> T;

    string uns = "No";

    for (int i = 0; i < S.length(); i++) {
        S.push_back(S[0]);
        S.erase(S.begin());

        if (S == T) {
            uns = "Yes";
            break;
        }
    }
    cout << uns << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1;i*2<=N;i++){
        if(i == N-i) continue;
        ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        vllin(a,n);
        ll k=a[0];
        vll v(0);
        FOR(i,1,n-1){
                k=k^a[i];
        }
        ll c=0;
        if(k!=0){
                sal("No")
                return 0;
        }else{
                FOR(i,0,n-1){
                        c=0;
                        FOR(j,1,v.sz){
                                if(a[i]==v[j-1]){
                                        c=1;
                                }
                        }
                        if(c==0){
                                v.pb(a[i]);
                        }
                        if(v.sz>3){
                                sal("No")
                                return 0;
                        }
                }
                sal("Yes")
        }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int primeFactors(int n)
{
	int N = n;
	set<int> s;
	while (n % 2 == 0)
	{
		s.insert(2);
		n = n / 2;
	}
	for (int i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			s.insert(i);
			n = n / i;
		}
	}
	if (n > 2)
		s.insert(n);
	int cnt = 0, ans = 0;
	for (auto j : s) {
		cnt = 0;
		while (N % j == 0) {
			cnt++; N = N / j;
		}
		int k = 0, p = 1;
		while (k + p <= cnt) {
			k = k + p;
			p++;
		}
		ans += p - 1;
	}
	return ans;
}

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n;
		cin >> n;
		cout << primeFactors(n) << endl;
	}
	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> A(n);
	vector<int> B(m);
	vector<int> C(m);

	priority_queue<pair<int, int> > P;
	for (int i = 0; i <= n-1; i++) {
		cin >> A[i];
		P.push(make_pair(A[i], 1));
	}

	for (int i = 0; i<= m-1; i++) {
		cin >> B[i] >> C[i];
		P.push(make_pair(C[i], B[i]));
	}

	unsigned long long ans = 0;

	for (int i = 0; i <= n-1; i++) {
		auto p = P.top();
		P.pop();
		ans += p.first;

		if (p.second > 1) {
			p.second--;
			P.push(p);
		}
	}

	cout << ans << endl;
}

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

const int MAXN = 10005;
const int d[] = {0, 2, 5, 5 ,4, 5, 6, 3, 7, 6};

int N, M, A[10], dp[MAXN], par[MAXN];
int main(){
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++)
		scanf("%d", &A[i]);
	sort(A, A + M);
	
	for(int i = 0; i <= N; i++){
		if(i == 0){
			dp[i] = 0;
			continue;
		}
		
		dp[i] = -1 << 20;
		for(int j = M - 1; j >= 0; j--)if(i >= d[A[j]]){
			if(1 + dp[i - d[A[j]]] > dp[i]){
				dp[i] = 1 + dp[i - d[A[j]]];
				par[i] = A[j];
			}
		}
	}
	
	while(N > 0){
		printf("%d", par[N]);
		N -= d[par[N]];
	}
	printf("\n");
	
	return 0;
}


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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(t*s>=d)
  cout<<"Yes"<<endl;
  else
  {
    cout<<"No"<<endl;
  }
  
  system("pause");
  return 0;
}


Measured memory_bytes: 3696
import qualified Data.Bits as Bits
import qualified Data.ByteString.Char8 as BS
import qualified Data.Char as Char
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import qualified Data.Vector.Unboxed.Mutable as UMVector
import qualified Data.Vector.Unboxed as UVector
import Data.Vector.Unboxed ((!))

xorLengths :: UVector.Vector Int -> Int -> Int -> Int -> [Int] -> [Int]
xorLengths as i l xorVal acc
	| i >= len = acc
	| i + l >= len = xorLengths as (i + 1) (l - 1) nextXor (l:acc)
	| xorVal' == xorVal + next = xorLengths as i (l + 1) xorVal' acc
	| otherwise = xorLengths as (i + 1) (l - 1) nextXor (l:acc)
	where
		len = UVector.length as
		current = as ! i
		next = as ! (i + l)
		xorVal' = xorVal `Bits.xor` next
		nextXor = xorVal `Bits.xor` current

main :: IO ()
main = do
	n <- readLn
	as <- UVector.unfoldrN n (BS.readInt . BS.dropWhile Char.isSpace) <$> BS.getLine
	print $ sum $ xorLengths as 0 0 0 []


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

int main(){
    long long X,K,D;
    cin >> X >> K >> D;
    if(X<0){
        X= -X;
    }
    long long counta=X/D;
    if(K<counta){
        cout << X-K*D << endl;
    }else{
        K-=counta;
        if(K%2==0){
            cout << X%D << endl;
        }else{
            cout << D-X%D << endl;
        }
    }
    system("pause");
    return 0;
}

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

const int N = 100005;

int prime[N];

signed main(){
  
  int x;
  cin >> x;

  for(int i=0;i<N;i++) prime[i] = 1;
  
  prime[0] = prime[1] = 0;
  
  for(int i=0;i*i<N;i++){
    
    if( !prime[i] ) continue;
    
    for(int j=i*2;j<N;j+=i){
      prime[j] = 0;
    }
    
  }
  
  for(int i=0;i<N;i++){
    if( !prime[i] ) continue;
    if( x <= i ){
      cout<<i<<endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

#define int long long

bool check(vector<int>& a,int g,int k){
    int n = a.size();
    int cnt = 0;
    vector<int> b(n+1),c(n+1);
    rep(i,n){
        b[i+1]=a[i]%g;
        c[i]=g-a[i]%g;
    }
    sort(b.begin(),b.end());
    sort(c.rbegin(),c.rend());
    
    rep(i,n)b[i+1]+=b[i];
    rep(i,n)c[n-i-1]+=c[n-i];
    rep(i,n+1){
        if(max(b[i],c[i])<=k)return true;
    }
    return false;
}

signed main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int sum = 0;
    rep(i,n)sum+=a[i];
    int ans = 1;
    REP(i,1,100000){
        if(sum%i==0){
            if(check(a,i,k))ans=max(ans,i);
            if(check(a,sum/i,k))ans=max(ans,sum/i);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int dp[2][2600][2600] = {};

signed main(){

    int n; cin >> n;
    int sum = 0;
    vector<int> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
        sum += t[i];
    }
    dp[0][0][0] = 1;
    int cur = 0;
    int nxt = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 2600; j++){
            for(int k = 0; k < 2600; k++){
                dp[nxt][j][k] = 0;
            }
        }

        for(int j = 0; j < 2600; j++){
            for(int k = 0; k < 2600; k++){
                if(dp[cur][j][k] == 0) continue;

                // 取らない
                dp[nxt][j][k] = 1;
                dp[nxt][j + t[i]][k] = 1;
                dp[nxt][j][k + t[i]] = 1;

           }
        }

        swap(cur, nxt);
    }

    int ans = INF;
    for(int j = 0; j < 2600; j++){
        for(int k = 0; k < 2600; k++){
            if(dp[cur][j][k] == 0) continue;
            ans = min(ans, max(max(j, k), sum - (j + k)));
        }
    }

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




Measured memory_bytes: 108728
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
char pass[16];

int judge(int i){
  char a = pass[i-1], b = pass[i];
  switch(b){
  case 'A':
    if(a == 'B' || a == 'D') return 0;
    break;
  case 'B':
    if(a == 'A' || a == 'E' || a == 'C') return 0;
    break;
  case 'C':
    if(a == 'B' || a == 'F') return 0;
    break;
  case 'D':
    if(a == 'A' || a == 'G' || a == 'E') return 0;
    break;
  case 'E':
    if(a == 'B' || a == 'D' || a == 'F' || a == 'H') return 0;
    break;
  case 'F':
    if(a == 'C' || a == 'E' || a == 'I') return 0;
    break;
  case 'G':
    if(a == 'D' || a == 'H') return 0;
    break;
  case 'H':
    if(a == 'E' || a == 'G' || a == 'I') return 0;
    break;
  case 'I':
    if(a == 'F' || a == 'H') return 0;
    break;
  }
  return 1;
}

int main(){
  rep(i, 1000){
    scanf("%s", pass);
    int f = 0;
    REP(j, 1, strlen(pass)) f += judge(j);
    if(!f) puts(pass);
  } 
  return 0;
}

Measured memory_bytes: 1112
import math
x = int(input())

def is_prime(n):
  if n == 1:
    return False
  else:
    for i in range(2, int(math.sqrt(n))+1):
      if n%i==0:
        return False
  return True

for i in range(x, 100004):
  if is_prime(i):
    print(i)
    break

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,K;
    vector<ll> P;
    long double C[1001];
    C[0] = 0.0;
    long double c = 0;
    for (int i = 1; i < 1001; i++) {
        c += (long double)i;
        C[i] = c / (long double)i;
    }
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        ll p;
        cin >> p;
        P.pb(p);
    }
    long double ans = -1;
    long double total = 0;
    for (int i = 0; i < N; i++) {
        if(i >= K){
            total += C[P[i]];
            total -= C[P[i-K]];
            ans = max(ans,total);
        } else {
            total += C[P[i]];
            ans = max(ans,total);
        }
    }
    printf("%.10Lf\n",ans);
}

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

struct task{
  long A;
  long B;
};

bool cmp(const task &a, const task &b){
  return a.B < b.B;
}

int main(){

  int N;
  bool answer=true;
  long timee=0;
  cin >> N;
  struct task work[N];
  for(int i=0; i<N; i++) cin >> work[i].A >> work[i].B;
  sort(work, work+N, cmp);

  for(int i=0; i<N; i++){
    timee += work[i].A;
    if(timee > work[i].B){
      answer = false;
      break;
    }
  }

  cout << (answer ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3328
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int[] tri = new int[3];
        for(int i = 0; i < 3; i++)
            tri[i] = scan.nextInt();

        Arrays.sort(tri);
        if((tri[1] == tri[0] && tri[1] != tri[2]) || (tri[1] == tri[2] && tri[1] != tri[0]))
            os.println("Yes");
        else
            os.println("No");
    }
}

Measured memory_bytes: 21588
from collections import Counter
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

cnt = Counter(a)
div = max(0, len(cnt) - k)

if div != 0:
  l = sorted(cnt.values())
  print(sum(l[:div]))
  
else:
  print(0)


Measured memory_bytes: 32572
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;   
}

int main() {
    string s;
    cin>>s;
    bool flag=true;
    rep(i,s.size()){
        if(i%2==0){
            if(s.at(i)=='L'){
                flag=false;
                //cout<<"AA"<<endl;
            }
        }
        else{
            if(s.at(i)=='R'){
                flag=false;
                //cout<<"CA"<<endl;
            }
        }
    }
    if(flag==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}





Measured memory_bytes: 256
//https://qiita.com/drken/items/a803d4fc4a727e02f7ba
//参考にさせて頂いたサイト
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
#define rep(i,n) for(int i=0;i<(n);i++)
int N,Q;
vector<vector<int> > G;

vector<bool> seen,finished;

int pos=01;
stack<int> hist;//last-in first-outのキュー？

void DFS(int v,int p){
    seen[v]=true;
    hist.push(v);

    for(auto nv:G[v]){
        if(nv==p)continue;

        if(finished[nv])continue;

        if(seen[nv]&&!finished[nv]){
            pos=nv;//サイクルだったらその頂点をメモ。
            return;
        }

        DFS(nv,v);

        if(pos!=-1)return;
    }
    hist.pop();
    finished[v]=true;//帰りがけで訪れられたら。
}

int main(){
    cin>>N;
    G.resize(N);
    rep(i,N){
        int a,b;
        cin>>a>>b;
        a--,b--;//0-indexedにする
        G[a].push_back(b);
        G[b].push_back(a);
    }

    seen.assign(N,false),finished.assign(N,false);
    pos= -1;
    DFS(0,-1);
    set<int> cycle;//要素が常にソートされる配列？
    while(!hist.empty()){
        int t=hist.top();
        cycle.insert(t);
        hist.pop();
        if(t==pos)break;
    }
    cin>>Q;
    for(int _=0;_<Q;++_){
        int a,b;
        cin>>a>>b;
        --a,--b;
        if(cycle.count(a)&&cycle.count(b))cout<<2<<endl;//cycle.countでは要素の検索をしている。
        else cout<<1<<endl;
    }
    return 0;
}
//N頂点とN辺からなると題に示されていることから、サイクルをただ一つ含むとわかる。
//a=97,z=122


Measured memory_bytes: 19204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class SSSPath
{
public:
  int solve();
};

int SSSPath::solve()
{
  int n;
  cin >> n;

  vector<vector<pair<int, int>>> adj( n );

  for ( auto i = 0; i < n; ++i )
    {
      int k, u, v, w;

      cin >> u >> k;

      for ( auto j = 0; j < k; ++j )
        {
          cin >> v >> w;
          adj[u].push_back( make_pair( v, w ) );
        }
    }

  const int infty = 2000000000;
  
  vector<int> d( n, infty );
  vector<bool> vs( n, true );
  
  d[0] = 0;

  while ( true )
    {
      int u, mc = infty;

      for ( auto i = 0; i < n; ++i )
        {
          if ( vs[i] && d[i] < mc )
            {
              mc = d[i];
              u = i;
            }
        }

      if ( mc == infty ) break;
      
      vs[u] = false;

      for ( auto it = adj[u].begin(); it != adj[u].end(); ++it )
        {
          if ( d[(*it).first] > d[u] + (*it).second )
            {
              d[(*it).first] = d[u] + (*it).second;
            }
        }
    }

  for ( auto i = 0; i < n; ++i )
    cout << i << " " << d[i] << endl;
  
  return 0;
}

int main()
{
  SSSPath s;

  s.solve();

  return 0;
}

Measured memory_bytes: 5748
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,i,ans=0;
int main()
{
	scanf("%d%d",&a,&b);
	if(a==0||b==0)
	{
	printf("Zero\n");
	
	}
	if(a>0)printf("Positive\n");
	else if(a<0&&b>0)
	{
		printf("Zero\n");
	}
	else if((a&1)^(b&1))printf("Positive\n");
	else printf("Negative\n");
		
	return 0;
}

Measured memory_bytes: 256