akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &k)

	ans := 0
	for b := 1; b <= n; b++ {
		// n = pb + r
		p := n / b
		r := n % b
		ans += p*max(b-k, 0) + max(r+1-k, 0)
		if k == 0 {
			ans--
		}
	}

	fmt.Println(ans)
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int main() {
    //変数の宣言
    double r;
    
    //入力
    scanf("%lf", &r);
    
    printf("%f %f\n", r*r*M_PI, 2.0*r*M_PI);
    
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  string s;
  cin >> s;
  bool ok = true;
  if (!(s.length() & 1))
  {
    for (int i = 0; i < s.length(); i += 2)
    {
      if (s.substr(i, 2) != "hi")
        ok = false;
    }
  }
  else
    ok = false;
  puts(ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>

using namespace std;

struct node {
	int key;
	node *next, *prev;
};

class list {
	int length;
public:
	node *head, *tail;
	list(): length(0) {
		head=new node;  //????????§??????????¢???????????????¨??????????????????????????¨??????????????????????????§????????¢???????¢?????????????????????????
		tail=new node;
		head->next=tail;
		head->prev=NULL;
		tail->next=NULL;
		tail->prev=head;
	} 

	int len(){  return length;  }

	void insert(int);
	void del(int);
	void dell();
	void delf();

	
};

void list::insert(int x)
{
	node* nx=new node;

	if( !nx ){
		cout<<"MEMORY ALLOCATION ERROR!"<<endl;
		exit(1);
	}

	length++;


	nx->next=head->next;
	nx->prev=head;
	head->next->prev=nx; 
	head->next=nx;
	nx->key=x;

	
}	

void list::del(int x)   //???????????????????????????????????????!!
{
	node *t=head;
	while( t->next != tail ) {
		t=t->next;
		if( t->key == x ){
			t->prev->next=t->prev->next->next;
			t->next->prev=t->next->prev->prev;

			delete t;


			



			length--;

			return;
		}
	}
}

void list::dell()
{
	if( head->next==tail )
		return;
	node *d=tail->prev;

	tail->prev->prev->next=tail;
	tail->prev=tail->prev->prev;


	delete d;

	length--;
}

void list::delf()
{
	if( head->next==tail )
		return;
	node *d=head->next;

	head->next->next->prev=head;
	head->next=head->next->next;

	delete d;
	length--;
}

void show(list l) 
{
	for( node *t=l.head->next; t !=l.tail; t=t->next ){
		if( t->next != l.tail )
			cout<<t->key<<' '<<flush;
		else
			cout<<t->key<<endl;
	}
}
int main() 
{

	long n;cin>>n;
	char com[20];
	int x;
	list dll;

	for( long i=0; i<n; i++ ) {
		scanf("%s",com);
		
		if( com[0]=='i' ){
			scanf("%d",&x);
			dll.insert(x);
		}else if( com[0]=='d' && com[6]=='F' )
			dll.delf();
		else if( com[0]=='d' && com[6]=='L' )
			dll.dell();
		else{
			scanf("%d",&x);
			dll.del(x);
		}
	}

	show(dll);
}

Measured memory_bytes: 32424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		int[] v = new int[n];
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(reader.readLine());
			v[i] = Integer.parseInt(st.nextToken());
			w[i] = Integer.parseInt(st.nextToken());
		}
		reader.close();
		System.out.println(getMaxValue(n, W, v, w));
	}
	
	private int getMaxValue(int n, int W, int[] v, int[] w) {
		int[][] dp = new int[n+1][W+1];
		for (int i = 1; i <= n; i++) {
			int vl = v[i-1];
			int wt = w[i-1];
			for (int j = 1; j <= W; j++) {
				if (wt > j) {
					dp[i][j] = dp[i-1][j];
				} else {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-wt] + vl);
				}
			}
		}
		return dp[n][W];
	}	
}


Measured memory_bytes: 29040
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, C, X, Y := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	ans := 0
	if 2*C < A+B {
		mi := min(X, Y)
		for mi > 0 {
			X--
			Y--
			ans += 2 * C
			mi--
		}
		if X > 0 && 2*C < A {
			ans += 2 * C * X
		} else if Y > 0 && 2*C < B {
			ans += 2 * C * Y
		} else {
			ans += A*X + B*Y
		}
	} else {
		ans += A*X + B*Y
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

using namespace std;

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

    string s,t;
    cin >> s >> t;

    int last = t.length();
    for(int x=0;x<=(s.size()-t.size());x++){
        int min = 0;
        for(int y=0;y<t.length();y++){
            if(s[x+y]!=t[y])min++;
        }
        //cout << min << endl;
        if(min<last){
            last = min;
        }
    }
    cout << last << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
set<int> multi;
bool tell(string str){
	if(str.size() == 0)return false;
 int z = std::stoll(str);
 if(z%2019 == 0)return true;
 return false;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
int n = (int)str.length();
int dp[2020];
memset(dp , 0 , sizeof(dp));
int ans = 0;
dp[str[0]-'0'] = 1;
for(int i = 1 ;  i < n ; i++){
	int dp2[2019] = {0};
	dp2[str[i]-'0']++;
	  for(int j = 0 ; j < 2019 ;j++){
			 if(dp[j] > 0){
			     dp2[(j*10 + (str[i]-'0'))%2019] += dp[j];
			     //dp2[(j*10 + (str[i]-'0'))%2019]++;
			  }
	  }
	 // cout<<endl;
	 // dp[str[i]-'0']++;
	 ans += dp2[0];
	 for(int i = 0 ; i < 2019 ; i++)dp[i] = dp2[i];
}
//return 0;
cout<<ans<<endl;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,ans = 0;
  cin >> N;
  rep(i,N+1){
    if(i == 0){
      continue;
    }
    else if(i < 10){
      ans++;
    }
    else if(i > 99 && i < 1000){
      ans++;
    }
    else if(i > 9999 && i < 100000){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3644
n, a, b, c = [int(it) for it in input().split()]
ls = [int(input()) for it in range(n)]
def dfs(cur, tmpA, tmpB, tmpC):
    if cur == n:
        return abs(a - tmpA) + abs(b - tmpB) + abs(c - tmpC) if tmpA > 0 and tmpB > 0 and tmpC else 10**20
    return min(
        dfs(cur + 1, tmpA + ls[cur], tmpB, tmpC) + (10 if tmpA > 0 else 0),
        dfs(cur + 1, tmpA, tmpB + ls[cur], tmpC) + (10 if tmpB > 0 else 0),
        dfs(cur + 1, tmpA, tmpB, tmpC + ls[cur]) + (10 if tmpC > 0 else 0),
        dfs(cur + 1, tmpA, tmpB, tmpC)
    )

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long maximum;
long long mod = 1000000007;
vector<long long> fct(0),invfct(0);
const int INF = 1001001001;

long long modpow(long long a,long long n, long long mod){
    long long res = 1;
    while(n>0){
        if ( n & 1 ) res = (res * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

void fct_input(long long maximum,long long mod){
    fct.resize(maximum+1,-1);
    fct.at(0) = 1;
    fct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        fct.at(i) = x;
    }
 }

void invfct_input(long long maximum,long long mod){
    invfct.resize(maximum+1,-1);
    invfct.at(0) = 1;
    invfct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        invfct.at(i) = modpow(x,mod - 2,mod);
    }
}

int main(){
  ll x,y;
  cin >> x >> y;
  ll nn = (x+y)/3;
  if((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  ll aa = min(x,y);
  ll no2 = aa - nn;
  if(no2<0 || no2>nn){
    cout << 0 << endl;
    return 0;
  }
  maximum = nn+1;
    fct_input(maximum,mod);
    invfct_input(maximum,mod);
    
    ll ans;
    ans = ((invfct.at(no2) * invfct.at(nn-no2) % mod) * fct.at(nn) ) % mod;
    cout << ans << endl;

}

Measured memory_bytes: 10624
#include <stdio.h>

int main(void){
int p,q,r,min,n1,n2,n3;
scanf("%d",&p);
scanf("%d",&q);
scanf("%d",&r);
n1 = p + q;
n2 = q + r;
n3 = r + p;
min = n1;
if(n2<min) {
  min = n2;
}
if(n3<min){
  min = n3;
}
printf("%d\n",min);
return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = (1LL << 50);

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };



int A[3][3];
int diff[3][3];
int main() {
	ll H, W;


	rep(i, 3) {
		rep(j, 3)
			cin >> A[i][j];
	}


	rep(i, 3) {
		rep(j, 3) {
			diff[i][j] = A[i][j] - A[i][(j + 1) % 3];

		}

	}

	bool flag = true;
	rep(i, 3) {

		if (diff[0][i] == diff[1][i] && diff[1][i] == diff[2][i])
			continue;
		else
			flag = false;

	}


	if (flag == false)
		cout << "No" << endl;



	else
		cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

num = a[0]
tmp = a[1]
for j in range(1, n):
  if abs(tmp-num/2) >= abs(a[j]-num/2):
    tmp = a[j]
  else:
    break
ans = [num, tmp]
print(*ans)

Measured memory_bytes: 20000
using System;

namespace ITP1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            string[] str1 = Console.ReadLine().Split(' ');
            n = int.Parse(str1[0]);
            m = int.Parse(str1[1]);

            int[,] a = new int[n, m];
            int[] b = new int[m];
            int[] ans = new int[n];

            for(int i = 0; i < n; ++i)
            {
                string[] str2 = Console.ReadLine().Split(' ');
                for(int j = 0; j < m; ++j)
                {
                    a[i, j] = int.Parse(str2[j]);
                }
            }

            for(int i = 0; i < m; ++i)
            {
                string str3 = Console.ReadLine();
                b[i] = int.Parse(str3);
            }

            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < m; ++j)
                    ans[i] += a[i, j] * b[j];
                Console.WriteLine("{0}", ans[i]);
            }

        }
    }
}

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=(ll)2e3 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 , MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
	ll n,k;
	cin >> n >> k;
	vl a(n);
	for(ll i=0;i<n;i++)
		cin >> a[i];

	ll logk=0,x=k;

	while(x){
		logk++;
		x/=2;
	}
	ll next[n][logk+1];

	for(ll i=0;i<n;i++){
		next[i][0]=a[i]-1;
	}

	for(ll i=1;i<=logk;i++){
		for(ll j=0;j<n;j++){
			next[j][i]=next[next[j][i-1]][i-1];
		}
	}

	x=k;
	ll ans,cur;
	cur=0;
	while(x){
		ll l=log2(x);
		// cout << cur << " ";
		cur=next[cur][l];
		// cout << l << " " << cur << "\n";
		x-=(1ll<<l);
	}

	cout << cur+1 << "\n";
	return;

}

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

	

	// to avoid printing in Scientific Notation like 2.14748e+09 and instead print: 2147483648.000000
	cout << fixed ;
	
	// precomp();
	ll t,z;
	// cin >> t;
	t=1;
	// z=t;
	while(t--){
			// cout << "Case #" << z-t << ": " << "\n";
	        work();
	
	}

	return 0;
}
	

Measured memory_bytes: 100004
# -*- coding:utf-8 -*-
def gcd(n,m):
    if n < m:
        tmp = m
        m = n
        n = tmp
    while m > 0:
        r = n % m
        n = m
        m = r
    return n
    
x, y = map(int,input().split())
print(gcd(x,y))

Measured memory_bytes: 7720
#include<stdio.h>
int main(){
int n,a[1000],b[1000],c[1000],i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&a[i],&b[i],&c[i]);
}
for(i=0;i<n;i++){
if(a[i]*a[i]+b[i]*b[i]==c[i]*c[i]||c[i]*c[i]+b[i]*b[i]==a[i]*a[i]||a[i]*a[i]+c[i]*c[i]==b[i]*b[i]){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return 0;
}

Measured memory_bytes: 1020
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	giftMoneyCount := readLineToInt(sc)

	outputValue := 0.0

	for index := 0; index < giftMoneyCount; index++ {
		inputValues := explodeString(" ", readLine(sc))

		inputMoney, err := strconv.ParseFloat(inputValues[0], 64)
		if err != nil {
			panic(err)
		}
		inputCurrency := inputValues[1]

		if inputCurrency == "BTC" {
			outputValue += inputMoney * 380000.0
		} else {
			outputValue += inputMoney
		}
	}

	fmt.Println(outputValue)
}

// helper

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return strings.TrimSpace(sc.Text())
}

func readLineToInt(sc *bufio.Scanner) int {
	intValue, err := strconv.Atoi(readLine(sc))
	if err != nil {
		panic(err)
	}

	return intValue
}

func explodeString(delimiter string, inputValue string) []string {
	splittedValue := strings.Split(inputValue, delimiter)

	var trimmedValues []string

	for _, value := range splittedValue {
		if value != "" {
			trimmedValues = append(trimmedValues, value)
		}
	}

	return trimmedValues
}

func explodeInt(delimiter string, inputValue string) []int {
	inputStrings := explodeString(" ", inputValue)

	var splittedInts []int

	for _, inputString := range inputStrings {
		var (
			intValue int
			err      error
		)
		intValue, err = strconv.Atoi(inputString)

		if err != nil {
			panic(err)
		}
		splittedInts = append(splittedInts, intValue)
	}

	return splittedInts
}


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

int main() {
    int N;
    int64_t W;
    cin >> N >> W;
    
    vector<int64_t> value(N + 1, 0);
    vector<int> weight(N + 1, 0);
    for (int i = 1; i < N + 1; i++) {
        cin >> weight[i] >> value[i];
    }
    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(W + 1, 0));
    for (int i = 1; i < N + 1; i++) {
        for (int64_t j = 0; j < W + 1; j++) {
            // 品物iをナップサックに入れることができる
            if (weight[i] <= j) {
                // 入れて、余った重量分をDPテーブルから参照
                int64_t temp1 = value[i] + dp[i - 1][j - weight[i]];
                // 入れない場合
                int64_t temp2 = dp[i -1][j];
                // 比較して価値の高い方をDPテーブルに記録
                dp[i][j] = max(temp1, temp2);
            }
            // 品物iを入れられない 
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N][W] << endl;
}

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back

using namespace std;

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


int N;
int a[3003];
ll pd[3003][3003];
bool calc[3003][3003];

ll solve(int i, int j){
	if(i==j)  return a[i];
	if(i>j) return 0;
	if(calc[i][j]) return pd[i][j]; calc[i][j] = 1;
	ll aa = min(solve(i+2, j)+a[i], solve(i+1, j-1)+a[i]);
	ll bb = min(solve(i, j-2)+a[j], solve(i+1, j-1)+a[j]);
	return pd[i][j] = max(aa, bb);
}

int main(){

	cin >> N; ll tt = 0;
	rep(i, 0, N) cin >> a[i], tt+=a[i];
	
	memset(pd, -1, sizeof pd);
	
	ll X = solve(0, N-1);
	
	cout << X - (tt-X) << '\n';
	
	return 0;
}

Measured memory_bytes: 79616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
  ll n;cin>>n;
  vector<P> v(n);
  rep(i,n){
    cin>>v.at(i).second>>v.at(i).first;
  }
  sort(v.begin(),v.end());
  bool ok = true;
  if (v.at(0).second > v.at(0).first){
    ok = false;
  }
  rep(i,n-1){
    if(v.at(i).second + v.at(i+1).second <= v.at(i+1).first){
      v.at(i+1).second += v.at(i).second;
    }
    else{
      ok = false;
    }
  }
  if (ok){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3328
#include  <bits/stdc++.h>
using namespace std; 
 
int main()
{
	int n,m;
	cin>>n>>m;
	int a[401]={0},an=0,e[101]={0},o[101]={0},p=0,q=0;
	int temp;
 	for(int i=1;i<=n*2;i++)
	{
		if(i%2==0)
		{
			p++;
	        e[p]=i;
		}
    }
	for(int i=1;i<=m*2;i++) 
	{
		if(i%2==1)
		{
			q++;
		   o[q]=i;
		}
    }
	for(int i=1;i<=n;i++) 
	{
		for(int j=1;j<=m;j++)
		{
			temp = e[i]+o[j];
			if(((e[i]+o[j]) != 0)&&((e[i]+o[j])%2==0))
			{
				an++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	   for(int j=i+1;j<=n;j++)
	   {
	      if(((e[i]+e[j]) != 0)&&((e[i]+e[j])%2==0))
			{
				an++;
			}
	   }
	for(int i=1;i<=m;i++)
	   for(int j=i+1;j<=m;j++)
	   {
	      if(((o[i]+o[j]) != 0)&&((o[i]+o[j])%2==0))
			{
				an++;
			}
	   }


	cout<<an;
	return 0;
}   

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(){
 
  char S[51];
  char T[51];
  scanf("%s %s",S,T);
 
  int Slen;
  int Tlen;
  int i;
  int j;
  int flag=0;
  int n = 0;
  Slen = strlen(S);
  Tlen = strlen(T);
  for(i = Slen - Tlen; i >= 0 ; i--){
    n = 0;
    for(j = 0; j < Tlen; j++){
      if( (S[i+j] != T[j]) && (S[i+j] != '?') )
        n = 1;
    }
 
    if(n == 0){
      flag = 1;
      for(j = 0; j < Tlen; j++){
        if(S[i+j] == '?'){
          S[i+j] = T[j];
        }
      }
      break;
    }
  }
 
  if( flag == 0 ){
    printf("UNRESTORABLE\n");
    return 0;
  }
 
  for(i = 0; i < Slen; i++){
    if(S[i] == '?') S[i] = 'a';
  }
  printf("%s\n",S);
  return 0;
}

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

const long long MOD = 1e9 + 7;

long long pw(long long a, long long n) {
    if (n == 0) return 1;
    long long q = pw(a, n / 2);
    if (n % 2 == 0) return q * q % MOD;
    return q * q % MOD * a % MOD;
}

long long fact[500005], inv[500005];

long long combi(int n, int k) {
    if (n < k || k < 0) return 0;
    return fact[n] * inv[n - k] % MOD * inv[k] % MOD;
}

int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(NULL);


    int n, m;
    cin >> n >> m;
    fact[0] = inv[0] = 1;
    for (int i = 1; i <= m; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = pw(fact[i], MOD - 2);
    }


    long long res = 0;
    for (int i = 0; i <= n; i++) {
        long long val = combi(n, i) * combi(m, i) % MOD;
        val = val * combi(m - i, n - i) % MOD * combi(m - i, n - i) % MOD;
        val = val * fact[i] % MOD * fact[n - i] % MOD * fact[n - i] % MOD;
        if (i % 2 == 0) {
            res += val;
        }
        else {
            res -= val;
        }
        res %= MOD;
        // cout << res << endl;
    }

    cout << (res + MOD) % MOD << endl;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int a[111111],b[111111];

int t[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	memset(t,0,sizeof(t));
	rep(i,n){
		int a,b;
		cin>>a>>b;
		a--; b--;
		t[a]++;t[b+1]--;
	}
	int res=0;
	rep(i,n+1){
		t[i+1]+=t[i];
		if(i+1<=t[i+1])maxch(res,i+1);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll add(ll a,ll b){return (a+b)%mod;}
ll mul(ll a,ll b){return (a*b)%mod;}

ll mpow(ll a,ll b){
  if(b==0)return 1;
  ll res=mpow( mul(a,a) , b/2);
  if(b&1)res=mul(res,a);
  return res;
}
ll divi(ll a,ll b){
  return mul(a, mpow(b,mod-2) );
}

ll fact[3000005];
ll Fact[3000005];
typedef pair<ll,ll> P;

unordered_map< ll , ll  > mem;

ll base=10000000000LL;

ll nCr(ll n,ll r){
  
  if(mem.count(n*base+r))
    return mem[n*base+r];
  
  return mem[n*base+r]=mul(fact[n], mul(Fact[r],Fact[n-r]) );
}

ll nHr(ll n,ll r){
  if(r==0)return 1;
  return nCr(n+r-1,r-1);
}

ll nBr(ll n,ll r){
  if(n<r)return 0;
  return nHr(n-r,r);
}

ll A,B,C,D,E;


int main(){
  fact[0]=1;
  for(ll i=1;i<3000005;i++){
    fact[i]=mul(fact[i-1],i);
  }
  for(ll i=0;i<3000005;i++)Fact[i]=divi(1,fact[i]);
  
  while(1){
    mem.clear();
    
    cin>>A>>B>>C>>D>>E;
    if(A==0&&B==0&&C==0&&D==0&&E==0)break;
    
    ll ans=0;
    for(ll i=0;i<=1000000;i++){
      ll j=-(D-E-i);
      if(i<A)continue;
      if(A==0&&i>0)continue;
      if(i>D)continue;
      if(j<B)continue;
      if(B==0&&j>0)continue;
      if(j>E)continue;
      ll L=nBr(i,A);
      ll R=nBr(j,B);
      ll tmp=mul(L,R);
      tmp=mul(tmp, nCr(A+B,A) );
      tmp=mul(tmp, nCr(A+B+C,C) );
      assert( D-i == E-j );
      tmp=mul(tmp, nHr(D-i,A+B+C) );
      ans=add(ans,tmp);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 123816
#include <iostream>
#include <string>
using namespace std;
int main(void){
    bool a[4]={false};
    string s,ans="Yes";
    cin>>s;
    for(int i=0;i<s.length();i++){
        switch(s[i]){
            case 'N':
            a[0]=true;
            break;
            case 'W':
            a[1]=true;
            break;
            case 'S':
            a[2]=true;
            break;
            case 'E':
            a[3]=true;
            break;
        }
    }
    if(a[0]!=a[2]||a[1]!=a[3]){
        ans="No";
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

void print_vector2(vector<vector<ll> >v){
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v){
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;
    if (a == b)
        return a;
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}

int main(){
        ll n, m;
        cin>>n>>m;
        vector<ll> h(n), v(n, 1);
        for(ll i=0; i<n; i++){
            cin>>h[i];
        }
//        print_vector1(h);
//        print_vector1(v);
        for(ll i=0; i<m; i++){
            ll a, b;
            cin>>a>>b;
            if(h[a-1] < h[b-1]){
                v[a-1] = 0;
            }
            else if(h[a-1] > h[b-1]){
                v[b-1] = 0;
            }
            else{
                v[a-1] = 0;
                v[b-1] = 0;
            }
        }
//        print_vector1(v);
        cout<<accumulate(v.begin(), v.end(), 0);

    return 0;
}


Measured memory_bytes: 4844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<deque>
using namespace std;

const int M = 1000001;
int B,n,m,k,a[M],res,f[M];
deque<int>mn,mx; 
int main()
{
	scanf("%d%d",&n,&k);
	a[0]=0x3f3f3f3f;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		if(a[i]>a[i-1]) f[i]=f[i-1]+1;
	}
	for(int i=1;i<=n;i++)
	{
		while(mn.size() && a[i]<a[mn.back()]) mn.pop_back();
		while(mx.size() && a[i]>a[mx.back()]) mx.pop_back();
		mn.push_back(i), mx.push_back(i);
		if(i<k) continue; res+=1;
		
		if(mn.size() && mn.front()<i-k) mn.pop_front();
		if(mx.size() && mx.front()<i-k) mx.pop_front();
		if(f[i]>=k-1) 
		{
			B+=1; continue;
		}
		if(mx.front()==i && mn.front()==i-k) res-=1;
	}
	if(B) res-=B-1;
	printf("%d\n",res);
}

Measured memory_bytes: 5888
#include<stdio.h>
  
#define AMAX 20
#define MMAX 2000
 
int n, q;
int isExist[ MMAX+1 ] = {0};

int main( void ) 
{
    int i, j;
    int num;

    scanf( "%d", &n );
    for( i=0; i<n; i++ ) {
        scanf( "%d", &num );
        for( j=MMAX-num; 0<j; j-- ) {
        	if( isExist[ j ] ) {
        		isExist[ j+num ] = 1;
        	}
        }
        isExist[ num ] = 1;        
    }
    scanf( "%d", &q );
    for( i=0; i<q; i++ ) {
        scanf( "%d", &num );
    	if( isExist[ num ] ) {
            printf( "yes\n" );      
        } else {
            printf( "no\n" );
        }
    }
    return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

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



int main(){
    int R;
    cin >> R;
    cout << std::setprecision(6) << R * 2 * 3.1415926535 << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;

void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	VI v(N); REP(i, N) cin >> v[i];

	VPII cnt1(100000 + 1, {0,0}), cnt2(100000 + 1, {0,0});
	for(int i = 0; i < N; i += 2){
		cnt1[v[i]].first += 1;
		cnt1[v[i]].second = v[i];
	}
	for (int i = 1; i < N; i += 2) {
		cnt2[v[i]].first += 1;
		cnt2[v[i]].second = v[i];
	}
	sort(ALL(cnt1), greater<pair<int, int>>());
	sort(ALL(cnt2), greater<pair<int, int>>());

	if(cnt1[0].second != cnt2[0].second){
		cout << (N / 2 - cnt1[0].first) + (N / 2 - cnt2[0].first) << endl;
	}

	else{
		cout << min((N / 2 - cnt1[0].first) + (N / 2 - cnt2[1].first), (N / 2 - cnt1[1].first) + (N / 2 - cnt2[0].first)) << endl;
	}
	return 0;
}



Measured memory_bytes: 2176
import sys
import heapq

f = sys.stdin

n,m,x = map(int,f.readline().split())
h = [None] + [int(f.readline()) for _ in range(n)]
tuple_abt = [tuple(map(int, line.split())) for line in f]

dict_abt = {}
for ai,bi,ti in tuple_abt:
    try:
        if ti <= h[ai]:
            dict_abt[ai][bi] = ti
    except KeyError:
        dict_abt[ai] = {bi:ti}
    try:
        if ti <= h[bi]:
            dict_abt[bi][ai] = ti
    except KeyError:
        dict_abt[bi] = {ai:ti}

class Tree:
    def __init__(self, t, h, jump_t=0, next_h=0):
        if jump_t:
            t += jump_t
            h -= jump_t
            if h < 0:# 登って辻褄を合わせる
                t += -h
                h = 0
            if next_h < h:# 降りて辻褄を合わせる
                t += h - next_h
                h = next_h
        self.t = t
        self.h = h
        self.d = t - h #基本的に高い位置の方が早い為

d = [None] * (n + 1)
d[1] = Tree(0, x)
q = [(d[1].d, 1)] # (d(v), v)
while len(q):
    _, u = heapq.heappop(q) #コストが最小の木を取得
    if u not in dict_abt:
        continue
    for v, t in dict_abt[u].items():
        dv = Tree(d[u].t, d[u].h, t, h[v])
        if d[v] == None or d[v].d > dv.d:
            d[v] = dv
            heapq.heappush(q,(d[v].d, v))
if d[-1]:
    print(d[-1].t + h[-1] - d[-1].h)
else:
    print(-1)

Measured memory_bytes: 164576
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int n,k,sum,max;
	int a[100001];
	while(scanf("%d %d",&n,&k)){
		if(n==0&&k==0)
		break;
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		sum=0;
		max=0;
		for(int i=0;i<n;i++){
			if(i<k)
			sum+=a[i];
			else if(i>=k){
				sum+=a[i];
				sum-=a[i-k];
			}
			if(i==k-1)
			max=sum;
			else if(i>k-1){
				max=(max<sum ? sum:max);
			}
		}
		printf("%d\n",max);
	}
}

Measured memory_bytes: 3496
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <math.h>
#include <time.h>
#include <assert.h>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 1000000007
#define N 1000005

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;}
template<typename U> U gcd(U a, U b){
    if(a == 0)return b;
    if(b == 0)return a;
    if(a >= b)return gcd(a % b, b);
    else return gcd(a, b % a);
}
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}
int pow(int a, ll b, int c){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % c;
        a = 1LL * a * a % c;
        b >>= 1;
    }
    return ans;
}

char s[N];
int a[N], f[N];
int C(int a, int b){
  if(b == 0 || b == a)return 1;
  int k = f[a] - f[b] - f[a-b];
  return k > 0 ? 0 : 1;
}
int main(){
  int T, m, i, j, k, n, K;
  scanf("%d%s", &n, s);
  rep(i, 0, n-1){
    a[i] = abs(s[i] - s[i+1]);
  }
  n--;
  rep(i, 1, n+1){
    k = i;
    j = 0;
    while(k % 2 == 0)k /= 2, j++;
    f[i] = f[i-1] + j;
  }
  rep(it, 0, 2) {
    m = 0;
    k = 0;
    rep(i, 0, n)if(a[i] & 1){
      m += C(n-1, i);
      k++;
    }
    if(m & 1){
      if(it == 0)puts("1");
      else puts("2");
      return 0;
    }
    if(k){
      puts("0");
      return 0;
    }
    rep(i, 0, n)a[i] /= 2;
  }
  puts("0");
}


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

int main() {
    string s;
    std::cin >> s;
    ll ns = s.length();
    vector<ll> xcnt(ns);
    ll now = 0;
    string t="";
    // x抜きが回分かチェック
    for (int i = 0; i < ns; i++) {
        if(s[i]!='x'){
            t = t + s[i];
        }
    }
    ll ts = t.size();
    for (int i = 0; i < ts/2; i++) {
        if(t[i] != t[ts-1-i]){
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    
    for (int i = 0; i < ns; i++) {
        if(s[i]=='x'){
            xcnt[now]++;
        }else{
            now++;
        }
    }
    ll res = 0;
    for (int i = 0; i < (ts+1)/2; i++) {
        res += (ll)abs( xcnt[i]-xcnt[ts-i] );
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 1464
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x = I()
    t = 100
    r = 0
    while t < x:
        r += 1
        t += t // 100

    return r


print(main())





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

signed main(){
  ll n, A, B; cin >> n >> A>> B;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	ll left = 0, right = 1e9+2;
	while(right - left > 1){
		ll mid = (right + left) / 2, num = 0;
		for(int i = 0; i < n; i++) {
			ll x = a[i] - mid * B;
			if(x <= 0) continue;
			num += (x + A - B - 1) / (A - B);
		}
		if(num > mid) left = mid;
		else right = mid;
		//cout << left << endl;
	}
	cout << right << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
  	set<int> st;
  	for(int i=0;i<n;i++){
    	int x; cin >> x;
        st.insert(x);
    }
  if(st.size()==n) puts("YES");
  else puts("NO");
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<limits.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[100][100];

void dijkstra(void);

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

  dijkstra();

  return 0;
}
  
void dijkstra(void){
  int i,u,v,minv,d[100],color[100];
  for(i=0;i<n;i++){
    d[i]=INT_MAX;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INT_MAX;
    u=-1;
    for(i=0;i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=BLACK;
    for(v=0;v<n;v++){
	if(color[v] != BLACK && M[u][v] != INT_MAX){
	  if(d[v] > d[u] + M[u][v]){
	    d[v] = d[u] + M[u][v];
	    color[v] = GRAY;
	  }
	}
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INT_MAX){
      printf("-1");
    }else{
      printf("%d",d[i]);
    }
    printf("\n");
  }
}
      
  



Measured memory_bytes: 2100
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
    
  
   
    void solve(){
        int n,k;
        cin>>n>>k;
        ll ans=0,a;
        vl pre(n+1);
        map<ll,ll> mp;
        ll pref =0;pre[0]=0; 
        mp[0] =1;
        for(int i=0;i<n;i++){
            cin>>a; a--;
            pref = pref+a;
            pref = pref%k;
            pre[i+1] =pref;
            if(i-k+1>=0) mp[pre[i-k+1]] --;
            if(mp.count(pref)){
                ans += mp[pref];
                mp[pref]++;
            }
            else {
                mp[pref] = 1;
            }
        }
        cout<<ans;
    }
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       // int n; cin>>n; for(int i=0;i<n;i++)
        solve();
        return 0;
    } 
    

Measured memory_bytes: 14336
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b * c / max({a, b, c}) / 2 << "\n";
    
    return 0;
}

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

char in[100];
int main(){
	while(cin.getline(in,99)&&in[0]){
		stack<long double> s;
		char* c = in;
		do{
			if('0' <= *c && *c <= '9' || *c == '-' && '0' < c[1] && c[1] <= '9'){
				int a = 0;
				bool minus = false;
				if(c[0] == '-'){
					minus = true;
					++c;
				}
				while('0'<=*c && *c <= '9'){
					a *= 10;
					a += *c-'0';
					++c;
				}
				if(minus) a = -a;
				s.push((long double)a);
			}else{
				long double b = s.top();
				s.pop();
				long double a = s.top();
				s.pop();
				switch(*c){
					case '+':
						s.push(a+b);
						break;
					case '-':
						s.push(a-b);
						break;
					case '*':
						s.push(a*b);
						break;
					case '/':
						s.push(a/b);
						break;
				}
				++c;
			}
			++c;
		}while(*c);
		printf("%.6f\n",(double)s.top());
		memset(in,0,sizeof in);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
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; }

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    long long a_foo = 0;
    rep(i, b) {
        if (a_foo == 0)
            a_foo = a;
        else
            a_foo = a_foo * 10 + a;
    }

    long long b_foo = 0;
    rep(i, a) {
        if (b_foo == 0)
            b_foo = b;
        else
            b_foo = b_foo * 10 + b;
    }

    if (a_foo > b_foo)
        cout << a_foo << endl;
    else
        cout << b_foo << endl;
}


Measured memory_bytes: 256