akhauriyash/Code-Regression huggingface dataset:
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int a, b, c;
    cin >> a >> b >> c;

    if ((a == b && b != c) || (b == c && c != a) || (c == a && a != b))
        print("Yes\n");
    else
        print("No\n");
        
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
  	cin >> s;
    if (s[s.size() - 1] == 's') {
        s.push_back('e');
      	s.push_back('s');
    } else {
        s.push_back('s');
    }
    cout << s << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>

#define INF (1e9)
#define LLINF (1e18)
#define LL long long

#define MAX_V 5000

using namespace std;

typedef pair<int ,int > P;	//to,cnt
typedef struct edge{
public:
	int to;
	int cost;
	edge(){}
	edge(int _to,int _cost){
		to = _to;
		cost = _cost;
	}
	bool operator<(const edge &a)const{
		if(cost == a.cost) return to > a.to;
		return cost > a.cost;		//for asc
	}
}edge;
typedef struct node{
public:
	int cost;
	int dist;
	node(){}
	node(int _cost,int _dist){
		cost = _cost;
		dist = _dist;
	}
}node;

vector<int > G[MAX_V + 1];

int cost[MAX_V + 1][MAX_V + 1];

int ans_cost[MAX_V + 1];

queue<pair<int ,int > > que;
priority_queue<edge> pque;

node citys[MAX_V + 1];

int V;
int E;

void search(int root){
	for(int i = 0;i < G[root].size();i++){
		int to = G[root][i];
		que.push(P(to,citys[root].dist - 1));
	}
	
	while(!que.empty()){
		P p = que.front();que.pop();
		if(cost[root][p.first] != INF) continue;
		cost[root][p.first] = citys[root].cost;
		if(p.second == 0) continue;

		for(int i = 0;i < G[p.first].size();i++){
			int _to = G[p.first][i];
			int _cnt = p.second - 1;
			que.push(P(_to,_cnt));
		}
	}
	
	return ;
}
void solve(){
	for(int i = 0;i < MAX_V + 1;i++){
		for(int j = 0;j < MAX_V + 1;j++){
			if(i == j) cost[i][j] = 0;
			else cost[i][j] = INF;
		}
	}
	for(int i = 1;i < V + 1;i++) search(i);

	/*for(int i = 1;i < V + 1;i++){
		printf("###");
		for(int j = 1;j < V + 1;j++){
			printf(" %d",cost[i][j]);
		}
		puts("");
	}*/

	for(int i = 0;i < MAX_V + 1;i++) ans_cost[i] = INF;

	pque.push(edge(1,0));
	
	while(!pque.empty()){
		edge e = pque.top();pque.pop();
		if(ans_cost[e.to] != INF) continue;
		ans_cost[e.to] = e.cost;

		for(int i = 1;i < V + 1;i++){
			if(cost[e.to][i] != INF && e.to != i){
				int _to = i;
				int _cost = e.cost + cost[e.to][i];
				pque.push(edge(_to,_cost));
			}
		}
	}

	return ;
}

int main(){

	scanf("%d%d",&V,&E);
	int _cost;
	int _dist;
	for(int i = 1;i < V + 1;i++){
		scanf("%d%d",&_cost,&_dist);
		citys[i] = node(_cost,_dist);
	}
	int _u,_v;
	for(int i = 0;i < E;i++){
		scanf("%d%d",&_u,&_v);
		G[_u].push_back(_v);
		G[_v].push_back(_u);
	}

	solve();

	printf("%d\n",ans_cost[V]);

	return 0;
}

Measured memory_bytes: 232288
#include "iostream"
#include "string"
#include "stdio.h"
#include "ctype.h"
#include "algorithm"
#include "stack"
#include "cmath"
#include "cstring"
#include "iomanip"
using namespace std;
int main()
{
    int N,A[200010],Num[200010];
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
        Num[i]=0;
    for(int i=2;i<=N;i++)
    {
        scanf("%d",&A[i]);
        Num[A[i]]++;
    }
    for(int i=1;i<=N-1;i++)
        printf("%d\n",Num[i]);
    printf("%d\n",Num[N]);
    return 0;
}


Measured memory_bytes: 5364
#include<bits/stdc++.h>
#define ll long long

int take()
{
    int n;
    scanf("%d",&n);
    return n;

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 5005
#define Int take()
#define LL takes()
#define end return 0
#define fo(n) for(int i=1;i<=n;i++)
#define rfo(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;

int main(){
    int n=Int;
    int a[n+1];
    pii p[n+1];
    ll ans=1,even=0,odd=1;
    fo(n){
        a[i]=Int;
        if(a[i]%2){
                p[i].first=2;p[i].second=1;
            }
        else{
             p[i].first=1;p[i].second=2;
        }
     ans*=3;
    }

 for(int i=1;i<=n;i++){
    odd*=p[i].second;
 }
cout<<ans-odd<<endl;
end;
}


Measured memory_bytes: 384
s = int(input())
cnt = 1
f = []
f.append(s)
for i in range(1,1000000):
    cnt += 1
    if f[i-1]%2==0:
        f.append(f[i-1]/2)
    else:
        f.append(f[i-1]*3+1)
    
    if len(f) != len(set(f)):
        print(cnt)
        break

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); 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--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int ans = 0;
    int a, b;
    cin >> a>> b;
    rep(i, 1000){
        if(1+a*i - i >= b){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



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

int n,m,num; 
int out[100010];
string a;

int main()
{
	cin>>n>>m;
	int now = n;
	cin>>a;
	while(now >= 1)
	{
		bool l = 0;
		for(int i = min(now,m);i >= 1;i--)
		{
			if(a[now - i] == '0')
			{
				out[++num] = i;
				now = now - i;
				l = 1;
				break;
			}
		}
		if(!l)
		{
			cout<<-1;
			return 0;
		}
	}
	for(int i = num;i >= 1;i--)
	cout<<out[i]<<' ';
	return 0;
} 

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
b_list = _li()

ans = b_list[0] + b_list[-1]
for i in range(N-2):
    ans += min(b_list[i], b_list[i+1])
print(ans)



Measured memory_bytes: 3188
n, k = map(int, input().split())
v = list(map(int, input().split()))

res = 0
r = min(n, k)
for i in range(r+1):
    for j in range(r-i+1):
        in_hand = v[:i] + v[n-j:] if i + j < n else v[:]
        in_hand.sort(reverse=True)
        for _ in range(k-len(in_hand)):
            if not in_hand or in_hand[-1] >= 0:
                break
            in_hand.pop()
        res = max(res, sum(in_hand))
print(res)


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

int main()
{
	int a, b, C;
	cin >> a >> b >> C;
	cout << fixed << setprecision(6);
	cout << a * b * sin((double)C / 180 * acos(-1)) / 2.0 << endl;
	cout << a + b + sqrt(a * a + b * b - a * b * 2 * cos((double)C / 180 * acos(-1))) << endl;
	cout << b * sin((double)C / 180 * acos(-1)) << endl;
	return 0;
}


Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    rep(i,0,n)
    cin>>h[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    rep(i,2,n){
        dp[i]=INT_MAX;
    repD(j,i-1,max(0,i-k))
    dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
}
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define    ll  long long	
ll a,b,cnt=1,d;
int main(){
   cin>>a>>b;
   d=__gcd(a,b);
   for(ll i=2;i*i<=d;i++)
   {
   	     if(d%i==0)cnt++;
		 while(d%i==0)d=d/i;
   }
   if(d>1)cnt++;
   cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF=1LL<<55LL; 
int cnt;
void merge(int *A,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++) L[i]=A[left+i];
  for(int i=0;i<n2;i++) R[i]=A[mid +i];
  L[n1]=INF;
  R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]) A[k]=L[i++];
    else A[k]=R[j++];
  }
}
void mergeSort(int *A,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  int S[n];
  for(int i=0;i<n;i++) cin>>S[i];
  cnt=0;
  mergeSort(S,0,n);
  for(int i=0;i<n;i++) cout<<S[i]<<" \n"[i==n-1];
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 10988
#include <cstdio>
using namespace std;
typedef long long ll;
int N; ll X, ans;
ll rec(int n, ll x) {
  if(n == 0) return 1;
  ll lng = (1LL<<(n+1))-3;
  ll num = (1LL<<(n))-1;
  if(x == 1) return 0;
  else if(x <= lng+1) return rec(n-1, x-1);
  else if(x <= lng+2) return num+1;
  else if(x <= 2*lng+2) return num+1+rec(n-1, x-lng-2);
  return 2*num+1;
}
int main() {
  scanf("%d %ld", &N, &X);
  printf("%ld\n", rec(N, X));
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 ||  n % 10 == 7 || n % 10 == 9){
			System.out.println("hon");
        } else if ( n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
		       System.out.println("pon");
        } else {
			System.out.println("bon");
		}
	}
}



Measured memory_bytes: 27064
#include<stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

  if(x-r<0 || x+r>W){
    printf("No\n");
  }else if(y-r<0 || y+r>H){
    printf("No\n");
  }else{
    printf("Yes\n");
  }

  return 0;
}


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

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

   vector<int> d(N);
   int maxi = 100000;
   int mini = 0;
   for(int i = 0;i < N;i++) {
       cin >> d.at(i);
       maxi = max(maxi,d.at(i));
       mini = min(mini,d.at(i));
   }

   sort(d.begin(),d.end());

   int ans = 0;

   for(int i = mini;i <= maxi;i++) {
       vector<int>::iterator it;
       it = upper_bound(d.begin(),d.end(),i);
       int bef = distance(d.begin(),it);
       int aft = N - bef;
       if(bef == aft) ans++;
   }

   cout << ans << endl;
}



Measured memory_bytes: 640
N = int(input())
A = [int(a) for a in input().split(' ')]
S = [0] * N
s = 0

S[N - 1] = A[N - 1]
for i in range(N - 2, -1, -1):
    S[i] = S[i + 1] + A[i]


for i in range(N - 1):
    s += A[i] * S[i + 1]
    s = s % 1000000007

print(s)


Measured memory_bytes: 31304
def check():
  A, B, C = map(int, input().split())
  K = int(input())
  while B<=A:
    if K==0:
      return 'No'
    B *= 2
    K -= 1
  while C<=B:
    if K==0:
      return 'No'
    C *= 2
    K -= 1
  return 'Yes'
print(check())

Measured memory_bytes: 9200
import java.util.*;

public class Main {
    static int INF = 1001001009;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int start = 0;
        int goal = n;
        
        // to: 隣接リスト(有向)
        
        // dist: startからの最短距離
        int[] dist = new int[n+1];
        Arrays.fill(dist, INF);
        dist[start] = 0;
        
        // ダイクストラ法: BFSで距離を配る。
        // (キューの先頭の点はそう来る他最短経路がないので最短距離が確定する)
        PriorityQueue<Point> que = new PriorityQueue<>();
        que.add(new Point(start, 0));
        while (!que.isEmpty()) {
            Point cur = que.poll();
            int p = cur.name;
            int dis = cur.dist;
            
            // distより大きいdisを持つ点からは配らせない
            if (dis > dist[p]) continue;
            
            // // 確定したpとdis
            // System.out.println(p + " " + dis);
            
            // 子に「自分の距離 + p→qの距離」を配る
            // 最短距離が更新される場合だけキューに入れる
            int q;
            int PtoQ;
            
            // +1のパターン
            q = p + 1;
            PtoQ = 1;
            if (q <= n && dis + PtoQ < dist[q]) {
                dist[q] = dis + PtoQ;
                que.add(new Point(q, dist[q]));
            }
            
            // +6のパターン
            for (int pow = 6; pow <= n; pow *= 6) {
                q = p + pow;
                PtoQ = 1;
                if (q <= n && dis + PtoQ < dist[q]) {
                    dist[q] = dis + PtoQ;
                    que.add(new Point(q, dist[q]));
                }
            }
            
            // +6のパターン
            for (int pow = 9; pow <= n; pow *= 9) {
                q = p + pow;
                PtoQ = 1;
                if (q <= n && dis + PtoQ < dist[q]) {
                    dist[q] = dis + PtoQ;
                    que.add(new Point(q, dist[q]));
                }
            }
        }
        System.out.println(dist[goal]);
    }
}
    
class Point implements Comparable<Point> {
    int name;
    int dist;
     
    Point(int name, int dist) {
        this.name = name;
        this.dist = dist;
    }
    
    @Override
    public int compareTo(Point o) { // longでもint
        //重みの小さい順
        if (this.dist < o.dist) {
            return -1;
        } 
        return 1;
    }
}

Measured memory_bytes: 26332
#include<cstdio>
#include<cmath>
int a[10],x[10],y[10],n,vis[10];
double ans;
double dis(int a,int b){
	return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
}
void check(){
	double sum=0;
	for(int i=1;i<n;i++)
		sum+=dis(a[i],a[i+1]);
	ans+=sum;
}
void dfs(int x){
	if(x==n+1){
		check();
		return;
	}
	for(int i=1;i<=n;i++){
		if(vis[i])continue;
		vis[i]=1;
		a[x]=i;
		dfs(x+1);
		vis[i]=0;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	dfs(1);
	int b=1;
	for(int i=1;i<=n;i++)
		b*=i;
	printf("%.10lf",ans/b);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll     long long int
#define pb     push_back
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std ;
int main()
{
     fast;
     int t=1;
    // cin>>t;
     while(t--)
     {
       ll n,i,j,k,a,b,c=0,d,ans,sum=0,x;
       cin>>a>>b>>n;
        x= min(b-1,n);
       cout<<(ll) (floor(a*x/b)-a*floor(x/b));
     }
     return 0;
}


Measured memory_bytes: 3652
// #define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << '\n';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<ll> a(n-1);
    rep(i,n-1) cin >> a[i];
    vector<ll> cnt(n);
    rep(i,n-1){
        cnt[a[i]-1]++;
    }

    print(cnt);
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return a;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int n; cin >>n;
  string s; cin >>s;
  int parL=0, parR=0;

  for (int i=0; i<n; i++){
    if (s.at(i) == '('){
      parR++;
    }else if (s.at(i) == ')'){
      if (parR == 0) parL++;
      else parR--;
    }
  }
  for (int i=0; i<parL; i++) cout <<'(';
  cout <<s;
  for (int i=0; i<parR; i++) cout <<')';
  cout <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

string s;

int cou[256];

int main()
{
	cin >> s;

	for(char c : s)
	{
		cou[c]++;
	}

	i64 result = 0;

	i64 sum = s.size();

	for(char c : s)
	{
		result += sum - cou[c];

		sum--;
		cou[c]--;
	}

	cout << result + 1 << endl;
	return 0;
}



	




Measured memory_bytes: 640
#include<stdio.h>

int func(int n, int* ng, int k){
    while(n > 0){
        for(int i=0; i<k; i++){
            if(n%10 == *(ng+i)){
                return 0;
            }
        }
        n = n/10;
    }
    return 1;
}

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int d[k];
    for(int i=0; i<k; i++){
        scanf("%d", &d[i]);
    }
    while(func(n, d, k) == 0){
        n++;
    }
    printf("%d", n);
    
    return 0;
}

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

int main(){
    long long n, x;
    cin >> n >> x;

    long long a[n];
    for(long long i = 0; i < n; i++) cin >> a[i];

    long long cnt = 0;

    for(long long i = 0; i < n; i++){
        if(i + 1 < n and a[i] + a[i+1] > x){
            long long eat = a[i] + a[i+1] - x;
            cnt += eat;
            if(eat <= a[i+1]){
                a[i+1] -= eat;
            }
            else{
                eat -= a[i+1];
                a[i+1] = 0;
                a[i] -= eat;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4416
#include<iostream>
using namespace std;
int main(){
    string s,t;
    int cnt=0;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int ans=1000000;
    for(int r=0;r<=n-m;r++){
        cnt=0;
        for(int i=0;i<m;i++){
            if(s[i+r]!=t[i]){
                cnt++;
            }
        }
        ans=min(ans,cnt);
    }
    
    cout<<ans;
}

Measured memory_bytes: 3616
H = int(input())
x = [[float('inf')]*2 for i in range(H)]

for i in range(H):
    X, L = map(int, input().split())
    x[i][0] = X - L
    x[i][1] = X + L

from operator import itemgetter
sf = sorted(x, key=itemgetter(1))

ans = 0
last = float('inf')*-1

for i in range(H):
    if last <= sf[i][0]:
        ans += 1
        last = sf[i][1]

print(ans)


Measured memory_bytes: 66780
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  long long N;
  cin >> N;
  std::vector<int> pn;
  pn.resize(N);
  for (int i = 0; i < N; ++i) { cin >> pn[i]; }
  std::vector<int> ref; 
  ref.resize(N);
  for (int i = 0; i < N; ++i) { ref[i] = i + 1; }
  
  int err = 0;
  for (int i = 0; i < N; ++i) { 
    if (pn[i] != ref[i]) err++;
  }
  if (err == 0 || err == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

struct edge { int u, v; ll w; };

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

bool kr_cmp(const edge& l, const edge& r) { return l.w < r.w; }

ll kruskal(int N, vector<edge> E) {
	sort(E.begin(), E.end(), kr_cmp);
	union_find uf(N);
	ll sum = 0;
	for (edge e: E)
		if (!uf.same(e.u, e.v)) {
			uf.unite(e.u, e.v);
			sum += e.w;
		}
	return sum;
}

int N;
ll D;
vector<edge> E;
ll a[200010];

void f(int l, int r) {
    if (r - l == 1) return;
    int m = (l + r) / 2;
    f(l, m);
    f(m, r);
    int i0, j0;
    {
        ll mi = LLONG_MAX;
        for (int i = l; i < m; i++) {
            ll x = a[i] - D * i;
            if (x < mi) {
                mi = x;
                i0 = i;
            }
        }
    }
    {
        ll mi = LLONG_MAX;
        for (int j = m; j < r; j++) {
            ll x = a[j] + D * j;
            if (x < mi) {
                mi = x;
                j0 = j;
            }
        }
    }
    for (int i = l; i < m; i++)
        E.pb({i, j0, a[i] + a[j0] + D * (j0 - i)});
    for (int j = m; j < r; j++)
        E.pb({i0, j, a[i0] + a[j] + D * (j - i0)});
}

int main() {
    cin >> N >> D;
    rep(i, N) scanf("%lld", &a[i]);
    f(0, N);
    cout << kruskal(N, E) << endl;
}


Measured memory_bytes: 115164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_169
{
    class F
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] ns = ReadInts();
            int n = ns[0];
            int s = ns[1];
            int[] array = ReadInts();

            long mask = 998244353;
            long[,] dp = new long[n, 3005];
            dp[0, 0] = 2;
            dp[0, array[0]] = 1;
            for(int i = 1; i < n; i++)
            {
                for(int j = 0; j < 3005; j++)
                {
                    dp[i, j] += dp[i - 1, j] * 2;
                    dp[i, j] %= mask;

                    if (j + array[i] <= 3000)
                    {
                        dp[i, j + array[i]] = dp[i - 1, j];
                        dp[i, j + array[i]] %= mask;
                    }
                }
            }

            WriteLine(dp[n - 1, s]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 98348
N = int(input())
Dict={}
for i in range(N):
    T=input()
    if Dict.get(T[0],None)==None:
        Dict[T[0]]=1
    else:
        Dict[T[0]]+=1

L=[]
if Dict.get("M",None)!=None:
    L.append(Dict["M"])
if Dict.get("R",None)!=None:
    L.append(Dict["R"])
if Dict.get("A",None)!=None:
    L.append(Dict["A"])
if Dict.get("C",None)!=None:
    L.append(Dict["C"])
if Dict.get("H",None)!=None:
    L.append(Dict["H"])
if(len(L)<3):
    print(0)
    exit()


S=0
for i in range(len(L)):
    for j in range(len(L)):
        if(i==j):break
        for k in range(len(L)):
            if(i==k):break
            if(j==k):break
            S+=L[i]*L[j]*L[k]
print(S)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,A,B,C;

int L[10];
int dfs(int k, int a, int b, int c){
    if(k == N){
        if(min(a, min(b,c))){
            return abs(a - A)+abs(b - B)+abs(c - C);
        } else {
            return MAX;
        }
    }
    int ans = MAX;
    ans = min(ans, dfs(k+1, a, b, c));
    ans = min(ans, dfs(k+1, a+L[k], b, c) + (a>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b+L[k], c) + (b>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b, c+L[k]) + (c>0 ? 10:0));
    return ans;
}
int main(){
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    int res = dfs(0,0,0,0);
    cout << res << endl;
}



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

int main() {
	int M, N;

	cin >> N;
	cin >> M;

	vector<int> A(M);
	vector<int> B(M);

	for (int i = 0; i < M; i++) {
		cin >> A[i];
		cin >> B[i];
	}

	// create graph
	vector<vector<int>> graph(N + 1);
	for (int i = 0; i < M; i++) {
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}

	// for (int i = 1; i < N + 1; i++) {
	// 	for (int j = 0; j < graph[i].size(); j++) {
	// 		cout << graph[i][j];
	// 	}
	// 	cout << endl;
	// }

	queue<int> q;
	vector<int> dist(N, -1);
	vector<int> mark(N);
	int point = 1;
	q.push(point);
	dist[point - 1] = 0;

	while (!q.empty()) {
		point = q.front();
		q.pop();

		for (int i = 0; i < graph[point].size(); i++) {
			if (dist[graph[point][i] - 1] == -1) {
				dist[graph[point][i] - 1] = dist[point - 1] + 1;
				mark[graph[point][i] - 1] = point;
				q.push(graph[point][i]);
			}
		}
	}

	bool falure = false;
	for (int i = 0; i < N; i++) {
		if (dist[i] == -1) {
			falure = true;
		}
	}

	if (!falure) {
		cout << "Yes" << endl;
		for (int i = 1; i < N; i++) {
			// cout << dist[i] << endl;
			cout << mark[i] << endl;
		}
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 12064
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,ans=0,x,minx=1000000000,maxx=1;
    cin >> N;
    vector<bool> v(1000000000,false);

    for(int i=0;i<N;i++){
        cin >> x;

        minx = min(minx,x);
        maxx = max(maxx,x);

        if(v.at(x-1)== false){
            v.at(x-1) = true;
        } 
        else{
            v.at(x-1)=false;
        }
    }

    for(int j=minx-1;j<maxx;j++){
        if(v.at(j) == true){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 122368
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;

int main() {
	string s; cin >> s;
	int n = s.size();

	int ans = 0;
	int st = 0;
	rep(i, 0, n) {
		if (s[i] == 'S') ++st;
		else {
			if (st == 0) ++ans;
			else --st;
		}
	}
	cout << ans + st << endl;
	return 0;
}

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

using namespace std;

int main(){
    int dis, num;
    cin >> dis >> num;

    vector<int> vec(num);
    for(int i=0; i<num; i++){
        cin >> vec.at(i);
    }

    int x,y;
    x = dis - (vec[num-1] - vec[0]);
    y = vec[1] - vec[0];

    int range;
    if(x<=y){
        range = dis -y;
    }
    else{
        range = dis -x;
    }

    int z;
    for(int i=1; i<num-1; i++){
        x = vec[i] - vec[i-1];
        y = vec[i+1] - vec[i];
        
        if(x<=y){
            z = dis - y;
        }
        else{
            z = dis - x;
        }
        if(z < range){
            range = z;
        }
    }
    cout << range << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int main()
{  
    int N;
    cin >> N;
    vector<int> K(N);
    int cnt = 0;
    for(int i = 0; i < N; i++) cin >> K.at(i);
    while(true){
        bool odd = false;
        for(int i = 0; i < N; i++){
            if(K.at(i) % 2 != 0) odd = true;
        }
        if(odd) break;

        for(int i = 0; i < N; i++){
            K.at(i) = K.at(i) / 2;
        }
        cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
    int n,k;
    cin >> n;
    char s[n], ans[n];
    for(int i = 0 ; i < n; i++) cin >> s[i];
    cin >> k;
    
    for(int i = 0; i < n ; i++){
        if(s[i] != s[k -1]){
            ans[i] = '*';
        } else {
            ans[i] = s[i];            
        }
    }
    for(int i = 0; i < n ; i++) cout << ans[i];
    cout << endl;

}

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


int main() {
	int N,sum_a=0,sum_b=0;
  	cin >> N;
	vector<int> number(N);
  	for(int i=0;i<N;i++){
    cin >> number.at(i);
  
  	}
 	 sort(number.begin(),number.end());
 	 reverse(number.begin(),number.end());
 	 for(int i=0;i<N;i++){
  	if(i%2==0){
    	sum_a += number.at(i);
  	  }else{
    	sum_b += number.at(i);
  	  }
 	 }
 	 cout << sum_a-sum_b << endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 1024;
int N,M;
int A,B;
string ans[MC];

int main(){
	cin >> N >> M >> A >> B;
	int x = 0 , y = 0 , z = (N/2) * (M/2);
	if(N&1) x = min(M/2,A);
	if(M&1) y = min(N/2,B);
	int p = (A-x+1) / 2;
	int q = (B-y+1) / 2;
	bool f = 0;
	if(p+q>z){
		if((A-x)%2==1 && (B-y)%2==1 && N%2==1 && M%2==1 && p+q==z+1){
			A -= 2;
			B -= 2;
			--x;
			--y;
			f = 1;
		} else {
			return cout << "NO" << endl , 0;
		}
	}
	cout << "YES" << endl;
	repp(i,0,N) repp(j,0,M) ans[i] += ".";
	A -= x;
	B -= y;
	for(int i = 0 ; i+1 < N ; i += 2) for(int j = 0 ; j+1 < M ; j += 2){
		
		if(A){
			ans[i][j] = '<'; ans[i][j+1] = '>';
			--A;
			if(A){
				ans[i+1][j] = '<'; ans[i+1][j+1] = '>';
				--A;
			}
		} else if(B){
			ans[i][j] = '^'; ans[i+1][j] = 'v';
			--B;
			if(B){
				ans[i][j+1] = '^'; ans[i+1][j+1] = 'v';
				--B;
			}
		}
	}
	repp(i,0,x){
		ans[N-1][i*2] = '<'; ans[N-1][i*2+1] = '>';
	}
	repp(i,0,y){
		ans[i*2][M-1] = '^'; ans[i*2+1][M-1] = 'v';
	}
	if(f){
		ans[N-3][M-3] = '<'; ans[N-3][M-2] = '>';
		ans[N-1][M-2] = '<'; ans[N-1][M-1] = '>';
		ans[N-2][M-3] = '^'; ans[N-1][M-3] = 'v';
		ans[N-3][M-1] = '^'; ans[N-2][M-1] = 'v';
	}
	repp(i,0,N) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>

int main(){
  int a,b,r,tmp;

  scanf("%d%d",&a,&b);

  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }

  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  
  printf("%d\n",b);
  
  return 0;
}

Measured memory_bytes: 592
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x:x[1])

cost = 0
limit = 0

for i in range(n):
    cost += ab[i][0]
    limit = ab[i][1]
    if limit < cost:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 53600
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int A[200001] = {0};
vector<ll> B, C, D;
ll N, K;

bool checkMinus(ll mid) {
    ll ans = 0;
    for(int i=0;i<D.size();i++) {
        ll v = (mid - D[i] + 1) /D[i];
        ans += upper_bound(B.begin(), B.end(), v)-B.begin();
    }
    return ans>=K;
}

bool checkPlus(ll mid) {
    ll ans = 0;
    for(int i=0;i<D.size();i++) {
        ll v = mid/D[i];
        ll buf = upper_bound(D.begin(), D.end(), v)-D.begin();
        if (buf>i) {
            buf--;
        }
        ans += buf;
    }
    
    for(int i=0;i<B.size();i++) {
        ll v = mid/B[i];
        ll buf = upper_bound(B.begin(), B.end(), v)-B.begin();
        if (buf>i) {
            buf--;
        }
        ans += buf;
    }
    ans /= 2;

    return ans>=K;
}

int main() {
    scanf("%lld %lld", &N, &K);
    for(int i=0;i<N;i++) {
        scanf("%d", &A[i]);
    }
    for(int i=0;i<N;i++) {
        if(A[i]>0) {
            D.push_back(A[i]);
        }
        else if(A[i]==0) {
            C.push_back(A[i]);
        }
        else {
            B.push_back(A[i]);
        }
    }

    ll sb = B.size();
    ll sc = C.size();
    ll sd = D.size(); 
    
    ll minus = sb*sd;
    ll zero = sb*sc+sc*sd+(sc)*(sc-1)/2;
    ll plus = N*(N-1)/2-minus-zero;

    if(K<=minus) {
        ll left = -1e18+1;
        ll right = -1;

        sort(B.begin(), B.end());

        while(right-left>1) {
            ll mid = (left+right)/2;
            if(checkMinus(mid)) {
                right = mid;
            }
            else {
                left = mid;
            }
        }
        cout << right << endl;
    }
    else if(minus<K && K<=minus+zero) {
        cout << 0 << endl;
    }
    else {
        K -= (minus+zero);
        ll left = -1;
        ll right = 1e18;

        for(int i=0;i<B.size();i++) {
            B[i] = -B[i];
        }
        sort(B.begin(), B.end());
        sort(D.begin(), D.end());

        while(right-left>1) {
            ll mid = (left+right)/2;
            if(checkPlus(mid)) {
                right = mid;
            }
            else {
                left = mid;
            }
        }
        cout << right << endl;
    }
    return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N;
	cin >> N;
	string s;
	cin >> s;
	LL red = 0, blue = 0;
	REP(i, N) {
		if (s[i] == 'R') {
			red++;
		} else {
			blue++;
		}
	}
	if (red > blue) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a2 = [i for i in a if i%2==0]
ans = 0
def saiki(i):
    if i == 1 or i%2 != 0:
        return 1
    return 1 + saiki(i//2)
if len(a2)==0:
    print(0)
else:
    for i in a2:
        ans += saiki(i//2)
    print(ans)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b;
    cin >> a >> b;
    if(a > b) {
        cout << "a > b" << endl;
    } else if(a < b) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N, K;
	cin >> N >> K;

	cout << K * (int)pow(K - 1, N - 1);

	return 0;
}


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


int main(){
    string o,e;
    cin >> o >> e;
    for(int i=0;i<e.size();i++){
        cout << o[i] << e[i];
    }
    if(o.size()>e.size())cout << o[o.size()-1];
    cout << endl;
}

Measured memory_bytes: 256
let draw h w =
	let rec draw1 w =
		if w = 0 then print_string "\n" else (print_string "#";draw2 (w-1))
	and draw2 w =
		if w = 0 then print_string "\n" else (print_string ".";draw1 (w-1))
	in
	let rec draw_l1 h w =
		if h = 0 then print_string "\n" else (draw1 w;draw_l2 (h-1) w)
	and draw_l2 h w =
		if h = 0 then print_string "\n" else (draw2 w; draw_l1 (h-1) w)
	in
	draw_l1 h w;;

let rec loop() =
	Scanf.sscanf(read_line()) "%d %d" (fun x y -> if x = 0 && y = 0 then () else (draw x y;loop()));;

loop();;



Measured memory_bytes: 2288
package main

import "fmt"

func pow(x, n int64) int64 {
	if n == 0 {
		return 1
	}
	for ; n > 0; n-- {
		x = x * x
	}
	return x
}

func main() {
	var D, N int64
	fmt.Scan(&D, &N)
	if N != 100 {
		fmt.Println(pow(10, D) * N)
	} else {
		fmt.Println(pow(10, D) * (N + 1))
	}
}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

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

const int MOD = 1000000007;
LL ab[2][1005];
const int MAX = 1000005;
LL fac[MAX], finv[MAX], inv[MAX];

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

LL nPr(LL n, LL r) {
	if (n < r) {
		return 0LL;
	}
	return (fac[n] *finv[n-r]) % MOD;
}

int main(){
	init();
	int nm[2];
	cin >> nm[0] >> nm[1];
	REP(i,2)REP(j, nm[i])scanf("%lld", &ab[i][j]);
	REP(i,2)sort(ab[i], ab[i] + nm[i]);
	REP(i, 2) {
		REP(j, nm[i] - 1) {
			if (ab[i][j] == ab[i][j + 1]) {
				printf("0\n");
				return 0;
			}
		}
	}
	vector<PII> vpii;
	REP(i, 2)REP(j, nm[i])vpii.PB(MP(ab[i][j], i));
	LL done = 0;
	SORT(vpii);
	vpii.PB(MP(-1, -1));
	vpii.insert(vpii.begin(), MP(-1, -1));
	LL ret = 1;
	REP(i, vpii.size() - 2) {
		auto x = vpii[i+1];
		if (vpii[i + 2].first == x.first) {
			ret = (ret*nPr(x.first - done - 1, nm[1-x.second] - 1)) % MOD;
		}
		else if (vpii[i].first == x.first) {
			ret = (ret*nPr(x.first - done, nm[1 - x.second])) % MOD;
		}
		else {
			ret = (((ret * nm[1 - x.second]) % MOD) * nPr(x.first - 1 - done, nm[1 - x.second] - 1))%MOD;
		}
		done += nm[1 - x.second];
		nm[x.second]--;
		if (nm[x.second] == 0)break;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 23680
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

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

    static class ACircle {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            long n = nl();
            pn(n * n);

        }

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21588
import collections

n, a = map(int,input().split())
num = list(map(int,input().split()))

for i in range(n):
    num[i] -= a
sums = collections.Counter([0, num[0]])

for i in num[1:]:
    c = collections.Counter()
    for p, q in sums.items():
        c[i + p] += q
    sums += c
print(sums[0] - 1)

Measured memory_bytes: 3572