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

int main(void){

	int n, p=1;
	scanf("%d", &n);

	int i, j;
	unsigned long long int ans=1;
	int s[1000];
	for(i=0; i<1000; i++){
		s[i]=0;
	}
/*	for(i=1; i<=n; i++){
		p *= i;
	}
	
	int ans=0;
	for(i=1; i<=p; i++){
		if(p%i==0){
			ans++;
		}
	}
*/
	int mem;
	for(i=2; i<=n; i++){
		mem = i;
		for(j=2; j<=n; j++){
			if(j==mem || mem==1){
				s[mem]++;
				break;
			}
			if(mem%j==0){
				s[j]++;
				mem /= j;
				j--;
			}
		}
	} 

	//printf("1000000007\n");
	//素因数分解
	for(i=2; i<=n; i++){
		if(s[i]!=0){
			ans *= (s[i]+1);
			/*if(ans - 1000000007 >= 0){
			do{
				ans = ans -1000000007;
			}while(ans - 1000000007 >= 0);
			}*/
			if(ans >= 1000000007){
				ans %= 1000000007;
			}
		}
	}

	printf("%llu\n", ans);
	return 0;
}	

Measured memory_bytes: 128
#include<stdio.h>
#define n 100000
#define q 50000

int main(){
  
  int s[n],t[q],c=0,countn,countq,i,j,left,right,mid;
  
  scanf("%d",&countn);
  for(i = 0; i < countn; i++){
    scanf("%d",&s[i]);
  }
  
  scanf("%d",&countq);
  for(i = 0; i < countq; i++){
    
    scanf("%d",&t[i]);
  }
  
  for(i = 0; i < countq; i++){
    left = 0;
    right = countn;
    while(left < right){
      
      mid = (left + right)/2;
      if(t[i] == s[mid]){
	c++;
	break;
      }
      if(t[i] > s[mid]) left = mid + 1;
      else if(t[i] < s[mid]) right = mid;
    }
  }
  
  
  printf("%d\n",c);
  
  return 0;
}

Measured memory_bytes: 1184
r11 = int(input())
r12 = int(input())
r22 = int(input())
r33 = r22 * 2 - r11
r32 = r22 * 2 - r12
r31 = r22 * 3 - r33 - r32
r21 = r22 * 3 - r11 - r31
r13 = r22 * 3 - r11 - r12
r23 = r22 * 3 - r13 - r33

print(r11, r12, r13)
print(r21, r22, r23)
print(r31, r32, r33)

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

template<typename integer>
integer __lcm(integer a, integer b) {
    return (a * b) / __gcd(a, b);
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (b - a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



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

struct Graph
{
std::size_t sz;
std::vector<std::vector<int>> elist;
// set avoids duplicates

Graph(int n) : sz(n), elist(n)
{}
void add_edge(int i,int j)
{
	elist[i].push_back(j);
	elist[j].push_back(i);
}
std::size_t size()
{
	return sz;
}


unsigned connected_components(std::vector<int>& components)
{	unsigned int num = 0;
	std::vector<bool> visited(sz,false);
	for(unsigned v = 0; v < sz; ++v)
	{		
		if(visited.at(v)== false)
		{	
			std::vector<int> nb;
			std::vector<int> nb2;
			components.push_back(0);
			visited.at(v) = true;	
			++components.at(num);
			for(auto & e : elist[v])
			{
				if(visited.at(e)== false)
				{
				nb.push_back(e);
				++components.at(num);
				visited.at(e) = true;			
				}			
			}
			while(!nb.empty())
			{
				for(auto & n : nb)
				{
					for(auto &e : elist.at(n))
					{	if(!visited.at(e))	
						{	nb2.push_back(e);
							++components.at(num);
							visited.at(e) = true;
						}					
					}
				}
				std::swap(nb, nb2);
				nb2.clear();
			}
			++num; 
		}
		
	}
	return num;
}


};





int main()
{
	int n, m;
	std::cin >> n >> m;
	Graph g(n);

	for(int l = 0 ; l < m ; ++l)
	{
		int i, j;
		std::cin >> i >> j;
		g.add_edge(i-1,j-1);
	}
	std::vector<int> components;
	int num = g.connected_components(components);
	if(num == 1)
	{
		std::cout << g.size() ;
		return 0;
	}
	int groups = 0;
	for(auto & m : components)
	{
		if(m > groups)
		groups = m; 
	}
	
	std::cout << groups << std::endl;
}





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

int main(){
  int64_t H,W;
  cin >> H >> W;

  int64_t row_odd= (W+1)/2;
  int64_t row_even= W/2;
  
  int64_t ans= (H==1 || W==1) ? 1
                              : row_odd*((H+1)/2) + row_even*(H/2);

  cout << ans << endl;
}


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

#define int long long

#define loop1(i,a,b) for(int i=a;i<b;i++)

using namespace std;


void dfs(int i,int v[],map<int,vector<int>> * mp,int val[])
{
    v[i]=1;
    // vector<int> temp=mp[i];
    for(auto j: (*mp)[i])
    {
        if(v[j]==0)
        {
            dfs(j,v,mp,val);
        }
        if(val[i]<val[j]+1)
        {
            val[i]=val[j]+1;
        }
    }
}
signed main()
{
    // typedef tree<int,null_type,less<int>,rb_tree_tag,
    // tree_order_statistics_node_update> indexed_set;
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    // vector<pair<int,int>> v;
    int val[n];
    int v[n];
    map<int,vector<int>> mp;
    loop1(i1,0,m)
    {   int x,y;
        cin>>x>>y;
        mp[x-1].push_back(y-1);
     
    }
       loop1(i1,0,n)
    {
        val[i1]=0;
        v[i1]=0;
     
    }
        loop1(i1,0,n)
    {  
        if(v[i1]==0)
        {
            dfs(i1,v,&mp,val);
        }
     
    }
    int mx=0;
          loop1(i1,0,n)
    {  
        if(mx<val[i1])
        {
            mx=val[i1];
        }
     
    }
    cout<<mx;
    

  

}

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

template <typename T, typename E>
struct SegmentTree {
private:
    typedef function<T(T, T)> F;
    typedef function<T(T, E)> G;
    int n;
    F f;
    G g;
    T d1;
    vector<T> nodes;

public:
    SegmentTree(int n_, F f, G g, T d1, const vector<T>& v=vector<T>()) {
        this->f = f;
        this->g = g;
        this->d1 = d1;
        nodes_init(n_);
        if (n_ == (int)v.size()) build(n_, v);
    }

    void nodes_init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        nodes.clear();
        nodes.resize(2 * n - 1, d1);
    }

    void build(int n_, const vector<T>& v) {
        for (int i = 0; i < n_; i++) {
            nodes.at(i + n - 1) = v.at(i);
        }
        for (int i = n - 2; i >= 0; i--) {
            nodes.at(i) = f(nodes.at(i * 2 + 1), nodes.at(i * 2 + 2));
        }
    }

    void update(int idx, E value) {
        int node_idx = idx + n - 1;
        nodes.at(node_idx) = g(nodes.at(node_idx), value);
        int current_idx = node_idx;
        while (current_idx) {
            current_idx = (current_idx - 1) / 2;
            nodes.at(current_idx) = f(nodes.at(2 * current_idx + 1), nodes.at(2 * current_idx + 2));
        }
    }

    T query(int query_left, int query_right, int cur_idx, int cur_left, int cur_right) {
        if (cur_right <= query_left || query_right <= cur_left) return d1;
        if (query_left <= cur_left && cur_right <= query_right) return nodes.at(cur_idx);
        T value_from_left = query(query_left, query_right, 2 * cur_idx + 1, cur_left, (cur_left + cur_right) / 2);
        T value_from_right = query(query_left, query_right, 2 * cur_idx + 2, (cur_left + cur_right) / 2, cur_right);
        return f(value_from_left, value_from_right);
    }

    T query(int query_left, int query_right) {
        return query(query_left, query_right, 0, 0, n);
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<int> a_list(n, INT_MAX);
    SegmentTree<int, int> segtree(n,
        [](int a, int b){return min(a, b);},
        [](int a, int b){return b;},
        INT_MAX,
        a_list);

    for (int i = 0; i < q; i++) {
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 0) {
            segtree.update(x, y);
        }
        else {
            cout << segtree.query(x, y + 1) << "\n";
        }
    }
}



Measured memory_bytes: 4088
import java.util.*;
class Main{
    public static void main(String[] args){
        // ----------入力-------------//
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();           // 展望台の数
        int M = sc.nextInt();           // 道の数

        // ---展望台の高さを記憶---//
        int[] height = new int[N];      // 展望台の高さ
        for(int i=0;i<N;i++){
            height[i] = sc.nextInt();
        }
        //-------良い展望台を識別するフラグ good を用意--------//
        boolean[] good = new boolean[N];    //良い展望台のときtrue
        Arrays.fill(good, true);            // trueで初期化
            //show(good);
        // ---道が入力されるたびに比較を行い，低い方はgoodフラグを下ろす---//
        int a,b;                // 道がつなぐ二つの展望台
        for(int j=0;j<M;j++){
            a = sc.nextInt() -1;   // 一つ目の展望台
            b = sc.nextInt() -1;   // 二つ目の展望台
            if(height[a]==height[b]){
                good[a]=false;
                good[b]=false;
            }
            else if(height[a]<height[b]){   // aが低い時，aのフラグを下ろす
                good[a]=false;
            }
            else{                               // bが低い時，bのフラグを下ろす
                good[b]=false;
            }
            //show(good);
        }
        // ---------出力-----------//
        int cnt=0;
        for(int k=0;k<N;k++){
            if(good[k]){
                cnt++;
            }
        }
        System.out.println(cnt);
    }

    /*
    static void show(boolean[] array){
        for(int l=0;l<array.length;l++){
            System.out.println(array[l]);
        }
    }
    */
}

Measured memory_bytes: 59020
import sys
from collections import deque 
d=deque(input())
#print(d)
q=int(input())
x=0 #0 means normal 1 means reverse 
for _ in range(q):
  ss=list(input().split())
  if ss[0]=='1':
    x=1-x
  else:
    f=int(ss[1])
    c=ss[2]
    if x==0:#normal
      if f==1:
        d.appendleft(c)
      else:
        d.append(c)
    else:#reverse
      if f==1:
        d.append(c)
      else:
        d.appendleft(c)
if x==0:
  print(''.join(d))
else:
  ans=[]
  for i in d:
    ans+=i
  print(''.join(ans[::-1]))




Measured memory_bytes: 10476
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;
ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}


int main()
{
 ll n;
 cin>>n;
 ll a=sqrt(n);
 
 while(1){
  if(n%a==0){
      break;
  }
  a--;
 }
 ll b=n/a;
 cout <<a+b-2<<endl;
}



Measured memory_bytes: 3668
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    ll wcount = 0;
    REP(i, s.size()){
        if(s.at(i) == 'W'){
            ans += i - wcount;
            wcount++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N;  string S;
    cin >> N >> S;
    vector<int> w(N+1,0), b(N+1,0);
    for(int i=0; i<N; i++){
        if(S[i]=='#') b[i]++;
        if(i>0) b[i]+=b[i-1];
    }
    for(int i=N-1; i>=0; i--){
        if(S[i]=='.') w[i]++;
        if(i<N-1) w[i]+=w[i+1];
    }

    int ans = N;
    for(int i=0; i<N; i++){
        if(S[i]=='#'){
            ans = min(ans, b[i]-1 + w[i]);
        }else{
            ans = min(ans, b[i] + w[i]+1);
        }
    }
    ans = min(ans, b[N-1]);
    cout << ans << endl;
}


Measured memory_bytes: 2180
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char grid[10][10];

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> grid[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int count=0;
            for(int k=0;k<h;k++){
                for(int l=0;l<w;l++){
                    if(grid[k][l]=='#' && (i & (1<<k)) && (j & (1<<l))){
                        count ++ ;
                    }
                }
            }
            if(count == k){
                ans+=1;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3616
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m;
    cin >> n >> m;

    lint sum = 0;
    rep(i, n){
        lint a;
        cin >> a;
        sum += a;
    }

    lint ans = 0;
    rep(i, m){
        lint b;
        cin >> b;
        ans += b * sum;
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}


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

int main(){
  int a,b,c;
  string ans;
  cin >> a >> b >> c;
  vector<int> vec{a,b,c};
  sort(vec.begin(),vec.end());
  if(vec.at(0)==5 && vec.at(1)==5 && vec.at(2) ==7){
    ans ="YES";
  }
  else{
    ans="NO";
  }
  cout << ans << endl;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  p(n * (n - 1) / 2);
}

Measured memory_bytes: 256
N,M=map(int,input().split())

from collections import Counter
 
def soinsuu(n):
    list_=[]
    while(n!=1):
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                list_.append(i)
                n=n//i
                break
        else:
            list_.append(n)
            n=1
    return sorted(list_)
 
def product(a):
    pro=1
    for b in a:
        pro=pro*b%(10**9+7)
    return pro
 
#n!,nPr,nCrの高速計算
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):
    return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
def nCr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)*n_func(r,mod)%mod
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
    
p=list(Counter(soinsuu(M)).values())
print(product([nCr(N+p[i]-1,p[i]) for i in range(len(p))]))

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

int main(){
    string s;
    cin >> s;
    
    int ans = 753;
    for(int i=0; i<s.size()-2; i++){
        int now = 0;
        for(int j=0; j<3; j++){
            now *= 10;
            now += s[i+j]-'0';
        }
        ans = min( abs(now-753), ans );
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

 int N,M,factn=1,factm=1,a,b,i,v;

 scanf("%d %d",&N,&M);
 
  for(i=N;i>=N-1;i--){
   factn=factn*i;
  };
  for(v=M;v>=M-1;v--){
   factm=factm*v;
  }; 
  
  printf("%d",(factn/2)+(factm/2));
  return 0;
  }

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <assert.h>

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define trace(x) cerr << #x << " = " << x << endl;



/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////////////////////////////////////////////
#define int long long

void solve(){

	int x , k , d;
	cin>>x>>k>>d;

	int av = abs(x);

	int moves = av/d;

	if(k >= moves){

		int val = av - moves*d;

		int rem = k - moves;
		if(rem&1){

			cout<<abs(val - d)<<endl;
			return;
		}
		cout<<val<<endl;
		return ;
	}

	int val = av - k*d;
	cout<<val<<endl;
}
signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t ; ++i)
        solve();
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	double X; cin >> X; X = (X/180) * M_PI;
	int K = 1;
	double x = 0, y = 1;
	double angle = X;
	while (abs(x) > 1e-6 || abs(y) > 1e-6) {
		x -= sin(angle);
		y += cos(angle);
		angle += X;
		if (angle > 2*M_PI) angle -= 2*M_PI;
		K++;
	}
	cout << K << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

// merging 2 given arrays with decending order
// merging is realized on array 'merged'
void merge(long a[], int na, long b[], int nb, long merged[]){
    int i = 0, j = 0;

    while(i < na || j < nb){
        if(j >= nb || (i < na && a[i] > b[j])){
            merged[i+j] = a[i];
            i++;
        }
        else{
            merged[i+j] = b[j];
            j++;
        }
    }
}

// sorting given array by merge sort
void merge_sort(long arr[], int narr){
    if(narr > 1){
        int m = narr /  2;
        int n = narr - m;

        long arr1[m], arr2[n];
        for(int i = 0; i < m; i++) arr1[i] = arr[i];
        for(int i = 0; i < n; i++) arr2[i] = arr[m+i];

        merge_sort(arr1, m);
        merge_sort(arr2, n);
        merge(arr1, m, arr2, n, arr);
    }
}

int main(){
    long tmp;
    int X, Y, Z, K;

    scanf("%d %d %d %d", &X, &Y, &Z, &K);

    long As[X], Bs[Y], Cs[Z];

    for(int i = 0; i < X; i++){
        scanf("%ld", &tmp);
        As[i] = tmp;
    }
    for(int i = 0; i < Y; i++){
        scanf("%ld", &tmp);
        Bs[i] = tmp;
    }
    for(int i = 0; i < Z; i++){
        scanf("%ld", &tmp);
        Cs[i] = tmp;
    }

    long ABs[X*Y];

    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            ABs[i*Y+j] = As[i] + Bs[j];
        }
    }

    merge_sort(ABs, X*Y);

    int lim = min(X*Y, K);
    long fin[lim*Z];
    
    for(int i = 0; i < lim; i++){
        for(int j = 0; j < Z; j++){
            fin[i*Z+j] = ABs[i] + Cs[j];
        }
    }

    merge_sort(fin, lim*Z);

    for(int i = 0; i < K; i++){
        printf("%ld\n", fin[i]);
    }

    return 0;
}

Measured memory_bytes: 78464
a = list(map(int, input().split()))
kiroku = []
for i in range(min(a[0], a[1])):
    if max(a[0], a[1])%(i+1) == 0 and min(a[0], a[1])%(i+1) ==0:
        kiroku.append(i+1)
print(kiroku[-a[2]])


Measured memory_bytes: 2940
a,b,c,d,e = input().split()

if int(a) == 0:
    print(1)
elif int(b) == 0:
    print(2)
elif int(c) == 0:
    print(3)
elif int(d) == 0:
    print(4)
elif int(e) == 0:
    print(5)

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

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define si(x) int((x).size())
#define mp make_pair
#define a first
#define b second

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef long long ll;

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}

const ll inf=1e17;

const int nmax=3.1e6;
int n;
ll m,t;
ll x[nmax];

ll dp[nmax];

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

	cin>>n>>m>>t;
	x[0]=0;
	rng(i,1,n+1)
		cin>>x[i];

	dp[0]=0;
	int j=0;
	ll w=inf;
	rng(i,1,n+1){
		while((x[i]-x[j+1])*2>t){
			chmin(w,dp[j]-2*x[j+1]);
			j++;
		}
		dp[i]=min(w+2*x[i],dp[j]+t);
	}
	cout<<dp[n]+m<<'\n';
}


Measured memory_bytes: 5120
from fractions import gcd
a,b,c,d = map(int,input().split())
#cnt = 0
#lst = [i for i in range(a,b+1) if i%c!=0 and i%d!=0]
#print(len(lst))

c_d = int(c*d/gcd(c,d))
a -= 1
c2 = (b//c) - (a//c)
d2 = (b//d) - (a//d)
cd = (b//(c_d)) - (a//(c_d))
print(b-a - (c2+d2-cd))
#print(b-a-(b//c+b//d - a//c+a//d  - b//c_d - a//c_d))
"""
a-=1
a2 = a//c + a//d - a//(c*d)
print(b-a-(b//c + b//d - b//(c*d) - a2))
"""
"""
for i in range(a,b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
print(cnt)
"""

Measured memory_bytes: 5048
fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<u64>();
    let mut b = read_vec::<u64>();
    let mut c = read_vec::<u64>();

    a.sort();
    c.sort();

    let mut ret = 0;
    for j in 0..n {
        let i = upper_bound(&a, b[j]-1);
        let k = upper_bound(&c, b[j]);
        ret += i * (n-k);
    }
    println!("{}", ret);
}

fn upper_bound(v: &Vec<u64>, k: u64) -> usize {
    let mut low = 0;
    let mut high = v.len();
    while low < high {
        let mid = (low + high) / 2;
        if v[mid] <= k {
            low = mid + 1;
        } else {
            high = mid;
        }
    }
    low
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int p, q, r;
    cin >> p >> q >> r;

    cout << min({
        p + q,
        q + r,
        p + r
    }) << endl;

    return 0;
%>

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let maxn = 1000010;
    let mut ki: Vec<(usize, usize)> = vec![(0, 0); maxn];
    let mut gu: Vec<(usize, usize)> = vec![(0, 0); maxn];
    for i in 0..maxn {
        ki[i].1 = i;
        gu[i].1 = i;
    }
    for i in 0..n {
        let po: usize = read();
        if i % 2 == 0 {
            ki[po].0 += 1;
        } else {
            gu[po].0 += 1;
        }
    }
    ki.sort();
    gu.sort();
    let l = maxn - 1;
    if ki[l].1 != gu[l].1 {
        println!("{}", n - ki[l].0 - gu[l].0);
    } else {
        println!(
            "{}",
            n - std::cmp::max(ki[l].0 + gu[l - 1].0, ki[l - 1].0 + gu[l].0)
        );
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 39164
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int r = sc.nextInt();
	int D = sc.nextInt();
	int x2000 = sc.nextInt();
	int rr = x2000;
	for(int i=2001;i<=2010;i++){
	    rr = r * rr - D;
	    if(i!=2010) System.out.println(rr);
	    else System.out.print(rr);
	}
    }
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string ret,s;
	while(cin>>s) ret+=toupper(s[0]);
	cout << ret << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

#ifdef ZERO_IQ
ios_base::sync_with_stdio ( false ), cin.tie ( 0 ), cout.tie ( 0 );
#endif

long long const mod = 1e9 + 7;

map<ll, ll> primefactorization(ll n) {
    map<ll, ll> primefactors;
    while (n % 2 == 0) {
        primefactors[2]++;
        n /= 2;
    }
    for (int i = 3; i <= sqrt(n); ++i) {
        while (n % i == 0) {
            primefactors[i]++;
            n /= i;
        }
    }
    if (n > 1)primefactors[n]++;
    return primefactors;
}


ll fp(ll base, ll exp) {
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        ll q;
        cin >> q;
        v.push_back(q);
    }
    if (n == 1) {
        return cout << 1, 0;
    }
    map<ll, ll> final;
    for (int j = 0; j < n; ++j) {
        map<ll, ll> fakeone = primefactorization(v[j]);
        for (auto i:fakeone) {
            final[i.first] = max(final[i.first], i.second);
        }
    }
    ll res = 1;
    for (auto i:final) {
        for (int j = 0; j < i.second; ++j) {
            res = ((res % mod) * (i.first % mod)) % mod;
        }
        //cout<<i.first<<" "<<i.second<<endl;
    }
    //cout<<res<<endl;
    ll outt=0;
    for (int k = 0; k < n; ++k) {
         outt=((outt%mod)+((res%mod)*(fp(v[k],mod-2)))%mod)%mod;
    }
    cout<<outt;

    return 0;
}

Measured memory_bytes: 896
#import numpy as np
import sys
#from collections import deque
#import copy


def xnxn(n=0, flag="v"):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            if flag == "l":
                return temp
            else:
                return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


x, y = xnxn()

for i in range(x + 1):
    if 2 * i + 4 * (x - i) == y:
        print("Yes")
        sys.exit()

print("No")


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

int N, A, B, C, *L;

// return MP
int dfs(int depth, int a, int b,int c) {
		if (depth == N) {
				if (min(min(a,b),c) > 0) return abs(A-a) + abs(B-b) + abs(C-c) - 30;
				else return 1000000000;
		}
		int du = dfs(depth+1, a, b, c);
		int ua = dfs(depth+1, a+L[depth], b, c) + 10;
		int ub = dfs(depth+1, a, b+L[depth], c) + 10;
		int uc = dfs(depth+1, a, b, c+L[depth]) + 10;
		return min(min(min(du, ua), ub), uc);
}

int main() {
		cin >> N >> A >> B >> C;
		L = new int[N];
		for (int i=0; i<N; i++) {
				cin >> L[i];
		}
		cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		if(i%2==1)
			cnt+=a[i];
	}
	ll ans[n]{};
	ans[0]=sum-2*cnt;
	for(ll i=1;i<n;i++)
	{
		ans[i]=2*a[i-1]-ans[i-1];
	}
	for(ll i=0;i<n;i++)
		cout<<ans[i]<<" ";
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 5184
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

int main() {
	char ch;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < 3; i++) {
		cin >> ch;
		if (ch == 'a') a++;
		else if (ch == 'b') b++;
		else c++;
	}
	if (a == 0 || b == 0 || c == 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define fi first
#define se second

const int N = 2000+10;
int n,z,w;
int a[N];
int b[N][N], s[N][N];
int dp[N][N], m1[N], m2[N];

int main(){
    cin>>n>>a[0]>>a[1]; n+=2;
    REP(i,2,n-1) cin>>a[i];
    /*
    dpmax[p1][p2][re] = max dpmin[p2+k][p2][re-k], k=1~re
    dpmin[p1][p2][re] = min dpmax[p1][p1+k][re-k], k=1~re
    dpmax2[p1][p2] = dpmax[p1][p2][n-p2-1] (p1<p2)
                   = max dpmin[p2+k][p2][n-p2-1-k], k=1~n-p2-1
                   = max dpmin2[p2+k][p2], k=1~n-p2-1
                   = max dpmin2[p][p2], p=p2+1~n-1
    dpmin2[p1][p2] = dpmin[p1][p2][n-p1-1] (p1>p2)
                   = min dpmax2[p1][p], p=p1+1~n-1
    m1[p2] = max dpmin2[p][p2], p=p2+1~n-1
    m2[p1] = min dpmax2[p1][p], p=p1+1~n-1
    re=0 => dpmax=dpmin=abs(a[p1]-a[p2]);
    ans=dpmax[0][1][n-2]
    */
    //FOR(i,n) b[i][0]=b[0][i]=s[i][0]=s[0][i]=abs(a[i]-a[0]);
    FOR(i,n) m2[i]=2100000000, m1[i]=-1;
    REPD(i,n-1,0)REPD(j,n-1,0){
        if(i==n-1||j==n-1){
            dp[i][j]=abs(a[i]-a[j]);
            if(i>j) m1[j]=max(m1[j],dp[i][j]);
            if(i<j) m2[i]=min(m2[i],dp[i][j]);
        }
        else{
            if(i<j){
                // max dpmin2[p][p2], p=p2+1~n-1
                dp[i][j]=m1[j];
                m2[i]=min(m2[i],dp[i][j]);
            }
            if(i>j){
                dp[i][j]=m2[i];
                m1[j]=max(m1[j],dp[i][j]);
            }
        }
        //printf("#%d %d\n",i,j);
        //FOR(ii,n){FOR(jj,n) printf("%4d ",dp[ii][jj]); puts("");}
    }
    cout<<dp[0][1]<<endl;
    return 0;
}


Measured memory_bytes: 16640
def main():
    n,m,q = map(int,input().split())

    l = [list(map(int,input().split())) for i in range(q)]
    ans = 0

    def count(a):
        score = 0
        for i in range(q):
            if a[l[i][1]-1] - a[l[i][0]-1] == l[i][2]:
                score += l[i][3]
        return score

    def dfs(x,now,s):
        if x == n:
            return count(s)
        score = 0
        for i in range(now,m+1):
            s.append(i)
            score = max(score,dfs(x+1,i,s))
            s.pop()
        return score
    print(dfs(0,1,[]))

if __name__ =="__main__":
    main()

Measured memory_bytes: 9272
def rotate(k, p):
    q=[]
    print('90' if k==1 else('180' if k==2 else '270'))
    for i in range(8):
        t=''
        for j in range(8)[::-1]:
            print(p[j][i], end='')
            t+=p[j][i]
        q.append(t)
        print()
    return q

p= [input() for _ in range(8)]
for i in range(1, 4):
    p= rotate(i, p)

Measured memory_bytes: 7432
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    int n;
    ll ans = 0;
    cin>>n;
    vector<bool> stone(n+4);
    ll lastred =0;
    vector<ll> red;
    rep(i,n)
    {
        char c;
        cin>>c;
        if(c=='R')
        {
            stone[i]=false;
            lastred = i;
            red.push_back(i);
        }
        else stone[i]=true;

    }

    sort(red.begin(),red.end(),greater<ll>());
    auto itr = red.begin();
    for(int i=0;i<n;i++)
    {
        if(stone[i]==true)
        {
           if(itr!=red.end())
           {
               if(*itr>i)
               {
                    swap(stone[i],stone[*itr]);
                    itr ++;
                    ans ++;
               }
           }


            
            
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4988
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int N, K; cin >> N >> K;
  int l[51];
  for(int i = 0;i < N; ++i){
    cin >> l[i];
  }
  
  sort(l, l + N, greater<int>());
  int score;
  for(int i = 0; i < K; ++i){
    score += l[i];
  }
  cout << score << endl;
}

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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int n,k;
    cin >> n >> k;
    int count = k;
    REPS(i,n-1){
        count *= (k-1);
    }
    cout << count << endl;



    

    return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

class union_find{
	private:
	vector<int> parent,rank,gs;
    int size;
	public:
    int count_group;
    union_find()=default;
    union_find(int n){ init(n); }

    void init(int n){
		size=n;
		count_group=n;
		parent.resize(size);
		rank.assign(size,0);
        gs.assign(size,1);
		for(int i=0; i<size; ++i) parent[i]=i;
	}

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

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
            gs[y]+=gs[x];
		} else {
			parent[y]=x;
            gs[x]+=gs[y];
			if(rank[x]==rank[y]) ++rank[x];
		}
		--count_group;
	}

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

    int group_size(int x){
        return gs[find(x)];
    };
};

void solve(){
    int N,M;
    cin >> N >> M;
    vector<int> p(N);
    rep(i,0,N){
        cin >> p[i];
        --p[i];
    }
    
    union_find uf(N);
    vector<int> x(M),y(M);
    vector<bool> ok(N);
    rep(i,0,M){
        cin >> x[i] >> y[i];
        --x[i];
        --y[i];
        uf.unite(x[i],y[i]);
    }
    
    int ans=0;
    rep(i,0,N) if(uf.is_same_group(i,p[i])) ++ans;

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
bool isAns = false;
char c = 0;
template<class F>
auto  maximize(int imin,int imax,const F &f){
    while(imax - imin > 1){
        int mid = imin + (imax - imin)/2;
        if(f(mid)) imin = mid;
        else imax = mid;
        if(isAns) return 0;
    }
    return imin;
}

signed main(){
    cin >> N; printf("0\n");
    cout.flush();
    string s; cin >> s;
    c = s.front();
    if(c == 'V'){
        return 0;
    } else {
        auto f = [&](int mid){
            printf("%d\n",mid);cout.flush();
            string s; cin >> s;
            char temp = s.front();
            if(temp == 'V'){ isAns = true ;return true;}
            if(mid % 2 == 0 and c == temp) return true;
            if(mid % 2 == 1 and c != temp) return true;
            return false;
        };
        int val = maximize(1,N,f);
        cout << val << endl; cout.flush();
        cin >> s;
    }
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    ll ans = k;
    reps(i, 1, n) {
        ans *= k - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int T,a[10];
void solve(){
    for(int i=0;i<(1<<10);i++){
        int pre1=0,pre2=0,flag=1;
        for(int j=0;j<10;j++){
            if((1<<j)&i){
                if(a[j]<pre1){flag=0;break;}
                pre1=a[j];
            }else{
                if(a[j]<pre2){flag=0;break;}
                pre2=a[j];
            }
        }if(flag){puts("YES");return;}
    }puts("NO"); return;
}
int main(){
    scanf("%d",&T);
    while(T--){
        for(int i=0;i<10;i++)scanf("%d",a+i);
        solve();
    }return 0;
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int c[100001];
int n, a;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    FOR(i, 1, n){
        read(a);
        c[a]++;
    }
    int ans=0;
    FOR(i, 1, 99999) ans=max(ans, c[i]+c[i-1]+c[i+1]);
    writeln(ans);
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
struct edge {
	int to, cost;
};

int a[100006];
int kj[200005], kji[200005];
int modpow(int a, int x, int mod) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod;
		x >>= 1;
	}
	return res;
}
int comb(int r, int c) {
	if (r < c)return 0;
	return kj[r] * kji[c] % mod*kji[r - c] % mod;
}

signed main() {
	int n, k; cin >> n >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	kj[0] = 1;
	for (int i = 1; i <= 200002; i++)kj[i] = kj[i - 1] * i%mod;
	rep(i, 200003)kji[i] = modpow(kj[i], mod - 2, mod);
	int s1 = 0, s2 = 0;
	rep(i, n) {
		s2 += (mod + a[i])*comb(i, k - 1) % mod;
		s2 %= mod;
	}
	rep(i, n) {
		s1 += (mod + a[i])*comb(n - i - 1, k - 1) % mod;
		s1 %= mod;
	}
	cout << (s2 + mod - s1) % mod << endl;
}

Measured memory_bytes: 4096
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    double n, x, t;
    cin >> n >> x >>t;
    int burnNum = ceil(n / x);
    int time = burnNum * t;
    cout << time << endl;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#include <random>  
#include <ctime>
#define pb push_back
#define x first
#define y second
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
using namespace std;

template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
typedef long long base;
typedef pair <int, int> point;


const string FILENAME = "input";
const int MAXN = 1e5 + 10;

typedef long double ld;

struct line {
	ld a, b, c;
	line(ld A = 0, ld B = 0, ld C = 0) {
		a = A, b = B, c = C;
	}
};

struct linek {
	ld a, k;
	linek() {}
	linek(line A) {
		a = A.c / -A.b;
		k = A.a / -A.b;
		//cout << a << '_' << k << endl;
	}
};

long long n, k;
long long ans = 0;

vector <line> arr;
vector <pair <int, linek>> res[2];

ld cross(linek a, linek b) {
	//a.k * x + a.a = b.k * x + b.a;
	return (b.a - a.a) / (a.k - b.k);
}

ld X;

bool cmp(pair <int, linek> a, pair <int, linek> b) {
	return a.y.k * X + a.y.a < b.y.k * X + b.y.a;
} 

struct fen {
	int arr[100001];
	fen() {

	}

	void reset() {
		for (int i = 0; i < n; ++i) {
			arr[i] = 0;
		}
	}

	void change(int i) {
		while (i < n) {
			++arr[i];
			i |= (i + 1);
		}
	}

	int get(int i) {
		int ans = 0;
		while (i > 0) {
			ans += arr[i];
			i = (i & (i + 1)) - 1;
		}
		return ans;
	}
};

fen box;

ld get(vector <pair <int, linek>> res) {
	X = -1e13;
	sort(res.begin(), res.end(), cmp);
	long long k = ((n * (n - 1) / 2)) / 2;
	for (int i = 0; i < n; ++i) {
		res[i].x = i;
		//k += abs(i - (n - 1 - i));
	}
	ld L = -1e13, R = 1e13;
	//cout << "?" << k << endl;
	for (int i = 0; i < 75; ++i) {
		ld M = (L + R) / 2;
		//if (i == 0) M = -0.999999;
		X = M;
		sort(res.begin(), res.end(), cmp);
		long long d = 0;
		box.reset();
		for (int j = 0; j < n; ++j) { 
			//if (i == 0) cout << res[j].x << ' ';
			d += box.get(res[j].x);
			box.change(res[j].x);
		}
		//if (i == 0) cout << "!" << d << endl;
		if (d <= k) {
			R = M;
		} else {
			L = M;
		}
	}
	return (L + R) / 2;
}

int main() {
	ios::sync_with_stdio(0);
	srand(time(0));
	//read(FILENAME);
	cin >> n;
	arr.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> arr[i].a >> arr[i].b >> arr[i].c;
		arr[i].c *= -1;
		res[0].pb({0, linek(arr[i])});
		swap(arr[i].a, arr[i].b);
		res[1].pb({0, linek(arr[i])});
	}
	cout << setprecision(9) << fixed << get(res[0]) << ' ' << get(res[1]) << endl;
}











Measured memory_bytes: 12116
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

  int N;
  cin >> N;
  vector<long double> seq(N);
  long double num = 1;
  for (int i = 0; i < N; i++) {
    cin >> seq[i];
    num *= seq[i];
  }

  long double den = 0;
  for (int i = 0; i < N; i++) {
    den += num / seq[i];
  }

  long double ans = num / den;
  cout << setprecision(52) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    long double r;
    cin>>r;
    cout<<setprecision(5)<<fixed<<2*acos(-1.0)*r<<"\n";
    return 0;
}



Measured memory_bytes: 3772