akhauriyash/Code-Regression huggingface dataset:
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define repl(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef unsigned long long ull;
//typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const ll N=(ll)(1e6+1);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
ll inv(int x){return binpow(x, MOD - 2);}
ll divide(ll x, ll y){return mul(x, inv(y));}
ll fact[N];
void precalc(){fact[0] = 1;for(ll i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
ll C(ll n, ll k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================


int main() {
//#ifdef _DEBUG
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
double n,x,t;
cin>>n>>x>>t;
double v=ceil(n/x);
//1cout<<v<<endl;
int ans=v*t;
cout<<ans<<endl;
}


Measured memory_bytes: 3764
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;

ll A[N],S[N],f[N][2],g[N][2],res,tmp;
int n,k;

int main(){
	n=IN();k=IN();
	For(i,1,n+1){
		A[i]=IN();
		S[i]=S[i-1]+A[i];
	}
	for (int i=1;i<=n;i++){
		f[i][0]=f[i][1]=max(f[i-1][0],f[i-1][1]);
		f[i][1]+=A[i];
	}
	for (int i=n;i>=1;i--){
		g[i][0]=g[i][1]=max(g[i+1][0],g[i+1][1]);
		g[i][1]+=A[i];
	}
	for (int i=k;i<=n;i++){
		tmp=max(tmp,f[i-k][0]-S[i-k]);
		res=max(res,tmp+g[i+1][0]+S[i]);
	}
	tmp=0;
	for (int i=k;i<=n;i++){
		tmp=max(tmp,f[i-k][1]);
		res=max(res,tmp+g[i+1][1]);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push
#define fi first
#define se second
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long int unsigned lliu;
typedef long long int lli;
typedef pair<lli,lli> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

int main(){__
    lli a, b;
    cin>>a>>b;
    if(a==1 || b==1)
        cout<<"1\n";
    else
    {
        cout<<(a*b+1)/2<<"\n";
    }
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define int long long
#define u64 unsigned long long
#define reg register
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=G.Head[x]; i; i=G.Nxt[i])

inline int Read() {
    int res = 0, f = 1;
    char c;
    while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
    do res = (res << 3) + (res << 1) + (c ^ 48);
    while (c = getchar(), c >= 48 && c <= 57);
    return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
    return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
    return a < b ? a = b, 1 : 0;
}

const int N = 3e5 + 5, M = 9e5 + 5;

int n, m, A[N], Ans, flag;

main() {
    n = Read(), m = Read();
    cout << (n + 2 * m) / (2 * m + 1);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
	int s[1001],i,n;
	long int sum=0;
	double sd,bs,mean;
	while(1){
		scanf("%d",&n);
		if(!n) break;
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
			sum+=s[i];
		}
		mean=(double)sum/n;
		bs=0;
		for(i=0;i<n;i++){
			bs+=pow(s[i]-mean,2);
		}
		sd=sqrt((double)bs/n);
		printf("%.8lf\n",sd);
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 310
using namespace std;
int n,m,l,q;
int a[N][N]={};
int dis[N][N]={},f[N][N]={};
int read(){int s=0,w=1;char c=getchar();while((c<'0'||c>'9')&&c!='-')c=getchar();if(c=='-')w=-1,c=getchar();while(c<='9'&&c>='0')s=(s<<3)+(s<<1)+c-'0',c=getchar();return s*w;}

int main()
{
    n=read();m=read();l=read();
    for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)dis[i][j]=f[i][j]=(int)0x3f3f3f3f3f3f3f3f;
    for(int i=1;i<=n;++i)dis[i][i]=f[i][i]=0;
    for(int i=1;i<=m;++i)
    {
        int x=read(),y=read(),z=read();
        f[x][y]=min(f[x][y],z);f[y][x]=min(f[y][x],z);
    }
    for(int k=1;k<=n;++k)
     for(int i=1;i<=n;++i)
      for(int j=1;j<=n;++j)
       f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
    for(int i=1;i<=n;++i)
     for(int j=1;j<=n;++j)
      if(i!=j&&f[i][j]<=l)dis[i][j]=min(dis[i][j],1);
    for(int k=1;k<=n;++k)
     for(int i=1;i<=n;++i)
      for(int j=1;j<=n;++j)
       dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
    q=read();
    for(int i=1;i<=q;++i)
    {
        int x=read(),y=read();
        printf("%d\n",dis[x][y]<(int)0x3f3f3f3f3f3f3f3f?dis[x][y]-1:-1);
    }
    return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> vec(m);
  rep(i,m) scanf("%d", &vec[i]);

  vector<bool> used(n+1, false);
  for(int i=m-1; i>=0; i--){
    if(!used[vec[i]]) printf("%d\n", vec[i]);
    used[vec[i]]=true;
  }
  for(int i=1; i<=n; i++) if(!used[i]){
    printf("%d\n", i);
  }

  return 0;
}

Measured memory_bytes: 3420
#include<stdio.h>

int n,S[10000000];


void maxHeapify(int i){
  int l, r,x,largest;

  l = left(i);
  r = right(i);
    if(l <= n && S[l] > S[i]){
    largest = l;
  }
  else largest = i;
  if(r <= n && S[r] > S[largest]){
    largest = r;
  }
  if(largest != i){
    x = S[i];
    S[i] = S[largest];
    S[largest] = x;
    maxHeapify(largest);
  }
  
}



int parent(int i){
  return i/2;
}
int left (int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
  
int main(){
  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&S[i]);
  }

  for(i=n/2; i >= 1 ;i--){
    maxHeapify(i);
  }




  
  for(i=1;i<=n;i++){
    printf(" %d",S[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

 

void solve()
{	
    ll n;
    cin>>n;
    char a[10];
    ll ac=0,wa=0,tl=0,re=0;
    for(ll i=0;i<n;i++){
        cin>>a;
        if(a[0]=='A') ac++;
        if(a[0]=='W') wa++;
        if(a[0]=='T') tl++;
        if(a[0]=='R') re++;

    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tl<<endl;
    cout<<"RE x "<<re<<endl;
}
     
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    //cout<<"helo";
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        if (ctr==14) cout<<1;
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 3804
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
  
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}


Measured memory_bytes: 3216
import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val keyword = Set("the", "this", "that")

    def decrementString(line: String): String = line.map {
      case ch if 'b' to 'z' contains ch => (ch - 1).toChar
      case ch if ch == 'a' => 'z'
      case ch => ch
    }

    @tailrec
    def go(line: String): String = {
      if (line.split(" ").exists(keyword.contains)) {
        line
      } else {
        go(decrementString(line))
      }
    }

    val sc = new java.util.Scanner(System.in)
    while (sc.hasNextLine) {
      println(go(sc.nextLine))
    }
  }
}

Measured memory_bytes: 47424
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int s;
	int c;
}pair_t;

int cmp(const void* p, const void* q) {
	return ((pair_t*)p)->s - ((pair_t*)q)->s;
}

int main(void) {
	int n,m;
	pair_t pair[10] = { 0 };
	int ans[6] = { 0 };
	int flag = 1;
	
	scanf("%d %d", &n,&m);

	for (int i = 0; i < m; i++) {
		scanf("%d %d", &pair[i].s,&pair[i].c);
	}
	
	qsort(pair, m, sizeof(pair_t), cmp);
	
	if(n>1)ans[1] = 1;
	for (int i = 0; i < m; i++) {
		if (pair[i].s == pair[i + 1].s && pair[i].c != pair[i + 1].c)
			flag = 0;
		ans[pair[i].s] = pair[i].c;
	}
	if (flag == 0 || ans[1] == 0) {
		if (flag == 0 || n > 1)printf("-1");
		else printf("0");
	}
	else {
		for (int i = 1; i <= n; i++)printf("%d", ans[i]);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  now, num, N, K, M, ans;
string S, s[100];
bool h,w[10], k[100];
char cc;


int main() {
	cin >> N>>M>>K;
	if (N > M) {
		if (N > K) {
			cout << N*10+M+K << endl;
		}
		else {
			cout << K * 10 + M + N << endl;
		}
	}
	else {
		if (M > K) {
			cout << M * 10 + N + K << endl;
		}
		else {
			cout << K * 10 + M + N << endl;
		}
	}
	return 0;

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <typename T>
using Edges = vector<Edge<T>>;
template <typename T>
using AdjList = vector<Edges<T>>;

template <typename T>
class Dijkstra {
    private:
        T INF = numeric_limits<T>::max() / 10;
        int V;           // 頂点数
        AdjList<T> adj;  // adj[始点][動的配列で始点から伸びる枝]
        vector<int> prever;

    public:
        Dijkstra(int n);
        vector<T> cost;
        void AddEdge(int f, int t, int c);
        bool HasPath(int t);                 // tに至るパスはあるか
        vector<int> GetShortestPath(int t);  // tへの最短路
        void Run(int f);
};

template <typename T>
Dijkstra<T>::Dijkstra(int n) : 
    V(n + 1), adj(V), prever(vector<int>(V, -1)), cost(V)
{
    fill(cost.begin(), cost.end(), INF);
}

template <typename T>
void Dijkstra<T>::AddEdge(int f, int t, int c) {
    adj[f].push_back(Edge<T>(t, c));
}

template <typename T>
bool Dijkstra<T>::HasPath(int t) {
    return cost[t] != INF;
}

template <typename T>
vector<int> Dijkstra<T>::GetShortestPath(int t) {
    vector<int> path;
    for (; t != -1; t = prever[t]) path.push_back(t);

    reverse(path.begin(), path.end());
    return path;
}

template <typename T>
void Dijkstra<T>::Run(int firstNode) {
    // 初期化
    cost.assign(V, INF);
    prever.assign(V, -1);

    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> pq;

    cost[firstNode] = 0;
    pq.push(Pi(cost[firstNode], firstNode));

    while (!pq.empty()) {
        Pi currentEdge = pq.top();
        pq.pop();
        if (cost[currentEdge.second] < currentEdge.first) continue;

        for (Edge<T> tmp : adj[currentEdge.second]) {
            T sumCost = currentEdge.first + tmp.cost;
            if (cost[tmp.to] > sumCost) {
                cost[tmp.to] = sumCost;
                prever[tmp.to] = currentEdge.second;
                pq.push(Pi(cost[tmp.to], tmp.to));
            }
        }
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n-1), b(n-1), c(n-1);

    REP(i, n-1) cin >> a[i] >> b[i] >> c[i];

    int q, k;
    cin >> q >> k;
    vector<int> x(q), y(q);
    REP(i, q) cin >> x[i] >> y[i];

    Dijkstra<LL> dij(n);
    REP(i, n-1){
        dij.AddEdge(a[i]-1, b[i]-1, c[i]);
        dij.AddEdge(b[i]-1, a[i]-1, c[i]);
    }
    
    dij.Run(k-1);
    REP(i, q){
        cout << dij.cost[x[i]-1] + dij.cost[y[i]-1] << endl;
    }

}


Measured memory_bytes: 13552
#pragma GCC optimize(200000)
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,p[1002],q[1002],mp[1002][1002];
inline int read(){
	int t=0;
	char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+v-'0';
		v=getchar();
	}
	return t;
}
inline void dfs(register int u,register int v){
	//cout<<u<<" "<<v<<endl;
//	if(u==n&&v>1)if(p[v-1]!=b)return;
	if(u==n+1){
	//	if(p[m]!=b)return;
		for(register int i=1;i<=n;++i){
			for(register int j=1;j<=m;++j){
				printf("%d",mp[i][j]);
			}putchar('\n');
		}
		exit(0);
	}
	if(min(u-1-p[v],p[v]+1)<=b&&min(u-1-p[v],p[v]+1)+n-u>=b&&min(v-1-q[u],q[u]+1)<=a&&min(v-1-q[u],q[u]+1)+m-v>=a){
	p[v]++;
    q[u]++;
		mp[u][v]=1;
		if(v==m){
			dfs(u+1,1);
		}
		else dfs(u,v+1);
		p[v]--;
		q[u]--;
	}
	if(min(u-p[v],p[v])<=b&&min(u-p[v],p[v])+n-u>=b&&min(v-q[u],q[u])<=a&&min(v-q[u],q[u])+m-v>=a){
		
		mp[u][v]=0;
		if(v==m){
			dfs(u+1,1);
		}
		else dfs(u,v+1);
	}
}
int main(){
	n=read();
	m=read();
	a=read();
	b=read();
	dfs(1,1);
	for(register int i=1;i<=n;++i){
			for(register int j=1;j<=m;++j){
				printf("%d",mp[i][j]);
			}putchar('\n');
		}
}

Measured memory_bytes: 41728
// c++include
#include <iostream>
#include <algorithm>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(ll i = 0; i < (n); i++)
typedef long long ll;


// main関数
int main(void) {
	ll n, k;
	vector<ll> h;

	cin >> n >> k;
	rpt(i, n) {
		ll a;
		cin >> a;
		h.push_back(a);
	}
	ll count = 0;
	rpt(i, n) {
		if (h[i] >= k)
			count++;
	}

	cout << count;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N,W;
ll INDEX[4],LAST;
ll table[4][105];
ll base_w;
vector<ll> V[4];

ll ans;

void recursive(ll index,ll sum,ll value){

	if(index == 4){

		//printf("sum:%lld value:%lld\n",sum,value);
		ans = max(ans,value);
		return;
	}

	//足さない
	recursive(index+1,sum,value);


	if(index == LAST){

		for(ll i = INDEX[index]-1; i >= 0; i--){
			if(sum+(base_w+index)*(i+1) > W)continue;

			ll add = table[index][i+1];
			recursive(index+1, sum+(base_w+index)*(i+1),value+add);
			return;
		}

	}else{

		for(ll i = 0; i < INDEX[index] && sum+(base_w+index)*(i+1) <= W; i++){

			ll add = table[index][i+1];
			recursive(index+1, sum+(base_w+index)*(i+1),value+add);
		}
	}
}


int main(){

	scanf("%lld %lld",&N,&W);

	for(int i = 0; i < 4; i++){

		INDEX[i] = 0;
	}

	ll tmp_w,tmp_v;

	scanf("%lld %lld",&base_w,&tmp_v);

	V[0].push_back(tmp_v);
	INDEX[0] = 1;
	LAST = 0;

	for(ll i = 1; i < N; i++){

		scanf("%lld %lld",&tmp_w,&tmp_v);
		V[tmp_w-base_w].push_back(tmp_v);

		INDEX[tmp_w-base_w]++;
		LAST = max(LAST,tmp_w-base_w);
	}

	for(int i = 0; i < 4; i++){
		if(V[i].size() == 0)continue;

		sort(V[i].rbegin(),V[i].rend());

		table[i][0] = 0;

		for(int k = 0; k < V[i].size(); k++){

			table[i][k+1] = V[i][k];
			table[i][k+1] += table[i][k];
		}
	}

	ans = -1;

	recursive(0,0,0);

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3832
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,M;
int A;
int B;
int main(){
	cin>>N>>M;
	bool D[10][10]={};
	for(int i=0;i<M;i++){
		cin>>A>>B;
		D[A][B]=true;
		D[B][A]=true;

	}
	bool P[9]={};
	int total=0;
	for(int i1=2;i1<N+1;i1++){
		if(!D[1][i1])continue;
		if(N==2){
			total+=1;
			continue;
		}
		P[i1]=true;
		for(int i2=2;i2<N+1;i2++){
			if(!D[i1][i2] || P[i2])continue;
			if(N==3){
				total+=1;
				continue;
			}
			P[i2]=true;
			for(int i3=2;i3<N+1;i3++){
				if(!D[i2][i3] || P[i3])continue;
				if(N==4){
					total+=1;
					continue;
				}
				P[i3]=true;
				for(int i4=2;i4<N+1;i4++){
					if(!D[i3][i4] || P[i4])continue;
					if(N==5){
						total+=1;
						continue;
					}
					P[i4]=true;
					for(int i5=2;i5<N+1;i5++){
						if(!D[i4][i5] || P[i5])continue;
						if(N==6){
							total+=1;
							continue;
						}
						P[i5]=true;
						for(int i6=2;i6<N+1;i6++){
							if(!D[i5][i6] || P[i6])continue;
							if(N==7){
								total+=1;
								continue;
							}
							P[i6]=true;
							for(int i7=2;i7<N+1;i7++){
								if(!D[i6][i7] || P[i7])continue;
								if(N==8){
									total+=1;
									continue;
								}
								P[i7]=true;
								for(int i8=2;i8<N+1;i8++){
									if(!D[i7][i8] || P[i8])continue;
									if(N==9){
										total+=1;
										continue;
									}
									P[i8]=true;

									P[i8]=false;
								}

								P[i7]=false;
							}

							P[i6]=false;
						}

						P[i5]=false;
					}

					P[i4]=false;
				}

				P[i3]=false;
			}

			P[i2]=false;
		}
		P[i1]=false;
	}

	cout<<total<<endl;

	return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    // 全部正か負にできれば累積和取れば良い
    let mut mn = 1 << 30;
    let mut mx = -(1 << 30);
    let mut mni = 0;
    let mut mxi = 0;
    for i in 0..n {
        if mn > a[i] {
            mn = a[i];
            mni = i;
        }
        if a[i] > mx {
            mx = a[i];
            mxi = i;
        }
    }

    let mut cnt = 0;
    let mut out = Vec::new();
    if mn == mx {
        println!("0");
        return;
    } else if mn.abs() > mx.abs() {
        for i in 0..n {
            if mni != i {
                cnt += 1;
                writeln!(out, "{} {}", mni + 1, i + 1).ok();
            }
        }
        for i in (1..n).rev() {
            cnt += 1;
            writeln!(out, "{} {}", i + 1, i).ok();
        }
    } else {
        for i in 0..n {
            if mxi != i {
                cnt += 1;
                writeln!(out, "{} {}", mxi + 1, i + 1).ok();
            }
        }
        for i in 1..n {
            cnt += 1;
            writeln!(out, "{} {}", i, i + 1).ok();
        }
    }
    println!("{}", cnt);
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	if (a + b > 2 * c) {
		ans += (2 * c)*min(x, y);
		if (x > y) {
			if (2 * c < a) ans += (2 * c)*(x - y);
			else ans += a*(x - y);
			cout << ans << endl;
		}
		else {
			if (2 * c < b) ans += (2 * c)*(y - x);
			else ans += b*(y - x);
			cout << ans << endl;
		}
	}
	else {
		ans += a*x + b*y;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;

int main() {
	int N;
	char s[5001];
	while(~scanf("%d", &N)) {
		scanf("%s", s);
		int len = strlen(s);
		vector<vector<mint>> dp(N + 1, vector<mint>(N + 2));
		dp[0][len] = 1;
		rep(i, N) rer(j, 0, N) {
			mint x = dp[i][j];
			if(x.x == 0) continue;
			dp[i + 1][j + 1] += x + x;
			if(j == 0) dp[i + 1][j] += x;
			else dp[i + 1][j - 1] += x;
		}
		mint ans = dp[N][0];
		printf("%d\n", ans.get());
	}
	return 0;
}


Measured memory_bytes: 98176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int N;
	cin >> N;
	vector<P> vec(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> vec[i].first >> vec[i].second;
	}
	sort(vec.begin(), vec.end());
	cout << vec[N - 1].first + vec[N - 1].second << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int c=0;
  for(int i=0;i<k;i++){
    c+=a.at(i);
  }
  cout<<c;
}

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

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

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    int a,b,k;
    cin >> a >> b >> k;
    int cnt = 0;
    for(int i = max(a,b); i >= 1; i--){
        if(a % i == 0 && b % i == 0){
            cnt++;
        }
        if(cnt == k){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, k;
    cin>>n>>k;
    set<ll> s;
    ll d, a;
    rep(i,k){
        cin>>d;
        rep(i,d){
            cin>>a;
            s.insert(a);
        }
    }
    cout<<n-s.size()<<endl;
}

Measured memory_bytes: 3556
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    if(N / 100 == 7 || (N % 100) / 10 == 7 || N % 10 == 7) {
        write("Yes");
    }
    else {
        write("No");
    }
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 3596
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
A = list(map(int,read().split()))
S = sum(A)
answer = 10 ** 10
for a,b in itertools.combinations(A,2):
    S1 = a + b
    S2 = S - S1
    x = abs(S1 - S2)
    if answer > x:
        answer = x
print(answer)


Measured memory_bytes: 5620
//Bismillahir rahmanir Rahim
//sajeedreefy
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    long long int n,x,s,i,sum=0;
 
    string st;
    cin >> st;
    s=st.size();
    if(st[0]=='48' && s==1)
    {
        cout << "Yes\n";
        return 0;
    }
    for(i=0;i<s;i++)
    {
       sum=sum+(st[i]-48);
    }
    if(sum%9==0)
    {
        cout << "Yes\n";
    }
    else if(sum%9!=0)
    {
        cout << "No\n";
    }
    return 0;
}
 

Measured memory_bytes: 3744
#include<stdio.h>
int main(void){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0){
            break;
        }else if(x<y){
            // x = x*y;
            // y = x/y;
            // x = x/y;
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
        
    }
    // scanf("%d %d", &x, &y);
    // while(x!=0 && y!=0){
    //     if(x > y){
    //         x = x*y;
    //         y = x/y;
    //         x = x/y;
    //     }
    //     printf("%d %d\n", x, y);
    //     scanf("%d %d", &x, &y);
    // }
    return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll mod=1000000007;

int main(){
  int a,b,c; cin>>a>>b>>c;
  int ans=a*100+b*10+c;
  if(ans%4==0)
  puts("YES");
  else
  puts("NO");

  return 0;
}


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

int main(){
    inti(N);
    long long a=0;
    rep(i,N) a+=i;
    cout << a;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, m;
  scanf("%d %d", &n, &m);
  int a[n][m], b[m], c[n];

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

  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      scanf("%d", &a[i][j]);
    }
  }

  for(int j=0; j<m; j++){
    scanf("%d", &b[j]);
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      c[i] += a[i][j]*b[j];
    }
    printf("%d\n", c[i]);
  }

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int n;
double ans;
pair<double,double> a[10];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  vector<int> v;
  for (int i = 0; i < n; i++) v.push_back(i);
  do {
    for (int i = 1; i < n; i++) {
      pair<double,double> f = a[v[i]], t = a[v[i-1]];
      double x = f.first - t.first;
      double y = f.second - t.second;
      ans += sqrt(x * x + y * y);
    }
  } while (next_permutation(v.begin(),v.end())); 
  for (int i = n; i >= 1; i--) ans /= i;
  cout << setprecision(20) << ans << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	string s;
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2])
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long X = long.Parse(Console.ReadLine());
            long l = X / 500;
            long p = (X % 500) / 5;
            Console.WriteLine(l*1000 + p*5);
        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int n,m;
char s[100000],t[100000];

int gcd(int x,int y){
    if(x>y){
        x+=y;
        y=x-y;
        x-=y;
    }if(x==0) return y;
    return gcd(y%x,x);
}

int main(){
    cin>>n>>m;
    int g=gcd(n,m);
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<m;i++)cin>>t[i];
    n/=g; m/=g;
    for(int i=0;i<g;i++){
        if(s[n*i]!=t[m*i]){
            cout<<-1;
            return 0;
        }
    }
    cout<<(long long)n*m*g;
    return 0;
}


Measured memory_bytes: 512
N, A, B, C, D = list(map(int, input().split()))

judge = "null"
for i in range(N):
	mx = D * i - C * (N - 1 - i)
	mn = C * i - D * (N - 1 - i)
	if mx >= B - A and mn <= B - A:
		print("YES")
		judge = "yes"
		break

if judge == "null":
	print("NO")

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

int main(){
    int n,s;
    s=1;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++){
        cin >> a.at(i);
    }
    for (int i=0; !(s==2); ){
        i++;
        s=a.at(s-1);
        if(s==2){
            cout << i<< endl;
            break;
        }
        if(i==n){
            cout << -1<< endl;
            break;
        }
    }

}

Measured memory_bytes: 640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
xy = list(map(int,read().split()))

if(n==1):
    print(0)
    exit()

max_num = max(xy)
min_num = min(xy)

max_ind = -1
min_ind = -1
same = False
big = []
small = []
for i in range(n):
    x,y = xy[i*2:i*2+2]
    if(x>y):
        x,y = y,x

    if(x==min_num)&(y==max_num):
        same = True

    if(x==min_num):
        min_ind = i
    if(y==max_num):
        max_ind = i

    big.append(y)
    small.append(x)

#最大と最小を違う色に塗る
ans = (max(big)-min(big)) * (max(small) - min(small))
if(same):
    print(ans)
    exit()

#同じ色に塗る
r = max_num - min_num
if(xy[min_ind*2]==min_num):
    min_pair = xy[min_ind*2+1]
else:
    min_pair = xy[min_ind*2]

if(xy[max_ind*2]==max_num):
    max_pair = xy[max_ind*2+1]
else:
    max_pair = xy[max_ind*2]

nums = []
for i in range(n):
    if(i==min_ind)|(i==max_ind):
        continue
    x,y = xy[i*2:i*2+2]

    nums.append((x,i))
    nums.append((y,i))

nums.append((min_pair,min_ind))
nums.append((max_pair,max_ind))

nums.sort()

set0 = set(range(n))
set1 = set()
set2 = set()

left = 0
right = 0
while(right <= len(nums)):
    if(not set0):
        b = nums[right-1][0] - nums[left][0]
        ans = min(ans,r*b)

        l_ind = nums[left][1]
        if(l_ind in set2):
            set2.remove(l_ind)
            set1.add(l_ind)
        else:
            set1.remove(l_ind)
            set0.add(l_ind)

        left += 1

    else:
        if(right==len(nums)):
            break
        r_ind = nums[right][1]
        if(r_ind in set1):
            set1.remove(r_ind)
            set2.add(r_ind)
        else:
            set0.remove(r_ind)
            set1.add(r_ind)
        right += 1

print(ans)

Measured memory_bytes: 219344
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
const ll INF = 1e9;
//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);

int main(){
  faster();
  ll n,y,ans=0;
  cin >> n >> y;
  for(ll i=0;i<=n;i++)for(ll j=0;j<=n;j++){
      if(n < i+j) continue;
      if(y == 10000*i+5000*j+1000*(n-i-j)){
          cout << i << " " << j << " " << (n-i-j) << endl;
          return 0;
      }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}








































//以下、ライブラリ

void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} //ユークリッドの互除法

ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} //桁数取得

ll POW(auto x,auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} //べき乗計算

Measured memory_bytes: 256
#! python3
# coding:utf-8
 
def main():
    n = int(input())
    ans = [0 for _ in range(n)]
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                eq = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if eq < n+1:
                    ans[eq-1]+=1
    for i in ans:   
        print(i)

if __name__ == "__main__":
    main() 

Measured memory_bytes: 9092
#include <cstdio>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

//DFS with recursive function
void dfs_visit(int u){
    int v;
    color[u] = GRAY;
    d[u] = ++tt; //first visit time
    for (v=0; v<n; v++){
        if (M[u][v] == 0) continue;
        if (color[v] == WHITE){
            dfs_visit(v);
        }
    }

    color[u] = BLACK;
    f[u] = ++tt; //done visit time
}

void dfs(){
    int u;
    //initialization
    for (u=0; u<n; u++){
        color[u] = WHITE;
    }
    tt = 0;

    for (u=0; u<n; u++){
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (u=0; u<n; u++){
        printf("%d %d %d\n", u+1, d[u], f[u]);
    }
}

int main(){
    int u, v, k, i, j;

    scanf("%d", &n);
    for (i=0; i<n; i++){
        for (j=0; j<n; j++){
            M[i][j] = 0;
        }
    }

    for (i=0; i<n; i++){
        scanf("%d %d", &u, &k);
        u--;
        for (j=0; j<k; j++){
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;

}

Measured memory_bytes: 1064
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	s := readBytes()
	a := make([]int, 4)
	for i := range a {
		a[i] = int(s[i] - '0')
	}

	var rec func(ops []byte, accm int) (string, bool)
	rec = func(ops []byte, accm int) (string, bool) {
		if len(ops) == 3 {
			if accm != 7 {
				return "", false
			}
			return fmt.Sprintf("%d%c%d%c%d%c%d=7", a[0], ops[0], a[1], ops[1], a[2], ops[2], a[3]), true
		}
		i := len(ops) + 1
		res, ok := rec(append(ops, '+'), accm+a[i])
		if ok {
			return res, ok
		}
		return rec(append(ops, '-'), accm-a[i])
	}

	ans, _ := rec(nil, a[0])
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    ll N; cin >> N;
    ll ans = 0;
    for(ll i = 1; i*(i+1) < N; i++){
        if(N % i == 0) ans += N/i-1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, i;
    priority_queue<int> index;
    cin >> n >> m;
    for(i=0; i<n; i++){
        int input;
        cin >> input;
        index.push(input);
    }
    for(i=0; i<m; i++){
        int temp = index.top()/2;
        index.pop();
        index.push(temp);
    }
    int64_t res = 0;
    while(!index.empty()){
        res += index.top();
        index.pop();
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18

using namespace std;

bool ch(int i);
string s;
long long n;
int main(){
	cin >> s;
	for(int i=0; i<s.size(); i++){
		n+=s[i]-'0';
		n*=10;
	}
	n/=10;
	
	int max=s.size()*9;
	
	for(int i=max; i>=1; i--){
//cout<<i<<endl;
		if(ch(i)){ cout<<i<<endl; return 0; }
	}
	
	return 0;
}

bool ch(int i){
//cout<<i<<endl;	
	string t, t2;
	for(int j=0; j<i/9; j++) t+='9';
//cout<<"$"<<endl;	
	i -= (i/9)*9;
	char c='0'+i;
	t2=c; t2+=t;
//cout<<
	long long m=0;
	
	for(int j=0; j<t2.size(); j++){
		m+=t2[j]-'0';
		m*=10;
	}
	m/=10;
	
	if(m<=n) return 1;
	else return 0;
}


Measured memory_bytes: 256
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const adjLists = Array.from(Array(n), () => []);
  const d = [], f = [];
  lines.forEach((l, i) => l.split(' ').splice(2).forEach(e => adjLists[i].push(e-1)));
  dfs(adjLists, d, f);
  for (let i = 0; i < n; i++) {
    console.log(i + 1, d[i], f[i]);
  }
})();

function dfs(adjLists, d, f) {
  const WHITE = 0, GRAY = 1, BLACK = 2;
  const color = Array.from(adjLists, () => WHITE);

  let time = 0;
  function visit(u) {
    color[u] = GRAY;
    d[u] = ++time;
    adjLists[u].forEach(v => {
      if (color[v] === WHITE) visit(v);
    });
    color[u] = BLACK;
    f[u] = ++time;
  }
  adjLists.forEach((e, u) => {
    if (color[u] === WHITE) visit(u);
  });
}



Measured memory_bytes: 18020
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    string x,y;
	cin >> x>> y;
    string ans="=";
    if(x<y)ans="<";
    else if(x>y)ans = ">";
      cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int temp;
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		if(b > c){
			temp = b;
			b = c;
			c = temp;
		}
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		
		System.out.println(a + " " + b + " " + c);
	}
}

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

class DisjointSet {
	public :
		// rank??°???????????????
		vector<int> rank, p;
		DisjointSet() {};
		DisjointSet(int size) {
			rank.resize(size, 0);
			p.resize(size, 0);
			for (int i = 0; i < size; i++)
				makeSet(i);
		}
		void makeSet(int i) {
			p[i] = i;
			rank[i] = 0;
		}

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

		void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		void link(int x, int y) {
			// ??????x?????????????????´??????????°?y???????????¶??°x???
			if (rank[x] > rank[y])
				p[y] = x;
			else {
				p[x] = y;
				if (rank[x] == rank[y])
					rank[y]++;
			}
		}
		int findSet(int x) {
			if (x != p[x])
				p[x] = findSet(p[x]);
			return p[x];
		}
};
int main()
{
	int n, a, b,t, q;
	scanf("%d %d", &n, &q);
	DisjointSet ds = DisjointSet(n);
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d", &t, &a, &b);
		if (t == 0)
			ds.unite(a, b);
		else
			printf("%d\n", ds.same(a, b) ? 1 : 0);
	}
	return 0;
}

Measured memory_bytes: 3304
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A[] = new int[N];
		int count[] = new int[N];
		for (int i = 0 ; i < N ; i ++) {A[i] = scan.nextInt();}
		for (int j = 0 ; j < N ; j ++) {count[j] = 0;}
		for (int k = 0 ; k < N ; k ++) {
			while (A[k] % 2 == 0){A[k] /= 2 ; count[k]=count[k]+1;};}
		for (int l = 0 ; l < N-1 ; l ++) {
			if (count[l] < count[l+1]) {count[l+1] = count[l];};}
		System.out.println(count[N-1]);
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define VEC vector<int>v
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    FAST();

     int n,m,a,b,res=1000;
    cin>>m>>n;
    VEC;
    map<int,int>mp;

    if(n==0)
    {
        cout<<m<<endl;
        return 0;
    }
    for(int i=0; i<n; i++)
    {
        cin>>a;
        v.pb(a);
        mp[a]++;
    }

    for(int i=0; i<n; i++)
    {
        a=v[i]-1;
        if(mp[a]==0)
        {

            if(abs(a-m)<res)
            {
                res=abs(a-m);
                b=a;
            }


        }
        a=v[i]+1;
        if(mp[a]==0)
        {
            if(abs(a-m)<res)
            {
                res=abs(a-m);
                b=a;
            }

        }


    }
    cout<<b<<endl;

}



Measured memory_bytes: 3660