akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll n;
  cin >> n;
  vector<int> w(3,0);
  vector<int> v(3,0);
  vector<int> a(3,0);
  vector<int> b(3,0);
  rep(i,3) cin >> a[i];
  rep(i,3) cin >> b[i];
  w = a;
  rep(i,3){
    v[i] = b[i]-a[i];
  }

  vector<ll> dp(n+1,0);
  dp[0]=0;
  rep(i,3)rep(j,n+1){
    dp[j] = max(dp[j], dp[j]);
    if(j+w[i]<=n) dp[j+w[i]] = max(dp[j+w[i]], dp[j]+v[i]);
  }

  n += dp[n];
  w = b;
  rep(i,3){
    v[i] = a[i]-b[i];
  }

  vector<ll> dp2(n+1,0);
  dp2[0]=0;
  rep(i,3)rep(j,n+1){
    dp2[j] = max(dp2[j], dp2[j]);
    if(j+w[i]<=n) dp2[j+w[i]] = max(dp2[j+w[i]], dp2[j]+v[i]);
  }

  ll ans = n + dp2[n];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 195584
#include<iostream>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  for(;cin>>n,n;)
    {
      // cerr<<(1<<(n+1))-1<<endl;
      int t[n][n+1];
      for(int i=0;i<n;i++)
	for(int j=0;j<n+1;j++)
	  cin>>t[i][j];
      int ans=100000*n;
      queue<int> qu;
      map<int,int> hash;
      qu.push(0);
      hash[0]=0;
      while(!qu.empty())
	{
	  auto bit = qu.front();
	  ///  cerr<<bit<<endl;
	  auto time = hash[bit];
	  //	  auto time = qu.front().second;
	  qu.pop();
	  if(bit==(1<<n)-1)
	    {
	      ans=min(ans,time);
	      continue;
	    }
	  for(int next=0;next<n;next++)
	    {
	      // cerr<<"next: "<<next<<" "<<(bit&(1<<next))<<endl;
	      if((bit&(1<<next))==0)
		{
		  //  cerr<<"next: "<<next<<endl;
		  int add=t[next][0];
		  for(int move=1;move<=n;move++)
		    {
		      if((bit&(1<<(move-1)))!=0)
			{
			  add=min(add,t[next][move]);
			}
		    }

		  if(hash.find(bit|(1<<next))==hash.end() ||
		     hash[bit|(1<<next)]>time+add)
		    {
		      hash[bit|(1<<next)]=time+add;
		      qu.push(bit|(1<<next));
		    }
		}
	    }
	}
      cout<<ans<<endl;

    }

}

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

int main(){
    int all, s1, s2, s3;
    cin >> all;
    s1 = all / 100;
    s2 = (all - s1 * 100) / 10;
    s3 = (all - s1 * 100 - s2 * 10) / 1;
    cout << s1 + s2 + s3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 200005;

int n, k;
int a[N], b[N];

int main () {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j <= n; j++) b[j] = 0;
		for (int j = 1; j <= n; j++) {
			int l = max(1, j - a[j]), r = min(n + 1, j + a[j] + 1);
			b[l]++, b[r]--;
		}
		for (int j = 1; j <= n; j++) b[j] += b[j - 1];
		bool flag = true;
		for (int j = 1; j <= n; j++) {
			if (a[j] != b[j]) flag = false;
		}
		if (flag) break;
		for (int j = 1; j <= n; j++) a[j] = b[j];
	}
	for (int i = 1; i <= n; i++) printf("%d ", a[i]);
	printf("\n");
	return 0;
}

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

using namespace std;

long long int  num,w;
int wat[100000+5];
int val[100000+5];
long long  dp[100010][101];

long long knapsack(long long  wt,long long  n)
{
    long long  &ret = dp[wt][n];
    if(wt ==0 || n==0)
        return 0;

    if(ret!=-1)
        return ret;
    ret = 0;

    if(wat[n-1]>wt)
         ret = knapsack(wt,n-1);

    else
    {
         ret = max(ret,max((val[n-1] + knapsack(wt - wat[n-1],n-1)),knapsack(wt,n-1)));
    }
    return ret;
}

int main()
{
    cin>>num>>w;
    for(int i=0;i<num;i++)
    {
        scanf("%lld %lld",&wat[i],&val[i]);
    }
    memset(dp,-1,sizeof dp);
    long long  ans = knapsack(w,num);
    cout<<ans<<endl;
}

Measured memory_bytes: 79232
def main():
    N = int(input())
    A = list(map(int, input().split()))
    total = sum(A)
    ans = float("inf")
    x = 0
    for i in range(N-1):
        x += A[i]
        ans = min(ans, abs(total - 2*x))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 76752
#include <stdio.h>

int main(void) {
	char s[3];
	int i;
	int a,b,c;
	scanf("%s", s);
	
	a = b = c = 0;
	for (i=0; i<3; i++){
		if(s[i]=='a'){a=1;}
		else if(s[i]=='b'){b=1;}
		else if(s[i]=='c'){c=1;}
	}
	
	if(a==1 && b==1 && c==1)printf("Yes");
	else printf("No");
	
	
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> s(n),t(n),u(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    int b=0;
    for(int i=0;i<n;i++){
        if(s[i]>b){
            if(t[i]<s[i]){cout<<0<<endl;return 0;}
            else{b=s[i];u[i]=1;}
        }
        else u[i]=b;
    }
    b=0;
    for(int i=n-1;i>=0;i--){
        if(b<t[i]){
            if(s[i]<t[i]){cout<<0<<endl;return 0;}
            else{b=t[i];u[i]=1;}
        }
        else u[i]=min(u[i],b);
    }
    ll ans=1;
    ll mod=1000000007;
    for(int i=0;i<n;i++){ans=ans*u[i]%mod;}
    cout<<ans<<endl;
}


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

#define int long long
#define PII pair < int , int >
const int seed = 233 , MOD = 20190816170251;
int N; char str[43];
map < PII , int > cnt;

signed main(){
	scanf("%d %s" , &N , str + 1);
	for(int i = 0 ; i < 1 << N ; ++i){
		int p = 0 , q = 0;
		for(int j = 1 ; j <= N ; ++j)
			if(i >> (j - 1) & 1) p = (p * seed + str[j]) % MOD;
			else q = (q * seed + str[j]) % MOD;
		++cnt[PII(p , q)];
	}
	reverse(str + 1 , str + 2 * N + 1); int ans = 0;
	for(int i = 0 ; i < 1 << N ; ++i){
		int p = 0 , q = 0;
		for(int j = 1 ; j <= N ; ++j)
			if(i >> (j - 1) & 1) p = (p * seed + str[j]) % MOD;
			else q = (q * seed + str[j]) % MOD;
		ans += cnt[PII(p , q)];
	}
	cout << ans; return 0;
}

Measured memory_bytes: 33024
input()
a = list(map(int, input().split()))
counter = [False] * 8
colorfulcounter = 0

for i in a:
    if 1 <= i <= 399:
        counter[0] = True
    elif 400 <= i <= 799:
        counter[1] = True
    elif 800 <= i <= 1199:
        counter[2] = True
    elif 1200 <= i <= 1599:
        counter[3] = True
    elif 1600 <= i <= 1999:
        counter[4] = True
    elif 2000 <= i <= 2399:
        counter[5] = True
    elif 2400 <= i <= 2799:
        counter[6] = True
    elif 2800 <= i <= 3199:
        counter[7] = True
    elif 3200 <= i:
        colorfulcounter += 1

print(max(sum(counter), 1), end = " ")
print(sum(counter) + colorfulcounter)

Measured memory_bytes: 38256
#---------------for input--------------------
numberN=int(input())
arrayS=list(map(int,input().split()))

numberQ=int(input())
arrayT=list(map(int,input().split()))
#---------------for input----------------------

def linearSearch(arrayS,arrayT,numberQ):
    machedNumber=0
    index=0
    while index<numberQ:
        if arrayT[index] in arrayS:
            machedNumber+=1
        index+=1
    print(machedNumber) 

#----------------for main------------------------
linearSearch(arrayS,arrayT,numberQ)
#----------------for main------------------------


Measured memory_bytes: 6556
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    map<string, int> s, t;
    set<string> c;
    for (auto i = 0; i < n; i++) {
        string tmp; cin >> tmp; s[tmp]++;
        c.insert(tmp);
    }
    cin >> m;
    for (auto i = 0; i < m; i++) {
        string tmp; cin >> tmp; t[tmp]++;
        c.insert(tmp);
    }

    int ans = 0;
    for (auto & elm : c) ans = max(ans, s[elm] - t[elm]);

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, l;
  cin >> n >> l;
  i64 ans = 0, eat = 1e9;
  for (i64 i = 0; i < n; i++)
  {
    ans += l + i;
    if (abs(l + i) < abs(eat))
      eat = l + i;
  }
  cout << ans - eat << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,res=1;

  scanf("%d%d",&x,&y);
  
  if(y<x){
      res=y;
      y=x;
      x=res;
  }

  while(res!=0){
      res=y%x;
      y=x;
      x=res;
  }

  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
//Chandigarh University
//author:- shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
#define lli long long int
#define endl "\n"
// #define loop(i,n) for(long long int (a)=i, (a)<n, (a)++)
#define mod 1000000007
using namespace std;
int main()
{
	lli n,k;
	cin>>n>>k;
	lli ar[n];
	for(lli i=0;i<n;i++)
	{
		cin>>ar[i];
	}
	if(k>=n)
	{
		cout<<0;
	}
	else
	{
		sort(ar,ar+n);
		lli sum=0;
		for(lli i=0;i<n-k;i++)
		{
			sum+=ar[i];
		}
		cout<<sum;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<long long> a(n),b(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a.at(i) >> b.at(i);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  long long min,max;
  min=a.at((n-1)/2)+a.at(n/2);
  max=b.at((n-1)/2)+b.at(n/2);
  
  cout << (max-min)/(n%2+1)+1 << endl;
}

Measured memory_bytes: 6428
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;


int a[15][15];
double dis[225];
int N ,D;
int main()
{
	scanf("%d%d",&N,&D);
	for(int i = 0 ; i < N ;i++)
	{
		for(int j = 0 ; j < D; j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int tmp = 0;
	int count1 = 0 ;
	for(int i = 0 ; i < N; i++)
	{
		for(int k = i+1 ;k < N ;k++)
		{
			
				tmp = 0;
				for(int j = 0 ; j < D ;j++)
				{
					tmp += (a[i][j]-a[k][j])*(a[i][j]-a[k][j]);
				}
				dis[count1++] = sqrt(tmp);
			
		
		}
		
	}
	int ans = 0;
	for(int i = 0 ; i < count1 ;i++)
	{
//		cout<<dis[i]<<"$";
		tmp = dis[i]/1;
		if(tmp==dis[i])
		{
			ans++;
		}
		
	}
	printf("%d",ans);
	
	
	return 0;
}

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

int main(){
  int N,A[202],cnt = 0;
  bool pin = "true";
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> A[i];
  }
  for(int i =0; i < N; i++){
    if(A[i] % 2 == 0){
   	  A[i] = A[i] / 2;
    }else break;
    if(i == (N - 1)){
      cnt += 1;
      i = 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine().Replace("/", ""));
        if (n <= 20190430)
        {
            Console.WriteLine("Heisei");
        }
        else
        {
            Console.WriteLine("TBD");
        }
    }
}


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

int main() {

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

    if (n == 0) break;
    
    int s[n];
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    
    double m = 0, total = 0;
    for (int i = 0; i < n; i++) {
      total += s[i];
    }
    m = total / (double)n;
    
    double a2 = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      sum += pow(s[i]-m,2);
    }
    a2 = sum / (double)n;
    
    printf("%.5f\n",sqrt(a2));
    
  }
  
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> clist(26, 99);
    for (int i = 0; i < n; i++){
        vector<int> t(26, 0);
        string s;
        cin >> s;
        for (int j = 0; j < (int)s.size(); j++){
            t[s[j] - 'a']++;
        }
        for (int j = 0; j < 26; j++){
            clist[j] = min(clist[j], t[j]);
        }
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < clist[i]; j++) cout << (char)('a'+i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  string s;
  cin >> s;
  ll b = 0;
  ll result = 0;
  for (char x : s) {
    if (x == 'B') {
      b++;
    }
    else {
      result += b;
    }
  }
  cout << result << endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    int a, w, t, r;
    a = w = t = r = 0;
    for(int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        if(s == "AC") ++a;
        if(s == "WA") ++w;
        if(s == "RE") ++r;
        if(s == "TLE") ++t;

    }

    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
    return 0;
}



Measured memory_bytes: 3644
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 5e5 + 5;

int main()
{
	//freopen("in.txt", "r", stdin);
	int a, b, c, k;
	while (cin >> a >> b >> c >> k)
	{
		int cot = 0;
		while (a>= b)
		{
			b *= 2;
			cot++;
		}
		while (b >= c)
		{
			c *= 2;
			cot++;
		}
		if (cot <= k)puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int trips(int n)
{
    int m,i,j,k,sum,ans=0;
    m = sqrt(n-5)+1;
    for(i=1;i<m;i++)
    {
        for(j=i;j<m;j++)
        {
            for(k=j;k<m;k++)
            {
                sum = pow(i,2) + pow(j,2) + pow(k,2) + i*j + j*k + i*k;
                if(sum==n)
                {
                    if(i!=j && j!=k)
                        ans += 6;
                    else if((i==j && j!=k) || (k==j && j!=i) || (i==k && j!=k))
                        ans += 3;
                    else if(i==j && j==k)
                        ans++;
                }
            }
        }
    }
    return ans;
}
int main()
{
    int n,i;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cout << trips(i) << endl;
    }
}


Measured memory_bytes: 3592
#include <stdio.h>
char main(){
  int a,b,k,i;
  scanf("%d\n",&k);
  scanf("%d %d",&a,&b);
  for(i=a/k;i<=b/k;i++){
    if(i*k>=a && i*k<=b){
      printf("OK");
      return 0;
    }
  }
  printf("NG");
  return 0;
}

Measured memory_bytes: 1712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AFiveAntennas {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;

            for (int i = 0; i < 5; i++) {
                int x = in.nextInt();

                min = Math.min(min, x);
                max = Math.max(max, x);
            }

            int k = in.nextInt();

            String answer = (max - min) > k ? ":(" : "Yay!";

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import java.util.*;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[] = new int[n];

		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}

		ArrayList<Integer> d = new ArrayList<>();
		d.add(a[0]);

		for(int i=1; i<n; i++) {
			if(d.get(d.size()-1)>=a[i]){
				d.add(a[i]);
			}else {
				int l=-1;
				int r=d.size();
				while(l+1<r) {
					int mid = (l+r)/2;
					if(d.get(mid)<a[i]) {
						r=mid;
					}else {
						l=mid;
					}
				}
				d.set(l+1, a[i]);
			}
		}
		System.out.println(d.size());
		sc.close();
	}
}


Measured memory_bytes: 59412
h,w=map(int,input().split())
a=[s for s in [input() for i in range(h)] if "#" in s]
l=[]
for i in range(w):
    if all([a[k][i]=="." for k in range(len(a))]):
        l.append(i)
for i in l[::-1]:
    for j in range(len(a)):
       a[j]=a[j][:i]+a[j][i+1:]
for i in range(len(a)):
    print(a[i])




Measured memory_bytes: 3064
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s;cin>>s;
  int w;cin>>w;
  for(int i = 0; s.size() > i; i++){
    if(i%w == 0)cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define PB emplace_back
using namespace std;
typedef long long ll;
template<typename T>
inline T read(T&x){
	x=0;int f=0;char ch=getchar();
	while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x=f?-x:x;
}
int n,k;
ll res=0;
int main(){
	read(n),read(k);
	if (k%2==0){
		int num=n/k;
		if (n%k>=k/2) num++;
		int num2=n/k;
		res=1LL*num*num*num+1LL*num2*num2*num2;
	}
	else{
		int num=n/k;
		res=1LL*num*num*num;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
//14:07:00 

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
#define INF (ll)(1e18)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

struct town
{
	int id;
	int x,y;
};
inline int d(town a,town b){return min(abs(a.x-b.x),abs(a.y-b.y));}

struct Edge
{
	int v1,v2;
	int wei;
	Edge(town a,town b)
	{
		v1=a.id;
		v2=b.id;
		wei=d(a,b);
	}
};


bool sortX (town a,town b){return a.x  <b.x  ;}
bool sortY (town a,town b){return a.y  <b.y  ;}
bool sortID(town a,town b){return a.id <b.id ;}
bool sortE (Edge a,Edge b){return a.wei<b.wei;}

struct disjoint
{
	vector<int> node;
	disjoint(int n)
	{
		node.resize(n);
		For(i,0,n-1) node[i]=i;
	}
	int find(int n)
	{
		if(node[n]==n) return n;
		return node[n]=find(node[n]);
	}
	bool add(int a,int b)
	{
		a=find(a); b=find(b);
		if(a==b) return false;
		node[a]=b;
		return true;
	}
	bool ask(int a,int b)
	{
		return find(a)==find(b);
	}
};

int span(int n,vector<Edge> &edge)
{
	disjoint dis(n);
	
	int ecnt=0;
	int ans=0;
	for(int i=0;ecnt<n-1;i++)
	{
		Edge &e=edge[i];
		//cout<<i<<"\n";
		if(dis.ask(e.v1,e.v2)) continue;
		else
		{
			dis.add(e.v1,e.v2);
			ans+=e.wei;
			ecnt++;
		}
	}
	return ans;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<town> to(n);
	vector<Edge> edge;
	For(i,0,n-1)
	{
		to[i].id=i;
		cin>>to[i].x>>to[i].y;
	}
	
	sort(all(to),sortX);
	For(i,0,n-2) edge.emplace_back(to[i],to[i+1]);
	sort(all(to),sortY);
	For(i,0,n-2) edge.emplace_back(to[i],to[i+1]);
	sort(all(edge),sortE);
	cout<<span(n,edge)<<"\n";
	return 0;
}











Measured memory_bytes: 10608
n = int(input())
sumn = 0
data = 10
check = False
for i in range(1,6):
	if(10**i==n):
		check = True

if(check):
	print(10)
else:
	while n>=10:
		sumn += n%10
		n //= 10
	sumn += n
	print(sumn)

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

using namespace std;

int n, cnt, lo, hi, mi, ta, tb;
vector< int > v[100005];
multiset< int > mm;
multiset< int >::iterator it;

int dfs(int a, int b) {
	multiset< int > re = multiset< int >();
	for (int i = 0; i < v[a].size(); i++)
		if (v[a][i] != b) {
			int tt = dfs(v[a][i], a);
			if (tt == -1 || tt + 1 > mi) {
				re.clear();
				return -1;
			}
			re.insert(tt + 1);
		}
	int ret = 0;
	//printf("%d:", a); for (it = re.begin(); it != re.end(); it++) printf(" %d", *it); printf("\n");
	mm = re;
	while (!re.empty()) {
		it = re.end();
		it--;
		ta = *it;
		re.erase(it);
		it = re.upper_bound(mi - ta);
		if (it == re.begin()) {
			if (ret == 0)
				ret = ta;
			else {
				if (b != 0 && mm.size() % 2 == 0) {
					re = mm;
					it = re.end();
					it--;
					re.erase(it);
					ret = 0;
					while (!re.empty()) {
						it = re.end();
						it--;
						ta = *it;
						re.erase(it);
						it = re.upper_bound(mi - ta);
						if (it == re.begin()) {
							if (ret == 0)
								ret = ta;
							else {
								re.clear();
								return -1;
							}
						} else {
							it--;
							re.erase(it);
						}
					}
					//printf("ret %d\n", ret);
					return ret;
				}
				re.clear();
				return -1;
			}
		} else {
			it--;
			re.erase(it);
		}
	}
	//printf("re %d\n", ret);
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &ta, &tb);
		v[ta].push_back(tb);
		v[tb].push_back(ta);
	}
	for (int i = 1; i <= n; i++)
		cnt += v[i].size() % 2;
	lo = 1, hi = n + 1;
	while (lo < hi) {
		mi = (lo + hi) / 2;
		//printf("mi %d\n", mi);
		if (dfs(1, 0) != -1)
			hi = mi;
		else
			lo = mi + 1;
	}
	printf("%d %d\n", cnt / 2, lo);
	return 0;
}

Measured memory_bytes: 17528
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

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

int main() {
    char x, y;  cin >> x >> y;
    if (x > y)  cout << '>' << endl;
    else if (x < y)  cout << '<' << endl;
    else  cout << '=' << endl;
}

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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>

void print(T x)
{
	std::cout << x << '\n';
}


int main() {
	int N,M,X,Y;
	cin >> N>>M>>X>>Y;
	vector<int>x, y;
	int xx, yy;
	x.pb(X);
	y.pb(Y);
	rep(i, N) {
		cin >> xx;
		x.pb(xx);
	}
	rep(i, M) {
		cin >> yy;
		y.pb(yy);
	}
	std::vector<int>::iterator maxi = std::max_element(x.begin(), x.end());
	std::vector<int>::iterator mini = std::min_element(y.begin(), y.end());
	size_t minIndex = std::distance(y.begin(), mini);
	size_t maxIndex = std::distance(x.begin(), maxi);
	//printf("%d\n",x[maxIndex]);
	//printf("%d\n", y[minIndex]);
	if (x[maxIndex] < y[minIndex])print("No War");
	else print("War");
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>

using namespace std;

enum status_t {
  WHITE,
  GRAY,
  BLACK,
};

#define GRAPH_SIZE 101

static uint32_t graph[GRAPH_SIZE][GRAPH_SIZE];
static status_t state[GRAPH_SIZE];
static uint32_t shortest_path[GRAPH_SIZE];

size_t minimum_spanning_tree(size_t num)
{
  size_t minimum_cost = 0;

  for (uint32_t i = 0; i < num; i++) {
    shortest_path[i] = UINT32_MAX;
    state[i] = WHITE;
  }

  shortest_path[0] = 0;
  state[0] = GRAY;

  while (true) {
    uint32_t minimum = UINT32_MAX;
    uint32_t to = 0;
    for (uint32_t j = 0; j < num; j++) {
      if ((shortest_path[j] < minimum) && state[j] != BLACK) {
        minimum = shortest_path[j];
        to = j;
      }
    }

    if (minimum == UINT32_MAX) break;

    state[to] = BLACK;
    minimum_cost += minimum;

    for (uint32_t j = 0; j < num; j++) {
      if ((graph[to][j] != UINT32_MAX) && (state[j] != BLACK)) {
        state[j] = GRAY;
        shortest_path[j] = min(shortest_path[j], graph[to][j]);
      }
    }
  }

  return minimum_cost;
}

#include <iostream>

int32_t main()
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 0; i < num; i++) {
    for (uint32_t j = 0; j < num; j++) {
      int32_t val;
      cin >> val;
      if (val == -1) {
        graph[i][j] = UINT32_MAX;
      } else {
        graph[i][j] = val;
      }
    }
  }

  cout << minimum_spanning_tree(num) << endl;

  return 0;
}

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

bitset<100055> chk;

int A[105];

int N, K;

int main() {
	cin >> N >> K;
	for(int i = 0; i < N; i++) cin >> A[i];

	for(int i = 1; i <= K; i++) {
		for(int j = 0; j < N; j++) {
			if(i < A[j]) break;
			if(!chk[i-A[j]]) {
				chk[i] = true;
				break;
			}
		}
	}

	puts(chk[K] ? "First" : "Second");
	return 0;
}

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

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if (A + B < 2 * C)
        cout << A * X + B * Y << endl;
    else
    {
        int num = min(X, Y);
        int ans1 = 2 * num * C + A * (X - num) + B * (Y - num);
        num = max(X, Y);
        int ans2 = 2 * num * C;

        cout << min(ans1, ans2) << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int x,a,b,c,ac=0,tot=0;
int main(){
	while(cin>>a>>b>>c){
		if(a==0){break;}
	for(int i=0;i<a;i++){
	cin>>x;tot+=x;
	if(i+1==b){
	ac+=x;}}
	if(ac==0){
		cout<<0<<endl;}else{
		cout<<tot*(100-c)/ac<<endl;}
	ac=0;x=0;tot=0;}

    return 0;}


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

int main(){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll lcm = d / __gcd(c, d) *c;
    ll temp_b = b/c + b/d - b/lcm;
    ll temp_a = (a-1)/c + (a-1)/d - (a-1)/lcm;
    cout << b-a+1 - (temp_b - temp_a) <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
int a[102],s1[102]={0},s2[102]={0};
int main()
{
   int a,b;
   scanf("%d%d",&a,&b);
   printf("%d\n",(a*3+b)/2);
}



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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll sumofketa(ll a,ll b){
    string s=to_string(a),t=to_string(b);
    return max(s.size(),t.size());
}

int main(void)
{
    ll n; cin>>n;
    ll ans=INF;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i!=0) continue;
        ans=min(ans,sumofketa(i,n/i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL pw[44], Ans, x;
LL work(LL x, LL p){
	int ans = 0;
	for(int i = p; ~i; i--){
		ans += x / pw[i];
		x %= pw[i];
	}
	return ans;
}
int main(){
	pw[0] = 1;
	for(int i = 1; i <= 35; i++)
		pw[i] = pw[i - 1] * 3;
	scanf("%lld", &x);
	x--; Ans++;
	for(int i = 1; i <= 35; i++){
		if(x >= pw[i] * 2){
			x -= pw[i] * 2;
			Ans += 2;
		}
		else if(x >= pw[i]){
			x -= pw[i];
			Ans++;
			Ans += work(x, i - 1);
			break;
		}
		else{
			Ans += work(x, i - 1);
			break;
		}
		//printf("%d  %lld  %lld  %lld\n", i, pw[i], x, Ans);
	}
	printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
int a, b;
cin >> a >> b;
if(a % 3 == 0){
  cout << "Possible";
}
  else if(b % 3 == 0){
  cout << "Possible";
}
else if((a + b) % 3 == 0){
  cout << "Possible";
}
else{
  cout << "Impossible";
}
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int x, a, b;
	cin >> x >> a >> b;
	a = abs(x - a); b = abs(x - b);
	if (a < b)print("A"); else print("B");





	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long a[100001],b[100001];
int main()
{
	long long n,k=0;
	cin>>n;
	for(int i=0;i<=n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=n-1;i>=0;i--)
	{
		k+=min(b[i],a[i+1]);
		b[i]-=min(b[i],a[i+1]);
		if(b[i]>0) 
		{
			long long s=min(b[i],a[i]);
			k+=s;
			b[i]-=s;
			a[i]-=s; 
		}
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    string hitachi = "";

    for (int i = 1; i <= 5; i++)
    {
        hitachi += "hi";
        if(hitachi == s)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int f[10000001];

signed main()
{
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++)
		for(int j=1;i*j<=n;j++)
			++f[i*j];
	
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=i*f[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 81716
n = int(input())
ans = [0] * (n+1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            a = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if a <= n:
                ans[a] += 1
for x in ans[1:]:
    print(x)

Measured memory_bytes: 69532
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, res, min, max;
std::vector<LL>A;

int main()
{
	in >> N;
	A.resize(N);
	rep(i, N) { in >> A[i]; }

	if (A[N - 1] != 2)
	{
		out << -1 << std::endl;
		return 0;
	}
	res = 2;
	for (int i = N - 1; i >= 0; --i)
	{
		if (A[i] >= res) res = A[i];
		else res = (res / A[i] + (res%A[i] == 0 ? 0 : 1))*A[i];
	}
	rep(i, N) res = res / A[i] * A[i];
	if (res != 2)
	{
		out << -1 << std::endl;
		return 0;
	}
	min = 2;
	for (int i = N - 1; i >= 0; --i)
	{
		if (A[i] >= min) min = A[i];
		else min = (min / A[i] + (min%A[i] == 0 ? 0 : 1))*A[i];
	}
	max = 2;
	for (int i = N - 1; i >= 0; --i)
	{
		if (A[i] < max) max = max / A[i] * A[i];
		max += A[i] - 1;
	}

	out << min << " " << max << std::endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  ll ans = 1;
  rep(i, n){
    ans *= (i+1);
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
   int n,count=1,count2=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
      cin>>a[i];
   for(int i=0;i<n;i++)
   {
      if(a[i]==count)
         count++;
      else
         count2++;
   }
   if(count2==n)
      cout<<-1;
   else 
      cout<<count2<<endl;

   return 0;
} //end main

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
    int ans = INF;
    rep(i, s.length()-2) {
        string si = s.substr(i, 3);
        ans = min(ans, abs(753 - stoi(si)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,m;
    scanf("%d %d",&A,&B);
    if (A>=1 && A<=9 && B>=1 && B<=9) {
        m=A*B;
        printf("%d\n",m);
    }
    else {
        printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    a -= 2
    b -= 2
    a %= 13
    b %= 13
    if a > b:
        print("Alice")
    elif a < b:
        print("Bob")
    else:
        print("Draw")
    return

#B
def B():
    n, m = LI()
    a = SR(n)
    b = SR(m)
    if a == b:
        print("Yes")
        return
    for y in range(n - m):
        for x in range(n - m):
            if a[y][x] == b[0][0]:
                flg = 0
                for yi in range(m):
                    for xi in range(m):
                        if b[yi][xi] == a[y + yi][x + xi]:
                            continue
                        flg = 1
                        break
                    if flg:
                        break
                if flg:
                    continue
                print("Yes")
                return
    print("No")
    return

#C
def C():
    n, m = LI()
    edg = [[] for i in range(n)]
    for _ in range(m):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
    def dfs(i, c):
        res = 0
        c[i] = False
        if not (True in c):
            c[i] = True
            return 1
        for e in edg[i]:
            if c[e]:
                res += dfs(e, c)
        c[i] = True
        return res
    print(dfs(0, [True] * n))
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


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

using namespace std;

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

    cout << setprecision(5) << setiosflags(ios::fixed); // printf("%.4f", x);

    int d;
    double e;

    while (cin >> d >> e, d) {
        double ans = 1e8;

        for (int y = d; y >= 0; --y) {
            const double x = d - y;
            ans = min(ans, abs(sqrt(y * y + x * x) - e));
        }

        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;
int main()
{
	long long n,m,p,x,i,z=0,v=0;
	cin>>n;
	long long a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		v+=a[i];
	}
	cin>>m;
	while(m--)
	{
		cin>>p>>x;
		z=v;
		cout<<z-a[p-1]+x<<endl;
	}
    return 0;
}


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

int main() {

  long long N,D,A;
  cin >> N >> D >> A;

  vector<pair<long long,long long>> mons(N);
  
  for(int i = 0;i < N;i++) cin >> mons.at(i).first >> mons.at(i).second;

  sort(mons.begin(),mons.end());
  vector<long long> num(N),s(N+1),p(N);
  for(int i = 0;i < N;i++) {
    num.at(i) = (mons.at(i).second+A-1)/A;
    p.at(i) = mons.at(i).first;
  }

  long long sum = 0;
  for(int i = 0;i < N;i++) {
    if(num.at(i) > s.at(i)) {
      long long dis = num.at(i)-s.at(i);
      sum += dis;
      int n = upper_bound(p.begin(),p.end(),p.at(i)+2*D)-p.begin();
      s.at(i) += dis;
      s.at(n) -= dis;
    }
    s.at(i+1) += s.at(i);
  }
  

  cout << sum << endl;
   
}


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

int main(){


char arr[]={'a', 'e', 'i', 'o' ,'u'};
char c;
cin >> c;
for(int i=0;i<5 ;i++){
    if(c==arr[i]) {cout<<"vowel"; return 0;}
}
cout<<"consonant";



return 0;

}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int cnt = 1;
		int ans = 0;
		while(cnt < B) {
			cnt--;
			cnt += A;
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static List<Tuple<int,int>>[] li;
	static bool[] b,bg;
	static long[] h;
	static bool gg=false;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int n=s[0],m=s[1];
		li=new List<Tuple<int,int>>[n+1];
		b=new bool[n+1];
		bg=new bool[n+1];
		h=new long[n+1];
		var e=new int[m][];
		for(int i=1;i<=n;i++){li[i]=new List<Tuple<int,int>>();}
		for(int i=0;i<m;i++){
			e[i]=sc.Ia;
			e[i][2]=s[2]-e[i][2];
			li[e[i][1]].Add(Tuple.Create(e[i][0],e[i][2]));
		}
		for(int i=1;i<=n;i++){h[i]=long.MaxValue;}
		h[1]=0;
		bool bo=true;
		for(int i=0;bo&&i<=n;i++){
			bo=false;
			for(int j=0;j<m;j++){
				if(h[e[j][0]]!=long.MaxValue&&h[e[j][1]]>h[e[j][0]]+e[j][2]){
					h[e[j][1]]=h[e[j][0]]+e[j][2];
					bo=true;
					if(i==n){b[e[j][1]]=true;}
				}
			}
		}
		Fu(n);
		Console.WriteLine("{0}",gg?-1:(Max(-h[n],0)));
	}
	static void Fu(int a){
		bg[a]=true;
		if(b[a]){gg=true;}
		for(int i=0;i<li[a].Count&&!gg;i++){
			if(!bg[li[a][i].Item1]){Fu(li[a][i].Item1);}
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 15828
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

int main(){
    int n, a;
    cin >> n >> a;
    cout << n*n - a << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
from math import factorial
def comb(n, k):
    return factorial(n) // (factorial(k) * factorial(n-k))
n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
cnt = Counter(v)
print(sum(v[:a]) / a)

if v[0] == v[a-1]:
    x = cnt[v[0]]
    ans = 0
    for i in range(a, min(x, b)+1):
        ans += comb(x, i)

    print(ans)

else:
    x = cnt[v[a-1]]
    for i in range(a):
        if v[i] == v[a-1]:
            y = i
            break

    print(comb(x, a-y))


Measured memory_bytes: 3316