akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define M (ll)(1e9+7)
ll n;
ll setsize[500011][2];
ll cost[200011];
void intial()
{
    for(ll i=0;i<500011;i++)
    {
        setsize[i][0]=i;
        setsize[i][1]=1;
    }
}
ll root(ll x)
{
    while(setsize[x][0]!=x)
    {   
        setsize[x][0]=setsize[setsize[x][0]][0];

        x=setsize[x][0];
    }
    
    return x;
}
void makeset(ll l,ll r)
{
    l=root(l);
    r=root(r);
    if(l!=r)
      {
        if(setsize[l][1]<setsize[r][1])
        {
            setsize[l][0] = setsize[r][0];
            setsize[r][1]+=setsize[l][1];
        }
        else
        {
            setsize[r][0]=setsize[l][0];
            setsize[l][1]+=setsize[r][1];
        }
      }
}

int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
   

    ll m;

    cin>>n>>m;

    intial();
    ll ap[m+11][2];

    for(ll i=0;i<m;i++){
      cin>>ap[i][0]>>ap[i][1];
    }

    vector<ll>ans;

    ans.push_back((n*(n-1))/2);
    ll ans1 = (n*(n-1))/2;

    for(ll i = m-1;i>=1;i--){
        ll l = ap[i][0];
        ll r = ap[i][1];

        if(root(l)!=root(r)){

            ll sz = setsize[root(l)][1];
            ll sz1 = setsize[root(r)][1];
            // cout<<sz<<" "<<sz1<<"\n";
            makeset(l,r);
            ans1 = ans1 - (sz*sz1);
            ans1 = max(0LL,ans1);
            ans.push_back(ans1);
        }else{
            ans.push_back(ans1);
        }


    }

    reverse(ans.begin(),ans.end());

    for(auto x:ans){
        cout<<x<<"\n";
    }


return 0;
}

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

int main()
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    bool reverse = false;
    for(int i=0;i<Q;++i)
    {
        int q;
        cin >> q;
        if(q == 1)
        {
            reverse = !reverse;
        }
        else
        {
            string s;
            cin >> q >> s;
            if(q==1&&!reverse || q==2&&reverse)
            {
                S.insert(0, s);
            }
            else
            {
                S.push_back(s[0]);
            }
        }
    }

    if(reverse)
    {
        for(int i=S.length()-1;i>=0;--i)
        {
            cout << S[i];
        }
    }
    else
    {
        for(int i=0;i<S.length();i++)
        {
            cout << S[i];
        }
    }
    
    cout << endl;

    return 0;
}


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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}


vector<vi> g;
vector<char> used;
vi mt;

bool dfs(int u)
{
    if (used[u])
        return false;
    used[u] = true;
    for (auto v : g[u])
    {
        if (mt[v] == -1 || dfs(mt[v]))
        {
            mt[v] = u;
            return true;
        }
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    g.resize(n);
    vector<pair<int, int>> a(n), b(n);
    mt.assign(n, -1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].fst >> a[i].snd;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i].fst >> b[i].snd;
    }
    for (int i = 0; i < n; i++)
    {
        int x1, y1;
        tie(x1, y1) = a[i];
        for (int j = 0; j < n; j++)
        {
            int x2, y2;
            tie(x2, y2) = b[j];
            if (x1 < x2 && y1 < y2)
            {
                g[i].PB(j);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        used.assign(n, false);
        if (dfs(i))
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,i,a[131072],k,m=0,g;
    scanf("%lld%lld",&n,&k);
    for(i = 1;i <= n;i++){
        scanf("%lld",&a[i]);m=llmax(m,a[i]);
        if(a[i] == k){printf("POSSIBLE\n");return 0;}
        if(i==1){g=a[i];}else{g=llgcd(g,a[i]);}
    }
    if(k <= m && k%g == 0){printf("POSSIBLE\n");}
    else{printf("IMPOSSIBLE\n");}
    return 0;
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
signed main(){

	ll H, N;
	cin>>H>>N;
	vector<pll> magics;
	for(int i=0;i<N;i++){
		int a, b;
		cin>>a>>b;
		magics.eb(a, b);
	}

	static ll DP[1050][10050]={};	//i番目の魔法まで使える場合の、jダメージ与えるための最小魔力
	for(int i=0;i<=N;i++)
		for(int j=0;j<=H;j++)
			DP[i][j]=INFLL;
	DP[0][0]=0;
	for(int i=0;i<N;i++){
		ll a, b;
		tie(a, b)=magics[i];
		for(int j=0;j<=H;j++){
			//魔法i+1を使わない場合
			DP[i+1][j]=min(DP[i+1][j], DP[i][j]);
			//魔法i+1を使う場合
			DP[i+1][min(H, j+a)]=min(DP[i+1][min(H, j+a)], DP[i+1][j]+b);
		}
	}

	ll ans=INFLL;
	cout<<DP[N][H]<<endl;

	return 0;
}

Measured memory_bytes: 80128
x=[int(i) for i in input().split()]
y=[0,0]
for ele in x:
    if ele==5: y[0]+=1
    elif ele==7: y[1]+=1
    else: continue
if y[0]==2:
    if y[1]==1:
        print('YES')
    else:
        print('NO')
else:
    print("NO")

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

using  ll =          long long;
using ull = unsigned long long;
const char en = '\n';
const ll INFL = 810000001919114514;
const int INF =         1919114514;

#define REP(i  ,n) for(int i=0;i<n;i++)
#define FOR(i,s,g) for(int i=s;i<g;i++)


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

	ll s,c,result=0;
	cin>>s>>c;
	
	result+=min(s,c/2);

	c-=result*2;
	result+=c/4;

	cout<<result<<en;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N,X;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &X);

  int *L=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&L[i]);
  }

  int sum=0;
  int index=1;
  while(sum<=X && index<N+1){
    sum+=L[index-1];
    index++;
  }

  if(sum<=X){
    printf("%d\n", index);
  }
  else{
    printf("%d\n", index-1);
  }


  return 0;

}


Measured memory_bytes: 128
package main

import (
    "fmt"
)

func main(){
    var a,b int
    fmt.Scanf("%d %d", &a,&b)
    if(b == 1) {
        fmt.Println("0")
        return;
    }else{
        ans := 1
        b -= a
        a--
        for b > 0 {
            b -= a
            ans++
        }
        fmt.Println(ans)
        return
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, a, b, x;
	cin >> n;
	vector<vector<pair<long long, long long>>> adj(n + 1);
	for (i = 0; i < n - 1; i++) {
		cin >> a >> b >> x;
		adj[a].push_back({ b, x });
		adj[b].push_back({ a, x });
	}

	vector<long long> dp(n + 1, 1LL << 60);
	dp[1] = 0;
	queue<long long> q;
	q.push(1);

	while (!q.empty()) {
		a = q.front();
		q.pop();

		for (auto p : adj[a]) {
			b = p.first;
			x = p.second;
			if (dp[a] + x < dp[b]) {
				dp[b] = dp[a] + x;
				q.push(b);
			}
		}
	}

	for (i = 1; i <= n; i++) cout << dp[i] % 2 << "\n";
	
	return 0;
}


Measured memory_bytes: 8704
program agc033a
  implicit none
  character(1000) s
  integer h, w, x, y
  integer, allocatable :: grid(:,:)

  read *, h, w
  allocate(grid(w, h))

  do y = 1, h
     read *, s
     do x = 1, w
        grid(x, y) = merge(0, 1000000, s(x:x) == '#')
     end do
  end do

  do x = 2, w
     grid(x, :) = merge(grid(x - 1, :) + 1, grid(x, :), grid(x, :) - grid(x - 1, :) > 1)
  end do

  do x = w - 1, 1, -1
     grid(x, :) = merge(grid(x + 1, :) + 1, grid(x, :), grid(x, :) - grid(x + 1, :) > 1)
  end do

  do y = 2, h
     grid(:, y) = merge(grid(:, y - 1) + 1, grid(:, y), grid(:, y) - grid(:, y - 1) > 1)
  end do

  do y = h - 1, 1, -1
     grid(:, y) = merge(grid(:, y + 1) + 1, grid(:, y), grid(:, y) - grid(:, y + 1) > 1)
  end do

  print *, maxval(grid)
end program agc033a


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

int main(){
    long H, N;
    cin >> H >> N;

    vector<int> A(N);
    long sum = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        sum += A[i];
    }

    if (sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
rikei = [int(input()) for i in range(4)]

for i in range(0, 4):
    for j in range(i + 1, 4):
        if rikei[i] < rikei[j]:
            tmp = rikei[i]
            rikei[i] = rikei[j]
            rikei[j] = tmp

bunkei = [int(input()) for i in range(2)]
if bunkei[0] < bunkei[1]:
    tmp = bunkei[0]
    bunkei[0] = bunkei[1]
    bunkei[1] = tmp

print(rikei[0] + rikei[1] + rikei[2] + bunkei[0])



Measured memory_bytes: 5600
#include <stdio.h>
int main(){
  int a, b, d, r;
  double f;
  scanf("%d %d",&a,&b);
  d = a/b; r = a%b; f = (double)a/(double)b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 1820
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, a[100009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	bool flag = false;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) flag = true;
	}
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		if (((long long)1e18 + 0) / ans < a[i]) {
			ans = -1;
			break;
		}
		else ans *= a[i];
	}
	if (flag) ans = 0;
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 4424
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int const N = (1<<15)+1;
  vector<int> prime(N);
  REP(i,N) prime[i] = i;
  prime[0] = prime[1] = 0;
  REP(i,N)
    if (prime[i])
      for (int j=2*i; j<N; j+=i)
        prime[j] = 0;
  vector<int> table = prime;
  prime.erase(remove(ALL(prime),0), prime.end());
  int n;
  while(cin>>n,n) {
    int res = 0;
    for (int i=0; prime[i]*2 <= n; ++i) {
      if (table[n-prime[i]])
        res++;
    }
    cout << res<< endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  ll a, b; cin >> a >> b;
  if(abs(a-b)%2==0) cout << abs(a-b)/2 << endk;
  else cout << min(min(a, b)+abs(a-b)/2, n-max(a, b)+1+abs(a-b)/2) << endk;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;

    int ans = 0;
    int g_cnt = 0;
    rep(i, s.size()) {
        if (s[i] == 'g') {
            if (g_cnt) {
                ans++;
                g_cnt--;
            } else {
                g_cnt++;
            }
        } else {
            if (g_cnt) {
                g_cnt--;
            } else {
                g_cnt++;
                ans--;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
n = int(input())

a = [0 for i in range(n)]
b = [0 for i in range(n)]
c = [0 for i in range(n)]

for i in range(n):
    a[i], b[i], c[i] = list(map(int, input().split()))

dp = []

for i in range(n):
    dp.append([0, 0, 0])


dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1, n):
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i])
    dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i])
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i])

print(max(dp[-1]))

Measured memory_bytes: 87708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

vector<vector<char>> table(100,vector<char>(100,'#'));
vector<vector<int>> dist(100,vector<int>(100,0));
vector<vector<bool>> seen(100,vector<bool>(100,0));
int h,w;

void init_seen(){
  rep1(i,h) rep1(j,w) seen[i][j] = 0;
}

void init_dist(){
  rep1(i,h) rep1(j,w) dist[i][j] = 0;
}

int main(){
  cin >> h >> w;
  rep1(i,h) rep1(j,w) cin >> table[i][j];
  
  int ans = 0;
  rep1(i,h){
    rep1(j,w){
      
  init_dist();
  init_seen();
  queue<pair<int,int>> q;
  pair<int,int> p = make_pair(i,j);
  q.push(p);
  while(!q.empty()){
    int a = q.front().first;
    int b = q.front().second;
    q.pop();
    if(seen[a][b]) continue;
    seen[a][b] = 1;
    if(a<1 || a>h) continue;
    if(b<1 || b>w) continue;
    if(table[a][b] == '#') continue;
    if(table[a+1][b] == '.' && !seen[a+1][b]){
      dist[a+1][b] = dist[a][b]+1;
      pair<int,int> next = make_pair(a+1,b);
      q.push(next);
    }
    if(table[a-1][b] == '.' && !seen[a-1][b]){
      dist[a-1][b] = dist[a][b]+1;
      pair<int,int> next = make_pair(a-1,b);
      q.push(next);
    }
    if(table[a][b+1] == '.' && !seen[a][b+1]){
      dist[a][b+1] = dist[a][b]+1;
      pair<int,int> next = make_pair(a,b+1);
      q.push(next);
    }
    if(table[a][b-1] == '.' && !seen[a][b-1]){
      dist[a][b-1] = dist[a][b]+1;
      pair<int,int> next = make_pair(a,b-1);
      q.push(next);
    }
  }
  int tmp = 0;
  rep1(i,h)rep1(j,w) tmp = max(tmp,dist[i][j]);
  ans = max(ans,tmp);
      
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, d, ans = 0;
    cin >> n >> d;
    int p = d + 1;
    while(1){
        ans++;
        p += d + 1;
        if(p >= n + 1){
            break;
        }
        p += d;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<int,int> > d;
  for(int i=0;i<n;i++){ 
    int a;
    cin >> a;
    d.push_back(make_pair(a,i));
  }
  sort(d.begin(),d.end());
  int ma = 1, now = 1;
  for(int i=1;i<n;i++){
  	if(d[i].second > d[i-1].second){now++;}
    else {now = 1;}
    if(now > ma) ma = now;
  }
  cout << n - ma << endl;
  return 0;
}

  


Measured memory_bytes: 2420
import math
import sys

sup = 1000000

is_prime = [0] * sup

count = [0] * sup

def setup():
    is_prime[2] = 1
    for n in range(3,sup,2):
        flag = True
        for i in range(3, int(math.floor(math.sqrt(n) + 1)), 2):
            if n % i == 0:
                flag = False
                break
        if flag:
            is_prime[n] = 1

def precount():
    for n in range(2, sup):
        count[n] = count[n-1] + is_prime[n]

def main():
    setup()
    precount()

    l = []

    for line in sys.stdin:
        l.append(int(line))

    for line in l:
         print(count[line])

if __name__ == "__main__":
    main()


Measured memory_bytes: 52888
import sys
readline = sys.stdin.readline

# 青木君からの到達距離 - 高橋君からの到達距離が最も大きい場所に逃げるべき
# そこに到達したときに、
# 高橋君と青木君の距離が偶数のとき
# 青 - x - x - x - 高
# 青 - x - x - 高 - x
# x - 青 - x - 高 - x
# x - 青 - x - x - 高
# x - x - 青 - x - 高
# x - x - 青- 高 - x 
# x - x - x - 終 - x 
# 青木君からの距離 - 1が答え
# 高橋君と青木君の距離が奇数のとき
# 青 - x - x - 高
# 青 - x - 高 - x
# x - 青 - 高 - x
# x - 青 - x - 高
# x - x - 青 - 高
# x - x - 終 - x
# やっぱり青木君からの距離 - 1が答え
# つまり、
# ・[青木君からの距離が遠い場所について]
# ・[青木君からの距離 - 1]が答え

N,u,v = map(int,readline().split())
G = [[] for i in range(N)]
for i in range(N - 1):
  a,b = map(int,readline().split())
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)

dist_from_u = [0 for i in range(N)] # 高橋君からの距離
dist_from_v = [0 for i in range(N)] # 青木君からの距離

stack = []
# 頂点, 高橋君からの距離, 親
stack.append([u - 1,0,-1])
while stack:
  e, dist, parent = stack.pop()
  dist_from_u[e] = dist
  for child in G[e]:
    if child == parent:
      continue
    stack.append([child, dist + 1, e])

stack = []
# 頂点, 青木君からの距離, 親
stack.append([v - 1,0,-1])
while stack:
  e, dist, parent = stack.pop()
  dist_from_v[e] = dist
  for child in G[e]:
    if child == parent:
      continue
    stack.append([child, dist + 1, e])
    
maxdiff_from_v = 0
for i in range(N):
  if dist_from_u[i] < dist_from_v[i]:
    if maxdiff_from_v < dist_from_v[i]:
      maxdiff_from_v = dist_from_v[i]
    
print(maxdiff_from_v - 1)


Measured memory_bytes: 33432
from collections import deque
h,w=map(int,input().split())
INF=10**18
a=[input() for _ in range(h)]
d=[[INF for _ in range(w)]for _ in range(h)]
q=deque([])
for i in range(h):
  for j in range(w):
    if a[i][j]=='#':
      d[i][j]=0
      q.append((i,j))
dx=[1,0,-1,0]
dy=[0,1,0,-1]
ans=0
while q:
  x,y=q.popleft()
  for i in range(4):
    nx=x+dx[i]
    ny=y+dy[i]
    if 0<=nx<h and 0<=ny<w:
      if d[nx][ny]==INF:
        q.append((nx,ny))
        d[nx][ny]=d[x][y]+1
        ans=max(ans,d[nx][ny])
print(ans)

Measured memory_bytes: 117060
#include <bits/stdc++.h>
using namespace std;
int K;
int main() {
    cin >> K;
    if(K % 2 == 0) {
        cout << (K/2) * (K/2) << endl;
    }else {
        cout << (K/2 + 1) * (K/2) << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#define maxn 105
using namespace std;
char s[maxn][maxn];
bool h[maxn],l[maxn];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		bool flag=0;
		for(int j=1;j<=m;j++)if(s[i][j]=='#'){flag=1;break;}
		if(!flag)h[i]=1;
	}
	for(int j=1;j<=m;j++){
		bool flag=0;
		for(int i=1;i<=n;i++)if(s[i][j]=='#'){flag=1;break;}
		if(!flag)l[j]=1;
	}
	for(int i=1;i<=n;i++){
		bool flag=0;
		for(int j=1;j<=m;j++){
			if(!h[i]&&!l[j]){
				flag=1;
				putchar(s[i][j]);
			}
		}
		if(flag)putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			List<Long> an = new ArrayList<>();
			an.add(c);
			an.add(a);
			an.add(b);
			StringBuilder sb = new StringBuilder();
			for (long l : an) {
				sb.append(l);
				sb.append(" ");
			}
			sb.setLength(sb.length()-1);
			System.out.println(sb);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


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

using namespace std;

int main()
{
    int N;

    cin >> N;

    vector<int> a(N);
    for (int i = 0; i < a.size(); i++)
    {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), std::greater<int>());

    int count = 1;
    for (int i = 1; i < a.size(); i++)
    {
        if (a[i - 1] != a[i])
        {
            count++;
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	
	static int S, T;
	static void f(int sum, int[] a, int[] b) {
		if (a.length == 0) {
			if (sum >= 0)
				S++;
			T++;
			return;
		}
		int[] na = new int[a.length - 1];
		for (int i = 0; i < a.length - 1; i++)
			na[i] = a[i + 1];
		for (int i = 0; i < b.length; i++) {
			int[] nb = new int[b.length - 1];
			int p = 0;
			for (int k = 0; k < b.length; k++) {
				if (i == k)
					continue;
				nb[p] = b[k];
				p++;
			}
			int win = a[0] > b[i] ? a[0] + b[i] : -(a[0] + b[i]);
			f(sum + win, na, nb);
		}
	}
	
	public static void main(String[] args) {
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int[] a = new int[9], b = new int[9];
			for (int j = 0; j < 9; j++)
				a[j] = sc.nextInt();
			for (int j = 0; j < 9; j++)
				b[j] = sc.nextInt();
			S = 0;
			T = 0;
			f(0, a, b);
			double p = (double)S / (double)T;
			System.out.printf("%.5f %.5f", p, (1.0 - p));
			System.out.println();
//			System.out.println(new Stringp + " " + (1.0 - p));
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int suu(char n) {
	return n-'0';
}

int main() {
	int a,b; cin >> a >> b;
	if(a<=0&&0<=b) {
		cout << "Zero" << endl;
		return 0;
	}
	else {
		if(a<0) {
			if(abs(a-b)%2==0) cout << "Negative" << endl;
			else cout << "Positive" << endl;
		}
		else cout << "Positive" << endl;
	}
}

Measured memory_bytes: 764
def main():
    X, Y = (int(i) for i in input().split())
    if (X+Y) % 3 != 0:
        return print(0)
    MOD = 10**9 + 7
    m = X + Y + 5
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m

    def COMBinitialize(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % MOD
                inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
                finv[i] = finv[i - 1] * inv[i] % MOD

    def COMB(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMBinitialize(m)

    n = (X+Y)//3
    r = X - n
    print(COMB(n, r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 85488
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5;
ll a[N+5],b[N+5],f[N+5];
ll n,k,sum,ans;
bool Check(ll x)
{
	for(int i=1;i<=n;i++)		
	b[i]=x/f[i];	
	ll res=0;	
	for(int i=1;i<=n;i++)		
	res+=max(0ll,a[i]-b[i]);	
	return res<=k;
}
ll cal()
{	
    ll l=0,r=(ll)1e12;	
	while(l+1<=r)	
	{	
		ll mid=(l+r)>>1; 	
		if(Check(mid))	
		r=mid;	
		else	
		l=mid+1;
	}
	return r;
}
int main()
{	
	scanf("%lld%lld",&n,&k);	
	for(int i=1;i<=n;i++)	
	{		
		scanf("%lld",&a[i]);		
		sum+=a[i];	
	}	
	for(int i=1;i<=n;i++)		
	scanf("%lld",&f[i]);	
	if(sum<=k)	
	{		
		printf("0\n");		
		return 0;	
	}	
	sort(a+1,a+n+1);	
	sort(f+1,f+n+1,greater<int>());	
	printf("%lld\n",cal());	
	return 0;
}


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 1e9 + 7;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

struct card {
    int r, c, x;

    bool operator<(const card& a) const {
        return x < a.x;
    }
};

struct DSU {
    vector<int> t, r;
    vector<int> d;

    DSU() {}

    DSU(int n) : t(n), r(n, 1), d(n, 1) {
        iota(all(t), 0);
    }

    int p(int v) {
        return (t[v] == v ? v : (t[v] = p(t[v])));
    }

    bool unite(int u, int v) {
        int pu = p(u), pv = p(v);
        //cout << u << ' ' << v << ' ' << pu << ' ' << pv << endl;
        if (pu == pv) {
            if (d[pu]) {
                d[pu] = 0;
                return 1;
            }
            return 0;
        }
        if (!(d[pu] | d[pv])) {
            return 0;
        }
        if (r[pu] > r[pv]) {
            swap(pu, pv);
        }
        r[pv] += r[pu];
        d[pv] &= d[pu];
        t[pu] = pv;
        return 1;
    }
};

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

    int n, h, w;
    cin >> n >> h >> w;
    vector<card> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].r >> a[i].c >> a[i].x;
    }
    sort(rall(a));
    DSU dsu(h + w + 1);
    ll ans = 0;
    for (card& el : a) {
        ans += el.x * dsu.unite(el.r, h + el.c);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3840
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ADiagonalString {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println("" + in.next().charAt(0) + in.next().charAt(1) + in.next().charAt(2));
        }

    }
}



Measured memory_bytes: 21844
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int m,d;  cin >> m >> d;
  int ans = 0;
  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= d; j++){
      int x10 = j/10;
      int x = j%10;
      if(i == x10*x and x >= 2 and x10 >= 2){
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
S = input()

if S[2:-1].count('C') != 1:
  print('WA')
else:
    if S[0] != 'A':
      print('WA')
    else:
        S = list(map(lambda x: x, S))
        S[0] = 'a'
        S[S[2:-1].index('C')+2] = 'c'
        if ''.join(S).islower():
          print('AC')
        else:
          print('WA')


Measured memory_bytes: 3060
#if _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

// Reads a 1D vector
template <class T>
void read1d(vector<T> & arg) {
	const int l = arg.size();
	for (int i = 0; i < l; ++i) cin >> arg[i];
}

void read() {}
// Reads arbitrary values
template <class T1, class... T2>
void read(T1& var1, T2&... var2) { cin >> var1; read(var2...); }



void pln() { cout << (DEBUG ? "]\n" : "\n"); }
template <class T1, class... T2>
void pln(const T1& var1, const T2& ... var2) { cout << var1 << " "; pln(var2...); }

// Prints arbitrary values and goes to next line
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout << (DEBUG ? " [ " : ""); pln(var1, var2...); }

// Prints arbitrary values and goes to next line ONLY IF IN DEBUG MODE
template <class T1, class... T2>
constexpr void debug(const T1& var1, const T2& ... var2) { if (!DEBUG) return;  cout << " debug : [ "; pln(var1, var2...); }





using ll = long long;
using ull = unsigned long long;


#define all(x) begin(x), end(x)

const bool MULTIPLE_TEST_CASES = 0;

void dfs(vector<set<int>>& graph, int root, int parent, vector<bool>& visited, int& size) {
	++size;
	visited[root] = true;

	for (int i : graph[root]) {
		if (i == parent || visited[i]) continue;
		dfs(graph, i, root, visited, size);
	}
}


void exec() 
{
	int n, m;
	cin >> n >> m;

	vector<bool> connected(n + 1, false);
	vector<set<int>> graph(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b;
		read(a, b);

		connected[a] = connected[b] = true;

		graph[a].insert(b);
		graph[b].insert(a);
	}

	int size = 1;
	vector<bool> visited(n + 1, false);
	for (int i = 1; i <= n; ++i) {
		if (!connected[i]) continue;
		int thisSize = 0;
		dfs(graph, i, -1, visited, thisSize);
		size = max(size, thisSize);
	}

	print(size);
}

















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

	if (!MULTIPLE_TEST_CASES)
		exec();
	else {
		int n;
		cin >> n;

		while (n--)
			exec();
	}

    return 0;
}

Measured memory_bytes: 46940
import java.util.Scanner;

public class Main {
    static public void main(String[] args){
        Scanner in = new Scanner(System.in);

        long N = in.nextInt();
        long M = in.nextInt();
        String S = in.next();
        String T = in.next();

        long L = lcm(N, M);
        long ln = L/N;
        long lm = L/M;

        int n=0;
        int m=0;
        while (n<N && m<M){
            if (n * ln == m * lm) {
                if (S.charAt(n) != T.charAt(m)){
                    System.out.println("-1");
                    System.exit(0);
                }
            }
            if (n*ln == m*lm){ n++; m++;
            }else if (n*ln < m*lm) n++;
            else m++;
        }

        System.out.println(L);
    }

    private static long gcd(long m, long n){
        if (m < n) return gcd(n, m);
        if (n == 0) return m;
        return gcd(n, m%n);
    }

    private static long lcm(long m, long n){
        return m * n / gcd(m, n);
    }
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    ll sum = 0;
    map<ll, int> cnt;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        sum += a;
        ++cnt[a];
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        ll b, c;
        cin >> b >> c;

        if (cnt.find(b) != cnt.end()) {
            ll tmp = cnt[b];
            sum -= b * tmp;
            cnt.erase(b);
            sum += c * tmp;
            cnt[c] += tmp;
        }
        cout << sum << newl;
    }

    return 0;
}

Measured memory_bytes: 7600
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for _ in range(m)]

s = sum(t)
for i in range(m):
    p = px[i][0] - 1
    x = px[i][1]
    print(sum(t) - t[p] + x)


Measured memory_bytes: 3060
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


int  main(void) {
	int  n, t[101], total=0;
	int  i,m, p, x;

	i_cin(n);i_cins(n, t);
	i_cin(m);
	for (i = 0; i < n; i++) {
		total += t[i];
	}
	for (i = 0; i < m; i++) {
		i_cin2(p, x); p--;
		i_cout(total-(t[p]-x));
	}

	return 0;
}
//
//int main(void)
//{
//	ull    a, b, n;
//	ull    y;
//
//	ull_cin(a);	ull_cin(b); ull_cin(n);
//
//	if (n == b||n == a) n--;
//	y = (a * n) / b - a * (n / b);
//
//	ull_cout(y);
//	return 0;
//}

//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 128
#include <cstdio>

int a[100007],n,q;
int bit[100007];

template<class T>
void build(T arr[],T bit[],unsigned int n){
    bit[0]=0;
    for(auto i=2u;i<n;i++) bit[i]=bit[i-1]+arr[i];
    for(auto i=n-1;i>0;i--) bit[i]-=bit[i-(i&-i)];
}

template<class T>
void update(T bit[],unsigned int n,unsigned int index,T diff){
    for(auto i=index;i<n;i+=(i&-i)) bit[i]+=diff;
}

template<class T>
T prefix(T bit[],unsigned int bound){
    T ret=0;
    while(bound>0){
        ret+=bit[bound];
        bound-=(bound&-bound);
    }

    return ret;
}

template<class T>
T query(T bit[],unsigned int l,unsigned int r){
    return prefix(bit,r-1)-prefix(bit,l-1);
}


int main(){

    scanf("%d%d",&n,&q);
    for(int i=0;i<q;i++){
        int com,x,y;
        scanf("%d%d%d",&com,&x,&y);
        if (com)
            printf("%d\n",query(bit,x,y+1));
        else 
            update(bit,n+1,x,y);
    }
    return 0;
}


Measured memory_bytes: 3080
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}

int n;
char s[N];
char c;
int ans=1;

int main()
{
	read(n);
	scanf("%s",s+1);
	c=s[1];
	Rep(i,2,n)
		if(s[i]!=c){
			ans++;
			c=s[i];	
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
L, S = map(int, input().split())

if L % 2 == 1 and S % 2 == 1:
    ans = int(L*(S-1)/2 + (L+1)/2)
else:
    ans = int(L*S/2)

if L == 1 or S == 1:
    ans = 1

print(ans)

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

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

  ll N, A, B; cin >> N >> A >> B;
  if (N == 1) {
    if (A == B) cout << "1";
    else cout << "0";
    return 0;
  }
  if (A > B) {
    cout << "0";
    return 0;
  }
  if (A == B) {
    cout << 1;
    return 0;
  }
  ll MAX = A + (N - 1) * B;
  ll MIN = A * (N - 1) + B;
  ll ans = MAX - MIN + 1;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
        
        int N;
        int digi100,digi10,digi1; //桁
        
        scanf("%d",&N);

        digi100 = N / 100; //100の位
        digi10 = ((N - 100 * digi100) / 10); //10の位
        digi1 = N - (100 * digi100 + 10 * digi10); //1の位

        if(digi100 == 7 || digi10 == 7 || digi1 == 7){
                printf("Yes\n");
        }
        else{
                printf("No\n");
        }

        return 0;
}


Measured memory_bytes: 1648
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    string S;
    cin>>S;

    int cnt = 1;
    REP(i,1,S.size()){
        if(S[i] == S[i-1]){
            cnt++;
            if(cnt == 3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }else{
            cnt = 1;
        }
    }

    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll k,q;cin>>k>>q;
    vector<ll>d(k+1);
    rep(i,k)cin>>d[i+1];
    while(q){
        q--;
        ll n,x,m;cin>>n>>x>>m;
        vector<ll>a(k+1);
        vector<ll>b(k+1);
        REP(i,1,k+1){
            a[i]=a[i-1]+d[i]%m;
            if(d[i]%m)b[i]=b[i-1]+1;
            else b[i]=b[i-1];
        }
        n--;
        ll ans=n/k*b[k]+b[n%k];
        ll cnt=x%m+n/k*a[k]+a[n%k];
        ans-=cnt/m;
        cout<<ans<<endl;
    }
}

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

class Main {

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        int A = sc.nextInt();
        int P = sc.nextInt();
        int ans = (3*A + P) / 2;

        System.out.println(ans);

    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x; cin >> x;
	if(x >= 400 && x <= 599) cout << 8;
	else if(x >= 600 && x <= 799) cout << 7;
	else if(x >= 800 && x <= 999) cout << 6;
	else if(x >= 1000 && x <= 1199) cout << 5;
	else if(x >= 1200 && x <= 1399) cout << 4;
	else if(x >= 1400 && x <= 1599) cout << 3;
	else if(x >= 1600 && x <= 1799) cout << 2;
	else cout << 1;

	return 0;
}

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

using namespace std;


int main()
{
    int a,b;
    char c;
    while(1){
        cin >> a >> c >> b;
        if(c == '+'){
            cout << a+b <<endl;
        }
        if(c == '-'){
            cout << a-b << endl;
        }
        if(c == '*'){
            cout << a*b << endl;
        }
        if(c == '/'){
            cout << a/b << endl;
        }
        if(c == '?'){
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3104
c=[]
for i in range(3):
  A = list(map(int, input().split()))
  c.append(A)
if c[0][0] + c[1][1]+ c[2][2] == c[1][0] + c[2][1] + c[0][2] == c[2][0] + c[0][1] + c[1][2]:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  vector<int> cnt(a[n-1]+1);
  for(int i=0;i<n;i++){
    for(int j=a[i];j<cnt.size();j+=a[i]){
      cnt[j]++;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(cnt[a[i]]==1)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7944
#include<stdio.h>
#include<math.h>

int main()
{
	int x,a,b;
	
	scanf("%d%d%d",&x,&a,&b);
	
	if((abs(x-a)) < (abs(x-b)))
	{
		printf("A\n");
	}
	else
	{
		printf("B\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
package main

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

// main is...
func main() {
	var n int
	fmt.Scanln(&n)

	var sc = bufio.NewScanner(os.Stdin)
	var list = make([]int, n)

	// スペースで区切られた各単語を、スペース削除してスキャナーを分割する
	// e.g. 1 2 3 4 5
	//  -> 1
	//     2
	//     3
	//     4
	//     5
	sc.Split(bufio.ScanWords)

	for idx := range list {
		if sc.Scan() {
			valueInt, _ := strconv.Atoi(sc.Text())
			list[idx] = valueInt
		}
	}

	max, tmp := 0, 0
	for i := n - 1; i > 0; i-- {
		if list[i-1] >= list[i] {
			tmp++
		} else {
			tmp = 0
		}

		if tmp > max {
			max = tmp
		}
	}

	fmt.Println(max)

}



Measured memory_bytes: 3072