akhauriyash/Code-Regression huggingface dataset:
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

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

int main(void){
    int n,i,a,b,r=0;
    scanf("%d",&n);
    for(i = 1;i <= n;i++){scanf("%d%d",&a,&b);r+=b-a+1;}
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int n, a, count = 0;
	
	cin>>n;
	
	rep(i,n){
		cin>>a;
		if(a%2==0)count++;
	}
	
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3088
(let ((n (read))
      (cc 0)
      (c 0)
      (hc (read)))
  (when (>= n 2)
    (loop for i from 2 to n
          do (let ((hn (read)))
               (if (>= hc hn)
                   (incf c)
                   (progn (setf cc (max cc c))
                          (setf c 0)))
               (setf hc hn))))
  (format t "~A~%" (max cc c)))

Measured memory_bytes: 57704
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr uint64_t mod=1e9+7;

// a^n%mod
uint64_t bin_pow(uint64_t a,uint64_t n){
    uint64_t ans=1;
    while(n>0){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans%mod;
}

//a^(-1)(mod)=a^(mod-2)
uint64_t inv_mod(uint64_t a){
  return bin_pow(a,mod-2);
}

int main()
{
  uint64_t n;
  cin>>n;
  vector<uint64_t> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  vector<uint64_t> vec(64,0);
  for (uint64_t i = 0; i < n; ++i)
  {
    for (uint64_t j = 0; j < 64; ++j)
    {
      vec[j]+=(a[i]>>j&1ULL);
    }
  }
  uint64_t ans=0;
  for (uint64_t i = 0; i < n; ++i)
  {
    for (uint64_t j = 0; j < 64; ++j)
    {
      if(a[i]>>j&1ULL)
      {
        ans+=(((n-vec[j])*(bin_pow(2, j)))%mod);
      }
      else ans+=(((vec[j])*(bin_pow(2,j)))%mod);
      ans%=mod;
    }

  }
  ans*=inv_mod(2);
  ans%=mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int d1[10] = { 20,19,20,19,20,19,20,19,20,19 };
	int d2[10] = { 20,20,20,20,20,20,20,20,20,20 };
	int Sd1 = 20 * 10 - 5;
	int Sd2 = 20 * 10;
	int SD = 196471;

	int n; cin >> n;
	int Y, M, D;
	int Sum = 0;
	for (int i = 0; i < n; i++) {
Sum = 0;
		cin >> Y >> M >> D;
		Sum += (Y - 1) / 3 * Sd2 + ((Y - 1) - (Y - 1) / 3)*Sd1;

		if (Y % 3 != 0) {
			for (int j = 0; j < M - 1;j++) {
				Sum += d1[j];
			}
			Sum += D;
		}
		else {
			for (int j = 0; j < M - 1;j++) {
				Sum += d2[j];
			}
			Sum += D;
		}
		cout << SD - Sum << endl;
	}
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define x first
#define y second
#define loop(i, start, end) for(int i=start; i<=end; ++i)
#define loopr(i, end, start) for(int i=end; i>=start; --i)
#define pb push_back
#define MOD 1000000007
#define mod(a) (a%MOD + MOD)%MOD
using namespace std;

template <typename T>
void inputArray(T *a, int start, int end) {
    loop(i, start, end) cin >> a[i];
}

template <typename T>
void printArray(T *a, int start, int end) {
    loop(i, start, end) cout << *(a+i) << ' ';
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

int main() {   
    IOS;
	string s;
    cin >> s;
    int n=s.length()-1;
    if(s[n]=='s') s+="es";
    else s+='s';
    cout << s;
    //cerr << " Execution : " << (1.0*clock())/CLOCKS_PER_SEC << "s" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

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

    int sum = 0;
    for(int i = 0; i < N; i++){
        int l,r;
        cin >> l >> r;

        sum += (r-l+1);
    }

    cout << sum << endl;
    
    return 0;
}

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

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<int>> d(n + 1, vector<int>(3, 0));
    for(int i = 0; i < n; i++){
        d[i + 1][0] = max(d[i][1] + a[i], d[i][2] + a[i]);
        d[i + 1][1] = max(d[i][0] + b[i], d[i][2] + b[i]);
        d[i + 1][2] = max(d[i][0] + c[i], d[i][1] + c[i]);
    }
    cout << max({d[n][0], d[n][1], d[n][2]}) << endl;
    return 0;
}


Measured memory_bytes: 6912
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

struct cust {
	int  m;
	int l;
	int k;
};
 
struct query {
	int type;
	int time;
	int id;
};
struct aa {
	int id;
	int time;
};
class Compare {
public:
	bool operator()(const query&l,const query&r) {
		return l.time==r.time?l.type==r.type?l.id>r.id:l.type>r.type:l.time > r.time;
	}
	bool operator()(const aa&l, aa&r) {
		return l.time > r.time;
	}
};

bool check(const int T, const vector<cust>&cus, const int n) {
	int waitnum = n;
	priority_queue<query,vector<query>,Compare>que;
	//vector<int>waits(cus.size());
	set<int>waits;
	for (int i = 0; i < cus.size(); ++i) {
		que.push(query{ 0,0,i });
	}
	while (!que.empty()) {
		query q(que.top());
		que.pop();
		if (q.type == 1) {
			auto it = waits.begin();
			if (it == waits.end()) {
				waitnum++;
			}
			else {
				const int cid = *it;
				const int nexttime = q.time + cus[cid].m;
				if (nexttime < T) {
					waits.erase(it);
					que.push(query{ 1,nexttime,0 });
				}
				else if (nexttime == T) {
					waits.erase(it);
				}
				else {
					return false;
				}
				
			}
		}
		else if (q.type == 0) {
			const int cid = q.id;
			if (waitnum) {
				waitnum--;
				const int nexttime = q.time + cus[cid].m;
				if (nexttime < T) {
					que.push(query{ 1,nexttime,0 });
				}
				else if (nexttime == T) {
				}
				else {
					return false;
				}
			}
			else {
				waits.emplace(cid);
				const int nexttime = q.time + cus[cid].l;
				que.push(query{ 2,nexttime,cid });
			}
		}
		else if (q.type == 2) {
			const int cid = q.id;
			auto it = waits.find(cid);
			if (it!=waits.end()) {
				waits.erase(it);
				const int nexttime = q.time + cus[cid].k;
				if (nexttime < T) {
					que.push(query{ 0,nexttime,cid });
				}
				else {
					return false;
				}
			}
			else {

			}
		}
	}
	return true;
}

int main() {
	while (1) {
		int N, T; cin >> N >> T;
		if (!N)break;
		vector<cust>cus;
		int totalm = 0;
		for (int i = 0; i < N; ++i) {
			int m, l, k; cin >> m >> l >> k;
			totalm += m;
			cus.push_back(cust{ m,l,k });
		}
		int amin = (totalm-1) / T + 1;
		for (int n = amin; n <= N; ++n) {
			if (check(T, cus, n)) {
				cout << n << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int removeb(int x, int i) {
    int tmp = x & ((1 << i) - 1);
    return ((x >> (i + 1)) << i) + tmp;
}

int insertb(int x, int i, int j) {
    int tmp = x & ((1 << i) - 1);
    return ((x >> i) << (i + 1)) + (j << i) + tmp;
}

vector<int> solve(int n, int a, int b) {
    if (n == 1) {
        return {a, b};
    }
    for (int i = 0; i < n; i++) {
        if ((a ^ b) & (1 << i)) {
            int c = removeb(a, i);
            int d = removeb(b, i);
            for (int j = 0; j < (1 << n); j++) {
                int x = removeb(j, i);
                if (x == c || x == d) {
                    continue;
                }
                if (__builtin_popcount(x ^ c) % 2 == 0 || __builtin_popcount(x ^ d) % 2 == 0) {
                    continue;
                }
                debug(c, x, d);
                vector<int> p = solve(n - 1, c, x);
                vector<int> q = solve(n - 1, x, d);
                for (int& v : p) {
                    v = insertb(v, i, (a >> i) & 1);
                }
                for (int& v : q) {
                    v = insertb(v, i, (b >> i) & 1);
                }
                p.insert(p.end(), q.begin(), q.end());
                return p;
            }
        }
    }
    return {};
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if (__builtin_popcount(a ^ b) % 2 == 0) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    vector<int> res = solve(n, a, b);
    for (int i : res) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

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

#define a first
#define b second

string fs(bool f) {return f?"Fennec":"Snuke";}

signed main(){
  bool flag = true, flag2 = true;
  int F, S;
  int N;
  vector<int> col;
  vector<vector<int> > tree;
  vector<pair<int,int> > in;
  queue<pair<pair<int,int>,int>> Q;
  
  cin>>N;

  col.resize(N);
  in.resize(N);
  tree.resize(N);
  
  for(int i = 0; i < N-1; i++){
    cin>>in[i].a>>in[i].b;
    in[i].a--;
    in[i].b--;

    tree[in[i].a].push_back(in[i].b);
    tree[in[i].b].push_back(in[i].a);
  }

  Q.push(make_pair(make_pair(0,0),1));
  Q.push(make_pair(make_pair(N-1,0),-1));
  // col[0] = 1;
  // col[N-1] = -1;
  
  while(!Q.empty()){
    pair<pair<int,int>,int> P = Q.front(); Q.pop();
    int now = P.first.first, dis = P.first.second, C = P.second;

    // cout<<now<<endl;

    if(flag && col[now] == -1 && C == 1){
      F = dis-1;
      flag = false;
    }
    
    if(flag2 && col[now] == 1 && C == -1){
      S = dis-1;
      flag2 = false;
    }
    
    
    if(col[now]) continue;
     col[now] = C;
    
    for(int i = 0; i < tree[now].size(); i++){
      //if(col[tree[now][i]]) continue;
      //col[tree[now][i]] = C ;
      Q.push(make_pair(make_pair(tree[now][i],dis+1),C));
    }
  }

  int a = count(col.begin(), col.end(), 1);
  
  cout<<fs(a > N - a)<<endl;
  
  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	sort(all(A));
	if (A[N - 1] - A[0] > 1) {
		cout << "No" << endl;
		return 0;
	}
	//not soloがいる場合
	int solo = 0;
	for (int i = 0;i < N;i++) {
		if (A[i] != A[N - 1])solo++;
	}

	if (A[N - 1] - solo <= 0) {
		cout << "No" << endl;
		return 0;
	}
	if ((A[N - 1] - solo) * 2 <= N - solo) {
		cout << "Yes" << endl;
		return 0;
	}
	//all soloの場合
	if (A[0] != A[N - 1]) {
		cout << "No" << endl;
		return 0;
	}
	if (A[0] == N - 1) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            if (list.Contains(0))
            {
                Console.WriteLine(0);
                return;
            }

            var result = 1L;
            for (var i = 0; i < n; i++)
            {
                var r = 1e18 / list[i];
                if (r < result)
                {
                    result = -1;
                    break;
                }
                result *= list[i];
            }

            if (result > (long)1e18)
                Console.WriteLine(-1);
            else
                Console.WriteLine(result);
        }
    }
}


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

int main() {
    int i, n, q, tmp, res = 0;
    set<int> s, t;
    cin >> n;
    for (i=0; i<n; i++) {
        cin >> tmp;
        s.insert(tmp);
    }

    cin >> q;
    for (i=0; i<q; i++) {
        cin >> tmp;
        if (s.count(tmp) > 0)
            res++;
    }

    cout << res << endl;
    return 0;
}

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

int main(void) {
  int N, D; cin >> N >> D;
  vector<vector<int> > X(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      int Xi; cin >> Xi;
      X.at(i).push_back(Xi);
    }
  }

  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      int dd = 0;
      for (int k = 0; k < D; k++) dd += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
      double d = sqrt(dd);
      if (d == (int)d) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

using llong = long long;

int main() {

    llong N;
    cin >> N;

    llong a = llong(sqrt(double(N)));
    while (N % a != 0) {
        a--;
    }

    llong b = N / a;

    cout << b + a - 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,x;
		int count = 0;
		while(true){
			n = sc.nextInt();
			x = sc.nextInt();
			if(n==0&&x==0)break;
			for(int i=1;i<=n-2;i++){
				for(int j=i+1;j<=n-1;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
			count=0;
		}
	}
}



Measured memory_bytes: 26444
N=int(input())
A=list(map(int, input().split()))
A.sort()
tmp=[]
i=N-1
while i>0:
  if A[i]==A[i-1]:
    tmp.append(A[i])
    i-=2
  else:
    i-=1
if len(tmp)>=2:
  print(tmp[0]*tmp[1])
else:
  print(0)

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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;

    long long ans = 0;

    long long m = n / (a + b);

    ans += a * m;

    n -= (a + b) * m;

    long long tmp = n;

    n -= a;
    if (n >= 0) ans += a;
    else ans += tmp;

    cout << ans << endl;
    
    
}


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

int main()
{
  int n;
  cin >> n;
  
  int odds = (n % 2 == 0) ? n / 2 : n / 2 + 1;
  
  double p;
  p = odds / (double)n;
  
  cout << setprecision(9) << fixed << p << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,Y;
int main(void){
	cin>>N>>Y;
	Y=Y/1000;
	for(int i=0;i<=N;i++)
		for(int j=0;j<=N-i;j++)
			if(i*10+j*5+(N-i-j)==Y){
				cout<<i<<' '<<j<<' '<<N-i-j;
				return 0;
			}
	cout<<"-1 -1 -1";
	return 0;
}

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

int main(void) {
    cin >> num;
    int array[num] = {};
    array[0] = 1;
array[1] = 1;
    for (int i= 2; i <= num; i++) array[i] = array[i - 1] + array[i - 2];
    cout << array[num] << endl;
}




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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll> a(n);
  ll result=1;
  if(n<=2){
    cout<<result;
    return 0;
  }
  rep(i, n)cin>>a[i];
  a.erase( unique(a.begin(), a.end()), a.end() );
  ll pre = a[1]-a[0];
  for(int i=2;i<a.size();i++){
    ll t = a[i]-a[i-1];
    if(t<0 && pre>0 || t>0 && pre<0){
      result++;
      pre=0;
    }else{
      pre=t;
    }
  }

  cout<<result;

  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

struct union_find {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    union_find(int n) : par(n), rank(n), siz(n) {
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

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

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
            siz[y] += siz[x];
        } else {
            par[y] = x;
            siz[x] += siz[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

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

    int size(int x) {
        return siz[root(x)];
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    union_find u(n);
    vector<int> res(n, -1);
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        a--; b--;
        u.unite(a, b);
        res[a]--;
        res[b]--;
    }

    for (int i = 0; i < n; ++i) {
        res[i] += u.size(i);
    }

    int c, d;
    for (int i = 0; i < k; ++i) {
        cin >> c >> d;
        c--; d--;
        if(u.same(c, d)){
            res[c]--;
            res[d]--;
        }
    }

    for (int i = 0; i < n-1; ++i) {
        cout << res[i] << " ";
    }
    cout << res[n-1] << endl;
}

Measured memory_bytes: 2432
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        System.out.println((x-z)/(y+z));
        sc.close();
    }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e3+9;
vector<int>v[N];
int x,l,r;
bool visited[N];
map<int,int>m;
void bfs(int x,int c){
    queue<pair<int,int>>q;
    q.push({x,c});
    while (!q.empty()){
        pair<int,int>temp=q.front();
        q.pop();
        if (visited[temp.first])
            continue;
        m[temp.second]++;
        visited[temp.first]=1;
        for (int i=0;i<v[temp.first].size();i++){
            q.push({v[temp.first][i],temp.second+1});
        }
    }
}
int main()
{
    FASTINOUT;
    cin>>x>>l>>r;
    v[l].push_back(r);
    v[r].push_back(l);
    for (int i=1;i<x;i++){
        v[i].push_back(i+1);
        v[i+1].push_back(i);
    }
    for (int i=1;i<=x;i++){
        bfs(i,0);
        memset(visited,false,sizeof visited);
    }
    for (int i=1;i<x;i++){
        cout<<m[i]/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

typedef vector<vvi> vvvi;
struct node{
	int foot,x,y,c;
	node(){}
	node(int foot,int x,int y,int c):foot(foot),x(x),y(y),c(c){}
};
const int MAX=INT_MAX/10;
int main(){
	int w,h;
	while(cin>>w>>h,w&&h){
		vvi s(w,vi(h));
		vector<pii> start,goal;
		REP(j,h)REP(i,w){
			char c;
			cin>>c;
			switch(c){
			case 'S':
				start.push_back(make_pair(i,j));
				s[i][j]=0;
				break;
			case 'T':
				goal.push_back(make_pair(i,j));
				s[i][j]=0;
				break;
			case 'X':
				s[i][j]=-1;
				break;
			default:
				s[i][j]=c-'0';
				break;
			}
		}
		vvvi cost(2,vvi(w,vi(h,MAX)));
		queue<node> q;
		REP(i,2)REP(j,start.size()){
			q.push(node(i,start[j].first,start[j].second,0));
			cost[i][start[j].first][start[j].second]=0;
		}
		while(!q.empty()){
			node n=q.front();
			q.pop();
			if(cost[n.foot][n.x][n.y]<n.c)continue;
			REP(i,9){
				int foot=(n.foot+1)%2;
				int x=n.x+dx[foot][i],y=n.y+dy[foot][i];
				if(x>=0&&y>=0&&x<w&&y<h&&s[x][y]>=0){
					int newcost=cost[n.foot][n.x][n.y]+s[x][y];
					if(cost[foot][x][y]>newcost){
						cost[foot][x][y]=newcost;
						q.push(node(foot,x,y,newcost));
					}
				}
			}
		}
		int best=MAX;
		REP(i,2)REP(j,goal.size()){
			best=min(best,cost[i][goal[j].first][goal[j].second]);
		}
		if(best==MAX){
			best=-1;
		}
		cout<<best<<endl;
	}
}

Measured memory_bytes: 956
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

ll dp[55][55][2600],in[55];

int main() {
	ll n, k, ans = 0;
	dp[0][0][0] = 1;
	cin >> n >> k;
	REP(i, n) cin >> in[i];
	REP(i, n) {
		REP(l, i + 1) {
			REP(j, 2520) {
				dp[i + 1][l + 1][j + in[i]] += dp[i][l][j];
				dp[i + 1][l][j] += dp[i][l][j];
			}
		}
	}
	REPO(i, n) ans += dp[n][i][i * k];
	cout << ans << endl;
}
	


Measured memory_bytes: 55552
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
//const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




//---------------------------------------------------------------
// 高速コンビネーション計算
//---------------------------------------------------------------
/*使用例
	// 前処理
	COMinit();

	// 計算例
	cout << COM(100000, 50000) << endl;
*/

// テーブルを作る前処理
ll fac[3000005], finv[3000005], inv[3000005];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 3000005; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll R1, R2, C1, C2;
	cin >> R1 >> C1 >> R2 >> C2;

	ll ans = 0;


	COMinit();

	for (int c = C1; c <= C2; c++) {
		ans += COM(R2 + c + 1, c +1) % MOD - COM(R1 + c, c + 1)%MOD;
		ans %= MOD;
	}

	if (ans < 0) {
		ans += MOD;
		cout << ans;
		return 0;
	}
	cout << ans;




}



Measured memory_bytes: 70528
#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>;

// rep(i, 3){cout << i << endl;}

vector<int> d;
int N, K;

// vector<vector<int>> a;

int main(){
    cin >> N >> K;
    vector<int> ans(N, 0);
    int tmp;
    d.resize(K);
    rep(i, K){
        cin >> d.at(i);
        rep(j, d.at(i)){
            cin >> tmp;
            ans.at(tmp-1)++;
        }
    }

    // 0 のaの要素
    int ans_v = 0;
    rep(i, N){
        if(ans.at(i)==0) ans_v++;
    }

    cout << ans_v << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
//#include<string>

using namespace std;

int tree_depth(vector<int>& parent, int node) {
	int depth = 0;
	while (parent.at(node) != -1) {
		node = parent.at(node);
		depth++;
	}
	return depth;
}

void disp_tree(vector<int>& parent, vector<vector<int>>& children) {
	for (int i = 0; i < parent.size(); i++) {
		cout << "node " << i << ": parent = " << parent.at(i) << ", depth = " << tree_depth(parent, i) << ", ";
		if (parent.at(i) == -1) {
			if (children.at(i).size() == 0) {
				cout << "root, []" << endl;
				return;
			}
			cout << "root, [";
			for (int j = 0; j < children.at(i).size() - 1; j++) cout << children.at(i).at(j) << ", ";
			cout << children.at(i).back() << "]" << endl;
		}
		else if (children.at(i).size() > 0) {
			cout << "internal node, [";
			for (int j = 0; j < children.at(i).size() - 1; j++) cout << children.at(i).at(j) << ", ";
			cout << children.at(i).back() << "]" << endl;
		}
		else {
			cout << "leaf, []" << endl;
		}
	}
}

int main(void) {

	int size, node, temp, childnum;
	cin >> size;
	vector<int> parent(size,-1);

	vector<vector<int>> children(size);
	for (int i = 0; i < size; i++) {
		cin >> node >> childnum;
		for (int i = 0; i < childnum; i++) {
			cin >> temp;
			children.at(node).push_back(temp);
			parent.at(temp) = node;
		}
	
	}
	disp_tree(parent, children);
	return 0;
}



Measured memory_bytes: 6128
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int main(){
  int N;
  while(cin>>N && N){
    vector<string> _city(N);
    REP(i, N) cin>>_city[i];
    vector<string> city;
    REP(i, N){
      bool ok = true;
      REP(j, N){
        if(i != j && _city[i].size() < _city[j].size() && _city[j].find(_city[i]) != -1) ok = false;
        if(i < j && _city[i] == _city[j]) ok = false;
      }
      if(ok) city.push_back(_city[i]);
    }
    N = city.size();

    int d[16][16] = {};
    REP(i, N)REP(j, N)if(i != j){
      string from = city[i];
      string to = city[j];
      int l = min(from.size(), to.size());
      for(int k = 1; k <= l; k++){
        if(from.substr(from.size() - k, k) == to.substr(0, k)){
          d[i][j] = k;
        }
      }
    }

    int dp[1<<16][16] = {};
    REP(S, 1<<N)REP(i, N) dp[S][i] = -INF;
    REP(i, N) dp[1<<i][i] = 0;
    REP(S, 1<<N)REP(from, N)if(dp[S][from] != -INF){
      REP(to, N)if(!(S >> to & 1)){
        int NS = S | 1<<to;
        dp[NS][to] = max(dp[NS][to], dp[S][from] + d[from][to]);
      }
    }

    int ans = 0;
    REP(i, N) ans += city[i].size();
    ans -= *max_element(dp[(1<<N)-1], dp[(1<<N)-1] + N);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = 1050000000;
constexpr auto MOD = 1000000007;

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

	ll a = sqrt(n),b;

	while (true) {
		if (n % a)a--;
		else break;
	}

	b = n / a;
	int ans = 0;
	while (b) {
		b /= 10;
		ans++;
	}
	cout << ans << endl;
}

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

using namespace std;
using ll = unsigned long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    int m1, n, m2, k;
    cin >> m1 >> n >> m2 >> k;
    if(m1 == m2){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }

    return;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, K; cin >> N >> K;
    long long ans = K;
    REP(i, N)ans *= K - 1;
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<bool> isPrime(150, true);
	isPrime[0] = isPrime[1] = false;
	rep(i, 2, 60)
	{
		if (isPrime[i])
		{
			for (int j = i * i; j < 130; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
	vector<int> pN(101, 0);
	rep(i, 2, n)
	{
		int now = i;
		for (int j = 2; j <= i; ++j)
		{
			if (!isPrime[j])continue;

			int cnt = 0;
			while (now%j == 0)
			{
				++cnt;
				now /= j;
			}
			pN[j] += cnt;
		}
	}

	int t, f, ft, tf, sf;
	t = f = ft = tf = sf = 0;
	rep(i, 2, 49)
	{
		if (pN[i] >= 2)++t;
		if (pN[i] >= 4)++f;
		if (pN[i] >= 14)++ft;
		if (pN[i] >= 24)++tf;
		if (pN[i] >= 74)++sf;
	}
	int ans = f * (f - 1) * (t - 2) / 2 + ft * (f - 1) + tf * (t - 1) + sf;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,m;cin>>n>>m;
  vector<vector<char>> a(n,vector<char>(n)),b(m,vector<char>(m));
  rep(i,n)rep(j,n)cin>>a[i][j];
  rep(i,m)rep(j,m)cin>>b[i][j];
  rep(i,n-m+1)rep(j,n-m+1){
    bool ans=true;
    rep(k,m)rep(l,m){
      if(a[i+k][j+l]!=b[k][l])ans=false;
    }
    if(ans){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
typedef complex<double> P;
namespace std{
	bool operator<(const P& a, const P& b){
		return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
		//return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
inline double cross(const P& a, const P& b){ return imag(conj(a)*b); }
inline double dot(const P& a, const P& b){ return real(conj(a)*b); }
struct L : public vector<P>{
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};
typedef vector<P> G;
inline int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if(cross(b, c) >  EPS)   return +1;      // counter clockwise
	if(cross(b, c) < -EPS)   return -1;      // clockwise
	if(dot(b, c)   < -EPS)   return +2;      // c--a--b on line
	if(norm(b)+EPS <norm(c)) return -2;      // a--b--c on line
	return 0;                                   // c is between a and b (inclusive)
}
int n;
int on[200][200];
bool can[200][200][200];

int dp[200][200];
ll pw[201];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	const int mod = 998244353;
	pw[0] = 1;
	rep(i, 200) pw[i + 1] = pw[i] * 2 % mod;
	
	cin >> n;
	G g;
	rep(i, n){
		int x, y; cin >> x >> y;
		g.emplace_back(x, y);
	}
	if(n < 3){
		cout << 0 << endl;
		return 0;
	}
	
	
	ll ans = pw[n] - n - 1 + 2 * mod;
	rep(i, n) for(int j = i + 1; j < n; j++){
		vi v;
		int sz;
		rep(k, n) if(k != i && k != j && abs(cross(g[k] - g[i], g[j] - g[i])) < EPS){
			if(k < j) goto SKIP;
			v.pb(k);
		}
		
		sz = v.size() + 2;
		ans += mod - pw[sz] + sz + 1;
		
		//dbg(sz, pw[sz] - sz - 1, i, j, v);
		SKIP:;
	}
	cout << ans % mod << endl;
	return 0;
}

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

int main(){
    long long N;
    cin >> N;
    long long ans = 0ll;

    for(long long i=2;i*i<=N;i++){
        if(i*i != N && N % i == 0ll){
            if(N / (N/i - 1ll) == N % (N/i - 1ll)) ans += (N/i - 1ll); 
            if((N / (i-1ll)) == N % (i-1ll)) ans += (i-1ll);
        }
    }
    ans += N-1;
    if(N == 2) ans = 0;

    cout << ans << endl;
}


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

int main() {
  string S; cin >> S;
  for(auto p : S) {
    if(p == ',') cout << " ";
    else cout << p;
  }
  cout << endl;
  return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int sum = 0;
  for (int i = 0; i < M; i++) {
  int A;
  cin >> A;
  sum += A;
  }
  if (sum > N) {
  cout << -1;
  }
  else if (sum <= N) {
  cout << N-sum;
  }
  
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;


int main()
{

     int n,i,j,a,b,c,ck=0,dk=0;

     cin>>n;
     cout<<n*n*n<<endl;
}



Measured memory_bytes: 3088
import copy
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    ans = 0
    H,W,K = map(int, readline().split())
    c_ = [list(map(int, list(readline().strip()))) for _ in range(H)]

    for a in range(H):
        for b in range(W):
            c = copy.deepcopy(c_)
            c[a][b] = 0

            seq = [[1] for _ in range(H)]
            ans_tmp = [0]
            
            score = 0
            weight = 1
            while True:
                # 落とす
                for i in reversed(range(H)):
                    for j in range(W):
                        if c[i][j] == 0:
                            for h in reversed(range(i)):
                                if c[h][j] != 0:
                                    c[h][j], c[i][j] = c[i][j], c[h][j]
                                    break

                # 消す
                for i, line in enumerate(c):
                    for j in range(1,W):
                        if line[j] == line[j-1]:
                            seq[i][-1] += 1
                        else:
                            seq[i].append(1)
                
                    acc = -1
                    for s in seq[i]:
                        acc += s
                        if s >= K:
                            score += s * line[acc] * weight
                            for j in range(acc - s + 1, acc + 1):
                                line[j] = 0
                    seq[i] = [1]
                
                weight *= 2

                ans_tmp.append(score)
                if ans_tmp[-1] == ans_tmp[-2]:
                    ans = max(ans, ans_tmp[-1])
                    break

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 58204
#include<stdio.h>
int main()
{
	int N;
	int a, b, c, d;
	while(~scanf("%d", &N))
	{
	if(N <= 9999 && N >= 1000)
	{
		a = N / 1000;
		b = N / 100 - N / 1000 * 10;
		c = N / 10 - N/ 100 * 10;
		d = N - N / 10 *10;
		if(a == b && b == c && c == d)
			printf("Yes\n");
				else if(a == b && b == c)
					printf("Yes\n");
						else if(b == c && c == d)
							printf("Yes\n");
							else
								printf("No\n");
	}
	}
}


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

int main() {
    long long n,k,q;
    cin >> n >> k >> q;
    long long a[q],sum[n]={0};
    bool ok[n],can=false;
    rep(i,q) {
        cin >> a[i];
        --a[i];
        sum[a[i]]++;
    }
    
    
    if(!can){
        rep(i,n){
            sum[i]+=k-q;
            //cout << sum[i] << endl;
            if(sum[i]<=0){
                ok[i]=false;
            }
            else ok[i]=true;
           //cout << ok[i] << endl;
    
        }
    }
    rep(i,n){
        if(ok[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    

}






Measured memory_bytes: 2304
// C

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
ll gcd(ll a,ll b) {
  if (b == 0){
    return a;
  }
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(){
  ll A,B;
  cin>>A>>B;
  cout << lcm(A,B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int L = 0, R = 0, U = 0, D = 0;
};

int main() {
	int h, w;
	cin >> h >> w;

	const int N_MAX = 2010;

	int field[N_MAX][N_MAX] = {};
	MyStruct f[N_MAX][N_MAX];
	string t;
	REP(i, h) {
		cin >> t;
		REP(j, w) {
			if (t[j] == '#') {
				field[i][j] = 1;
			}
			else if (t[j] == '.') {
				field[i][j] = 0;
			}
		}
	}

	REP(i, h) {
		REP(j, w) {
			if (field[i][j] == 1) {
				f[i][j].L = 0;
			}
			else if (j == 0) {
				f[i][j].L = 1;
			}
			else {
				f[i][j].L = f[i][j - 1].L + 1;
			}
		}
	}

	REP(i, h) {
		for (int j = w - 1; j >= 0; j--) {
			if (field[i][j] == 1) {
				f[i][j].R = 0;
			}
			else if (j == w - 1) {
				f[i][j].R = 1;
			}
			else {
				f[i][j].R = f[i][j + 1].R + 1;
			}
		}
	}

	REP(j, w) {
		REP(i, h) {
			if (field[i][j] == 1) {
				f[i][j].U = 0;
			}
			else if (i == 0) {
				f[i][j].U = 1;
			}
			else {
				f[i][j].U = f[i - 1][j].U + 1;
			}
		}
	}

	REP(j, w) {
		for (int i = h - 1; i >= 0; i--) {
			if (field[i][j] == 1) {
				f[i][j].D = 0;
			}
			else if (i == h - 1) {
				f[i][j].D = 1;
			}
			else {
				f[i][j].D = f[i + 1][j].D + 1;
			}
		}
	}

	int ans = 0;

	REP(i, h) {
		REP(j, w) {
			ans = max(ans, f[i][j].L + f[i][j].R + f[i][j].U + f[i][j].D - 3);
		}
		
	}

	ANS(ans);
	return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int d, t, s;
    int x;
    cin >> d >> t >> s;
    x = t * s;
    if(x >= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int train[10];

int main(void){
	int input;
	int index = 0;
	while(cin >> input){
		if(input != 0){
			train[index] = input;
			index++;
		}
		else if(input == 0){
			index--;
			printf("%d\n",train[index]);
			train[index] = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3028
import math

Line = [int(s) for s in input().split()]

A,B,H,M = Line[0],Line[1],Line[2],Line[3]

# print(A,B,H,M)

kakudo = abs(  H/12*360 + M/12/60*360 - M/60*360 )

if kakudo > 180 :
    kakudo = 360 - kakudo

# print(kakudo)

ans = math.sqrt(A**2 + B**2 - 2*A*B*round(math.cos(math.radians(kakudo)),100))

print(ans)

Measured memory_bytes: 9456
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
/*----------------------------------------------------------------------------------*/


int main() {
    int N, M, R; cin >> N >> M >> R;
    vector<int> r(R);
    rep(i,R) cin >> r[i];

    const int inf = 1e9;
    vector<vector<int>> dist(N, vector<int>(N, inf));
    rep(i,M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k,N) rep(i,N) rep(j,N) {
        chmin(dist[i][j], dist[i][k]+dist[k][j]);
    }

    vector<int> order(R);
    rep(i,R) order[i] = i;

    ll ans = inf;
    do {
        ll tmp = 0;
        repf(i,1,R) {
            int now = r[order[i]];
            int before = r[order[i-1]];
            tmp += dist[now-1][before-1];
        }
        chmin(ans, tmp);
    } while (next_permutation(order.begin(), order.end()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384