akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

void solve(const int N, const vector<ll> A, vector<ll> &ms) {
    {
        int i = 0;
        ll sign = -1;
        ll v = A[i];
        int cur;
        for (int j = 1; j <= N - 2; j++) {
            cur = (i + j) % N;
            v = v + sign * A[cur];
            sign *= -1;
        }
        // cout << i << "," << v << "," << cur << "," << A[(cur + 1) % N] << endl;
        ms[i] = (v + A[(cur + 1) % N]) / 2;
    }

    for (int i = 1; i < N; i++) {
        ms[i] = A[i - 1] - ms[i - 1];
    }
}

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

    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] *= 2;
    }

    vector<ll> ms(N);
    solve(N, A, ms);

    cout << ms[0];
    for (int i = 1; i < N; i++) {
        cout << " " << ms[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2928
#include<stdio.h>

int main(){
int a,b,c,d;
int ascore,bscore;
scanf("%d %d %d %d",&a,&b,&c,&d);
ascore=a+b+c+d;
scanf("%d %d %d %d",&a,&b,&c,&d);
bscore=a+b+c+d;
if(ascore<bscore)
{
printf("%d\n",bscore);
}else if(ascore>bscore)
{
printf("%d\n",ascore);
}
else if(ascore==bscore)
{
printf("%d\n",ascore);
}
return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int n;
    string a;
    cin >> n;
    unordered_set<string> s;
    for range(i,n){
        cin >> a;
        if (s.find(a) != s.end()) { s.erase(a); }
        else { s.insert(a); }
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 10404
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
const int N = 102;
int a[N];

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] == a[j] || a[i] == a[k] || a[j] == a[k])
					continue;
				if (a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[i] + a[k] > a[j])
					ans++;
			}
		}
	}
	cout << ans;
}

int32_t main() {
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}


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

int main()
{
  ios::sync_with_stdio(false);
  int n, x, s = 0, b = 0;
  cin >> n >> x;

  vector<int> vs(n);
  for (int i = 0; i <= n; ++i)
    cin >> vs[i];

  for (int i = 0; i <= n && s <= x; ++i)
  {
    s += vs[i];
    b++;
  }

  cout << b << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int res=0;
  int K;cin>>K;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int l=1;l<=K;l++){
        int tmp=__gcd(i,j);
        res+=__gcd(tmp,l);
      }
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 3628
from collections import Counter

n = int(input())
s = [None] * n
for i in range(n):
    s[i] = input().rstrip()

m = int(input())
t = [None] * m
for i in range(m):
    t[i] = input().rstrip()

ctr = Counter(s) - Counter(t)
if ctr:
    print(ctr.most_common(1)[0][1])
else:
    print(0)

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

using namespace std;

int h,w;
int H,W;

int main()
{
    scanf("%d%d%d%d",&H,&W,&h,&w);
    int ans =(H - h)* W;
    ans -= (H - h) * w;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n, m;
    cin >> n >> m;
    vector <ll> a(m), b(m);
    for(ll i=0; i<m; i++)
    {
        cin >> a[i] >> b[i];
    }
    ll cx = INT_MIN, cy = INT_MAX;
    for(ll i=0; i<m; i++)
    {
        cx = max(cx, a[i]);
        cy = min(cy, b[i]);
    }
    ll ans = max(0LL, cy - cx + 1);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;

    int ans = 0;

    for( int i = 0; i < s.length(); i++ )
        if( s[ i ] != t[ i ] )
            ans++;
    
    cout << ans << "\n";
    
    return 0;
}

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

int main(){
  int n;cin>>n;
  
  int cnt=1;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a%2==0){
      if(a%3!=0)if(a%5!=0)cnt=0;
    }
  }
  
  if(cnt)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long				ll;
typedef pair <int, int> ii;
 
/*
struct point{
	ll x;
	ll y;
	point(){x = 0;y = 0;}
	point(ll x, ll y):x(x), y(y){}
};
*/

int main() {
	
	int n, m;
	cin >> n >> m;
	
	//vector<int> a(m), b(m);
	vector<int> ans(n);
	int a, b;
	rep(i, m) {
		cin >> a >> b;
		ans[a-1]++;
		ans[b-1]++;
	}
	
	rep(i, n) cout << ans[i] << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    int k = sc.nextInt();
    int n = sc.nextInt();
    int res = 0;
    int[] num = new int[n];
    for(int i = 0; i < n; ++i) {
      num[i] = sc.nextInt();
    }
    Arrays.sort(num);
    for(int i = 1; i < n; ++i) {
      if(res < num[i] - num[i - 1]) res = num[i] - num[i - 1];
    }
    if(res < k + num[0] - num[n - 1]) res = k + num[0] - num[n - 1];
    System.out.println(k - res);
  }
}


Measured memory_bytes: 85120
#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() { string s1, s2;
  cin >> s1 >> s2;
  if(s1[0]==s2[2]&&s1[2]==s2[0]&&s1[1]==s2[1]){
    puts("YES");
  }else{
    puts("NO");
  }
}

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

int main() {

  int N;
  long long int K;
  
  cin >> N>>K;
 int  A[N+1];
  int arrive[N+1];
        A[0]=0;
  arrive[0]=-1;
        for(int i=1; i<N+1;i++){
         cin >>A[i]; 
          arrive[i]=-1;
        }
  int s=1;
  int t=0;
    while(arrive[s]==-1){
      if(t==K){
       cout << s <<endl; 
        break;
      }      
      arrive[s]=t;
      t=t+1;
      s=A[s];       
    }
  long long int syuuki;
  if(arrive[s]>-1){
   if(t<=K){
     syuuki=t-arrive[s];
     K=K-arrive[s];
     K=K%syuuki;
     K=K+arrive[s];
     
 
    for(int i=1;i<(N+1);i++){
      if(arrive[i]==K){
        cout << i << endl;
      }//if
     }//for
   }
  }
  
  return 0;

}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName



bool solve(){
	rep(i,5){
		int x;cin>>x;
		if(x==0)cout<<i+1<<endl;
	}
  	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(15);
  solve();
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(seq);
	LL ff = seq / 100, ss = seq % 100;
	if(1 <= ff && ff <= 12) {
		if(1 <= ss && ss <= 12)		puts("AMBIGUOUS");
		else	puts("MMYY");
	}
	else {
		if(1 <= ss && ss <= 12)		puts("YYMM");
		else	puts("NA");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  int n,k; cin >> n >> k;

  if (n%k==0) cout << 0 << endl;
  else cout << 1 << endl;
}

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


Measured memory_bytes: 256
package main

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

type Edge struct {
	to   int
	outi int
}

var mat [][]Edge
var visited []bool
var ans []int
var k int

func dfs(cur, color int) {
	visited[cur] = true

	nexts := mat[cur]
	i, nxcolor := 0, 1
	for i < len(nexts) {
		if visited[nexts[i].to] {
			i++
			continue
		}
		if nxcolor == color {
			nxcolor++
			continue
		}

		dfs(nexts[i].to, nxcolor)

		k = max(k, nxcolor)
		ans[nexts[i].outi] = nxcolor

		i++
		nxcolor++
	}
}

func main() {
	n := readInt()

	mat = make([][]Edge, n)
	for i := range mat {
		mat[i] = make([]Edge, 0)
	}

	for i := 0; i < n-1; i++ {
		a, b := readInt()-1, readInt()-1
		mat[a] = append(mat[a], Edge{b, i})
		mat[b] = append(mat[b], Edge{a, i})
	}

	ans = make([]int, n-1)
	visited = make([]bool, n)

	dfs(0, -1)

	fmt.Println(k)
	for i := range ans {
		fmt.Println(ans[i])
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

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

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

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

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

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 13696
fun main() {
    var (a, b, c, d) = readIntList()

    while (true) {
        if (c > 0) {
            c -= b
        } else {
            println("Yes")
            return
        }
        if (a > 0) {
            a -= d
        } else {
            println("No")
            return
        }
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 36404
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string A, B, C;
	cin >> A >> B >> C;
	Cout(YES(A.back() == B[0] && B.back() == C[0]));
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

b=sorted(b)
c=sorted(c)

from bisect import bisect_right

d=[]
for i in range(n):
    index = bisect_right(c,b[i])    

    d.append(n-index)

import numpy as np
s=sum(d)
cum=np.cumsum(d)

ans=0
for j in range(n):
    dex = bisect_right(b,a[j])
    if dex==0:
        ans+=s
    elif dex==n:
        continue
    else:
        ans+=s-cum[dex-1]

print(ans)
        


Measured memory_bytes: 44164
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define PI 3.14159265
#define take(a,n) for(int i=0;i<(n);i++) cin>>(a)[i]
#define out(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int (i)=0;i<(n);(i)++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

void fastscan(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}

ll poww(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=b;i++)
  {
    ans*=a;
  }
  return ans;
}

inline ll max(ll a, ll b)
{
  if(a>b) re a;
  else re b;
}

inline ll min(ll a, ll b)
{
  if(a>b) re b;
  else re a;
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}


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

  int t=1;
  //fastscan(t);
  while(t--)
  {
    int n,m,k;
    cin>>n;
    vi a(n),b(n),c(n-1);
    forup(i,n)
    {
      cin>>a[i];
      a[i]--;
    }
    forup(i,n)
    {
      cin>>b[i];
    }forup(i,n-1)
    {
      cin>>c[i];
    }
    int ans=0;
    forup(i,n) ans+=b[i];
    for(int i=0;i<n-1;i++)
    {
      if(a[i]==(a[i+1]-1))
      {
        ans+=c[a[i]];
      }
    }

    cout<<ans;


  }


  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int count=0;
			int n=scan.nextInt();
			int[] num = new int[51];
			for(int i=0;i<=9;i++){
				for(int j=0;j<=9;j++){
					for(int k=0;k<=9;k++){
						for(int l=0;l<=9;l++){
							num[i+j+k+l]++;
							//if((i+j+k+l)==n){
								//count++;
						}
					}
				}
			}
			System.out.println(num[n]);
		}
	}
}

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

int main () {
  int N, x;
  std::cin >> N >> x;
  std::vector<int> data(N);
  for (int i=0; i<N; i++) {
    std::cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  int count = 0;
  for (int i=0; i<N; i++) {
    if (x >= data.at(i)) {
      count++;
      x -= data.at(i);
      if (i == N-1 && x > 0) {
      count--;
      }
    }
    else {
      break;
    }
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
T,A,S = map(int, input().split(' '))

persons = [T, A, S]

def check_even(persons):
    for person in persons:
        if person % 2 != 0:
            return False
    return True

# 1 1 1 の判定を先にするため

# 0回目
if not check_even(persons):
    print(0)
    exit()

# 全数同値 -> 無限
if T == A and A == S:
    print(-1)
    exit()

count = 1

while True:
    for person in persons:
        tmp_0 = persons[0]
        tmp_1 = persons[1]
        tmp_2 = persons[2]

        persons[0] = 0 + tmp_1 / 2 + tmp_2 / 2
        persons[1] = tmp_0 / 2 + 0 + tmp_2 / 2
        persons[2] = tmp_0 / 2 + tmp_1 / 2 + 0

        if check_even(persons):
            count += 1
        else:
            print(count)
            exit()


Measured memory_bytes: 9136
#include <cstdio>
#include <algorithm>	// sort
#include <functional>	// greater<T> 構造体

using namespace std;

#define MAX_N 200001
#define ceil(x) ((x) == ll(x) ? x : ll(x) + 1) 
typedef long long ll;

/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;			// メンバーの数 (1≦N≦2・10^5)
ll K;			// 修行回数上限 (1≦N≦10^{18})
ll a[MAX_N];	// 消化コスト (1≦a[i]≦10^6)
ll f[MAX_N];	// 食べにくさ (1≦f[i]≦10^6)

int cond(ll x) {
	// 修行回数上限
	ll k = K;
	// 消化コストを減らして，タイムをx以下にできる(1)か否(0)か
	for(int i = 1; i <= N; i++) {
		if(a[i] * f[i] <= x) continue;
		// 不可能
		if(ceil((a[i] * f[i] - x) / double(f[i]) ) > k) return 0;
 		// k 更新
		k -= ceil((a[i] * f[i] - x) / double(f[i]) );
	}
	// 可能
	return 1;
}

int main () {

	// メンバー数と修行上限の読込み
	scanf("%d %lld", &N, &K);

	// 消化コストと食べにくさの読込み
	for(int i = 1; i <= N; i++)	scanf("%lld", a + i);
	for(int i = 1; i <= N; i++)	scanf("%lld", f + i);

	// 修行前の最適割り当て(ソーティング) 
	// 消化コストの低いメンバー
	std::sort(a + 1, a + 1 + N);
	std::sort(f + 1, f + 1 + N, std::greater<int>());

	// 2分探索
	ll L = -1, R = a[N]*f[1]+1;	// 求める最小値xは(L, R] の範囲内
	while(R - L > 1) {
		ll m = (L + R) / 2;
		if(cond(m) == 1) R = m;
		else L = m;
	}

	// 結果はRの値
	printf("%lld\n", R);

	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S,T;
    cin >> S >> T;
    int n=S.size();
    for(int i=0;i<n;++i) if(S[i]!=T[i]) {cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3592
a,b,x = map(int,input().split(" "))
ans = 0
if a == b and b == x:
    if b % x == 0:
        print(1)
    else:
        print(0)
else:
    D1 = b // x
    if a % x == 0:
        D2 = a // x - 1
    else:
        D2 = a // x
    print(D1 - D2)

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

int main() {
  int N; cin >> N;
  vector<int> v(N), v1(N), v2(N);
  rep(i, N) cin >> v1[i];
  rep(i, N) cin >> v2[i];
  v = v1; sort(v.begin(), v.end());
  int c1 = 0, c2 = 0, cnt = 1;
  do {
    if(v == v1) c1 = cnt;
    if(v == v2) c2 = cnt;
    ++cnt;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(c1-c2) << endl;
}

Measured memory_bytes: 256
N = int(input())
Wset = []
for i in range(N):
    Wset.append(input())
if len(Wset) == len(set(Wset)):
    for i in range(N - 1):
        if Wset[i][-1] != Wset[i + 1][0]:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
mod = 10**9 + 7
def comb(N,x):
    numerator = 1
    for i in range(N-x+1,N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1,x+1):
        denominator = denominator * j % mod
    d = pow(denominator,mod-2,mod)
    return numerator * d % mod

n,k = map(int,input().split())

for i in range(1,k+1):
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Measured memory_bytes: 74064
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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;
    }
};

int main() {

    int n, q;
    cin >> n >> q;
    UnionFind u(n);

    int c, x, y;
    for(int i = 0; i < q; i++){
        cin >> c >> x >> y;
        if(c == 0) {
            u.unite(x, y);
        }else {
            if(u.same(x,y)) {
                cout << 1 << endl;
            }else {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3188
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]

li = [k]*n
for i in a:
    li[i-1] +=1
ans = list(map(lambda x:x-q,li))

for i in ans:
    if(i>=1):
        print("Yes")
    else : print("No")

Measured memory_bytes: 14440
import java.util.Scanner;


public class Main {
	static String[] a = new String[] {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
	static String[] b = new String[] {"D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C"};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int sum = 0;
		int count = 0;
		int amount = 0;
		while(stdIn.hasNext()) {
			count++;
			String tmp = stdIn.next();
			String[] tmpA = tmp.split(",");
			int v = Integer.parseInt(tmpA[0]);
			int a = Integer.parseInt(tmpA[1]);
			sum += v*a;
			amount += a;
		}
		double tmpAve = (double)amount / (double)count;
		int tmpAAve = amount / count;
		if(tmpAve%1.0 >= 0.5) {
			tmpAAve += 1;
		}
		System.out.println(sum +"\n"+tmpAAve);
	}
	
}

Measured memory_bytes: 17128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> pl;
const int INF=100000001;

int main(){
  int n; cin>>n;
  vector<int> a(n+1);
  vector<int> b(n+1);
  for(int i=1;i<n+1;i++) cin>>a[i];

  int m=0;
  for(int i=n;i>0;i--){
    int sum=0;
    int j=2;
    while(i*j<=n){
      if(b[i*j]==1)
      sum++;
      j++;
    }
    if(sum%2==0){
      if(a[i]==1){
        b[i]++;
        m++;
      }
    }else{
      if(a[i]==0){
        b[i]++;
        m++;
      }
    }
  }
  cout<<m<<endl;
  for(int i=1;i<=n;i++){
    if(b[i]==1)
    cout<<i<<(i==n?"\n":" ");
  }
  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define amod 998244353
#define mod 1e9+7
#define ll long long

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

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

  if(a==0)
  cout<<"1\n";
  else if(b==0)
  cout<<"2\n";
  else if(c==0)
  cout<<"3\n";
  else if(d==0)
  cout<<"4\n";
  else if(e==0)
  cout<<"5\n";



return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

  int main(void){
  int N;
  cin >> N; //Nは問題文のK
    unsigned long int x =0;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        for(int k = 0; k < N; k++){
          x = x + gcd( gcd(i+1,j+1) , k+1);
        }
      }
    }
    cout << x << endl;
}

Measured memory_bytes: 3636
s = input()
k = int(input())

len1s = 0
for i in range(len(s)):
    if s[i] == "1":
        len1s += 1
        continue
    else:
        res = s[i]
        break
else:
    res = "1"

if k <= len1s:
    ans = "1"
else:
    ans = res

print(ans)


Measured memory_bytes: 3060
import sys

N=int(input())
L= list(map(int, input().split()))  
#if L[0]!=L[0]:
    #ans1=1
ans=0
for i in range(N):
    for j in range(1,N):
        for z in range(2,N):
            if L[i]!=L[j] and L[j]!=L[z] and L[i]!=L[z]:
                if L[i]<L[j]+L[z] and L[j]<L[i]+L[z] and L[z]<L[j]+L[i]:
                    if i<j and j<z:
                        ans+=1
                    #ans+=1
print(ans)

Measured memory_bytes: 9228
n, a, b = map(int, input().split())

M = 10 ** 9 + 7

all = pow(2, n, M) - 1
all %= M

def C(n,x):
    num = 1
    den = 1
    for i in range(x):
        num *= (n-i)
        num %= M
        den *= (i+1)
        den %= M

    inv = pow(den, M-2, M)

    return num * inv % M

ans = all - C(n,a) - C(n,b)
ans %= M
print(ans)

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  int a,b,c;
  cin >>a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
int x[20][20];
int main(){
    int n, d;
    cin >> n >> d;
    REP(i,n){
        REP(j,d){
            cin >> x[i][j];
        }
    }
    ll s = 0;
    for (int i = 0; i < n ; i++)
    {
       
        for (int j = i+1; j < n; j++)
        { ll cnt = 0;
            for (int k = 0; k < d; k++)
            {
                cnt += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            double y = sqrt(cnt);
            //cerr << y << endl;
            if (y == (int)y)
            {
                s++;
            }
        }
    }

    cout << s << endl;
    return 0;
}

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


K = [[0]*N for i in range(M)]


for i in range(M):
    tmp = list(map(int, input().split()))
    for j in tmp[1:]:
        K[i][j-1] = 1
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    tmp = [0]*M
    for j in range(N):
        if (i >> j) % 2 == 1:
            for k in range(M):
                tmp[k] += K[k][j]
    for j in range(M):
        if tmp[j] % 2 != p[j]:
            break
        if j == M-1:
            ans += 1


print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  ll n, m;
  cin >> n >> m;
  if (n >= m)
  {
    cout << m / 2 << endl;
  }
  else
  {
    ll ans = n;
    m -= 2 * n;
    ans += m / 4;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        
        String result = (s1.substring(0,1) + s2.substring(0,1) + s3.substring(0,1)).toUpperCase();
        
        System.out.println(result);
      
    }
}


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

vector<vector<P>> graph;
vector<int> ans;

void dfs(int node, int color = -1, int pre = -1){ 
    int k = 1;
    for(auto v : graph[node]){
        int fi = v.first;
        int se = v.second;
        if(fi == pre){
            continue;
        }
        if(k == color){
            ++k;
        }
        ans[se] = k;
        ++k;
        dfs(fi, ans[se], node);
    }

}

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

    graph.resize(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].emplace_back(b, i);
        graph[b].emplace_back(a, i);
    }

    ans.resize(n-1);
    dfs(0);

    int k = 0;
    for(auto m : graph){
        k = max(k, (int)m.size());
    }
    cout << k << endl;
    rep(i, n-1){
        cout << ans[i] << endl;
    }

    return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  char c;
  cin >> c;
  if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u') prt("vowel");
  else prt("consonant");
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod = 1e9 + 7;
constexpr int INF = 2e9;

int main() {
  ll n;
  cin >> n;
  string res = "";
  n--;

  while (n >= 0) {
    res += char('a' + (n % 26));
    n /= 26;
    n--;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
} 

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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 200000;
int h,w,n;
pii xy[MAX_N];
pii yx[MAX_N];

int main()
{
  cin >> h >> w >> n;
  for (int i = 0; i < n; ++i) {
    cin >> xy[i].first >> xy[i].second;
    yx[i].first = xy[i].second;
    yx[i].second = xy[i].first;
  }

  sort(xy,xy+n);
  sort(yx,yx+n);
  int col = 1, row = 1, m = h;
  for (int i = 0; i < h; i++) {
    auto it = lower_bound(yx,yx+n,mp(col,row+1));
    if (it != yx+n && it->first == col)
      m = min(m, it->second-1);
    if (col < w && !binary_search(xy,xy+n,mp(row+1,col+1))) {
      col++;
    }
    if (row < h) row++;
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 3328
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        if 2*i > len(dp)-1:
            pass
            '''
            elif dp[2*i] == 0:
            pass
            '''
        else:
            for j in range(2*i, len(dp), i):
                dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)


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

int main(){
	double l, r;
	int la=0,lb=0,lc=0,ld=0;
	int ra=0,rb=0,rc=0,rd=0;
	while(cin >> l >> r){
		if(l >= 1.1){
			la++;
		}
		else if(l >= 0.6){
			lb++;
		}
		else if(l >= 0.2){
			lc++;
		}
		else{
			ld++;
		}

		if(r >= 1.1){
			ra++;
		}
		else if(r >= 0.6){
			rb++;
		}
		else if(r >= 0.2){
			rc++;
		}
		else{
			rd++;
		}
	}
	cout << la << " " << ra << endl;
	cout << lb << " " << rb << endl;
	cout << lc << " " << rc << endl;
	cout << ld << " " << rd << endl;
}

Measured memory_bytes: 1228
N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]


def D2NC(D: int, N: int) -> list:
    res = []
    while D > 0:
        res.insert(0, D % N)
        D //= N
    if not res:
        res.append(0)
    return res


ans = -10**9
for i in range(1, 2**10):
    pattern = ''.join([str(j) for j in D2NC(i, 2)]).zfill(10)
    idx = 0
    ct = 0
    count = [0 for i in range(N)]
    for j in pattern:
        if j == '1':
            idx_2 = 0
            for k in F:
                if k[idx] == 1:
                    count[idx_2] += 1
                idx_2 += 1
        idx += 1
    pro = 0
    for j in range(N):
        pro += P[j][count[j]]
    ans = max(ans, pro)

print(ans)


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


int main(void){
  string T;
  cin >> T;
  for(int64_t i=0;i<T.size();i++){
    if(T.at(i)=='?'){
      T.at(i)='D';
    }
  }
  cout << T << endl;
  
  
  
  
}

Measured memory_bytes: 3720
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 1000, OO = 1e18 + 100, M = 998244353, P = 6151, SQ = 120, lg = 22;
typedef pair <int, int> pii;

int32_t main() {
    use_fast;
    int n, ans = 0;
    cin >> n;
    set <int> s;
    for(int i = 0; i < n; i++) {
    	int x;
    	cin >> x;
    	s.insert(x);
    	if(*s.begin() == x)
    		ans++;
	}
	cout << ans << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 9600
n = gets.chop.to_i
h = gets.chop.split.map(&:to_i)


f = []

n.times do
  f << 0
end


ans = 0

tmp_arr = []

index = 0


while 1 do

  #これはok
  if h == f then
    break
  end

  for i in 0..n-1 do
    if h[i] != f[i]  then
      tmp_arr << i
    end

    if h[i] == f[i] || i == n-1 then

      if !tmp_arr.empty?
        ans +=1
      end

      for tmp in tmp_arr do
        f[tmp] += 1
      end

      tmp_arr = []

    end

  end
end


puts ans


Measured memory_bytes: 1788
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll a,b;
  cin>>a>>b;

  cout<<a*b / gcd(a,b)<<endl;
 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

string curr;
ll sum = 0;

void rec(int ind, ll now1, ll now2) {
    if(ind == curr.size()) {
        sum += now1 + now2;
        return;
    }
    rec(ind + 1, curr[ind] - '0', now2 + now1);
    rec(ind + 1, now1 * 10 + (curr[ind] - '0'), now2);
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> curr;
    rec(0, 0, 0);
    cout << sum / 2ll << 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 repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    int target = 1;
    for(int i=0;i<n;i++){
        if(a[i] == target){
            target++;
        }else{
            ans++;
        }
    }
    if(ans<=n-1)cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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


int main()
{
    long long h,w,hh,ww;
    std::cin >> h >> w;
    long long ws = w / 3;
    long long min = 1000000000;
    for(long long i = 0; i  < 2; i++){
        ww = w - ws;
        long long a,b,c;
        a = h * ws;
        b = h * (ww / 2);
        c = h * ((ww + 2 - 1)/2);
        min = std::min(std::max(std::abs(a - b),std::max(std::abs(b - c),std::abs(c - a))),min);
        a = h * ws;
        b = ww * (h / 2);
        c = ww * ((h + 2 - 1) / 2);
        min = std::min(std::max(std::abs(a - b),std::max(std::abs(b - c),std::abs(c - a))),min);
        ws = (w + 3 - 1) / 3;
    }

    long long hs = h / 3;
    for(long long i = 0; i < 2; i++){
        hh = h - hs;
        long long a,b,c;
        a = w * hs;
        b = w * (hh / 2);
        c = w * ( (hh + 2 - 1) / 2 );
        //std::cerr << a << " : " << b << " : " << c << std::endl;
        min = std::min(std::max(std::abs(a - b),std::max(std::abs(b - c),std::abs(c - a))),min);

        a = w * hs;
        b = hh * (w / 2);
        c = hh * ((w + 2 - 1) / 2);
        min = std::min(std::max(std::abs(a - b),std::max(std::abs(b - c),std::abs(c - a))),min);
        hs = (h + 3 - 1) / 3;
    }
    std::cout << min << std::endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  ll n;
  string s;
  cin >> n >> s;
  ll res = 1LL;
  ll now = 0LL;
  for(int i = 0;i < 2*n;++i){
    if((s[i] == 'B' && now % 2 == 0)
       || s[i] == 'W' && now % 2 == 1){
      ++now;
    }else{
      res = (res * now) % mod;
      --now;
    }
  }
  if(now != 0){
    puts("0");
    return 0;
  }
  for(ll i = 1;i <= n;++i){
    res = (res * i) % mod;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
//By Vlgd
#include<bits/stdc++.h>
#define INF 20000000
using namespace std;
int A[200000],n;
long long ms(int x,int y,int T[]){
	if (y-x>1){
		int m=(x+y)/2;
		int p=x,q=m,i=x;
		long long a=ms(x,m,T);
		long long b=ms(m,y,T);
		long long cnt=0;
		while (p<m||q<y){
			if (q>=y||(p<m&&A[p]<=A[q])) T[i++]=A[p++];
			else{
				T[i++]=A[q++];
				cnt+=(m-p);
			}
		}
		for (int i=x;i<y;i++) A[i]=T[i];
		return a+b+cnt; 
	}
	else return 0;
}
main(){
//	FILE *fp=fopen("5D.txt","r");
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	int *t=(int*)malloc(sizeof(int)*n);
	printf("%lld\n",ms(0,n,t));
//	for(int i=0;i<n;i++) printf("%d ",A[i]);
	free(t);
}


Measured memory_bytes: 4404
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long H, W, N; cin >> H >> W >> N;
	vector<int> a(N), b(N); rep(i, 0, N) { cin >> a[i] >> b[i]; }
	map<pair<int, int>, int >mp;
	int dx[] = { 1,1,0,-1,-1,-1,0,1 }, dy[] = { 0,1,1,1,0,-1,-1,-1 };
	rep(i, 0, N) {
		mp[make_pair(--a[i],--b[i])]++;
		rep(j, 0, 8) {
			int x = a[i] + dx[j], y = b[i] + dy[j];
			mp[make_pair(x, y)]++;
		}
	}
	vector<long long>v(10, 0); v[0] = (H - 2)*(W - 2);
	for (auto &e : mp) {
		if (1 <= e.first.first&&e.first.first <= (H - 2) && 1 <= e.first.second&&e.first.second <= (W - 2)) {
			v[0]--;
			v[e.second]++;
		}
	}
	rep(i, 0, 10)cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 57344
<?php /*atcoder.php*/

$t = new temp();

$t->stdin(fgets(STDIN));

unset($t);

class temp{
	public function stdin($data = null){
		$ans = $data;
		$yen1 = fgets(STDIN);

		if($ans <= 500 ){
			if($ans <= $yen1){
				echo "Yes";
			}else{
				echo "No";
			}
		}else{
			$buf = $ans % 500;
			if(0 == $buf){
				echo "Yes";
			}else{
				if($buf <= $yen1){
					echo "Yes";
				}else{
					echo "No";
				}
			}
		}
	}
	
}

?>


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  int k;
  cin >> k;
  cout << (k/2)*((k+1)/2) <<endl;
  return 0;
}

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

const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;
#define ll long long
vector<int> edge[MAXN];
vector<int> son[MAXN];
int vis[MAXN] = {0};
int n;
ll k;

void tree(int x) {
    vis[x] = 1;
    for (int i : edge[x]) {
        if (!vis[i]) {
            son[x].push_back(i);
            tree(i);
        }
    }
}

ll solve(int x, int dep) {
    ll ans = 1;
    ll v = max(k - dep, k - 2);
    for (int i = 0; i < son[x].size(); i++) {
        ans *= ((v - i) * solve(son[x][i], dep + 1)) % mod;
        ans %= mod;
    }
    return ans;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    tree(1);
    ll ans = (solve(1, 1) * k) % mod;
    cout << ans;
}



Measured memory_bytes: 20288
H,W,A,B = map(int,input().split())
N=H+W
fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=10**9+7

def combination(n):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if k<0 or k>n or n<0:
        return 0
    return (fact[n]*ifact[k]*ifact[n-k])%p
combination(N)

b = op(H-A+B-1, B)
res = 0
for i in range(A):
    res = (res + op(W-B-2+i, i))%p
res = (res*b)%p
for i in range(H-A):
    res = (res + op(B+i, i)*op(H-i-1+W-B-2,W-B-2))%p
if H-A==1 and W-B==1:
    res = 1
elif H-A==1:
    res = op(W-B+H-2, H-1)
elif W-B==1:
    res = op(H-A+W-2, W-1)
print(res)

Measured memory_bytes: 46188