akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

int main(void){
	char s[20]={}, t[20]={}, u[20]={};
	int a, b, i, p, q;
	scanf("%s %s",&s, &t);
	scanf("%d %d",&a, &b);
	scanf("%s",u);

	p=0;
	q=0;
	for(i=0;i<10;i++){
		p=p+fabs(s[i]-u[i]);
		q=q+fabs(t[i]-u[i]);
		//printf("%d %d %d\n", s[i], t[i], u[i]);
	}

	if(p==0){
		a=a-1;
	}
	if(q==0){
		b=b-1;
	}

	printf("%d %d\n", a, b);
}

Measured memory_bytes: 128
n=int(input())
a=[int(i) for i in input().split(" ")]
x=0

for i in range(n):
    mi = i
    for j in range(i, n):
        if a[j] < a[mi]:
            mi = j
    
    if i != mi:
        x += 1
        a[i], a[mi] = a[mi] , a[i]

print(" ".join([str(i) for i in a]))
print(x)

Measured memory_bytes: 7776
import heapq
from collections import defaultdict
n,m = map(int,input().split())
dct = defaultdict(list)

for i in range(n):
    a,b = map(int,input().split())
    dct[a].append(-b)

h = []
ans = 0

for i in range(1,m+1):
    if dct[i]:
        for item in dct[i]:
            heapq.heappush(h, item)
    if h:
        ans += heapq.heappop(h)
print(-ans)

Measured memory_bytes: 27652
until(n,m=gets.split.map(&:to_i)).all?(&:zero?)do
r,p,a=[],[],[]
n.times{r.unshift(gets.gsub("?",".").split)}
m.times{p<<gets.split}
p.each{|p|r.each{|r|if/#{r[2]}/=~p[1]&&/#{r[1]}/=~p[0]
a<<p*" "if/p/=~r[0]
break
end}}
puts a.size,a
end

Measured memory_bytes: 9548
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int a, b, m, a1 = 10000000, b1 = 10000000, c=10000000, x, y, z;
	cin >> a >> b >> m;
	vector<int>veca(a),vecb(b);
	rep(i, a) {
		cin >> veca[i];
		a1 = min(a1, veca[i]);
	}
	rep(i, b) {
		cin >> vecb[i];
		b1 = min(b1, vecb[i]);
	}
	for (int i = 0; i < m; i++) {
		cin >> x >> y >> z;
		c = min(c, veca[x-1] + vecb[y-1] - z);
	}
	cout << min(c, a1 + b1) << endl;
}



Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming2
{
    class Point
    {
        public int x;
        public int y;
        public Point()
        {
            x = 0;
            y = 0;
        }
    }
       
    class Program
    {
        static void Main()
        {
            string[] str;
            Point point = new Point();
            int agree = 0;
            double radian = 0;
            while (true)
            {
                str = Console.ReadLine().Split(',').ToArray();
                int d = int.Parse(str[0]);
                int a = int.Parse(str[1]);
                if (d == 0 && a == 0)
                {
                    break;
                }
                radian = agree * Math.PI / 180;
                point.y += (int)(d*Math.Cos(radian));
                point.x += (int)(d * Math.Sin(radian));
                agree += a;
            }
            Console.WriteLine(point.x);
            Console.WriteLine(point.y);
        }
    }
}

Measured memory_bytes: 9340
#pragma region
#include <bits/stdc++.h>

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  int n;
  cin >> n;
  vi32 v(n);
  cin >> v;
  sort(all(v));
  f80 ans = v[0];
  reps(i, n - 1) {
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
}


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

def prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return 0
    return 1

while True:
  if(prime(x) == 1):
    print(x)
    exit()
  else:
    x = x+1

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

int main(int argc, const char * argv[]) {
    int N;
    scanf("%d", &N);
    
    int a = N / 1000;
    int b = (N - a * 1000) / 100;
    int c = (N - a * 1000 - b * 100) / 10;
    int d = N - a * 1000 - b * 100 - c * 10;
    
    if ((a == b && b == c) || (b == c && c == d)) {
        puts("Yes\n");
    } else {
        puts("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'



int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif
    
    ll n,d;cin>>n>>d;
    ll mn=inf;
    for(ll i=0;i<(1LL<<n);i++)
    {
        bool mark[n]={0};
        for(ll j=0;j<n;j++)
        {
            if(i&(1LL<<j))
            {
                for(ll k=max(j-d,0LL);k<=min(j+d,n-1);k++)
                    mark[k]=1;
            }
        }
        bool ch=1;
        for(ll i=0;i<n;i++)
            if(!mark[i]) ch=0;

        ll x=__builtin_popcount(i);
        if(ch)
        {
            // cout<<i<<" "<<x<<endl;

            mn=min(mn,x);
        }
    }
    cout<<mn;


    #ifdef APNA_IO
        end_routine();
    #endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int n; cin >> n;
  vector<P> ab(n);
  
  for (int i = 0; i < n; ++i) cin >> ab[i].first >> ab[i].second;
  sort(ab.begin(), ab.end(), [](P &p1, P &p2){ return p1.first + p1.second > p2.first + p2.second; });
  
  ll t = 0, a = 0;
  for (int i = 0; i < n; ++i)
    if (i % 2 == 0) t += ab[i].first;
    else a += ab[i].second;
  
  cout << t - a << endl;
}

Measured memory_bytes: 1024
class RH():
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod
        self.rev = pow(base, mod-2, mod)

        l = len(s)
        self.h = h = [0]*(l+1)
        tmp = 0
        for i in range(l):
            num = ord(s[i])
            tmp = (tmp*base + num) % mod
            h[i+1] = tmp
    def calc(self, l, r):
        return (self.h[r] - self.h[l] * pow(self.base, r-l, self.mod)) % self.mod
    def fixed(self, length):
        v = pow(self.base, length, self.mod)
        h = self.h; mod = self.mod
        def fixed_calc(l):
            return (h[length+l] - h[l] * v) % mod
        return fixed_calc
T = input(); P = input()
MOD = 10**18+9
HT = RH(T, 11, MOD)
HP = RH(P, 11, MOD)

pv = HP.calc(0, len(P))
calc = HT.fixed(len(P))
for i in range(len(T)-len(P)+1):
    if calc(i) == pv:
        print(i)

Measured memory_bytes: 49584
#include <iostream>
#include <algorithm>
#include <cstring>

#define ll long long 

using namespace std;

int n, K;
int a[105];
int dp[100050];

int solve(int k){
  if(dp[k] != -1)
    return dp[k];
  
  for(int i = 0; i < n; i++){
    if(k >= a[i])
      if(solve(k - a[i]) == 0)
        return dp[k] = 1;
  }

  return dp[k] = 0;
} 

int main()
{
    int max_v = 0;

    cin >> n >> K;

    memset(dp, -1, sizeof dp);

    for(int i = 0; i < n; i++)
      cin >> a[i];
    
    dp[0] = 0;
    if(solve(K) == 1)
      cout << "First" << endl;
    else
      cout << "Second" << endl;
    
    return 0;
}

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

int main(){
  ll N;
  cin >> N;
  vector<ll>B(N+2);
  vector<ll>A(N+1);
  
  ll ans = 0;
  rep(i,N+1)cin >> A[i];
  rep(i,N)cin >> B[i];
  
  for(int i = 0; i < N; i++){
    if(A[i] >= B[i])ans += B[i]; //B[i]だけ倒して町にはモンスターが残る
    else if(A[i] < B[i]){
      ans += A[i];//町にいるモンスターは全滅
      B[i] -= A[i]; //倒せる残りの数を更新
      if(A[i+1] >= B[i]){ //次の街にいるモンスターのほうがキャパより多い
        ans += B[i];
        A[i+1] -= B[i];
      }
      else if(A[i+1] < B[i]){ //次の街も全滅させられる
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
  int n,x,d=0;
  cin >> n;
  int m[n];
  cin >> x;
  for(int i=0;i<n;i++){ 
    cin >> m[i];
    x-=m[i];
    d++;
  }
  sort(m,m+n);
  while(m[0] <= x) {
    x-=m[0];
    d++;
  }
cout << d << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

static const int MAX = 100000 + 1;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    vector<int> v[MAX];
    int a, b;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        v[a].push_back(b);
    }
    for (int i = 1; i <= m; i++)
    {
        for (int j : v[i])
        {
            pq.push(j);
        }
        if(pq.empty())
            continue;
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int n, m, h[100010], gObs = 0, good, x, y;
vector <int> r[100010];

int main() {
    cin>>n>>m;
    for(int i = 0; i < n; i++)
        cin>>h[i];
    for(int i = 0; i < m; i++) {
        cin>>x>>y;
        r[x-1].push_back(y-1);
        r[y-1].push_back(x-1);
    }
    for(int i = 0; i < n; i++) {
        good = 1;
        for(size_t j = 0; j < r[i].size(); j++)
            if(h[i] <= h[r[i][j]]) {
                good = 0;
                break;
            }
        if(good)
            gObs++;
    }
    cout<<gObs;
    return 0;
}


Measured memory_bytes: 9124
#include <iostream>
#include <map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

#define ALL(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;


// typedef tree<int, null_type, less_equal, rb_tree_tag, tree_order_statistics_node_update> obj;


tree<
	 int,
     null_type,
     less<int>,
     rb_tree_tag,
     tree_order_statistics_node_update> obj;


int32_t main()
{
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n; cin>>n;
        vector<int> v(n);
        for(auto &x : v) { cin>>x; x = -x; }
      //  reverse(ALL(v));
        
		int ans = 0;
		for (int i = 0; i < n; i++)
		{
			obj.insert(v[i]);
			if(i == obj.order_of_key(v[i])) ans++;
		}
		
		cout<<ans<<endl;
    }
    return 0;

}


Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX = 1001;
typedef pair<int,int> QQ;
typedef pair<int,int> PP;
typedef pair<PP,QQ> P;

int main(){
  int n;

  while(cin >> n ,n){
    int id,uni,ac,pe;
    int tc[MAX+1];
    fill(tc,tc+MAX,0);
    vector<P> v;

    while(n--){
      cin >> id >> uni >> ac >> pe;
      v.push_back(P(PP(-ac,pe),QQ(id,uni)));
    } 
    sort(v.begin(),v.end());

    int cnt = 0;
    int size = v.size();
    for(int i = 0; i < size ; i++){
      int u = v[i].second.second;
   
      if(cnt < 10){
	if(tc[u] < 3){
	  cout << v[i].second.first << endl;
	  cnt++;
	}
      }
      else if(cnt < 20){
	if(tc[u] < 2){
	  cout << v[i].second.first << endl;
	  cnt++;
	}
      }
      else if(cnt < 26){
	if(tc[u] < 1){
	  cout << v[i].second.first << endl;
	  cnt++;
	}
      }
      tc[u]++;
    } 
  }

  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;


int main(){
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
if(e-a>k)cout<<":(";
else cout<<"Yay!";
}

Measured memory_bytes: 256
#Input
n,m,l = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for i in range(m)]

c = [list(sum([A[i][k] * B[k][j] for k in range(m)]) for j in range(l)) for i in range(n)]

#Output
for i in c:
    print(*i)

Measured memory_bytes: 9104
<?php

$x = fgets(STDIN);
$fh = 500;
$f = 5;

$hp = $x/$fh;
//echo floor($hp);
$hp = floor($hp)*1000;
//echo $hp;

$hp2 = $x%$fh;
//echo $hp2;
$hp2 = $hp2/5;
//echo $hp2;
$hp2 = floor($hp2)*5;
echo $hp+$hp2;
 ?>


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


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(), a.end());
    int a_max = a.at(n-1);
    int b = -1, d = 1e9;
    rep(i,n-1) {
        int half = a_max%2 == 0 ? a_max/2 : a_max/2 + 1;
        int di = abs(half - a.at(i));
        if (di < d) {
            d = di;
            b = a.at(i);
        }
    }
    cout << a_max << ' ' << b << endl;
    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

struct Warshall_Floyd{
    int V;
    long long int *d;//d[i_v1*V+i_v2]= v1tov2
    vector<  pair<int,int>  > *edges;
    Warshall_Floyd(int N): V(N){
        d = new long long int[V*V];
        edges=new vector<  pair<int,int>  >[V];
        rep(i,V*V){
            d[i]=LLINF;
        }
    }
    void push_edges(int a,int b, int c){
        edges[a].pb( mp(c,b));
        edges[b].pb( mp(c,a));
        if(ite(a,b)>c)d[a*V+b]=c;
        if(ite(b,a)>c)d[b*V+a]=c;
    }
    long long int ite(int i,int j){
        return d[i*V+j];
    }
    void solve() { 
        for (int i = 0; i < V; i++)      // via
        for (int j = 0; j < V; j++)    // start
        for (int k = 0; k < V; k++)  // end
         d[j*V+k] = min(ite(j,k), ite(j,i) + ite(i,k));
    }
    void free_wf(){
        delete[] d;
        delete[] edges;
    }
    
};

int main(void){
    int N,M,R;
    scanf("%d %d %d",&N,&M,&R);
    Warshall_Floyd WF(N);
    vector<int> r;
    rep(i,R){
        int _r;
        scanf("%d",&_r);_r--;
        r.pb(_r);
    }
    rep(i,M){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        a--;b--;
        WF.push_edges(a,b,c);
    }
    WF.solve();
    sort(r.begin(), r.end());
    long long int ans=LLINF;
    do{
        long long int sans=0;
        rep(i,r.size()-1){
            sans+=WF.ite(r[i],r[i+1]);
        }
        ans=min(ans,sans);
    }while (next_permutation(r.begin(), r.end()));
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

  int N;
  int X;

  int d_cnt;

  cin >> N;
  cin >> X;

  vector<int> m(N);

  for(int i=0;i<N;i++){
    cin >> m[i];
    X=X-m[i];
  }

  d_cnt=N;

  int min= *min_element(m.begin(),m.end());
  
  d_cnt=d_cnt + X/min;

  cout << d_cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char *ss[2]={"JOI","IOI"};
int main(){
    char str[10005];
    while(scanf("%s",str)!=-1){
        int sz=strlen(str);
        for(int ix=0;ix<2;ix++){
            int an=0;
            for(int i=0;i<sz-2;i++){
                bool is=true;
                for(int j=0;j<3;j++){
                    if(str[i+j]!=ss[ix][j])is=false;
                }
                if(is)an++;
            }
            printf("%d\n",an);
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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




int main() {

	ll N;
	string S;
	cin >> N >> S;

	vector<ll> k(N+1);

	k[0] = 0;
	repn(i, N) {
		if (S[i - 1] == '(') { k[i] = k[i - 1] + 1; }
		else { k[i] = k[i-1] - 1; }
	}

	ll m = 0;
	repn(i, N) m = min(m, k[i]);

	ll b = max(-m, 0);
	ll f = k[N] + b;

	repn(i, b)cout << '(';
	cout << S;
	repn(i, f) cout << ')';

	system("PAUSE");
}


Measured memory_bytes: 504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		String c=a+b;
		int bool=0;
		int sum=Integer.parseInt(c);
		for(int i=1;i<=Math.sqrt(sum);i++){
			if(sum%i==0&&sum==i*i){
				bool=1;
			}
		}
		if(bool==1){
			System.out.println("Yes");
		}
		if(bool==0){
			System.out.println("No");
		}	
	}
}

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

#define ll long long
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define f first
#define s second
#define vecll vector<ll>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<ll,ll>>
#define mapllll map<ll,ll>
#define mapstrll map<string,ll>
#define mapllvecll map<ll,vecll>
#define setll set<ll>
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL); cout.tie(NULL);

using namespace std;

ll const N=1e5+5;
ll const inf=1e18+5;
ll const MOD=1e9+7;

ll t,n,m,x,y,z,w,k;

ll power(ll a,ll b)
{
    ll ans = 1;
    while(b>0)
    {
        if(b&1) ans = (ans*a)%MOD;
        b >>= 1;
        a = (a*a)%MOD;
    }
    return ans;
}

int main()
{
    fio

    cin>>n>>k;

    ll a[k+1];
    ll b[k+1];

    ll ones = 0;
    for(ll i=k;i>=1;i--)
    {
        a[i] = power(k/i,n);

        for(ll j=i+i;j<=k;j+=i)
        {
            a[i] = ((a[i]-a[j]) + MOD)%MOD;
        }
    }

    for(ll i=1;i<=k;i++)
    {
        ones = (ones + ((i*a[i])%MOD))%MOD;
    }

    cout<<ones;
    return 0;
}



Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    int ans=0;
    REP(i,h)cin>>s[i];
    REP(is,1<<h)REP(js,1<<w){
        int cnt = 0;
        REP(i,h)REP(j,w){
            if(is>>i&1)continue;
            if(js>>j&1)continue;
            if(s[i][j]=='#')cnt++;
        }
        if(cnt==k)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b, c; readV(a, b, c);
  writeln(min(a+b, b+c, c+a));
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n;
	static int a[200000], b[200000]={0};
	int half, co,sum;
	int i, j;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	/*半分までの確定している部分をb[i]に入れる*/
	half=n/2;
	for (i = half; i < n; i++) {
		b[i] = a[i];
	}
	/*半分よりまえの部分をb[i]に入れる*/
	for (i = half; i >= 0; i--) {
		sum = 0;
		for (j = i; j < n; j += i+1) {
			if (b[j] == 1) {
				sum+=b[j];//ボールの数の合計
			}
		}
		if(sum%2!=a[i]){
			b[i]=1;
		}
	}
	co = 0;
    for(i=0;i<n;i++){
        if(b[i]==1){
			co++;//1の数をカウント
		}
    }
	printf("%d\n",co);
	int cnt=0;
	for(i=0;i<n;i++){
		if(b[i]==1){
			printf("%d ",i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll, ll>
#define mii         map<pii, ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a + b + p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    int n, q;
    string s;
    cin>>n>>q>>s;
    int pre[n];
    pre[0] = 0;
    rep(i, 1, sz(s)) {
        pre[i] = pre[i-1];
        if(s[i] == 'C' && s[i-1] == 'A') {
            pre[i]++;
        }
    }
    while(q--) {
        int l, r;
        cin>>l>>r;
        l--; r--;
        int ans = pre[r] - pre[l];
        cout<<ans<<endl;
    }
    
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 1488
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    X = I()
    ans = 100

    for i in range(1, 10**19):
        ans = int(ans * 1.01)
        if ans >= X:
            print(i)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74940
#include<stdio.h>

int main(void){
  int n,d1,d2;
  int p,wal,longest_p,longest_wal;
  int isfirst=0;

  while(1){
    scanf("%d",&n);
    if(n==0) break;

    isfirst=0;
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&p,&d1,&d2);
      wal=d1+d2;

      if(isfirst!=0){
        if(wal>longest_wal){ longest_p=p; longest_wal=wal; }
      }
      else{ isfirst++; longest_p=p; longest_wal=wal; }
    }
    printf("%d %d\n",longest_p,longest_wal);
  }
  return 0;
}



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

void solve(long long K, std::string S){
    if (S.size() <= K) cout << S << '\n';
    else cout << S.substr(0, K) << "..." << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long K;
    cin >> K;
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3624
include Math

x = y = 0
degree = 90

$<.each_line do |line|
	d, t = line.split(',').map(&:to_i)
	break if d.zero? and t.zero?

	radian = degree * PI / 180
	x += d * cos(radian)
	y += d * sin(radian)

	degree -= t
end

p x.to_i
p y.to_i

Measured memory_bytes: 6160
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define ll long long
#define MAX 2020
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,K,a[MAX];
int mn[MAX];
ll ans=1e18;
int main()
{
	n=read();K=read();memset(mn,63,sizeof(mn));
	for(int i=0;i<n;++i)a[i]=read();
	for(int i=0;i<=n;++i)
	{
		for(int j=0;j<n;++j)
			mn[j]=min(mn[j],a[(j-i+n)%n]);
		ll ret=0;
		for(int j=0;j<n;++j)ret+=mn[j];
		ans=min(ans,ret+1ll*K*i);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	int n, x[105];
	cin >> n;
	for(int i = 1; i <= n; i++)	cin >> x[i];
	int ans = 0x3f3f3f3f;
	for(int i = 1; i <= 100; i++){
		int s = 0;
		for(int j = 1; j <= n; j++)
			s += (i - x[j]) * (i - x[j]);
		if(s < ans) ans = s;
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,a,i,j;
    int arr[1000];
    scanf("%d",&n);
    for(i = 0; i < n ;i++){
        scanf("%d",&a);
        arr[i] = a;
    }
    for(j = 0 ; j < n/2 ; j++) {
        int t = arr[j];
        arr[j] = arr[n - j - 1];
        arr[n - j - 1] = t;
    }
    for(int k = 1;k <= n; k++){
        printf("%d",arr[k-1]);
        if(k == n) {
            printf("\n");
        }else {
            printf(" ");
        }
    }
    return 0;
}


Measured memory_bytes: 2696
import sys
from operator import mul
from functools import reduce

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

MARCH = 'MARCH'
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [input().rstrip() for _ in range(N)]

S = [s for s in S if s[0] in MARCH]

A = [0]*5
for s in S:
	A[MARCH.index(s[0])] += 1

#print(A)

if sum(A) < 3:
	print(0)
	sys.exit()

ans = cmb(sum(A), 3)
#print(ans)

for a in A:
	if a<=1:continue
	if a>=3:
		ans -= cmb(a, 3)
	ans -= cmb(a, 2) * (sum(A)-a)

print(ans)

Measured memory_bytes: 53852
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll dp[11][156][22];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 1;
	while (kkt--) {
		string jupi; cin >> jupi;
		ll n = stoll(jupi);
		ll N = jupi.size();
		ll mx = 1;
		for (int i = 0; i < N; i++) mx *= 10;
		vector<ll> perm(10); for (int i = 0; i < 10; i++) perm[i] = i;
		ll sa = 0;
		ll res = -1;
		do {
			ll t = 0;
			for (int i = 0; i < N; i++) {
				t = t * 10 + perm[i];
			}
			ll tmp = min(llabs(n - t), mx - llabs(n - t));
			if (chmax(sa, tmp)) {
				res = t;
			}else if(sa == tmp && t < res){
				res = t;
			}

		} while (next_permutation(perm.begin(), perm.end()));
		string s;
		for (int i = 0; i < N - to_string(res).size(); i++) s += '0';
		s += to_string(res);
		cout << s << endl;
	}
	return 0;

}



Measured memory_bytes: 3300
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	boolean result = true;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		Set<Long> set = new HashSet<>();
		for (int i = 0; i < N; ++i) {
			long A = Long.parseLong(tokens[i]);
			if (set.contains(A)) {
				result = false;
				break;
			}
			set.add(A);
		}
	}

	void calc() {
	}

	void showResult() {
		System.out.println(result ? "YES" : "NO");
	}
}


Measured memory_bytes: 63756
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=998244353;
int n;
ll a[310];
ll dp[310][90010];
ll sum=0;
ll thmod(int n){
  ll res=1;
  rep(i,n){
    res=(res*3)%MOD;
  }
  return res;
}
ll add(){
  ll res=0;
  rep(i,n){
    res+=a[i];
  }
  return res;
}
ll solve(){
  ll res=0;
  fill(dp,0);
  dp[0][0]=1;
  ll all=thmod(n);
  //  prin(all);
  ll sum=add();
  rep1(i,n){
    rep(j,sum+1){
      if(0<=j-a[i-1]) dp[i][j]=(dp[i-1][j-a[i-1]]+(dp[i-1][j]*2)%MOD)%MOD;
      else dp[i][j]=(dp[i-1][j]*2)%MOD;
    }
  }
  rep(i,sum-(sum+1)/2+1){
    res=(res+dp[n][(sum+1)/2+i])%MOD;
  }
  res=(res*3)%MOD;
  /*  rep(j,n+1){
    rep(i,sum+1){
      cout<<dp[j][i]<<" ";
    }
    cout<<"\n";
    }*/
  //  prin(res);
  res=(all-res)%MOD;
  if(res<0) res+=MOD;
  //  prin(res);
  if(sum%2==1) return res;
  else{
    fill(dp,0);
    dp[0][0]=1;
    rep1(i,n){
      rep(j,sum/2+1){
	if(0<=j-a[i-1]) dp[i][j]=(dp[i-1][j-a[i-1]]+dp[i-1][j])%MOD;
	else dp[i][j]=dp[i-1][j];
      }
    }
    res=(res+(dp[n][sum/2]*3)%MOD)%MOD;
    /*    rep(j,n+1){
      rep(i,sum/2+1){
	cout<<dp[j][i]<<" ";
      }
      cout<<"\n";
      }*/
    return res;
  }
}
int main(){
  cin>>n;
  rep(i,n) cin>>a[i];
  prin(solve());
    


  
  return 0;
}


Measured memory_bytes: 218240
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x)
{
  while(x->left != NIL)
    {
      x = x->left;
    }
  return x;
}

Node treeSearch(Node u, int k)
{
  if(u == NIL || k == u->key)
    {
      return u;
    }
  if(k < u->key)
    {
      return treeSearch(u->left,k);

    }
  else
    {
      return treeSearch(u->right,k);
    }

 }

Node treeSuccessor(Node x)
{
  Node y;

  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;

  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}

/*void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y


  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;

      if(z->key < x->key) x = x->left;
      else x = x->right;
    }

  z->parent = y;

  if(y == NIL) root =z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u != NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }
}

void preorder(Node u){
  if(u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

     if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
     }

    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

    /* else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));*/

  }
  return 0;
}

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

vector<int> enum_divisors(int N){
    vector<int> res;
    for (int i=1; i * i <= N; i++){
        if (N % i == 0){
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> Seen(1000000, 0);
    for (int i=0; i<N; i++){
        cin >> A[i];
        Seen[A[i]-1]++;
    }

    if (N == 1){
        cout << 1 << endl;
        return 0;
    }

    // sort(A.begin(), A.end());
    N = A.size();
    if (N == 1){
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for (int i=0; i<N; i++){
        bool flag = true;
        vector<int> d_nums = enum_divisors(A[i]);
        for (int d : d_nums){
            // printf("a = %d, d: %d\n", A[i], d);
            if (Seen[d-1] > 0){
                if (d == A[i] && Seen[d-1] == 1){
                    continue;
                }
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8012
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int N;
    cin >> N;

    bool is_ok = true;
    rep(i, 0, N)
    {
        int A;
        cin >> A;
        if (A%2==0)
            is_ok &= A%3==0 or A%5==0;
    }
    if (is_ok)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n , k;
  cin >> n >> k;
  ll a[n + 1] = {};
  for(ll i = 0;i < k;i++){
      ll x;
      cin >> x;
      for(ll j = 0;j < x;j++){
          ll y;
          cin >> y;
          a[y]++;
      }
  }
  
  ll cnt = 0;
  for(ll i =1;i <= n;i++){
      if(a[i] == 0){
         cnt++; 
      }
  }
    cout << cnt << endl;
    
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  if (N%2==1){
    int M;
    double L;
    M=N/2+1;
    L=N;
    cout << M/L << endl;
  }
    else 
     cout << 0.500000000 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
  
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
  
const ll MOD=1e9+7;
const ll INF=1e18;
  
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
 
int cake[110][4];
priority_queue<int, vector<int> , greater<int> >que;
 
int main(){
    int n,w,d;
    while(true){
        cin >> n >> w >> d;
        if(n + w + d == 0)break;
        cake[1][0] = 0; cake[1][1] = 0; cake[1][2] = w; cake[1][3] = d;
        for(int t = 1;t <= n;t++){
            int p,s;
            cin >> p >> s;
            int x1 = cake[p][0],y1 = cake[p][1],x2 = cake[p][2],y2 = cake[p][3];
            int count = 0;
            for(int i = 1;i <= t;i++){
                if(i == p)continue;
                count++;
                for(int j = 0;j < 4;j++){
                    cake[count][j] = cake[i][j];
                }
            }
            int x = x2 - x1,y = y2 - y1;
            s = s % ( 2*x + 2*y );
            int x1_2,y1_2,x2_2,y2_2,tate = 0,len = 0;
            if(s < x){
                len = s;
            }else if(s < x+y){
                len = s - x;
                tate = 1;
            }else if(s < x+y+x){
                len = x+y+x - s;
            }else{
                len = x+y+x+y - s;
                tate = 1;
            }
 
            if(tate == 1){
                if(len < (y+1)/2){
                    x2_2 = x2,  y2_2 = y2,  x1_2 = x1,  y1_2 = y1+len;
                    y2 = y1+len;
                }else{
                    x1_2 = x1,  y1_2 = y1,  x2_2 = x2,  y2_2 = y1+len;
                    y1 = y1+len;
                }
            }else{
                if(len < (x+1)/2){
                    x1_2 = x1+len,  y1_2 = y1,  x2_2 = x2,  y2_2 = y2;
                    x2 = x1+len;
                }else{
                    x1_2 = x1,  y1_2 = y1,  y2_2 = y2,  x2_2 = x1+len;
                    x1 = x1+len;
                }
            }
            count++;
            cake[count][0] = x1,cake[count][1] = y1,cake[count][2] = x2,cake[count][3] = y2;
            count++;
            cake[count][0] = x1_2,cake[count][1] = y1_2,cake[count][2] = x2_2,cake[count][3] = y2_2;
 
        }
         
        for(int i = 1;i <= n+1;i++){
            que.push( (cake[i][2]-cake[i][0])*(cake[i][3]-cake[i][1]) );
        }
        int ans = que.top(); que.pop();
        cout << ans ;
        while(!que.empty()){
            ans = que.top(); que.pop();
            cout << " " << ans;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3128
#include <stdio.h>

int prime(int n){
    int i;
    if (n < 2) return 0;
    if (n == 2) return 1;
    if ((n & 1) == 0) return 0;
    for (i = 3; i * i <= n; i += 2) if(n % i == 0) return 0;
    return 1;
}

int main(){
    int n, p, c = 0;
    scanf("%d", &n);
    while (n--) {
        scanf("%d", &p);
        c += prime(p);
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 596
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pii pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=2e5+10;

    pii a[N];priority_queue< int,vc<int>,greater<int> > q;
	void main()
	{
		int n=qread(),C=qread(),K=qread();
		fo(i,1,n) a[i].FR=qread(),a[i].SE=a[i].FR+K;sort(a+1,a+n+1);
		int ans=0;a[n+1].FR=INF+INF;
		fo(i,1,n+1)
		{
			while(sz(q) and q.top()<a[i].FR)
			{
				int cnt=C;while(cnt-- and sz(q)) q.pop();
				ans++;
			}q.push(a[i].SE);
		}write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
namespace WoZhenTaMaShiGeLaJi
{
	const int N=2050,M=200100,MOD=1000000007;
	template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
	template<typename T>inline void inc(T a,T &b){b=((b+a)%MOD+MOD)%MOD;}
	typedef long long ll;
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	ll inv(ll x){return qpow(x,MOD-2);}
	ll t1[N*2][N*2],*t2[N*2],**f;
	ll fact[N*4];
	int A[M],B[M];
	int n,mx,my;
	ll ans;
	ll C(int a,int b){return fact[a]*inv(fact[b])%MOD*inv(fact[a-b])%MOD;}
	void initialize()
	{
		for(int i=0;i<N*2;i++)t2[i]=t1[i]+N;f=t2+N;
		fact[0]=1;for(int i=1;i<N*4;i++)fact[i]=fact[i-1]*i%MOD;
		
		scanf("%d",&n);
		mx=my=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",A+i,B+i);
			f[-A[i]][-B[i]]++;
			check_max(A[i],mx);
			check_max(B[i],my);
		}
	}
	void solve()
	{
		initialize();
		for(int i=-mx;i<=mx;i++)
			for(int j=-my;j<=my;j++)
			{
//				printf("f[%d][%d] = %lld\n",i,j,f[i][j]);
				inc(f[i][j],f[i+1][j]);
				inc(f[i][j],f[i][j+1]);
			}
		ans=0;
		for(int i=1;i<=n;i++)
			inc(f[A[i]][B[i]],ans);
		for(int i=1;i<=n;i++)
			inc(-C(A[i]+B[i]+A[i]+B[i],A[i]+A[i]),ans);
		ans=(ans*inv(2)%MOD+MOD)%MOD;
		printf("%lld\n",ans);
	}
}
int main()
{
	WoZhenTaMaShiGeLaJi::solve();
	return 0;
}


Measured memory_bytes: 131328
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int t = s.nextInt();
    int c = 10000;
    for(int i = 0; i < n; i++){
      int ci = s.nextInt();
      if(s.nextInt() <= t)
        c = c > ci ? ci : c;
    }
    if(c <= 1000)
      System.out.println(c);
    else
      System.out.println("TLE");
  }
}

Measured memory_bytes: 23124
#include <iostream>
using namespace std;
typedef long long int ll;
typedef double db;
//
#define M 1000000007
#define mp make_pair
#define pb push_back
#define START ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
int main()
{
	START
	ll m,ans=0,n,sum;
	cin >> m >> n >> sum;
	if(m>n){
		ans=sum/m;
		if(sum%m==0)
			ans=ans;
		else
			ans=ans+1;
	}
	else
	{
		ans = sum/n;
		if(sum%n!=0)
			ans+=1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll x; cin>>x;
    ll syo = x / 11;
    ll yojo = x % 11;
    ll ans = syo*2;
    if((x%11 != 0)){
        if(yojo > 6) ans+=2;
        else ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
st = list(str(input()))
s = [st[i] for i in range(len(st))]
ans = []
lis = []
for k in range(len(s)):
  lis = st
  while lis != [s[k] for _ in range(len(lis))]:
    cou = []
    for i in range(len(lis)-1):
      if lis[i+1] == s[k] or lis[i] == s[k]:
        cou.append(s[k])
      else:
        cou.append("X")
    lis = cou
  ans.append(len(lis))
print(len(s)-max(ans))

Measured memory_bytes: 3064