akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;


const ll inf = 1e9;
const long long MOD = 1000000007;

const int MAX_V = 1000000;

Graph G(MAX_V);       //グラフ
int V;                      //頂点数
int cnt = 0;

int color[MAX_V];           //頂点i（1or-1）

//頂点を１とー１で塗っていく
bool dfs(int v, int c) {
    color[v] = c;          //頂点vをcで塗る
    if (c == 1)cnt++;
    rep(i, G[v].size()) {
        //隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c)return false;
        //隣接している頂点がまだ塗られていないなら-cを塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c))return false;
    }
    //全ての頂点が塗れたらtrue
    return true;
}

void solve() {
    rep(i, V) {
        if (color[i] == 0) {
            if (!dfs(i, 1)) {
                cout << "No" << endl;
            }
        }
    }
    cout << "Yes" << endl;
}

int main() {
    ll n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (dfs(1, 1))cout << cnt * (n - cnt) - m << endl;
    else cout << n * (n - 1) / 2 - m << endl;
    return 0;
}

Measured memory_bytes: 30440
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;

const int maxn=200000+10;
int L[maxn][2],R[maxn][2];
char str[maxn];

int main()
{
    int i,j,n,K,C;
    scanf("%d%d%d",&n,&K,&C);
    scanf("%s",str+1);
    for(i=1;i<=n;i++){
        if(str[i]=='x'){
            L[i][0]=max(L[i-1][0],L[i-1][1]);
            L[i][1]=L[i][0];
        }else {
            L[i][0]=max(L[i-1][0],L[i-1][1]);
            int v=0;
            if(i-C>1)
                v=L[i-C-1][1];
            L[i][1]=v+1;
        }
        L[i][0]=max(L[i][0],L[i-1][0]);
        L[i][1]=max(L[i][1],L[i-1][1]);
        //printf("i=%d L0=%d L1=%d\n",i,L[i][0],L[i][1]);
    }
    for(i=n;i>=1;i--){
        if(str[i]=='x'){
            R[i][0]=max(R[i+1][0],R[i+1][1]);
            R[i][1]=R[i][0];
        }else {
            R[i][0]=max(R[i+1][0],R[i+1][1]);
            int v=0;
            if(i+C+1<=n)
                v=max(R[i+C+1][1],R[i+C+1][1]);
            R[i][1]=v+1;
        }
        R[i][0]=max(R[i][0],R[i+1][0]);
        R[i][1]=max(R[i][1],R[i+1][1]);
        //printf("i=%d R0=%d R1=%d\n",i,R[i][0],R[i][1]);
    }
    
    for(i=1;i<=n;i++){
        if(str[i]=='x')
            continue;
        if(L[i][0]+R[i][0]==K-1)
            printf("%d\n",i);
    }
    return 0;
}




Measured memory_bytes: 4736
import java.util.*;
public class Main{
	static int MAXN = 1000001;  
	static int[] spf = new int[MAXN];  
	static int[] hash1 = new int[MAXN]; 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
		}
		if(hasValidNum(arr,n)){
			System.out.println("pairwise coprime");
		}
		else if(findGCD(arr,n)==1){
			System.out.println("setwise coprime");
		}
		else{
			System.out.println("not coprime");
		}
	}
	static void sieve() { 
    spf[1] = 1; 
    for (int i = 2; i < MAXN; i++) 
        spf[i] = i; 
    for (int i = 4; i < MAXN; i += 2) 
        spf[i] = 2;  
    for (int i = 3; i * i < MAXN; i++)  
    {  
        if (spf[i] == i)  
        { 
            for (int j = i * i; j < MAXN; j += i) 
  
                // Marking spf[j] if it is not 
                // previously marked 
                if (spf[j] == j) 
                    spf[j] = i; 
        } 
    } 
}
    static void getFactorization(int x) { 
    int temp; 
    while (x != 1)  
    { 
        temp = spf[x]; 
        if (x % temp == 0)  
        { 
  
            // Storing the count of 
            // prime factors in hash 
            hash1[spf[x]]++; 
            x = x / spf[x]; 
        } 
        while (x % temp == 0) 
            x = x / temp; 
    } 
}

static boolean check(int x) 
{ 
    int temp; 
    while (x != 1)  
    { 
        temp = spf[x]; 
  
        // Checking whether it common 
        // prime factor with other numbers 
        if (x % temp == 0 && hash1[temp] > 1) 
            return false; 
        while (x % temp == 0) 
            x = x / temp; 
    } 
    return true; 
}
static boolean hasValidNum(int []arr, int n) 
{ 
  
    // Using sieve for generating prime factors 
    sieve(); 
  
    for (int i = 0; i < n; i++) 
        getFactorization(arr[i]); 
  
    // Checking the common prime factors 
    // with other numbers 
    for (int i = 0; i < n; i++) 
        if (!check(arr[i])) 
            return false; 
  
    return true; 
}
static int gcd(int a, int b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
  
    // Function to find gcd of array of 
    // numbers 
    static int findGCD(int arr[], int n) 
    { 
        int result = 0; 
        for (int element: arr){ 
            result = gcd(result, element); 
  
            if(result == 1) 
            { 
               return 1; 
            } 
        } 
  
        return result; 
    }     
}


Measured memory_bytes: 71372
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A, B;
  cin >> A >> B;
  if (A.at(0) == B.at(2) && A.at(2) == B.at(0) && A.at(1) == B.at(1)) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	n := readi()
	a := make([]int, n)
	cntA := make(map[int]int)
	sum := 0
	for i := 0; i < n; i++ {
		a[i] = readi()
		cntA[a[i]]++
		sum += a[i]
	}
	q := readi()
	b := make([]int, q)
	c := make([]int, q)
	for i := 0; i < q; i++ {
		b[i] = readi()
		c[i] = readi()
	}

	ans := sum
	for i := 0; i < q; i++ {
		cntB, ok := cntA[b[i]]
		if ok {
			cntA[b[i]] = 0
			cntA[c[i]] += cntB
		}
		ans = ans - (cntB * b[i]) + (cntB * c[i])
		fmt.Println(ans)
	}
}

/*-------------------utilities-------------------*/

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

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 chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

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

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

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

// func searchInts(a []int, k int) int {
// 	return binarySearch(len(a), func(i int) bool {
// 		return a[i] >= k
// 	})
// }

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

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

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

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

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    string S;
    cin >> S;
    int N = S.length();

    int red = 0;
    int blue = 0;
    REP(i,N){
        char c = S[i];
        if(c == '0'){
            red++;
        }
        else{
            blue++;
        }
    }

    int ans = min(red, blue)*2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int arr[n];
    int i=0;
    while(i<n){
        arr[i]=0;i++;
    }
    int t=k;
    while(t--){
        int d;
        scanf("%d",&d);
        while(d--){
            int l;
            scanf("%d",&l);
            arr[l-1]++;
        }
    }int flag=0;
    int j=0;
    while(j<n){
        if(arr[j]==0)flag++;j++;
    }printf("%d",flag);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N;
    cin >> N;
    ll ans = N * (N - 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#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;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

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

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int ans = 0, N, H, W; cin >> N >> H >> W;
	REP(i,N){
		int A, B; cin >> A >> B;
		ans += (A >= H&&B >= W);
	}
	cout << ans << endl;



}



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

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<int> H(N+1,0);
  vector<int> vec(N+1,0);
  for(int i=1; i<N+1; i++){
    int h;
    cin>>h;
    H[i]=h;
  }
  int count=0;
  int flag=-1;
  while(true){
    int l,r;
    for(int i=1; i<N+1; i++){
      if(vec[i]<H[i]){
	l=i;
	break;
      }
      else if(i==N) flag=1;
    }
    if(flag==1) break;
        
    for(int i=l; i<N+1; i++){
      if(vec[i]==H[i]){
	r=i;
	break;
      }
      else if(i==N) r=N+1;
    }
    for(int j=l; j<r; j++){
      vec[j]++;
    }
    count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  3e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, l, r, d;

void solve(){
	cin>>l>>r>>d;
	deb1(r/d-(l-1)/d)
}

int main(){
	fastio;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}

Measured memory_bytes: 3648
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        Map<Long,Long> hs=new HashMap<>(); 
        while(t-->0)
        {
            int n=sc.nextInt();long sum=0,x=0,pre=0;
            for(long i=1;i<=n;i++)
            {
                long m=sc.nextLong();
                sum+=m;
                hs.merge(m,1l,Long::sum);
            }
            int q=sc.nextInt();
            while(q-->0)
            {
                long b=sc.nextLong(),c=sc.nextLong();
                if(hs.containsKey(b))
                {
                sum=sum-(hs.get(b)*b)+(hs.get(b)*c);
                if(!hs.containsKey(c))
                hs.put(c,hs.get(b));
                else hs.put(c,hs.get(b)+hs.get(c));
                hs.remove(b);
                }
                pw.println(sum);
            }
        }
           pw.close();
    }
}
  

Measured memory_bytes: 69028
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long fac[200005],inv[200005],fx[200005];
int h,w,a,b;
int work(int n,int m)
{
	return 1ll*fac[n]%mod*fx[m]%mod*fx[n-m]%mod;
}
int main()
{
	fac[0]=1;fac[1]=1;for(int i=2;i<=200003;++i)fac[i]=fac[i-1]*i%mod;
	inv[0]=1;inv[1]=1;for(int i=2;i<=200003;++i)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	fx[0]=1;fx[1]=1;for(int i=2;i<=200003;++i)fx[i]=inv[i]%mod*fx[i-1]%mod;
	scanf("%d%d%d%d",&h,&w,&a,&b);
	a=h-a;b++;
	long long ans=0;
	for(int i=1;i<=a;++i)
	{
		ans=(ans+1ll*work(b-2+i-1,b-2)%mod*work(h-i+w-b,h-i))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
//                     بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
//                   لآ اِلَهَ اِلّا اللّهُ مُحَمَّدٌ رَسُوُل اللّهِ
#include <bits/stdc++.h>

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	int a, b, c;
	cin >> a  >> b >> c;
	vector<int> v;
	if(a < b){
		for(int i = 1; i <= b ; i++){
		if(a % i == 0 && b %  i == 0){
			v.push_back(i);
		}
	}
	sort(v.rbegin(),v.rend());
	cout << v[c-1] << endl;
	}
	else{
		for(int i = 1; i <= a ; i++){
		if(a % i == 0 && b %  i == 0){
			v.push_back(i);
		}
	}
	sort(v.rbegin(),v.rend());
	cout << v[c-1] << endl;
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
typedef long long ll;
ll A, B, ans;
int main(){
	scanf("%lld%lld", &A, &B);
	if(A == B) return puts("1"), 0;
	int r = 60;
	for(; (A >> r & 1) == (B >> r & 1) ; r--);
	A &= (1LL << r + 1) - 1;
	B &= (1LL << r + 1) - 1;
	int k = r - 1;
	for(; !(B >> k & 1) && ~k; k--);
	ans += (1LL << r + 1) - A;
	if(A > (1LL << k + 1)) ans -= A - (1LL << k + 1);
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
f = True
if N%2 == 1:
  for i in range(N):
    if A[i] != ((i+1)//2)*2:
      f = False
      break
else:
  for i in range(N):
    if A[i] != (i//2)*2 + 1:
      f = False
      break
m = N//2
if f:
  print((2**m)%1000000007)
else:
  print(0)

Measured memory_bytes: 13880
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_N = 1e5 + 10;

int main()
{
	fast_cin();

	int N, A, B;
	cin >> N >> A >> B;
	int X[max_N];
	for (int i = 1; i <= N; ++i) {
		cin >> X[i];
	}

	int md = B / A;
	ll ans = 0;
	for (int i = 1; i < N; ++i) {
		if (X[i + 1] - X[i] <= md) {
			ans += (X[i + 1] - X[i]) * A;
		} else {
			ans += B;
		}
	}

	cout << ans << endl;
}


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

void solve(long long X, long long Y, long long Z) {
    cout << Z << ' ' << X << ' ' << Y << endl;
}

int main() {
    long long X;
    std::cin >> X;
    long long Y;
    std::cin >> Y;
    long long Z;
    std::cin >> Z;
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_n
// Problem link : 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
using namespace std;
#define ll long long int
ll n;
ll a[405];
ll sum[ 405 ][ 405 ]={0};

ll solve(){

	ll dp[401][401]={0};
	for(ll i = 0; i<n ; i++){
		ll val = a[i];
		for(ll j = i+1 ; j < n ; j ++){
			val += a[j];
			sum[i][j] = val;
		}
	}
	for(ll i = 1; i < n ; i++){
		ll r = 0, c = i;
		while(c<n){ 
			ll val = 1e17;
			for(ll pivot = r; pivot<c; pivot++){
				val = min(val, dp[r][pivot]+dp[pivot+1][c] + sum[r][c]);
			}
			dp[r][c] = val;
			r++;c++; 
		} 
	} 

	return dp[0][n-1];
}

int main(){
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	cout<<solve()<<endl;
	return 0;
}























Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j,cnt=0;
    cin>>n;
    for(i=1;i<n;i++){
        for(j=1;j*i<n;j++){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

vector<pair<int,int> > v;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cout << setprecision(6) << fixed;

    int n;
    cin >> n;

    int a, b;
    for(int i=0;i<n;++i){
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }

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

    double sol = 0;

    do{
        for(int i=0;i<n-1;++i)
            sol += hypot(v[i].first-v[i+1].first, v[i].second-v[i+1].second);
        
    }while(next_permutation(v.begin(), v.end()));

    for(int i=1;i<=n;++i)
        sol /= i;

    cout << sol << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

int main()
{
    string a, b, c; cin >> a >> b >> c;
    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int modNum = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ans = 0;
	
		
		
		if(a * 2 >= b){
			ans += b / 2;
			b -= ans * 2;
		}else{
			ans += a;
			a -= ans;
			b -= ans * 2;			
		}
		
		
		
			if(b >= 4){
				ans += b/4;
			}
		
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 21716
import sys
input = sys.stdin.readline
 
n = int(input())
d = [int(input()) for i in range(n)]
d.sort()
 
#初期値
now = d.pop() #一番大きい値
ans = 1 # １段目
#print(" ")
while len(d) != 0:
    next = d.pop()
    #print(next)
    if now > next:
        ans += 1
        now = next
 
print(ans)

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

int main(){
    int A,B,C,D; cin>>A>>B>>C>>D;
    int maximum=max(A,C);
    int minimum=min(B,D);
    if(minimum<maximum){
        cout<<0;
    }
    else{
        cout<<minimum-maximum;
    }
    return 0;
}


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

struct StronglyConnectedComponents {
    int id = 0;
    vector<vector<int>> gg, rg;
    vector<int> comp, order, seen, depth;
    StronglyConnectedComponents(int v) : \
    gg(v), rg(v), comp(v, -1), seen(v, 0), depth(v, 1) { }
    void add_edge(int x, int y) {
        gg[x].emplace_back(y);
        rg[y].emplace_back(x);
    }
    int operator[](int k) { return comp[k]; }
    void dfs(int u) {           // order, seen
        seen[u] = true;
        for (int v: gg[u]) if (!seen[v]) dfs(v);
        order.emplace_back(u);
    }
    void rdfs(int u, int id) {  // comp, depth
        comp[u] = id;
        for (int v: rg[u]) {
            if (comp[v] == -1) rdfs(v, id);
            depth[u] = max(depth[u], depth[v] + 1);
        }
    }
    int build() {
        for (int u = 0; u < gg.size(); ++u) if (!seen[u]) dfs(u);
        reverse(begin(order), end(order));
        for (int u: order) if (comp[u] == -1) rdfs(u, id++);
        return id;
    }
    vector<vector<int>> make_graph() {
        vector<vector<int>> g_comp(id);
        set<pair<int, int>> connect;
        for (int u = 0; u < gg.size(); ++u) for (int v: gg[u]) {
            int x = comp[u], y = comp[v];
            if (x == y) continue;
            if (connect.count({x, y})) continue;
            g_comp[x].emplace_back(y);
            connect.emplace(x, y);
        }
        return g_comp;
    }
};

int main() {
    int n; cin >> n;
    int sz = 0;
    map<pair<int, int>, int> idx;
    for (int u = 0; u < n; u++) {
        for (int v = u + 1; v < n; v++) {
            idx[{u, v}] = idx[{v, u}] = sz++;
        }
    }
    vector<vector<int>> a(n, vector<int>(n - 1));
    for (auto &ai: a) for (int &aij: ai) cin >> aij, aij--;
    StronglyConnectedComponents scc(sz);
    for (int u = 0; u < n; u++) for (int i = 0; i < n - 2; i++) {
        scc.add_edge(idx[{u, a[u][i]}], idx[{u, a[u][i + 1]}]);
    }
    if (scc.build() != sz) {
        cout << -1 << endl;
    } else {
        cout << *max_element(scc.depth.begin(), scc.depth.end()) << endl;
    }
    return 0;
}

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

int main() {
	string s,t;
	cin >> s >> t;
	const string z = "UNRESTORABLE";
	int sl=s.size(),tl=t.size();
	string k = "";
	vector<string> vs(50,"");
	for(int i=0;i<sl-tl+1;i++)
	{
		bool b = true;
		for(int j=0;j<tl;j++)
		{
			if(s.at(i+j)== '?')
			{
				continue;
			}
			else if(s.at(i+j)==t.at(j))
			{
			 	continue;
			}
			else
			{
				b = false;
			}
		}
		if(b==true)
		{
			string ss=s;
          			for(int j =i;j<i+tl;j++)
			{
				ss.at(j)=t.at(j-i);
			}
			for(int j=0;j<sl;j++)
			{
				if(ss.at(j)=='?')
				{
					ss.at(j)='a';
				}
			}
			vs.at(i)=ss;
		}
	}
	sort(vs.begin(),vs.end());
	for(int i=0;i<50;i++)
	{
		k = vs.at(i);
		if(k!="")
		{
			break;
		}
	}
	if(k=="")
	{
		k = z;
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const lines = input.split('\n');
  //分割代入を使ってみた
  const [N, D] = lines[0].split(' ').map(s => parseInt(s));
  //mapで座標の2次元配列を作成
  const points = lines.slice(1).map(line => line.split(' '));

  let ans = 0;
  //i番目とj番目の点の距離を計算する
  //このようにすると重複がなく全ての組み合わせを列挙できる
  for (let i = 0; i < N - 1; i++) {
    for (let j = i + 1; j < N; j++) {
      let sumOfSquare = 0;
      for (let k = 0; k < D; k++) {
        sumOfSquare += Math.pow(points[i][k] - points[j][k], 2);
      }
      const distance = Math.sqrt(sumOfSquare);
      if (Number.isInteger(distance)) {
        ans++;
      }
    }
  }
  console.log(ans);

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


Measured memory_bytes: 7372
import scala.io.StdIn._
object Main extends App {
  val n = readLine.toInt
  val surveys = (1 to n).map{i => readLine.split(" ").map{_.toInt}}.toList
  val Array(x1, y1, h1) = surveys.find(_(2) != 0).get

  val candidates = (for {
    xi <- 0 to 100
    yi <- 0 to 100
    hi = h1 + Math.abs(x1 - xi) + Math.abs(y1 - yi)
  } yield (xi, yi, hi)).toList

  val (cx, cy, ch) = eliminate(candidates, surveys)
  println(s"$cx $cy $ch")

  def eliminate(candidates: List[(Int, Int, Int)], surveys: List[Array[Int]]): (Int, Int, Int) = {
    candidates match {
      case Nil => throw new Exception("impossible")
      case c :: Nil => c
      case c :: cs => 
        val Array(x, y, h) = surveys.head
        val filtered = candidates.filter{ c =>
          val calculatedH = c._3 - Math.abs(c._1 - x) - Math.abs(c._2 - y)
          if (h > 0) calculatedH == h else calculatedH <= 0
        }
        eliminate(filtered, surveys.tail)
    }
  }
}

Measured memory_bytes: 32104
#include <bits/stdc++.h>
using namespace std;
#define FOR0(a,b) for(int i = a; i < b; ++i)
#define FORE(a,b) for(int i = a; i <= b; ++i)
#define x first 
#define y second
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1000000+10;

int c[maxn],n;
int lowbit(int x) {
    return x&(-x);
}
void add(int x, int d) {
    while(x <= 1000000) {
        c[x] += d;
        x += lowbit(x);
    }
}
int sum(int x) {
    int ret = 0;
    while(x) {
        ret += c[x];
        x -= lowbit(x);
    }
    return ret;
}
inline int read()
{
    int k=0;
    char f=1;
    char c=getchar();
    for(;!isdigit(c);c=getchar() )
        if(c=='-')
            f=-1;
    for(;isdigit(c);c=getchar() )
        k=k*10+c-'0';
    return k*f;
}

struct Cor{
    int l,r,i;
    bool operator < (const Cor& rhs) const {
        return r < rhs.r;
    }
}cor[maxn];
int ans[maxn];
int a[maxn],q,vis[maxn];
int main() {
    cin>>n>>q;
    for(int i = 1; i <= n; ++i)
        a[i] = read();
    int l,r;
    for(int i = 0; i < q; ++i) {
        cor[i].l = read(); cor[i].r = read();
        cor[i].i = i;
    }
    sort(cor, cor+q);
    int cur = 0;
    l = 1;
    for(int i = 0; i < q; ++i) {
        for(int j = l; j <= cor[i].r; ++j) {
            add(j,1);
            if(vis[a[j]])
                add(vis[a[j]],-1);
            vis[a[j]] = j;
        }
        l = cor[i].r+1;
        ans[cor[i].i] = sum(cor[i].r)-sum(cor[i].l-1);
    }
    for(int i = 0; i < q; ++i)
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 17404
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	count := 0
	a := 0
	i := 0
	l := len(s)
	for i < l {
		if string(s[i]) == "A" {
			a++
			i++
			continue
		}

		if string(s[i]) == "B" && i < l - 1 && string(s[i+1]) == "C" {
			count += a
			i += 2
		} else {
			a = 0
			i += 1
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 3204
#include<stdio.h>
#define N 100
#define NEVER 0
#define FIRST 1
#define SEC 2
int n,A[N][N];
int tr[N],de[N],fi[N],times;

void visit(int u){
  int i;
  tr[u]=FIRST;
  de[u]=++times;
  for(i=0;i<n;i++){
    if(A[u][i]==0)continue;
    if(tr[i]==NEVER){
      visit(i);
    }
  }
  tr[u]=SEC;
  fi[u]=++times;
}

void DeFiSe(){
  int j;
  for(j=0;j<n;j++)tr[j]=NEVER;
  times=0;

  for(j=0;j<n;j++){
    if(tr[j]==NEVER)visit(j);
  }
  for(j=0;j<n;j++){
    printf("%d %d %d\n",j+1,de[j],fi[j]);
  }
}

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

  for(i=0;i<n;i++){
    scanf("%d%d",&c,&d);
    c--;
    for(j=0;j<d;j++){
      scanf("%d",&k);
      k--;
      A[c][k]=1;
    }
  }
  DeFiSe();
  return 0;
}



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


int main() {
  string s; cin >> s;
  cout << string(s.size(),'x') << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

in_N = [int(i) for i in input().split()];
in_d = [int(i) for i in input().split()];

#print(in_N);
#print(in_d);

#calc
total = 0;
for i in range(in_N[0]):
    for j in range(len(in_d)-1):
        #print(i);
        #print(j);
        if(i+j+1 == len(in_d)):break;
        total += in_d[i]*in_d[i+j+1];

print(total);

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
ll a[N]; 

void solve(){
    int n;
    cin >> n;
    map <ll,ll> mp;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i]; 
        mp[a[i]] ++;
        
    }
    ll sum = 0;
    for(auto it : mp)
        sum += (it.Y * (it.Y - 1))/2ll;
    for(int i = 1; i <= n; ++i) {
        sum -= (mp[a[i]] * (mp[a[i]] - 1))/2ll; 
        sum += ((mp[a[i]] - 2) * (mp[a[i]] - 1))/2ll;
        cout << sum << " ";
        sum += (mp[a[i]] * (mp[a[i]] - 1))/2ll; 
        sum -= ((mp[a[i]] - 2) * (mp[a[i]] - 1))/2ll;
    }
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


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


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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


vector<ll> A, B, C;
map<ll, ll> m;
int main() {

    ll N;
    cin >> N;

    A.assign(N, 0);
    for(ll i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
    }

    ll Q;
    cin >> Q;
    B.assign(Q, 0);
    C.assign(Q, 0);
    for(ll i = 0; i < Q; i++) {
        cin >> B[i] >> C[i];
    }

    ll sum = 0;
    for(auto itr = m.begin(); itr != m.end(); itr++) {
        sum += itr->first * itr->second;
    }

    for(ll i = 0; i < Q; i++) {
        sum = sum - (B[i] * m[B[i]]) + (C[i] * m[B[i]]);
        cout << sum << endl;
        m[C[i]] += m[B[i]];
        m[B[i]] = 0;
    }


        

    return 0;    
}



Measured memory_bytes: 11260
#include <bits/stdc++.h>
using namespace std;
string a;
long long k;
void solve()
{
    if (a.length()==1) cout<<a[0];
    else if (a[0]==a[1])
    {
        if (k==1) cout<<a[0];
        else
        {
            if (a[0]=='1')
            {
                long long i;
                for (i=0;i<a.length();i++)
                    if (a[i]!=a[0]) break;
                if (i<k) cout<<a[i];
                else cout<<a[0];
            }
            else cout<<a[0];
        }
    }
    else
    {
        if (k==1) cout<<a[0];
        else
        {
            if (a[0]=='1')
            {
                long long i;
                for (i=0;i<a.length();i++)
                    if (a[i]!=a[0]) break;
                if (i<k) cout<<a[i];
                else cout<<a[0];
            }
            else cout<<a[0];
        }
    }
    cout<<endl;
}
int main()
{
    while(cin>>a>>k)
        solve();
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		string S = GetString();
		
		int N = S.Length;
		int[] c = new int[N];
		for(int i = 0; i < N; i++)
			c[i] = (int)(S[i] - '0');

		if(c[0] == 0 || c[N - 1] == 1)
		{
			Console.WriteLine(-1);
			return;
		}

		for(int i = 1; i <= N - 1; i++)
		{
			if(c[i - 1] != c[N - i - 1])
			{
				Console.WriteLine(-1);
				return;
			}
		}

		var ans = new StringBuilder();
		int p = N - 1;
		for(int i = N - 2; i >= 0; i--)
		{
			ans.AppendFormat($"{p + 1} {i + 1}\n");
			if(c[i] == 1)
				p = i;
		}

		Console.Write(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 22100
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  if(scanString==scanString)end("H");end("D");
}


Measured memory_bytes: 256
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
for i in range(m):
  skill=0
  for j in range(n):
    skill+=l[j][i+1]
  if skill<x:
    print(-1)
    break
else:
  min_total=0
  for i in range(n):
    min_total+=l[i][0]
  for i in range(2**n):
    total=0
    s=[0]*m
    for j in range(n):
      if (i>>j)&1:
        total+=l[j][0]
        for k in range(m):
          s[k]+=l[j][k+1]
    if min(s)>=x:
      if min_total>=total:
        min_total=total
  print(min_total)

Measured memory_bytes: 9240
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
const double eps = 0.000000000001;
typedef long long ll;
struct edge { int to; int cost;};
int h[100006];
int rmin[100006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> h[i];
	rmin[n] = inf;
	for (int i = n - 1; i >= 0; i--) {
		rmin[i] = min(rmin[i + 1], h[i]);
	}
	rep(i, n) {
		if (h[i] - rmin[i] >= 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

}

Measured memory_bytes: 1792
import math
a,b,h,m=map(int,input().split())
h = (h/12) * 360 + (m/60) * 30
m = (m/60) * 360
if abs(h-m) > 180:
    r=360-abs(h-m)
else:
    r=abs(h-m)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(r))))

Measured memory_bytes: 9480
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
inline ll add(ll a, ll b){ return ((a%MOD)+(b%MOD))%MOD;}
inline ll mul(ll a, ll b){ return ((a%MOD)*(b%MOD))%MOD;}
inline ll sub(ll a, ll b){ return ((a%MOD)-(b%MOD)+MOD)%MOD;}
// const int N = 1e5+7;
 
#define deb(x) {x}
#ifndef local
    #define deb(x) ;
#endif
///---------------------------------------------------------------

void solve()
{
    int n;cin>>n;
    int ans=0;
    rep(i,1,n+1)if(i%3!=0 && i%5!=0)ans+=i;
    cout<<ans<<endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    #ifdef local
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
    int t=1;
    // cin>>t;
    rep(a,0,t)
    {
        // cout<<"Case #"<<a+1<<": ";
        solve();
    }

    // solve();
    
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;
    double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;
    cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "
    <<time_taken<<" seconds\n";}
    #endif
}

Measured memory_bytes: 3652
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX
using Graph =vector<vector<int> >;
ll p[MAX_B],x[MAX_B],c[MAX_B];
int main(){
    int n,q;cin>>n>>q;
    Graph G(n);
    rep(i,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        cin>>p[i]>>x[i];
        p[i]--;
        c[p[i]]+=x[i];
    }
    
    queue<int>que;
    que.push(0);
    int vis[MAX_B];
    vis[0]=1;
    while(que.size()){
        int u=que.front();
        que.pop();
        for(int i:G[u]){
            if(vis[i]==1)continue;
            vis[i]=1;
            c[i]+=c[u];
            que.push(i);
        }
    }
    rep(i,n)cout<<c[i]<<" ";cout<<endl;
    
}


Measured memory_bytes: 26868
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

const int max_n = 100001;
vector< bool > is_prime(max_n, true);
void init()
{
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= max_n; ++i)
    {
        if (is_prime[i])
        {
            for (int j = i + i; j <= max_n; j += i) is_prime[j] = false;
        }
    }
}

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

    init();

    int sum[max_n + 1];
    rep (i, max_n + 1) sum[i] = 0;
    for (int i = 0; 2 * i + 1 <= max_n; ++i)
    {
        int num = 2 * i + 1;
        if (is_prime[num] && is_prime[i + 1]) ++sum[num];
    }
    rep (i, max_n) sum[i + 1] += sum[i];

    int q;
    cin >> q;
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << "\n";
    }

    return 0;
}



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

int main(){
    int n, x;
    cin >> n >> x;
    int m[101] = {0};
    for(int i=0; i<n; i++) cin >> m[i];

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

    sort(m, m+n);

    x = x - c;

    int ans = n;
    ans += x / m[0];

    cout << ans << endl;

    return 0;
}


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

int w[100000],n,k;
int cntp(int p)
{
	int cnt=1,wgh=0;
	for(int i=0;i<n;)
	{
		if(wgh+w[i]<=p)
		{
			wgh+=w[i++];
		}
		else
		{
			if(wgh>0)cnt++;
			else return k+1; 
			wgh=0;
		}
	}
	return cnt;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;scanf("%d",w+i++));
	int l=0,r=1000000000,m;
	while(l<r)
	{
		m=(l+r)/2;
		if(cntp(m)>k)l=m+1;
		else r=m;
	}
	for(m--;;m++)
	{
		if(cntp(m)<=k)break;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 3092
s = input().split(" ");
n = int(s[0]);
a = int(s[1]);
b = int(s[2]);
if a > b :
  print(0);
else :
  if n == 1 :
    if a==b :
      print(1);
    else :
      print(0);
  else :
    ans = (b - a)*(n - 2)+1;
    print(ans);

Measured memory_bytes: 3060