akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N, K;
    int d;
    int x;
    int *ans;
    cin >> N >> K;
    ans = new int[N];
    fill(ans, ans + N, 0);

    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> x;
            ans[x - 1]++;
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (ans[i] == 0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void solve1()
{
    int h, w, k; cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }

    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < (1 << h); i++) {
        for(int j = 0; j < (1 << w); j++) {
            cnt = 0;
            for(int k = 0; k < h; k++) {

                for(int l = 0; l < w; l++) {
                    if ( !(i & (1 << k)) && !(j & (1<<l)) &&
                    c[k][l] == '#')
                    {
                        cnt ++;
                    }
                }

            }

            if(cnt == k) {
                ans ++;
            }
        }
    }

    cout << ans << endl;


}

int main()
{
    solve1();
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int total = 0;
       for(int i = 1;i <= N;i++){
           total += i;
       }
       System.out.println(total);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef pair<int , int> pp;
#define X first
#define Y second
typedef long long int ll;
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int N = 1e6 + 1;
const ll K = 1e9 + 7;

ll dp[N], a[N];
ll k, n;

ll fun(ll index) {
    if (index >= n - 1) {
        return 0;
    }
    if (dp[index] != -1) {
        return dp[index];
    }
    ll temp = 1e18;

    for (ll i = 1; i <= k && i + index < n; i++) {

        temp = min(abs(a[index + i] - a[index] ) + fun(index + i), temp);
    }
    return dp[index] = temp;
}
int main() {
    cin >> n;
    cin >> k;

    for (ll i = 0; i <= n; i++) {
        dp[i] = -1;
    }
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << fun(0);
}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

void insert(vector<int> &v, int element);

int extract(vector<int> &v);

void disp(vector<int> &v);

void insert(vector<int> &v, int element) {
    v.push_back(element);
    int current_index = v.size() - 1;
    int parent_index = -1;
    if (v.size()==1) {
    } else {
        parent_index = (current_index - 1) / 2;
        while ((v[parent_index] < v[current_index])&&(current_index != 0)) {
            swap(v[parent_index], v[current_index]);
            current_index = parent_index;
            parent_index = (current_index - 1) / 2;
        }
    }
}

int extract(vector<int> &v) {
    int root = v[0];
    int tail = v[v.size()-1];
    int left, left_index, right, right_index;
    v[0] = tail;
    v.pop_back();

    int current_index = 0;
    while (1) {
        left_index = 2 * current_index + 1;
        right_index = 2 * current_index + 2;
        left = left_index < v.size() ? v[left_index] : -1;
        right = right_index < v.size() ? v[right_index] : -1;
        if ((left > v[current_index])&&(left > right)) {
            swap(v[current_index], v[left_index]);
            current_index = left_index;
        } else if (right > v[current_index]) {
            swap(v[current_index], v[right_index]);
            current_index = right_index;
        } else {
            break;
        }
    }
    return root;
}


void disp(vector<int> &v) {
    for (int i=0; i<v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

int main() {
    string operation;
    int element;
    vector<int> v;
    while ((cin >> operation)&&(operation!="end")) {
        if (operation == "insert") {
            cin >> element;
            insert(v, element);
        } else if (operation == "extract") {
            element = extract(v);
            cout << element << endl;
        }
    }
}

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

using namespace std;
int n, k;
const int INF = 1e9 + 5;

int main(void) {
    scanf("%d %d", &n, &k);
    vector<int> h(n);
    for (int &x : h) {
        scanf("%d", &x);
    }

    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + k; ++j) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n - 1]);
    return 0;
}

Measured memory_bytes: 4044
//20
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
template <class I>
inline void read(I &x){
    int f=1;
    char c;
    for(c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(x=0;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c&15),c=getchar());
    x*=f;
}
int n;
int tot=0,num[N],cnt[32],p[33],f[(1<<16)+7],ans;
inline bool pd(int x,int w){
	return (x&w)==w;
}/*
bool dfs(int x,int fa,int w){
	int res=0;
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(y==fa) continue;
		if(!pd(edge[i],w))ans[w]+=dfs(y,x,w);
		else dfs(y,x,w),res+=1;
	}
	ans[w]+=res/2;
	if(x==1) ans[w]+=res&1;
	return res&1;
}*/
inline bool ch(int x,int y){
	int res=x+y;
	if((res^y)==x) return 0;
	return 1;
}
int g(int x){
	int now=0,res=0,sz=0;
	while(x){
		if(x&1) res^=p[now],sz++;
		x>>=1;
		now++;
	}
	return res?sz:sz-1;
}
int main(){
	//freopen("xor.in","r",stdin);
	//freopen("xor.out","w",stdout);
	read(n);
	for(int i=1;i<n;i++){
		int x,y,z;
		read(x),read(y),read(z);
		num[x]^=z,num[y]^=z;
	}
	for(int i=0;i<n;i++)
		cnt[num[i]]++;
	for(int i=1;i<=31;i++){
		ans+=cnt[i]/2;
		if(cnt[i]&1)
			p[tot++]=i;
	}
	for(int i=1;i<1<<16;i++){
		f[i]=g(i);
		for(int j=i;j;j=(j-1)&i){
			f[i]=min(f[i],f[j]+f[i^j]);
		}
	}
	if(tot)
	    printf("%d\n",ans+f[(1<<(tot-1))-1]);
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
/* Justin Choi */
#include <bits/stdc++.h>
using namespace std;

string FILENAME = "filename";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forl(V, N) for(int V = 0; V < N; V++)
#define for1(V, N) for(int V = 1; V <= N; V++)
#define fore(E, X) for(auto &E:X)
#define newl cout << endl
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)

#define graph unordered_map<int, unordered_set<int>>
#define um unordered_map
#define us unordered_set
#define vi vector<int>
#define pi pair<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define ins insert

int main() {
    qio; int n; cin >> n;
    vi nums(n); forl(i, n) cin >> nums[i];
    bool good = true;
    forl(i, n) {
        if(nums[i]%2==0 and nums[i]%3 and nums[i]%5) good = false;
    }
    if(good) println("APPROVED");
    else println("DENIED");
}

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

int main(){
  int N,D,x[10][10];
  cin>>N>>D;
  for (int n(0);n<N;n++)
    for (int d(0);d<D;d++)
      cin>>x[n][d];
  int cnt(0);
  for (int i(0);i<N;i++){
    for (int j(i+1);j<N;j++){
      int q(0);
      for (int d(0);d<D;d++){
        q+=(x[i][d]-x[j][d])*(x[i][d]-x[j][d]);
      }
      double qd=sqrt(q);
      if (ceil(qd) == floor(qd)) cnt+=1;
    }
  }
  cout << cnt <<endl;
  return 0;
}


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

int main() {
	int N, K ; cin >> N >> K ; 
	vector<int>H(N+1,0) ; 
	for ( int i=1; i<=N; ++i ) {
		cin >> H[i] ; 
	}
	vector<int>dp(N+1,INT_MAX) ;
	dp[0] = 0 ;
	dp[1] = 0 ; 
	dp[2] = abs(H[2]-H[1]) ; 
	for ( int i=1; i<=N; ++i ) {
		for ( int j=i+1; j<=min(i+K,N); ++j ) {
			dp[j] = min(dp[j],dp[i]+abs(H[i]-H[j])) ; 
		}
	}
	cout << dp[N] << endl ; 
	return 0 ; 
}

Measured memory_bytes: 1024
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
using namespace std;
const double PI = acos(-1);
const double G = 9.8;
struct Node {
    double lx, ly, rx, ry;
};
Node a[55];
double f(double A,double B,double x,double y)
{
    return y - A * x * x - B * x;
}
double X, Y;
double v;
int n;
int judge(double x)
{
    double B = tan(x);
    double v1 = v * sin(x);
    double v2 = v * cos(x);
    double t = 2.0 * v1 / G;
    double xx = v2 * t;
    double A = (- B / xx);

    for(int i = 1; i <= n; i++)
    {
        if(a[i].lx > X) continue;
        if(f(A,B,a[i].lx,a[i].ly) * f(A,B,a[i].lx,a[i].ry) <= 0)return 0;
        if(f(A,B,a[i].rx,a[i].ry) * f(A,B,a[i].lx,a[i].ry) <= 0 && a[i].ry > Y)return 0;
        double del = B * B - 4 * A * (-a[i].ly);
        if(del < 0) continue;
        double x1 = (-B + sqrt(del)) / A / 2;
        double x2 = (-B - sqrt(del)) / A / 2;
        if(x1 >= a[i].lx && x1 <= a[i].rx) return 0;
        if(x2 >= a[i].lx && x2 <= a[i].rx) return 0;
      //  printf("%f %f\n", x1, x2);
    }
    for(int i = 1; i <= n; i++) {
        if(a[i].lx <= X && a[i].rx >= X) {
            double yx = A * X * X + B * X;
            if(a[i].ly >= Y && a[i].ly <= yx) return 0;
            if(a[i].ry >= Y && a[i].ry <= yx) return 0;
        }

    }
    if(A * X * X + B * X < Y) return 0;
//    printf("%f\n", x);
//    printf("%f\n", A + B);
//    printf("%f\n", A * 4 + 2 * B);\
//    printf("%f %f %f\n", v, v1, v2);
//    printf("%f\n", xx);
    return 1;
}
int main()
{

    //freopen("in.txt", "r", stdin);
    double x,y;
    while(scanf("%d %lf %lf %lf",&n,&v,&x,&y) != EOF)
    {
        X = x; Y = y;
        for(int i = 1; i <= n; i++)
        {
            scanf("%lf %lf %lf %lf",&a[i].lx,&a[i].ly,&a[i].rx,&a[i].ry);
            if(a[i].lx <= X && a[i].rx >= X) a[i].rx = X;
        }
        if(abs(X) < 1e-8) {
            double h = v * v / G / 2;
            if(h < Y) {
                printf("No\n");
                continue;
            }
            int flag = 1;
            for(int i = 1; i <= n; i++) {
                if(abs(a[i].lx) < 1e-8) {
                    if(a[i].ly <= Y) flag = 0;
                    if(a[i].ry <= Y) flag = 0;
                }
            }
            printf("%s\n", flag ? "Yes" : "No");
            continue;
        }
        double m = PI / 2;
        int flag = 0;
        for(double i = m / 1000000; i < m; i += m / 1000000)
        {
            if(judge(i)){flag = 1; break;}
        }
        if(flag)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

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

using namespace std;
using ll = long long;

long double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n - 1; i++){

        int c; cin >> c; c--;
        a[c]++;
    }
    for(auto i : a)cout << i << endl;
}

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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, a, b;
	cin>>n>>a>>b;
	if(a+b-1>n || (ll)a*b<n){
		cout<<-1<<'\n';
		return 0;
	}
	FOR(i, n-a, n){
		cout<<i+1<<' ';
	}
	int now=0;
	while(now<n-a){
		FORR(i, now, now+b-1){
			if(i>=n-a){
				continue;
			}
			cout<<i+1<<' ';
		}
		now+=b-1;
	}
	return 0;
}


Measured memory_bytes: 2176
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    string S,T;
    cin>>S>>T;

    int c=0;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]) c++;
    }

    cout<<c<<endl;
}


Measured memory_bytes: 3472
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

h = int(input())

count = 0
while h > 1:
    count += 1
    h = h // 2

ans = 1
for i in range(count):
    ans = (ans*2)+1

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N, X;
    cin >> N >> X ;
  	vector<int> a(N);
    int sum = 0;
    
    for(int i = 0; i < N; ++i){
    	cin >> a[i];
        sum += a[i];
        if(sum > X){
          cout<< i+1;
          break;
        }
    }
    if(sum <= X)
      cout << N+1;
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  int i=1;
  int amari;
  string ans="NO";
  vector<int> num(100,0);
  while(1){
    amari = (a*i) % b;
    if(amari == c){
      ans = "YES";
      break;
    }
    else{
      if(num[amari]) break;
      num[amari]++;
    }
    i++;
  }
  cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int i,j,l=0;
	cin>>a;
	for(i=0;i<a.size();i++)
	if(a[i]=='C')
	{
		l++;
		break;
	}
	for(j=i;j<a.size();j++)
	if(a[j]=='F')
	{
		l++;
		break;
	}
	if(l==2)
	cout<<"Yes";
	else
	cout<<"No";
}

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

n = int(input())
spot = [int(x) for x in input().split()]
spot = [0] + spot + [0]
cost = 0
for i in range(len(spot)-1):
    cost += abs(spot[i] - spot[i+1])
change = 0
for k in range(len(spot)-2):
    if (spot[k+1]-spot[k])*(spot[k+2]-spot[k+1]) >= 0:
        change = 0
    else:
        change = 2*min([abs(spot[k+1]-spot[k]),abs(spot[k+2]-spot[k+1])])
    print(cost-change)

Measured memory_bytes: 14172
#include <iostream>
#define MAX 52
#define DIV 1000000007
using namespace std;
char S1[MAX];
char S2[MAX];

int get_type(int i){
  //1 tate 2 yoko
  if(S1[i]==S2[i]){
    return 1;
  }else{
    return 2;
  }
}

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

  for(int i=0;i<N;i++){
    cin>>S1[i];
  }
  for(int i=0;i<N;i++){
    cin>>S2[i];
  }

  long long c = 1;
  int i = 0;
  int before;
  if(get_type(i)==1){
    c = c*3;
    before=1;
  }else{
    c = c*6;
    before=2;
  }
  i = i + get_type(i);

  while(i<N){
    if(get_type(i)==1){
      if(before==1){
      c = c*2;
      }else{
        ;
      }
      before =1;
    }else{
      if(before==1){
      c = c*2;
      }else{
        c = c*3;
      }
      before =2;
    }
    i = i + get_type(i);
  }

  cout<<(c%DIV)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;
vector<ll> w,v;
int n;
vector<vector<ll> > dp;
ll call(int s,int i)
{
    if(s <= 0)
        return 0;
    if(i == n+1)
        return 0;
    if(dp[s][i] != -1)
        return dp[s][i];
    ll ans=0;
    ans = call(s,i+1);
    if(s >= w[i])
    {
        ans = max(ans,call(s-w[i],i+1)+v[i]);
    }
    
    dp[s][i] = ans;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>n>>x;
    w.resize(n,0);
    v.resize(n,0);
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    dp.resize(x+1,vector<ll>(n+1,-1));
    cout<<call(x,0);
    
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a,b,dep,p,q;
int vis[N],path[N];
vector<int>e[N];
int dfs1(int now,int deep)
{
	vis[now]=1;
	if(now==n)
	{
		dep=deep;
		return 1;
	}
	for(int i=0;i<e[now].size();i++)
	{
		if(vis[e[now][i]])
			continue;
		path[deep]=e[now][i];
		if(dfs1(e[now][i],deep+1))
			return 1;
	}
	return 0;
}
int dfs2(int now)
{
	vis[now]=1;
	int sum=1;
	for(int i=0;i<e[now].size();i++)
		if(!vis[e[now][i]])
			sum+=dfs2(e[now][i]);
	return sum;
}
int main()

{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	path[0]=1;
	dfs1(1,1);
	//1:(0)---(dep/2),(dep/2+1)---(dep-1)  2:(0)---(dep/2-1),(dep/2)---(dep-1)
 	memset(vis,0,sizeof(vis));
 	p=dfs2(1);
	if(dep%2)
	{
		memset(vis,0,sizeof(vis));
		for(int i=0;i<=dep/2;i++)
			vis[path[i]]=1;
		q=dfs2(path[dep/2+1]);
		if(p-q>q)
			printf("Fennec\n");
		else
			printf("Snuke\n");
	}
	else
	{
		memset(vis,0,sizeof(vis));
		for(int i=0;i<=dep/2-1;i++)
			vis[path[i]]=1;
		q=dfs2(path[dep/2]);
		if(p-q>q)
			printf("Fennec\n");
		else
			printf("Snuke\n");
	}
	return 0;
}
///

Measured memory_bytes: 11136
# 解説AC
# Tの部分集合をUとすると
# A[i]番目の項目について、
# (1)Tに選ばれない
# (2)Uに選ばれない
# (3)Uに選ばれる
# の3通りの遷移がある
# (1)(2)の場合も含めて数え上げていく（その場合、和は変わらない）

import sys
readline = sys.stdin.readline

N,S = map(int, readline().split())
A = list(map(int,readline().split()))
DIV = 998244353

# dp[i][j] = i番目の数まで見たときにjになっている場合の数
dp = [[0] * (S + 1) for i in range(N + 1)]
dp[0][0] = 1
for i in range(len(A)):
  for j in range(S + 1):
    if dp[i][j] == 0:
      continue
    dp[i + 1][j] += dp[i][j] * 2
    dp[i + 1][j] %= DIV
    if j + A[i] <= S:
      dp[i + 1][j + A[i]] += dp[i][j]
      dp[i + 1][j + A[i]] %= DIV
      
print(dp[-1][-1])


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

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

    for(int i=0; i<4; ++i)
    {
        for(int j=i+1; j<4; ++j)
        {
            if(S[i] == S[j] && j-i==1)
            {
                std::cout << "Bad" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Good" << std::endl;

    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> like(m);
  
  int k = 0;
  int a = 0;
  
  for(int i=1; i<=n; i++){
    cin >> k;
    for(int j=1; j<=k; j++){
      cin >> a;
      like[a-1]++;
      a = 0;
    }
    k = 0;
  }
  
  int count = 0;
  
  for(int i=0; i<m; i++){
    if(like[i] == n) count ++;
  }
    
  cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >>S;
  int K;
  cin >>K;
  vector<string> Z;
  for(int i=0; i<S.size(); i++){
    int a=S.size()-i;
    string b="";
    for(int j=0; j<min(K,a); j++){
      b+=S[i+j];
      Z.push_back(b);
    }
  }
  sort(Z.begin(), Z.end());
  long long c=Z.size()-1;
  auto IT=unique(Z.begin(), Z.end());
  Z.erase(IT, Z.end());
  cout<<Z[K-1]<<endl;
}

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

int main(){

    int N,K;
    cin >> N >> K;
    char S[N];
    for(int i=0;i<N;i++){
        cin >> S[i];
    }

    S[K-1]=tolower(S[K-1]);

    for(int i=0;i<N;i++){
        cout << S[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

class UnionFind {
    public:
    int n;
    vector<int> par, rank, size;  //親, 深さ, その木の要素数

    UnionFind(int n): n(n) {
        for(int i=0;i<n;++i){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
    }

    //根を求める
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int p = find(par[x]);
            size[x] = size[p];
            return par[x] = p;
        }
    }

    //xとyの属する集合の併合
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        
        size[x] += size[y];
        size[y] = size[x];
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //同じ集合に属するか否か
    bool is_same(int x, int y){
        return find(x) == find(y);
    }
};

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

    UnionFind uf = UnionFind(n);
    int com, x, y;
    while(q--) {
        cin >> com >> x >> y;
        if(com == 0) {
            uf.unite(x, y);
        } else {
            cout << uf.is_same(x, y) << endl;
        }
    }
}


Measured memory_bytes: 3280
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[2][100]={100};
    for(int i(0);i<2;i++){
        for(int j(0);j<n;j++){
            cin>>a[i][j];
        }
    }
    int candy[2][100]={0};
    candy[0][0] = a[0][0];
    candy[1][0] = a[0][0] + a[1][0];
    for(int i(1);i<n;i++){
        candy[0][i] = candy[0][i-1] + a[0][i];
    }
    for(int i(1);i<n;i++){
        candy[1][i] = max(candy[0][i],candy[1][i-1]) + a[1][i];
    }
    cout<<candy[1][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n;
  cin>>n;
  vector<ll>c(n,0);
  for(ll i=0;i<n;i++){
    cin>>c[i];
    c[i]--;
  }
  if(n==1){
    ll k=c[0]<1000000?1:0;
    cout<<k<<endl;
    return 0;
  }
  vector<ll>dp(n,0);
  vector<ll>v(n,0);
  vector<ll>vv(n,-1);
  dp[n-1]=1;
  v[c[n-1]]=1;
  vv[c[n-1]]=n-1;
  for(ll i=n-2;i>=0;i--){
    if(v[c[i]]==0||vv[c[i]]-i==1){
      dp[i]=dp[i+1];
      v[c[i]]=dp[i];
    }
    else{
      dp[i]=dp[i+1]+v[c[i]];
      v[c[i]]=dp[i];
    }
    vv[c[i]]=i;
    dp[i]%=MOD;
    v[c[i]]%=MOD;
  }
  cout<<dp[0]<<endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
	int N; SCD(N);
	getchar();
	string A,B,C;
	getline(cin,A);
	getline(cin,B);
	getline(cin,C);

	int ans = 0;
	REP(i,N){
		if ((A[i] == B[i]) and (B[i] == C[i])) continue;
		if ((A[i] == B[i]) or (B[i] == C[i]) or (C[i] == A[i])){
			ans += 1;
			continue;
		}
		ans += 2;
	}

	PRINTD(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** DSL_2 - B : RangeQuery - Range Sum Query **/
const int MAX_N = 1<<17;
class RSQ {
public:
	int n, dat[2*MAX_N-1];
	
	void init(int n_) {
		n=1;
		while (n<n_) n*=2;
		for (int i=0; i<2*n-1; i++) dat[i]=0;
	}
	
	RSQ() {}
	
	void add(int k, int a) {
		k += n-1;
		dat[k] += a;
		while (k>0) {
			k = (k-1)/2;
			dat[k] += a;
		}
	}
	
	int query(int a, int b, int k, int l, int r) {
		if (r<=a || b<=l) return 0;
		
		if (a<=l && r<=b) {
			return dat[k];
		} else {
			int vl = query(a, b, k*2+1, l, (l+r)/2);
			int vr = query(a, b, k*2+2, (l+r)/2, r);
			
			return vl + vr;
		}
	}
};

int main()
{
	int N, Q;
	cin>>N>>Q;
	RSQ ST;
	ST.init(N);
	
	rep(i, Q) {
		int c, x, y;
		cin>>c>>x>>y;
		if (c) {
			cout << ST.query(x-1, y, 0, 0, ST.n) << endl;
		} else {
			ST.add(x-1, y);
		}
	}
}

Measured memory_bytes: 2188
def main():
    X, N = map(int, input().split())
    p = set(map(int, input().split()))
    for diff in range(N+3):
        if X - diff not in p:
            print(X - diff)
            return
        if X + diff not in p:
            print(X+diff)
            return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N=1e5+5;
void fast()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}
int n,m,ans;
vi v[N];
priority_queue<int>q;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
	}
	for(int i=0;i<N;i++)sort(v[i].begin(),v[i].end());
	for(int i=1;i<=m;i++)
	{
		for(int j=0;j<v[i].size();j++)
		{
			q.push(v[i][j]);
		}
		if(!q.empty())ans+=q.top(),q.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int a,b;
    cin >> a >> b;
    if(a <= b*2) {
        cout << 0;
    }else {
        cout << a-b*2;
    }
}



Measured memory_bytes: 256
#!/usr/bin/python
# coding: utf-8

import sys

# q: 4の倍数, a: 奇数1個または偶数任意個
# a q a q a q ... q a
def solve(N, a):
  n4 = len([v for v in a if v % 4 == 0])                # 4の倍数
  n2 = len([v for v in a if v % 4 != 0 and v % 2 == 0]) # 4の倍数でない偶数
  n1 = len([v for v in a if v % 2 != 0])                # 奇数
  na = n4 + 1
  if n2 > 0: na -= 1
  return "Yes" if n1 <= na else "No"

def splitIntoNums(line):
  words = line.strip().split()
  return [int(w) for w in words]

while True:
  l1 = sys.stdin.readline()
  l2 = sys.stdin.readline()
  if not l1: break
  N, = splitIntoNums(l1)
  a  = splitIntoNums(l2)
  if len(a) != N: raise
  print(solve(N, a))


Measured memory_bytes: 12832
//AtCoder 5091
//https://www.luogu.com.cn/problem/AT5091
#include<bits/stdc++.h>
using namespace std;
long long f[4][25000010],v[5],c[5];
long long knapsack(int C){
	memset(f,0,sizeof(f));
	for(int i=1;i<=3;i++){
		for(int j=0;j<=C;j++){
			if(j>=v[i])f[i][j] = max(f[i-1][j],f[i][j-v[i]]+c[i]);
			else f[i][j] = f[i-1][j];
		}
	}
	return f[3][C];
}
int main()
{
	int n;cin>>n;
	int ga,sa,ba,gb,sb,bb;
	cin>>ga>>sa>>ba>>gb>>sb>>bb;
	long long ans = n;
	v[1] = ga;c[1] = gb-ga;
	v[2] = sa;c[2] = sb-sa;
	v[3] = ba;c[3] = bb-ba;
	ans += knapsack(ans);
	
	v[1] = gb;c[1] = -c[1];
	v[2] = sb;c[2] = -c[2];
	v[3] = bb;c[3] = -c[3];
	ans += knapsack(ans);
	cout << ans << endl;
}

Measured memory_bytes: 781568
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll A, B; cin >> A >> B;
	string s; cin >> s;

	if (s[A] == '-') {
		rep(i, 0, A) {
			if (s[i] >= '0' && s[i] <= '9') {
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
		rep(i, A + 1, A + B + 1) {
			if (s[i] >= '0' && s[i] <= '9') {
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	else {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    const ll m=(ll)1e9+7;
    ll h,w,n;cin>>h>>w>>n;
    
    map<ll,ll> mp;
    rep(i,n){
        ll a,b;cin>>a>>b;
        repe(j,-1,1)repe(k,-1,1){
            ll ta=a+j,tb=b+k;
            if(ta<=1||ta>=h||tb<=1||tb>=w)continue;
            ++mp[ta*m+tb];
        }
    }

    vl ans(10);
    ans[0]=(h-2)*(w-2);
    for(auto &p:mp){
        --ans[0];
        ++ans[p.second];
    }
    rep(i,10)cout<<ans[i]<<endl;
}

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

using namespace std;

int main(void)
{
  int n,k; cin>>n>>k;
  vector<int> l(n);
  for(int i=0;i<n;i++){ cin>>l[i]; }
  
  sort(l.begin(),l.end(),greater<int>());
  
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=l[i];
  }
  
  cout<<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
Ac = Counter(A)
setA = list(set(A))
r = 0
for i in range(len(setA)):
    r = max(r, Ac[setA[i]-1]+Ac[setA[i]]+Ac[setA[i]+1])
print(r)

Measured memory_bytes: 15072
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int N, W;
  cin >> N >> W;
  vll v(N), w(N);
  for(int i = 0; i < N; i++){
    cin >> v.at(i) >> w.at(i);
  }
  vvll dp(110, vll(11000, 0));
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= W; j++){
      chmax(dp.at(i+1).at(j), dp.at(i).at(j));
      if(j >= w.at(i)) chmax(dp.at(i+1).at(j), dp.at(i+1).at(j-w.at(i)) + v.at(i));
    }
  }

  cout << dp.at(N).at(W) << endl; 
}


Measured memory_bytes: 12372
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
void reverse(string& str) 
{ 
    int n = str.length(); 
  
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
} 
int fun(string s,char c)
{
    int n=s.length();
    if(n==1)
    {
        if(s[0]!=c)
        {
         return 1;
        }
        else {
        return 0;
        }
    }
    else {
    int l=0,k=0;
   int r=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=c)
        {
           l++;
        }
    }
    for(int i=n/2;i<n;i++)
    {
        if(s[i]!=c)
        {
            k++;
        }
    }
   // cout<<l<<" "<<k<<endl;
   string p=s.substr(0,n/2);
        string o=s.substr(n/2,n/2);
        r+=min(k+fun(p,char(c+1)),l+fun(o,char(c+1)));
        return r;
    }
}



  
int main() {
       ll int n;
       cin>>n;
       ll int d;
       cin>>d;
       d*=2;
       d++;
       int l=n/d;
       if(n%d!=0)
       l++;
       cout<<l<<endl;
}


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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    string s;
    cin>>s;
    int ans = 0;
    int p = 0;
    REP(i,s.size()) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            p++;
        }
        else {
            ans = max(ans,p);
            p = 0;
        }
    }
    ans  = max(ans,p);
    cout<<ans<<endl;
    return 0;
}

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


using namespace std;
using ll = long long;
using pq = priority_queue<int, vector<int>, greater<int>>;

vector<pq> groups;

struct UnionFind{
    vector<int> par;
    vector<int> rank;

    void init(int n) {
        par = vector<int>(n);
        rank = vector<int>(n);

        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            par[y] = x;
        } else {
            par[x] = y;
            if (rank[x] == rank[y]) ++rank[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int N, M;
int a[100000];

int main() {
    cin >> N >> M;

    UnionFind uf;
    uf.init(N);

    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    map<int, int> groupidmap;

    int n_groups = 0;

    for (int i = 0; i < N; ++i) {
        int root = uf.find(i);
        if (groupidmap.find(root) == groupidmap.end()) {
            groupidmap[root] = n_groups;
            n_groups++;
            groups.push_back(pq());
        }
        int groupid = groupidmap[root];
        groups[groupid].push(a[i]);
    }

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

    ll ans = 0;
    for (pq& group : groups) {
        ans += group.top();
        group.pop();
    }

    pq all;

    for (pq& group : groups) {
        while (!group.empty()) {
            //cout << group.top() << endl;
            all.push(group.top());
            group.pop();
        }
    }
    // 2 2
    // 3 4
    // 4 6
    // n (n - 1) * 2

    for (int i = 0; i < (n_groups - 1) * 2 - n_groups; ++i) {
        if (all.empty()) {
            cout << "Impossible" << endl;
            return 0;
        }
        ans += all.top();
        all.pop();
    }

    cout << ans << endl;

    
}

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

int n, m, s, z1, z2;
int main()
{
	int i;
	cin >> n >> m;
	for (i = 22; i <= m; i++) {
		z1 = i / 10;
		z2 = i % 10;
		if (z1 >= 2 && z2 >= 2 && z1 * z2 <= n) s++;
	}
	cout << s;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(n)]
l = [0] * m

for i in range(n):
    for j in range(k[i][0]):
        l[k[i][j + 1] - 1] += 1

print(l.count(n))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;
}


Measured memory_bytes: 3652
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
li = sorted([list(map(int, input().split())) for i in range(N)])
total = 0

for i in range(N):
    total += li[i][1]
    if total >= K:
        print(li[i][0])
        exit()

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

#define ll long long int
#define ri register int

using namespace std;

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

	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(abs(h[i] - h[i - 2]) + dp[i - 2], abs(h[i] - h[i - 1]) + dp[i - 1]);
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
n=input()
ans=0
nl=len(n)
if nl==1:
    print(n)
    exit()
if nl>1:
    ans+=9
if nl==3:
    ans+=int(n)-99
    print(ans)
    exit()
if nl>3:
    ans+=900
if nl==5:
    ans+=int(n)-9999
if nl==6:
    ans+=90000
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  string a;
  cin >> a;
  long long ans = 0, c = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == 'W') {
      ans += c;
    } else c++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  int x3, y3, x4, y4;
  x3 = x2-y2+y1;
  y3 = y2+x2-x1;
  x4 = x1-y2+y1;
  y4 = y1+x2-x1;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int n;cin>>n;
    vector<ll> a(n),v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        v.push_back(a[i]-(i+1));
    }
    sort(all(v));
    ll m=n/2;
    ll b=v[m];
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-(b+i+1));
    }
    cout<<ans<<endl;
}   


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int q;
string s,head,tail;
bool r;

signed main() {
    cin >> s >> q;
    rep(i,q) {
        int t;
        cin >> t;
        if (t == 1) r = !r;
        else {
            int f;
            char c;
            cin >> f >> c;
            if (r) {
                if (f == 1) tail.pb(c);
                else head.pb(c);
            } else {
                if (f == 1) head.pb(c);
                else tail.pb(c);
            }
        }
    }
    reverse(all(head));
    string ans = head + s + tail;
    if (r) {
        reverse(all(ans));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1348
n=int(input())
xy=[list(map(int, input().split())) for _ in range(n)]

ans=0
for x1, y1 in xy:
	for x2, y2 in xy:
		ans+=((x1-x2)**2+(y1-y2)**2)**0.5
print(ans/n)

'''
文字式にする、町の数をｎとするとき。

１経路に道 ( n-1 )　×　経路の数 n!　÷　道の種類 nC２　÷　経路の数 n!

= ( n-1 )　×　 n!　÷　 nC２　÷　n!
= ( n-1 )　÷　 nC２　　　　　　　　　
= ( n-1 )　÷　 ( n( n-1 ) ÷ 2・1 )
= 2 　÷　 n　　　　　　
'''

Measured memory_bytes: 3060
k = gets.to_i
a = 1
b = 1
c = 1
ans = 0
while a <= k
  while b <= k
    while c <= k
      ans += a.gcd(b.gcd(c))
      c += 1
    end
    c = 1
    b += 1
  end
  b = 1
  a += 1
end
puts ans

Measured memory_bytes: 14308