akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}


int main(){
  int64_t n, p; 
  cin >> n >> p;
  map<int64_t, int64_t> res;
  res = prime_factor(p);
  //cout << res[2] << res[3] << endl;
  queue<int64_t> A;
  int64_t tmp = n;
  for (auto p : res) {
  int64_t key = p.first;
  int64_t val = p.second;
  // key, valueを使う
  //cout << key << val << endl;
  while(val>=tmp) {A.push(key); val -= tmp;}
  /*else if(val>tmp){
    while (!(A.empty())){
      A.pop();
    }
    A.push(key);
    //tmp = val;
  }*/
}
int64_t ans = 1;
//if(tmp>=n) {
while(!(A.empty())){
  int64_t a = A.front();
  ans *= a;
  A.pop();
}
//}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 101

void Initialize(int *);
int IsEmpty(int);
int IsFull(int);
void Push(int [],int,int *);
int Pop(int [],int *);

int main(){
  int top,x;
  int result,temp_a,temp_b;
  int Stack[MAX];
  char s[100];

  Initialize(&top);
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      temp_a = Pop(Stack,&top);
      temp_b = Pop(Stack,&top);
      x = temp_b + temp_a;
      Push(Stack,x,&top);
    }
    
    else if ( s[0] == '-' ){
      temp_a = Pop(Stack,&top);
      temp_b = Pop(Stack,&top);
      x = temp_b - temp_a;
      Push(Stack,x,&top);
    }
    
    else if ( s[0] == '*' ){
      temp_a = Pop(Stack,&top);
      temp_b = Pop(Stack,&top);
      x = temp_b * temp_a;
      Push(Stack,x,&top);
    }
    
    else {
      x = atoi(s);
      Push(Stack,x,&top);
    }
    
  }

  result = Pop(Stack,&top);
  printf("%d\n",result);
  
  return 0;
}

void Initialize(int *top){
  int i;

  *top = 0;
}

int IsEmpty(int top){
  if (top == 0)
    return 1;

  return 0;
}

int IsFull(int top){
  if (top == MAX - 1)
    return 1;

  return 0;
}

void Push(int S[],int x,int *top){
  if (IsFull(*top)){
    fprintf(stderr,"Over flow\n");
    exit(0);
  }

  (*top)++;
  S[*top] = x;
}

int Pop(int S[],int *top){
  if (IsEmpty(*top)){
    fprintf(stderr,"Under flow\n");
    exit(1);
  }

  (*top)--;
  return S[*top + 1];
}



Measured memory_bytes: 2116
#https://qiita.com/vain0x/items/fbde8b66927b84080811
#http://kmjp.hatenablog.jp/entry/2019/09/01/1000
#2人の選手が互いに相手を次の対戦相手に指定しているとき以外組めない
#したがって貪欲で一意

n = int(input())
a = []

for i in range(n):
    ai = list(map(int, input().split( )))
    ai.reverse()
    for j in range(n-1):
        ai[j]-=1
    a.append(ai)

##キューの管理のどこがおかしいかわからなかったがあきらめる

can={i for i in range(n)}
nxt=set()
cnt = 0
rem=n*(n-1)//2
while rem:
    cnt+=1
    for i in can:
        if i not in nxt and a[i]:
            p = a[i][-1]
            if p not in nxt:##この判定しないと1日に複数回試合することになる
                if a[p][-1]==i:
                    a[p].pop();a[i].pop()
                    nxt.add(i);nxt.add(p)
    rem-=len(nxt)//2

    can=nxt.copy()###copy
    nxt=set()
    if not can:
        break
       
if rem:
    print(-1)
else:       
    print(cnt)
        
        
        


Measured memory_bytes: 63196
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int TopIndex = 1;
const int DummySize = 1;

void BubbleClimb(vector<int>& Heap, int InsertIndex)
{
	int ParentIndex = InsertIndex / 2;
	if(InsertIndex == TopIndex || Heap[InsertIndex] <= Heap[ParentIndex]) return;
	swap(Heap[InsertIndex], Heap[ParentIndex]);
	InsertIndex = ParentIndex;
	BubbleClimb(Heap, InsertIndex);
}

void Insert(vector<int>& Heap, int k)
{
	Heap.push_back(k);
	int InsertIndex = Heap.size() - 1;
	BubbleClimb(Heap, InsertIndex);
}

void maxHeapify(vector<int>& A, int i)
{
	int H = A.size() - 1;
	int l = 2 * i;
	int r = 2 * i + 1;
	//????????????????????????????????§???????????§????????????????????¶
	int largest;
	if(l <= H && A[l] > A[i]){
		largest = l;
	}else{
		largest = i;
	}
	if(r <= H && A[r] > A[largest]){
		largest = r;
	}
	//i???????????????????????§????????´???
	if(largest != i){
		swap(A[i], A[largest]);
		//?????°??????????????????
		maxHeapify(A, largest);
	}
}

void ExtractMax(vector<int>& Heap)
{
	int TailIndex = Heap.size() - 1;
	cout << Heap[TopIndex] << endl;
	swap(Heap[TailIndex], Heap[TopIndex]);
	Heap.pop_back();
	maxHeapify(Heap, TopIndex);
}

int main()
{
	vector<int> Heap(DummySize);
	while(true){
		string Command;
		cin >> Command;
		if(Command == "insert"){
			int k;
			cin >> k;
			Insert(Heap, k);
		}else if(Command == "extract"){
			ExtractMax(Heap);
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 6968
#include<stdio.h>
int main(void)
{
  int a,b,c,box;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    box=a;
    a=b;
    b=box;
  }
  if(b>c){
    box=b;
    b=c;
    c=box;
  }
  if(a>b){
    box=a;
    a=b;
    b=box;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
using namespace std;
//     for(i=0;i<n;i++)
//     for(j=0;j<n;j++

int main()
{
    ll i,j,k,n,q,t,c=0,a,b;
    cin>>a>>b;
    k=max(a+b,a-b);
    k=max(k,a*b);
    cout<<k<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n;
  cin >>n;
  pair<pair<string,int>,int> p[n];
  rep(i,n) cin >>p[i].first.first>>p[i].first.second;
  rep(i,n){
    p[i].second =i+1;
    p[i].first.second*=-1;
  }
  sort(p,p+n);
  rep(i,n) cout <<p[i].second<<endl;
}
  

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


int solve(VI h){
    int result = 0;

    int min_flower = INF;
    REP(i, h.size()) { if(h[i] < min_flower) min_flower = h[i]; }
    REP(i, h.size()) { h[i] -= min_flower; }

    result += min_flower;
    VI tmp;
    REP(i, h.size()){
        if(h[i] != 0){
            tmp.PB(h[i]);
        }else if(tmp.size() != 0){
            result += solve(tmp);
            tmp.clear();
        }
    }
    if(tmp.size() != 0) result += solve(tmp);

    return result;
}

int main(){
    long long N;
    scanf("%lld",&N);
    VI h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&h[i]);
    }
    int res = solve(std::move(h));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    int ans = 1; 
    for(int i = 0;i < n;i++){
      p[i] = sc.nextInt();
    }
    int min = p[0];
    for(int j = 1;j < n;j++){
      if(p[j] < min){
        min = p[j];
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 66828
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define ii pair<int, int>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define make_pair mp
#define MAX (int)1e5+5
#define INF (int)1e9
#define K 26
#define rep(i,a,b) for(int i = a; i<b; i++)
#define vi vector<int>



int32_t main() {
	int s,w;
	cin >> s >> w;
	if(w>=s){
		printf("unsafe\n");
	}else{
		printf("safe\n");
	}
	return 0;
}

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

Measured memory_bytes: 256
num = [int(i) for i in input().split()]
num.sort()
count = 0
a = num[2]-num[1]
count += a//2+a%2
if a%2 == 1:
    num[0]+=1
b = num[2]-num[0]
if b%2 == 0:
    count += b//2
    print(count)
else:
    count += (b+1)//2+1
    print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
enum class Walked { wa, un };
struct P {
public:
    int x, y;
    P(int x, int y) : x(x), y(y) {};
    P(): x(0), y(0) {};
};
int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };

void solve() {
    int H, W, N;
    cin >> H >> W >> N;

    vector<string> town(H);
    P start_p;
    for (int i = 0; i < H; ++i) {
        cin >> town[i];
        for (int j = 0; j < W; ++j) {
            if (town[i][j] == 'S') {
                start_p = P(j, i);
            }
        }
    }
    int hp = 1;
    vector<bool> ate(N, false);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        vector<vector<Walked>> walked(H, vector<Walked>(W, Walked::un));
        vector<vector<int>> dis(H, vector<int>(W, INT_MAX));
        dis[start_p.y][start_p.x] = 0;
        queue<P> q;
        q.push(start_p);
        while(!q.empty()) {
            P po = q.front();
            q.pop();
            if (walked[po.y][po.x] == Walked::wa) continue;
            if (town[po.y][po.x] == 'X') continue;
            walked[po.y][po.x] = Walked::wa;
            int d = dis[po.y][po.x];
            int g_n = town[po.y][po.x] - '0';
            if (1 <= g_n && g_n <= 9 &&  g_n <= hp && !ate[g_n - 1]) {
                ans += d;
                start_p = po;
                hp += 1;
                ate[g_n - 1] = true;
                break;
            }
            for (int i = 0; i < 4; ++i) {
                int nx = po.x + dx[i];
                int ny = po.y + dy[i];
                if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
                dis[ny][nx] = d + 1;
                q.push(P(nx, ny));
            }
        }
    }

    cout << ans << endl;

}

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



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

// definitions
#define __Imperial_Lord__ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c <<endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d <<endl
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<endl
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<long double> vld;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;

template <class ...Args>
istream &read_args(Args &...args) {return (cin >> ... >> args);}
#define read(...)   __VA_ARGS__; read_args(__VA_ARGS__)

// cin and cout overloaded for vectors
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v) 
        is >> i;        
    return is;
}
template<typename T>             
ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v) 
        os << i << ' '; 
        return os;
}

ll none(ll i,ll j,ll n,ll m)
{
	if((i==0&&(j==0||j==m-1)) || (i==n-1&&(j==0||j==m-1))) return 2;
	else if(i==0 || j==0 || i==n-1 || j==m-1) return 3;
	else return 4;
}

// code beigns in main
int main()
{
	__Imperial_Lord__
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
    	ll read(n);
    	if(n%1000)
    	{
    		p1(1000-n%1000);
    	}
    	else p1(0);
    }	
    exec;
}

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


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;

int main(void){
	string s;
	cin >> s;

	if (s.size() != 4){
		cout << "No" << endl;
		return 0;
	}

	bool ok = true;
	for (int i = 0; i < s.size(); i++){
		int counter = 0;
		for (int j = 0; j < s.size(); j++){
			if (i == j)continue;
			if (s[i] == s[j]){
				counter++;
			}
		}
		if (counter != 1){
			ok = false;
			break;
		}
	}

	if (ok){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
string s;

int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	if( a <= x && x <= a + b) 
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

vector<int> G[100100];
int r = 0;

int dfs(int v, int p) {
  int a = 0, f = 0;
  for (int u: G[v]) {
    if (u == p) continue;
    int t = dfs(u, v);
    if (t) a += t;
    else f++;
  }
  return a + f - (f > 0);
}

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

  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int r = 0;
  while (r < n && G[r].size() < 3) r++;
  cout << (r == n ? 1 : dfs(r, -1)) << '\n';

  

  



  




  
  return 0;
}

Measured memory_bytes: 12324
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const double EPS  = 1e-10;
const bool debug = 0;
//-----------------------------------//

int main() {
	string s;
	cin >> s;
	int ans = 0;
	REP(i, s.size()) if (s[i] == '+') ans++; else ans--;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    REP(i, N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    REP(i, N-1){
        ll ans = S[i] + C[i];
        Rep(j,i+1,N-1){
            int n = 0;
            ll t = S[j];
            while(ans > t){
                t += F[j];
                n++;
            } 
            ans = t + C[j];
        }
        pr(ans);
    }
    pr(0);
}

Measured memory_bytes: 256
import math
k=int(input())
gcd_xy=0
ans=0
for x in range(1,k+1):
    for y in range(1,k+1):
        gcd_xy=math.gcd(x,y)
        for z in range(1,k+1):
            ans += math.gcd(gcd_xy,z)
print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  ll N, M, X;
  cin >> N >> M >> X;
  vector<ll> C(N);
  vector<vector<ll>> A(N, vector<ll>(M, 0));
  REP(i, N) {
    cin >> C[i];
    REP(j, M) cin >> A[i][j];
  }
  ll mn = -1;
  for (int i = 0; i < (1 << N); i++) {
    ll num = 0;
    vector<ll> rikai(M,0);
    REP(j,N){
      bool t = i & (1 << j);
      if (t == false) {
        continue;
      }
      num += C[j];
      REP(k, M) { rikai[k] += A[j][k]; }
    }
    bool t = true;
    REP(j,M){
      if(rikai[j]<X){
        t = false;
        break;
      }
    }
    if(t){
      mn = mn == -1 ? num : min(num, mn);
    }
  }
  cout << mn << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100002

int N, M, K;
int fa[MAXN] = {0}, ans[MAXN] = {0}, siz[MAXN] = {0};

int find (int x) {
    fa[x] = fa[x] == x ? x : find (fa[x]);
    return fa[x];
}

void uni (int x, int y) {
    fa[find (x)] = find (y);
}

int main () {
    cin >> N >> M >> K;
    for (int i = 1; i <= N; i ++)
        fa[i] = i;

    for (int i = 1; i <= M; i ++) {
        int a, b; cin >> a >> b;
        uni (a, b);
        ans[a] --;
        ans[b] --;
    }

    for (int i = 1; i <= N; i ++) 
        siz[find (i)] += 1;
    
    for (int i = 1; i <= N; i ++)
        ans[i] += siz[find (i)];

    for (int i = 1; i <= K; i ++) {
        int c, d; cin >> c >> d;
        if (find (c) == find (d)) {
            ans[c] --;
            ans[d] --;
        }
    }

    for (int i = 1; i <= N; i ++)
        cout << ans[i] - 1 << " ";
    
    return 0;
}

Measured memory_bytes: 2304
#include <cstdio>
#include <iostream>
using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
int main() {
  string O,E;
  cin >> O >> E;
  int s =  O.size()==E.size() ? O.size()*2 : O.size()*2-1;
  for(int i=0;i<s;i++){
    if(i%2==0) printf("%c",O[i/2]);
    else printf("%c",E[i/2]);
  }
  printf("\n");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	double r;
	double a;
	double b;

	scanf("%lf",&r);
	a = r*r*3.141592653589;
	b = 2*r*3.141592653589;
	printf("%f %f\n",a,b);
	return 0;
}


Measured memory_bytes: 2104
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

string N;

int main() {
    fastio();
    cin >> N;
    ll px = 0, py = 1, x, y;
    ll size = N.size();
    REP(i, size) {
        int d = N[i] - '0';
        x = min(px + d, py + 10 - d);
        y = min(px + d + 1, py + 10 - d - 1);
        px = x;
        py = y;
    }
    cout << px << "\n";
	return 0;
}

Measured memory_bytes: 1948
import bisect

N = int(input())
A = [10**10 - int(input()) for i in range(N)]
INF = 10**12

dp = [INF for i in range(N+1)]
#print(A,dp)

for a in A:
    i = bisect.bisect_right(dp,a)
    dp[i] = a
#print(dp)
res = bisect.bisect_left(dp,INF)
print(res)

Measured memory_bytes: 7848
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int n, p[20], m;
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    sum += p[i];
    m = max(p[i], m);
  }

  cout << sum - m/2 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[100000];
signed main(){
	int a,b;
	cin>>a>>b;
	f(i,a){
		cin>>x[i];
		if(i&&x[i]+x[i-1]>=b){
			puts("Possible");
			f(j,i-1){
				cout<<j+1<<endl;
			}
			for(int j=a-1;j>=i;j--)cout<<j<<endl;
			return 0;
		}
	}
	puts("Impossible");
}


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

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

using namespace std;

int main(void){
  int ans = 0;
  rep(i, 3){
    int t;
    cin >> t;
    ans += t;
  }
  if(ans > 21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int x[52];
long long dp[51][2503];
int main(){
	fastIO;  
	int n,a;
	cin>>n>>a;
	for(int i=1;i<=n;i++)cin>>x[i];
	dp[0][0] = 1;
	int cnt=0;
	for(int i=1;i<=n;i++){
		for(int j=i-1;j>=0;j--){
			for(int k=0;k<=cnt;k++){
				dp[j+1][k+x[i]]+=dp[j][k];	
			}
		}
		/*for(int i=0;i<=n;i++){
			for(int j=0;j<=35;j++){
				cout<<dp[i][j]<<" ";
			}
			cout<<'\n';
		}	
		cout<<'\n';*/
		cnt+=x[i];
	}
	long long ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[i][i*a];
	}	
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1280
div = 1000000007
from math import factorial

N, M = [int(n) for n in input().split()]

res = 1
res *= factorial(N)
res *= factorial(M)
if abs(N-M) > 1:
  res *= 0
elif abs(N-M) == 1:
  res *= 1
else:
  res *= 2
res %= div

print(res)

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define int long long
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; }

signed main()
{
    int N,K; cin>>N>>K;
    double ans=0.0;
    for(int i=1;i<=N;i++){
        double x=i;
        double p=1.0/N;
        while(x<K){
            x*=2;
            p/=2;
        }
        ans+=p;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int fu = 0;
int saishou = 1e9;
ll goukei = 0;

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline void getA() {
	char C = getcha();
	int pn = 1;
	if (C == '-') { fu ^= 1; C = getcha(); }
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	goukei += A;
	saishou = min(saishou, A);
}

int main() {
	fread(cn, 1, cm, stdin); 
	ci = cn;
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	rep(i, N) getA();

	if (fu & 1) goukei -= saishou * 2;

	co(goukei);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
int N, K;
ll dist[20][20];
ll f(int visited, int pos) {
	if (visited == (1 << (2 * K)) - 1) {
		return 0;
	}
	ll r = INF;
	for (int i = 0; i < K; ++i) {
		if (((visited >> i) & 1) == 0) {
			r = min(r, f(visited | (1 << i), i) + dist[pos][i]);
		} else if (((visited >> (K + i)) & 1) == 0) {
			r = min(r, f(visited | (1 << (K + i)), K + i) + dist[pos][K + i]);
		}
	}
	return r;
}
vector<vector<pair<int, int>>> G;
int main() {
	int M, P;
	cin >> N >> M >> K >> P;
	--P;
	G.resize(N);
	for (int i = 0; i < M; ++i) {
		int x, y, w;
		cin >> x >> y >> w;
		--x; --y;
		G[x].push_back({y, w});
		G[y].push_back({x, w});
	}
	vector<int> a(2 * K + 1);
	a[2 * K] = P;
	for (int i = 0; i < K; ++i) {
		int s, t;
		cin >> s >> t;
		--s; --t;
		a[i] = s;
		a[i + K] = t;
	}
	for (int i = 0; i < 2 * K; ++i) {
		vector<ll> D(N, INF);
		priority_queue<pair<ll, int>> Q;
		D[a[i]] = 0;
		Q.push({0, a[i]});
		while (!Q.empty()) {
			ll d = -Q.top().first;
			int v = Q.top().second;
			Q.pop();
			if (d != D[v]) continue;
			for (auto p : G[v]) {
				int vv = p.first;
				ll dd = d + p.second;
				if (dd < D[vv]) {
					D[vv] = dd;
					Q.push({-dd, vv});
				}
			}
		}
		for (int j = i + 1; j <= 2 * K; ++j) {
			if (D[a[j]] == INF) {
				cout << "Cannot deliver" << endl;
				return 0;
			}
			dist[i][j] = dist[j][i] = D[a[j]];
		}
	}
	cout << f(0, 2 * K) << endl;
}


Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long int lli;



int main()
{   
    int X[10][10];
    int count = 0;
    int N, D;
    int sum;
    cin >> N >> D;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }
    for(int i = 0; i< N - 1; i++){
        for(int j = i + 1; j < N; j++){
            sum = 0;
            for(int k = 0; k < D; k++){
                sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]) ;
            }
            if(floor(sqrt(sum)) == ceil(sqrt(sum))){
                count ++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	ll ma = -100000000;
	ll mi = 100000000;
	ll sum = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		ma = max(ma, a);
		mi = min(mi, a);
		sum += a;
	}
	cout << mi << " " << ma << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3212
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from itertools import product
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N = INT()
    ans = [0]*(N+1)
    for x, y, z in product(range(1, int(N**0.5)+1), repeat=3):
        buf = x**2+y**2+z**2+x*y+y*z+z*x
        if buf <= N:
            ans[x**2+y**2+z**2+x*y+y*z+z*x] += 1
    print(*ans[1:], sep="\n")

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9488
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 200000
#define STRLEN 20

int main(void){
    long long x,y, n, d, count=0;
    scanf("%lld %lld", &n, &d);
    for(int i=0;i<n;i++){
        scanf("%lld %lld", &x,&y);
        if(x*x + y*y <= d*d )
        count++;
        x=y=0;
    }
    printf("%lld\n", count);
    return 0;
}


Measured memory_bytes: 1736
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = "";
		if(n==0)s = "0";
		while(n!=0){
			if(n<0){
				s = String.valueOf(n - ((n-1)/-2)*-2) + s;
				n = (n-1)/-2 ;
			}
			else {
				s = String.valueOf(n - (n/-2)*-2) + s;
				n /= -2;
			}
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 23252
a, b = input().split()
if a == "H"and b == 'H':
  print('H')
elif a == 'H' and b == 'D':
  print('D')
elif a == 'D' and b == 'H':
  print('D')
elif a == 'D' and b == 'D':
  print('H')

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define clean(used) memset(used,false,sizeof(used))
using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a==1||b==c){
        if(a==1&&b!=c)cout << 0 << endl;
        else cout << 1 << endl;
    }else if(a==2){
        cout << 3 << endl;
    }else if(c<b){
        cout << 0 << endl;
    }else{
        int ans = (c*(a-1)+b)-(b*(a-1)+c)+1;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;
    vector<int> d;
    for(int i = 1; (ll)i * i <= m; ++i){
        if(m % i == 0){
            d.emplace_back(i);
            if(i * i != m)  d.emplace_back(m / i);
        }
    }
    int ans = 0;
    for(int x : d)  if(m / x >= n)  chmax(ans, x);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
#define i_am_god retun 0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;
std::set<int>::iterator it;

bool jbmo;
set<int>p;
int n,rez;
pair<pair<int,int>,char>pt[1000];

int main(){ _
    cin >> n ;
    for(int i=1;i<=n;i++){
        cin >> pt[i].fr.fr >> pt[i].fr.sc ;
        pt[i].sc='r';
    }
    for(int i=n+1;i<=2*n;i++){
        cin >> pt[i].fr.fr>>pt[i].fr.sc;
        pt[i].sc='b';

    }
    sort(pt+1,pt+2*n+1);
/*    for(int i=1;i<=2*n;i++){
        cout<<pt[i].fr.fr<<" "<<pt[i].fr.sc<<" "<<pt[i].sc<<endl;
    } */
    for(int i=1;i<=2*n;i++){
        jbmo=false;
        if(pt[i].sc=='r'){ p.insert(pt[i].fr.sc); continue;}
        if(p.begin()==p.end()) continue;
            int lef=pt[i].fr.sc;
            it=p.end();
            it--;
            if(*p.begin()>lef) continue;
            while(it!=p.begin()){
                if(*it<lef){
                    rez++;
                    int x=*it;
                    it--;
                    p.erase(x);
                    jbmo=true;
                    break;
                }
                it--;
            }
            if(*it<lef && jbmo==false){
               int x=*it;
               p.erase(x);
               it++;
               rez++;
            } 

    }
    cout<<rez;



}

Measured memory_bytes: 256
import math

n = int(input())

sin60 = math.sin(math.radians(60))
cos60 = math.cos(math.radians(60))
tan60 = math.tan(math.radians(60))

li = [[0, 0], [100, 0]]

for i in range(n):
    j = 0
    if n == 0:
        pass
    elif n == 1:
        li = [[0, 0], [100/3, 0], [50, 100/3*sin60], [100/3*2, 0], [100, 0]]
    else:
        for _ in range(4**i):
            sx = (li[j][0]*2 + li[j+1][0])/3
            sy = (li[j][1]*2 + li[j+1][1])/3
            tx = (li[j][0] + li[j+1][0]*2)/3
            ty = (li[j][1] + li[j+1][1]*2)/3
            ux = (tx-sx)*cos60 - (ty-sy)*sin60 + sx
            uy = (tx-sx)*sin60 + (ty-sy)*cos60 + sy
            li[j+1:0] = [[sx, sy], [ux, uy], [tx, ty]]
            j += 4

for i in range(len(li)):
    print('{:.8f} {:.8f}'.format(li[i][0], li[i][1]))


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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int M = -1;
    // いか
    int ans = 0;
    vector<int> box(N, 0);
    vector<int> index;
    for (int i = N - 1; i >= 0; i--) {
        int cnt = 0;
        for (int j = i; j < N; j += (i + 1)) {
            if (box[j] == 1) cnt++;
        }
        if (A[i] == 0 && cnt % 2 == 0) {
            continue;
        } else if (A[i] == 1 && cnt % 2 == 0) {
            ans++;
            box[i] = 1;
            index.push_back(i);
        } else if (A[i] == 0 && cnt % 2 == 1) {
            ans++;
            box[i] = 1;
            index.push_back(i);
        } else {
            continue;
        }
    }
    cout << ans << endl;
    if (ans != 0) {
        reverse(index.begin(), index.end());
        for (int i = 0; i < index.size() - 1; i++) {
            cout << index[i] + 1 << " ";
        }
        cout << index[index.size() - 1] + 1 << endl;
    }
}

Measured memory_bytes: 3192
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;
void check_input() {
    assert(cin.eof() == 0);
    int tmp;
    cin >> tmp;
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;


int solve() {
    ll k;cin>>k;
    ll n = 50;

    ll q = k/n;
    ll r = k%n;
    dump(q, r);

    vec<ll> a(n, n-1);
    rep(i, r){
        rep(j, n){
            if (j==i) a[j] += n;
            else a[j]--;
        }
    }
    rep(i, n){
        a[i] += q;
    }
    cout << 50 << endl;
    rep(i, sz(a)) cout << a[i] << (i!=sz(a)-1 ? " " : "\n");

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3664
function Main(input)
{
  input = input.split(" ");
  var k = parseInt(input[0],10);
  var n = parseInt(input[1],10);
  var ret = k - n + 1;
  if( ret < 0 ) ret = 0;
  console.log("%d",ret);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()

    stk = []
    ans = collections.deque()

    for i in S:
        if i == '(':
            stk.append(i)
        else:
            if stk and stk[-1] == '(':
                stk.pop()
            else:
                ans.appendleft('(')
        ans.append(i)
    
    while stk:
        ans.append(')')
        stk.pop()

    print(''.join(ans))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10100
#include <stdio.h>

#define MAX 102

int p[MAX], cost[MAX][MAX];

void MinCost(int);
int min();
int rec(int, int);
int min(int, int);

int main(){
  int n, a;

  scanf("%d",&n);
  for(a = 1; a <= n; a++) scanf("%d%d",&p[a-1],&p[a]);
  MinCost(n);

  printf("%d\n",cost[1][n]);
  return 0;
}

void MinCost(int n){
  int a, b;
  for(a = 1; a <= n; a++) cost[a][a] = 0;
  for(a = 1; a < n; a++) cost[a][a+1] = p[a-1]*p[a]*p[a+1];

  for(b = 0; b <= n-3; b++){
    for(a = 3+b; a <= n; a++){
      cost[a-2-b][a] = rec(a-2-b,a);
    }
  }
}

int rec(int r, int c){
  int MIN=2000000000,n=c-r, a;
  for(a = 0; a < n; a++){
    MIN = min(MIN, cost[r][r+a] + cost[r+a+1][c] + p[r-1]*p[r+a]*p[c]);
  }
  return MIN;
}

int min(int x, int y){
  if(x < y) return x;
  else return y;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <string.h>
int main(void){
    
    int i,j;
    char a[101],b[27]={0};
    
    scanf("%s",a);
    
    for(i=0;i<strlen(a);i++){
        for(j=0;j<26;j++){
            if(a[i]-'a'==j){
                b[j]++;
            }
        }
    }
    
    for(i=0;i<26;i++){
        if(b[i]%2!=0){
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
}


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

const int64_t mod = 1e9 + 7;

int64_t solve1(int n, vector<int64_t> a) {
    int64_t res = 0;
    vector<int64_t> csum(n + 1, 0);
    csum[0] = 0;
    for (size_t i = 0; i < n; i++) {
        csum[i + 1] = csum[i] + a[i];
    }
    for (size_t i = 0; i < n; i++) {
        int64_t sum = (csum[n] - csum[i + 1]) % mod;
        res += a[i] * sum;
        res %= mod;
    }
    return res;
}

int64_t solve2(int n, vector<int64_t> a) {
    int64_t res = 0;
    for (size_t i = 0; i < n; i++) {
        for (size_t j = i + 1; j < n; j++) {
            res += a[i] * a[j];
            res %= mod;
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int64_t> a(n);
    for (auto &i : a) cin >> i;
    // printf("solve1: %lld\nsolve2: %lld\n", solve1(n, a), solve2(n, a));
    cout << solve1(n, a) << endl;
}


Measured memory_bytes: 7960
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long double ld;
const long double PI = acos(-1);

int main() {
  ld a, b, x;
  cin >> a >> b >> x;
  ld c, ans;
  if (a * a * b / 2 < x) {
    c = b - (2 * x / (a * a) - b);
    ans = atan(c / a);
  }
  else {
    c = 2 * x / (a * b);
    ans = atan(b / c);
  }
  cout << fixed << setprecision(10) << ans * 180 / PI << endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
 
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
    print(0)    
    exit() 
    
if a == b == c:
    print(-1)
    exit()
    
cnt = 0
while (a % 2 == 0 and b % 2 == 0 and c % 2 == 0): 
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    cnt += 1
 
print(cnt)

Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int h[1500];
int cumsum_h[1501];
int w[1500];
int cumsum_w[1501];
int main(){
  while(true){
    int N;
    int M;
    cin >> N >> M;
    if(N == 0 && M == 0){
      break;
    }
    for(int i = 0; i < N; i++){
      cin >> h[i];
    }
    for(int i = 0; i < M; i++){
      cin >> w[i];
    }

    cumsum_h[0] = 0;
    for(int i = 0; i < N; i++){
      cumsum_h[i + 1] = h[i] + cumsum_h[i];
    }
    cumsum_w[0] = 0;
    for(int i = 0; i < M; i++){
      cumsum_w[i + 1] = w[i] + cumsum_w[i];
    }

    map <int, int> h_count;
    for(int i = 0; i < N; i++){
      for(int j = i + 1; j < N + 1; j++){
        int cur_h = cumsum_h[j] - cumsum_h[i];
        if(h_count.find(cur_h) == h_count.end()){
          h_count[cur_h] = 1;
        } else {
          h_count[cur_h] ++;
        }
      }
    }

    long long ans = 0;
    for(int i = 0; i < M; i++){
      for(int j = i + 1; j < M + 1; j++){
        int cur_w = cumsum_w[j] - cumsum_w[i];
        if(h_count.find(cur_w) != h_count.end()){
          ans += (long long) h_count[cur_w];
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 16464
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &aa : a){
        cin >> aa;
    }
    vector<int> ans;
    for(int i=-100;i<=100;i++){
        int sum = 0;
        for(auto aa : a){
            sum += (aa-i)*(aa-i);
        }
        ans.push_back(sum);
    }
    cout << *min_element(ans.begin(), ans.end()) << endl;
    return 0;
}


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

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


int main()
{
   	int n;cin>>n;
   	vector<pair<double,double>> a(n);
   	rep(i,n){
   	    double x,y;
   	    cin>>x>>y;
   	    a[i]={x,y};
   	}
   	sort(all(a));
   	double res=0;
   	do{
   	    rep(i,n-1){
   	        double dx=a[i].first-a[i+1].first;
   	        double dy=a[i].second-a[i+1].second;
   	        res+=sqrt(pow(dx,2)+pow(dy,2));
   	    }
   	}while(next_permutation(all(a)));
   	double p=1;
   	for(int i = 1; i<=n;++i)p*=i;
   	printf("%.10f",res/p);
}

Measured memory_bytes: 256