akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),M = in();
    vector<int> A(N,11);
    bool ok = 1;
    REP(i,M){
        int dig = in()-1,num = in();
        if(dig == 0 && num == 0 && N != 1){
            ok = 0;
        }else if(A[dig] == 11){
            A[dig] = num;
        }else if(A[dig] != num){
            ok = 0;
        }
    }
    if(A.size() == 1&&A[0] == 11)A[0] = 0;
    REP(i,N){
        if(i == 0){
            if(A[i] == 11)A[i] = 1;
        }else{
            if(A[i] == 11)A[i] = 0;
        }
    }
    if(ok){
        REP(i,N)cout << A[i];
        cout << "\n";
    }else{
        cout << -1 << "\n";
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

void dfs(ll d, ll current, ll K, vector<ll> &all) {
  if (d == 9) return;

  for (ll i = -1; i <= 1; i++) {
    // 一番小さい桁で差の絶対値が1以下になるものを、末尾につける
    ll add = current % 10 + i;
    if (add < 0 || add > 9) continue;

    ll n = current * 10 + add;
    all.push_back(n);
    dfs(d + 1, n, K, all);
  }
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll K;
  cin >> K;

  vector<ll> all;

  for (ll i = 1; i <= 9; i++) {
    all.push_back(i);
  }

  for (ll i = 1; i <= 9; i++) {
    dfs(0, i, K, all);
  }

  sort(all.begin(), all.end());

  // for (auto a : all) {
  //   cout << a << endl;
  // }

  cout << all[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int cnt4 = 0;//4
		int cnt2 = 0;//2
		int cnt1 = 0;//other
		for(int i=0; i<n; i++) {
			int a = sc.nextInt();
			if(a%4==0) {
				cnt4++;
			} else if(a%2==0) {
				cnt2++;
			}
		}
		cnt1=n-cnt4-cnt2;
		if(cnt2>0) {
			cnt1++;
		}
		if(cnt1<=cnt4+1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 48508
import sys

ERROR_INPUT = 'input is invalid'
ERROR_INPUT_NOT_UNIQUE = 'input is not unique'


def main():
    S = get_input1()
    T = get_input2()

    count = 0
    for t in T:
        if t in S:
            count += 1

    print(count)


def get_input1():
    n = int(input())
    if n > 10000:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        li.append(x)

    return li


def get_input2():
    n = int(input())
    if n > 500:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split(' '):
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        elif int(x) in li:
            print(ERROR_INPUT_NOT_UNIQUE)
            sys.exit(1)
        li.append(x)

    return li


main()

Measured memory_bytes: 6236
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=1e5+5;
int dp[N];
map<int,bool> m;
int n,t;

int build(int id)
{
    if(id>n)
        return 0;
    if(id==n)
        return 1;

    if(dp[id]!=-1)
        return dp[id];

    int ans=0;
    if(!m.count(id+1))
        ans+=build(id+1),ans%=mod;
    if(!m.count(id+2))
        ans+=build(id+2),ans%=mod;

    return dp[id]=ans;

}

int32_t main()
{
    fast;
    cin>>n>>t;
    for(int i=0;i<t;i++)
    {
        int x;cin>>x;
        m[x]=true;
    }
    MSET(dp,-1);
    cout<<build(0);
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


void subsetsUtil(vector<int>& A, vector<vector<int> >& res, 
                 vector<int>& subset, int index) 
{ 
    res.push_back(subset); 
    for (int i = index; i < A.size(); i++) { 
  
        subset.push_back(A[i]); 
  
        subsetsUtil(A, res, subset, i + 1); 
  
        subset.pop_back(); 
    } 
  
    return; 
} 
  
vector<vector<int> > subsets(vector<int>& A) 
{ 
    vector<int> subset; 
    vector<vector<int> > res; 
 
    int index = 0; 
    subsetsUtil(A, res, subset, index); 
  
    return res; 
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, x;
	cin>>n>>m>>x;
	vector<int> array(n);
	for(int i = 0; i < n; i++)
	{
		array[i]=i;
	}

	vector<vector<int> > res = subsets(array); 
  
  	int minim = imx;
  	vector<vector<int> > mat(n, vector<int> (m+1));
  	for(int i = 0; i < n; i++)
  	{
  		for(int j = 0; j < m+1; j++)
  		{
  			cin>>mat[i][j];
  		}
  	}

    for (int i = 0; i < res.size(); i++)
    { 
    	int sum = 0;
    	vector<int> tem(m+1);
        for (int j = 0; j < res[i].size(); j++) 
        	for(int k = 0; k < m+1; k++)
        		tem[k]+=mat[res[i][j]][k];
        int f = 0;
        for(int k = 1; k<=m; k++)
        {
        	if(tem[k]<x)
        	{
        		f = 1;
        		break;
        	}
        }
        if(!f)
        	minim = min(tem[0], minim);
    } 
    if(minim==imx) cout<<-1<<endl;
    else
    	cout<<minim<<endl;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {
    }
    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

using T = tuple<double, double, double, double>;
double d(T a, T b) {
    double x1, y1, z1, r1, x2, y2, z2, r2;
    tie(x1, y1, z1, r1) = a;
    tie(x2, y2, z2, r2) = b;
    return max(0.0, sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2) + pow(z1 - z2, 2)) -
                        r1 - r2);
}
int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        vector<T> v(n);
        rep(i, n) {
            double x, y, z, r;
            cin >> x >> y >> z >> r;
            v[i] = make_tuple(x, y, z, r);
        }

        vector<tuple<double, int, int>> es;
        rep(i, n) {
            rep(j, i) {
                es.emplace_back(d(v[i], v[j]), i, j);
            }
        }
        sort(all(es));

        double ans = 0;
        UnionFind uf(n);
        for (auto e : es) {
            double c;
            int a, b;
            tie(c, a, b) = e;
            if (!uf.find(a, b)) {
                uf.unite(a, b);
                ans += c;
            }
        }
        cout <<fixed<<setprecision(3)<< ans << endl;
    }
}


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

using namespace std;

const int N=1e5+10;
const int INF=1e9+10;
int a[N];

bool in(int a,int b)
{
    return a>0&&a<=b;
}

int main()
{
    int n,k;

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

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

        map<int,int> mp;
        int Min=INF;
        int cnt=0;

        for(int l=0,r=0;l<n;l++)
        {
            while(r<n&&cnt<k)
            {
                if(mp[a[r++]]++==0&&in(a[r-1],k))
                {
                    cnt++;
                }
            }
            if(cnt==k)
            {
                Min=min(Min,r-l);
            }
            if(in(a[l],k)&&mp[a[l]]--==1)
            {
                cnt--;
            }
        }
        if(Min==INF) Min=0;
        cout<<Min<<endl;
    }

    return 0;
}



Measured memory_bytes: 8216
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

cnt = 0
(0..A).to_a.each do |a|
  (0..B).to_a.each do |b|
    (0..C).to_a.each do |c|
      cnt += 1 if 500*a+100*b+50*c == X
    end
  end
end

puts cnt


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    if(n>=30) puts("Yes");
    else puts("No");
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3552
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        Integer empireA[] = new Integer[n];
        Integer empireB[] = new Integer[m];
        for(int i=0; i<n; i++){
            empireA[i] = sc.nextInt();
        }
        Arrays.sort(empireA, Collections.reverseOrder());
        for(int i=0; i<m; i++){
            empireB[i] = sc.nextInt();
        }
        Arrays.sort(empireB);
        for(int z=x+1; z<=y; z++){
            if(empireA[0] < z && empireB[0] >= z){
                System.out.println("No War");
                break;
            }
            if(z == y) System.out.println("War");
        }
    }
}

Measured memory_bytes: 23764
N = int(input())
Alist = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Clist = list(map(int, input().split()))

SaticefactonalPoint = 0

for i in range(N):
    EatingDish = Alist[i]
    SaticefactonalPoint += Blist[EatingDish-1]
    if i >= 1:
        HavingEatenDish = Alist[i-1]
        if HavingEatenDish + 1 == EatingDish:
            SaticefactonalPoint += Clist[HavingEatenDish-1]

print(SaticefactonalPoint)

Measured memory_bytes: 3064
from itertools import permutations

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

ans = 0
for comb in permutations(range(1, N), N-1):
    v = 0
    valid = True
    for i in comb:
        if i not in graph[v]:
            valid = False
            break
        v = i
    if valid:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
using namespace std;
#define MAX 10000
#define WHITE 0
#define BLACK 2

int n,e;
int col[MAX];


int main(){
    vector<int> P[MAX];
    int s,t;
    cin>>n>>e;
    for(int i=0;i<e;i++){
        cin>>s>>t;
        P[t].push_back(s);
    }
    for(int i=0;i<n;i++) col[i]=WHITE;

    bool fin=false;
    bool end;
    while(fin==false){
        fin=true;
        for(int i=0;i<n;i++){
            end=true;
            if(col[i]==WHITE){
                fin=false;
                if(!P[i].empty()){
                    for(int j=0;j<P[i].size();j++){
                        int a = P[i][j];
                        if(col[a]==WHITE) end=false;
                    }
                }
                if(end==true){
                    cout<<i<<endl;
                    col[i]=BLACK;
                    i=0;
                }
            }
        }
    }
    return 0;
}


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

int main(void) {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '+') {
      ans += 1;
    } else {
      ans -= 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 20000000
#define mod 1000000007
#define INF2 1000000000000000000
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
string S[51];
int d[51][51];
int H, W;
typedef pair<int, int> P;
int bfs() {
    rep(i, 51) rep (j, 51) d[i][j] = INF;
    queue<P> que;
    que.push({0, 0});
    d[0][0] = 0;
    while(que.size()) {
        P p = que.front(); que.pop();
        rep(i, 4) {
            int x = p.first + dx[i];
            int y = p.second + dy[i];
            if(x < 0 || x >= H || y < 0 || y >= W) continue;
            if (S[x][y] == '#' || d[x][y] != INF) continue;
            d[x][y] = d[p.first][p.second] + 1;
            que.push({x, y});
        }
    }
    return d[H - 1][W - 1];
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> H >> W;
    rep(i, H) cin >> S[i];
    int cnt = 0;
    rep(i, H) rep(j, W) if(S[i][j] == '#') cnt++;
    int ans = bfs();
    if(ans >= INF) {
        cout << -1 << endl;
   } else {
       cout << H * W - ans - cnt - 1 << endl;
   }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
			sum += s[i];
		}
		Arrays.sort(s);
		if(sum % 10 != 0) {
			System.out.println(sum);
			return;
		}
		for(int i = 0; i < n; i++) {
			if(s[i] % 10 != 0) {
				System.out.println(sum - s[i]);
				return;
			}
		}
		System.out.println(0);
	}
}

Measured memory_bytes: 22356
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int64 gcd(int64 a, int64 b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int h, w; cin >> h >> w;
		vector<string> s(h);
		vector<vector<int>> cnt(h, vector<int>(w, 0));
		rep (i, h) {
			cin >> s[i];
		}
		rep (i, h) {
			vector<int> done(w);
			rep (j, w) {
				if (s[i][j] == '#') continue;
				if (done[j]) continue;
				int l = 0;
				while (j + l < w) {
					if (s[i][j + l] == '#') break;
					l++;
				}
				rep (k, l) {
					cnt[i][j + k] += l;
					done[j + k] = 1;
				}
			}
		}
		rep (j, w) {
			vector<int> done(h);
			rep (i, h) {
				if (s[i][j] == '#') continue;
				if (done[i]) continue;
				int l = 0;
				while (i + l < h) {
					if (s[i + l][j] == '#') break;
					l++;
				}
				rep (k, l) {
					cnt[i + k][j] += l;
					done[i + k] = 1;
				}
			}
		}
		int ans = -1;
		rep (i, h) {
			rep (j, w) {
				ans = max(ans, cnt[i][j] - 1);
			}
		}
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 20096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 0; i <= 100000; i++){
        int A = (double)i * 0.08;
        int B = (double)i * 0.1;
        if(a == A and B == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    K = int(input())
    A = [int(a) for a in input().split()]
    if A[K-1] != 2: print(-1)
    else:
        minN, maxN = 2, 3
        for i in reversed(range(K - 1)):
            lb = (minN - 1) // A[i]
            hb = maxN // A[i]
            if lb == hb: 
                print(-1)
                break
            else:
                minN = A[i] * (lb + 1)
                maxN = A[i] * hb + A[i] - 1
        else: print(minN, maxN)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 14076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[10];
    cin>>s;
    if(s[2]==s[3])
    {
        if(s[4]==s[5])
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else if(s[4]==s[5])
    {
        if(s[2]==s[3])
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else
    {
        cout<<"No";
    }
    cout<<endl;
    return 0;
}


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

int main(){
    int a[3];
    int b[3];
    int c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 3; j++){
            if(c[0][i] - c[0][j] != c[1][i] - c[1][j] ||
                c[1][i] - c[1][j] != c[2][i] - c[2][j]){
                cout << "No\n";
                return 0;
            }
        }
    }
    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 3; j++){
            if(c[i][0] - c[j][0] != c[i][1] - c[j][1] ||
                c[i][1] - c[j][1] != c[i][2] - c[j][2]){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int N, R, L;
template<class T> struct SegmentTree
{
    int n = 1;
    //score, team
    vector<pair<int, int>> node;
    SegmentTree(int sz)
    {
        while(n < sz) n *= 2;
        for(int i = 0; i < 2 * n - 1; i++) node.push_back(make_pair(-INF, -i));
    }
    void update(int pos, int val)
    {
        pos += (n - 1);
        node[pos].first += val;
        while(pos > 0)
        {
            pos = (pos - 1) / 2;
            node[pos] = max(node[2 * pos + 1], node[2 * pos + 2]);
        }
    }
    int getRoot() { return -node[0].second - (n - 1); }
};
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> R >> L;
    SegmentTree<int> teams(N);
    vector<int> d(R), t(R), x(R);
    for(int i = 0; i < R; i++)
    {
        cin >> d[i] >> t[i] >> x[i];
        d[i]--;
    }
    int now = 0, target = 0;
    map<int, int> times;
    for(int i = 0; i < R; i++)
    {
        times[target] += t[i] - now;
        teams.update(d[i], x[i]);
        target = teams.getRoot();
        now = t[i];
    }
    times[target] += L - now;
    int ans = -1, maxv = -INF;
    for(auto x : times)
    {
        if(x.second > maxv)
        {
            maxv = x.second;
            ans = x.first;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 12392
package main

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

func main() {
	r := nextInt()
	fmt.Printf("%d", r*r*3)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)5e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

void solve() {
	int n; cin >> n;
	cout << (1000 - n % 1000) % 1000;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		switch (s) {
		case "A":
			System.out.println("T");
			break;
		case "T":
			System.out.println("A");
			break;
		case "G":
			System.out.println("C");
			break;
		case "C":
			System.out.println("G");
			break;
		}
	}
}

Measured memory_bytes: 24276
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;

#define int long long
const long long INF = 1LL << 61;

struct sol {
	long long x, cost;
	long long c;

	sol(long long xx, long long cc, long long C) {
		x = xx;
		cost = cc;
		c = C;
	}

	long long getCost(long long y) {
		long long d = y - x;
		return d * d + cost + c;
	}

	long long time(sol sol2) {
		long long l = sol2.x;
		long long r = 5e8L;
		long long ans = r;


		while (l <= r) {
			long long mid = l + (r - l) / 2;
			if (getCost(mid) >= sol2.getCost(mid)) {
				ans = mid;
				r = mid - 1;
			}
			else {
				l = mid + 1;
			}
		}
		return ans;
	}
};

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	long long c;
	cin >> n >> c;

	vector<long long> heights;
	for (int i = 0; i < n; i++) {
		long long h;
		cin >> h;
		heights.push_back(h);
	}

	vector<long long> dp(n, INF);
	dp[0] = 0LL;
	deque<sol> all;
	
	all.push_back({ heights[0], 0, c });
	for (int i = 1; i < n; i++) {
		while (all.size() >= 2 && all[0].getCost(heights[i]) >= all[1].getCost(heights[i])) {
			all.pop_front();
		}
		dp[i] = all[0].getCost(heights[i]);
		sol add(heights[i], dp[i], c);
		while (true) {
			if (all.size() < 2) {
				break;
			}

			if (all[all.size() - 2].time(all[all.size() - 1]) < all[all.size() - 2].time(add)) {
				break;
			}

			if (all[all.size() - 2].time(all[all.size() - 1]) == all[all.size() - 2].time(add)) {
				long long tm = all[all.size() - 2].time(all[all.size() - 1]);
				if (all[all.size() - 1].getCost(tm) < add.getCost(tm)) {
					break;
				}
			}
			all.pop_back();
		}
		all.push_back(add);

	}
	cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 9332
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

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

	ll N,K,p;
	cin>>N>>K;
	ll a[N+1]={0};
	// cin>>p;
	while(K){
		cin>>p;
		ll temp;
		for (int i = 0; i < p; ++i)
		{
			cin>>temp;
			a[temp]++;
		}
		K--;
	}
	ll ans=0;
	for (int i = 1; i <=N; ++i)
	{
		if (a[i]==0)
			ans++;
	}
	cout<<ans;

	return 0;
}


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


int main(){
  int n,l;
  cin>>n>>l;
  string s[n];
  rep(i,0,n){
    cin>>s[i];
  }
  sort(s,s+n);
  string ans="";
  rep(i,0,n){
    ans+=s[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    int h, w, k;
    cin >> h >> w >> k;
    char c[10][10];

    rep(i, h) cin >> c[i];

    int ans = 0;

    rep(i, 1 << h) rep(j, 1 << w) {
        int cnt = 0;
        rep(x, h) rep(y, w) {
            if(!(i >> x & 1) && !(j >> y & 1) && c[x][y] == '#') cnt++;
        }
        if(cnt == k) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] array = new int[n];
        
        int sum = 0;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            sum += array[i];
        }
        
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (array[i] * 4 * m >= sum) count++;
        }
        
        if (count >= m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
import bisect


def read_input():
    n, q = map(int, input().split())
    s = list(input().strip())
    queries = []
    for _ in range(q):
        st, ed = map(int, input().split())
        queries.append((st - 1, ed - 1))

    return n, s, queries


def submit():
    n, s, queries = read_input()

    # AC pointを列挙する
    ac_st = []
    for i in range(n - 1):
        if s[i] == "A" and s[i + 1] == "C":
            ac_st.append(i)

    for ql, qr in queries:
        print(bisect.bisect_right(ac_st, qr - 1) -\
              bisect.bisect_left(ac_st, ql))


if __name__ == "__main__":
    submit()

Measured memory_bytes: 20124
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var n = Console.ReadLine().ToCharArray().Count(x => x == 'o');
            

             Console.WriteLine(700 + n*100);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int miny,maxy;
int cou1=0,cou2=0;

int main()
{
    while(1)
    {
        scanf("%d%d",&miny,&maxy);
        if(miny==0&&maxy==0)break;
        if(cou2!=0)printf("\n");
        cou1=0;
        for(int i=miny;i<=maxy;i++)
        {
            if((i%4==0&&i%100!=0)||i%400==0)
            {
                printf("%d\n",i);
                cou1++;
            }
        }
        if(cou1==0)printf("NA\n");
        cou2++;
    }
    return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long;

int main() {
    int A, B;
    std::cin >> A >> B;
    if (A >= 13) {
        std::cout << B << std::endl;
    }
    else if (A >= 6) {
        std::cout << B / 2 << std::endl;
    }
    else {
        std::cout << 0 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvl             vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}

int help(vi& A){
   int n=sz(A);
   vi dp(n);
   dp[0]=0;
   rep2(i,1,n){
      int x=INT_MAX;
      if(i>=2) x=min(x,dp[i-2]+abs(A[i]-A[i-2]));
      x=min(x,dp[i-1]+abs(A[i]-A[i-1]));
      dp[i]=x;
   }
   return dp[n-1];
}
int main() {
   fio
  // i_o();
   int n;
   cin>>n;
   vi h(n);
   rep(i,n) cin>>h[i];
   d1(help(h));
   return 0;
}



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

void solve(long long X){
 ll ans = 0;

 ans += (X / 500)*1000;
 X %= 500;
 ans += (X/5)*5;
 cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
def isPrime(x):
    if x==2:
        return True
    
    if x<2 or x%2==0:
        return False
    
    for n in range(3,int(x**0.5)+1,2):
        if x%n==0:
            return False
    return True   

n=int(input())
num=[int(input()) for i in range(n)]

i=0
for nm in num:
    if isPrime(nm):
        i+=1
        
print(i)

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

using P = pair<int,int>;

bool solve(){
    int n, m, h, k;
    cin >> n >> m >> h >> k;
    if(n==0) return false;
    vector<int> s(n), p(n), q(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
        p[i] = i;
    }
    vector<P> v(m);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--;
        v[i] = P(b,a);
    }
    sort(v.begin(), v.end());
    
    set<P> st;
    for(int i=0;i<m;i++){
        int a = v[i].second;
        st.insert(P(min(p[a],p[a+1]),max(p[a],p[a+1])));
        swap(p[a],p[a+1]);
    }
    int sum = 0, ans;
    for(int i=0;i<n;i++){
        if(p[i]<k) sum += s[i];
        q[p[i]] = i;
    }
    ans = sum;
    for(auto e : st){
        int x = e.first, y = e.second;
        if(x<k && y>=k){
            ans = min(ans, sum-s[q[x]]+s[q[y]]);
        }
    }
    cout << ans << endl;
    return true;
}

int main(){
    while(solve());
    return 0;
}



Measured memory_bytes: 4336
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias route = Tuple!(long, "From", long, "To");
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    long warea, barea;
    bool flag = (s[0] == 'W');
    foreach (e; s)
    {
        if(flag && e == 'W')
        {
            warea++;
            flag = false;
        }

        if(!flag && e == 'B')
        {
            barea++;
            flag = true;
        }
    }
    writeln(warea + barea - 1);
}


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

int main() {
	int a,b;
	cin >> a >> b;
	char* s;
	if(a==b) s= "a == b";
	if(a < b) s= "a < b";
	if(a > b) s= "a > b";
	
	cout << s << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1156
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.StringTokenizer;

import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String c = sc.next();
        String c1 = String.valueOf(c.charAt(0));
        String c2 = String.valueOf(c.charAt(1));
        String c3 = String.valueOf(c.charAt(2));
        
        c1=change19(c1);
        c2=change19(c2);
        c3=change19(c3);
        
    	System.out.println(c1 + c2 + c3);   
    
    }
    private static String change19(String str) {
    	if ("1".equals(str)) {
    		str="9";
    	} else if ("9".equals(str)) {
    		str="1";
    	}
    	
    	return str;
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int x[300005];
int n;

int main(){
	scanf("%d",&n);
	fore(i,0,3*n)scanf("%d",x+i);
	sort(x,x+3*n);
	reverse(x,x+3*n);
	ll r=0;
	fore(i,0,n)r+=x[2*i+1];
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=100000000000000000;
ll MOD=1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n),v(n);
    int t=0; //合計時間
    rep(i,n) {cin >> a.at(i);a.at(i)*=2;t+=a.at(i);}
    rep(i,n) {cin >> v.at(i);v.at(i)*=2;}
    vector<int> mv(2*t+1); //0.5秒刻みで調べる各時刻の出しうる最高速度
    mv.at(0)=0;
    int nt=0;
    int q=0;
    
    for(int i=1;i<t;i++){
        nt++;
        if (nt==a.at(q) && v.at(q) >v.at(q+1)) {nt=0;q++;}
        mv.at(i)=min(mv.at(i-1)+1,v.at(q));
        if (nt==a.at(q) && v.at(q) <=v.at(q+1)) {nt=0;q++;}
    }
    mv.at(t)=0;
    for (double i=t-1;i>0;i--){ 
        mv.at(i)=min(mv.at(i+1)+1,mv.at(i));
    }
    int ans=0;
    int o=0;
    for (int i=1;i<t+1;i++){
        o++;
        ans+=(mv.at(2*i)+mv.at(2*i-1));
    }
    double yy=ans;
    yy=yy/4;
    printf("%.10f\n", yy);
}


Measured memory_bytes: 512
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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


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

#define endl "\n"
#define ioss ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
//#define int long long

typedef  long long ll;

using namespace std;


int main()
{
	ioss	
	int n,k;cin>>n>>k;
  if(k>=n){cout<<0<<endl;return 0;}
  else{
    vector<int> v(n);
  	for(int i=0;i<n;i++)
    {
      cin>>v[i];
    }
    ll sum=0;
    sort(v.rbegin(),v.rend());
    for(int i=k;i<n;i++)
    {
      sum=sum+v[i];
    }
    cout<<sum<<endl;
  }
	return 0;
}














Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import heapq

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
jobs = {}
for job in AB:
    if job[0] in jobs:
        jobs[job[0]].append(job[1])
    else:
        jobs[job[0]] = [job[1]]

hq = []
reword_sum = 0
for i in range(1, M + 1):
    if i in jobs:
        for reword in jobs[i]:
            heapq.heappush(hq, -reword)

    if len(hq):
        reword_sum += heapq.heappop(hq)

print(-reword_sum)

Measured memory_bytes: 33868