akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stdio.h>
 
using namespace std;
 
int main(){
    int N;
    string S;
    string num;
    string O = "0";
    int place = 0;
    int digit = 0;
    cin>>N>>S;
    int count=0;
    for(int i=0;i<1000;i++){
        place = 0;
        digit = 0;
        num = to_string(i);
        if(i<10) num = O+O+num;
        if(i<100&&i>9)num = O+num;
        while(place<N){
            if(S.at(place)==num.at(digit))digit++;
            if(digit==3){
                count++;
                break;
            }
          place++;
        }
    }
  cout<<count<<endl;
}

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


#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

max_element = 1

L = []
R = []

L.append(A[0])
R.append(A[N-1])

for j in range(N-2):
    L.append(gcd( L[-1], A[j + 1]))
    R.append(gcd( R[-1], A[N - j - 2]))

ans = 1

for i in range(N):
    if i == 0:
        temp = L[N-2]
    elif i == N-1:
        temp = R[N-2]
    else:
        temp = gcd( L[N-2-i], R[i-1])
    
    if temp > ans:
        ans = temp

print(ans)

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

void solve(long long K, long long A, long long B) {
  if (A / K == B / K) {
    if (A % K == 0) {
      cout << "OK" << endl;
    } else {
      cout << "NG" << endl;
    }
  } else {
    cout << "OK" << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long K;
  scanf("%lld", &K);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(K, A, B);
  return 0;
}


Measured memory_bytes: 3760
///*
#include<iostream>
#include<string>
using namespace std;

int main() {

	string a, b, c;
	int i, j, k;

	cin >> a >> b >> c;

	if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	return 0;
}

//*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;
vector<int> p;

signed main() {

    cin >> n;
    p.resize(n);
    for(auto&&i:p) cin >> i;

    int c = 0;
    for(int i = 0; i < n; i++) {
        if(p[i] == i + 1) {
            if(i == n-1)
                swap(p[i], p[i-1]);
            else
                swap(p[i+1], p[i]);
            c++;
        }
    }

    
    cout << c << endl;
    
  
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    int N;
    std::cin >> N;
    std::vector<std::vector<long long>> A(N, std::vector<long long>(N, 0));
    for(auto& a: A) {
        for(auto& val: a) {
            std::cin >> val;
        }
    }

    auto B = A;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            for(int k = 0; k < N; ++k) {
                B[i][j] = std::min(B[i][j], B[i][k] + B[k][j]);
            }
        }
    }

    bool isExist = true;
    for(int i = 0;i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            if(B[i][j] < A[i][j]) {
                isExist = false;
                break;
            }
        }
    }

    if(!isExist) {
        std::cout << -1 << std::endl;
    } else {
        long long ans = 0;
        for(int u = 0; u < N; ++u) {
            for(int v = 0; v < N; ++v) {
                bool isAdd = true;
                for(int w = 0; w < N; ++w) {
                    if(w != u && w != v) {
                        if(A[u][v] == B[u][w] + B[w][v]) {
                            isAdd = false;
                            break;
                        }
                    }
                }
                if(isAdd) ans += A[u][v];
            }
        }
        std::cout << ans / 2 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
using namespace std;
int main(){

int i,n,t,h;
string tc,hc;

cin>>n;

for(i=0; i<n; i++){

cin>>tc>>hc;

if(tc>hc)t+=3;
else if(tc<hc)h+=3;
else{
t++;
h++;
}

}

cout<<t<<" "<<h<<"\n";

}

Measured memory_bytes: 1208
#include<stdio.h>

int adj[102][102];

int main(){
	int i,j,n,u,k,v;	scanf("%d",&n);

	for(i=0;i<n;i++){

		scanf("%d%d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			adj[u][v]=1;
		}
	}

	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(j>1)printf(" ");
			printf("%d",adj[i][j]);
		}
		printf("\n");
	}


	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <functional>
#include <map>
#include <string>
using namespace std;
#define INF 1000000000;
#define MOD 1000000007;
typedef long long int ll;
int main(void){
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
}

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

#include <iomanip>

using namespace std;

int main()
{ int n;

  cin>>n;
  
  double ans;
  
  
  if(n%2==0)
  ans=0.5000000000;
  
  else
  {int t= (n+1)/2;
  ans=(double)t/n;
  }
  	
	cout << fixed << setprecision(10);
	cout<<ans;
	
	
	
	return 0;
	
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(N, A));
    }

    private static long solve(int N, long[] A) {
        long area = 0;

        Arrays.sort(A);
        for (int i=N-2; i>=0; i--) {
            if (A[i] == A[i+1]) {
                if (area == 0) {
                    area = A[i];
                    i -= 1;
                } else {
                    area *= A[i];
                    return area;
                }
            }
        }

        return 0;
    }
}

Measured memory_bytes: 50564
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    int maxi = 0, second = INF;
    rep(i,0,N)maxi = max(maxi, V[i]);
    rep(i,0,N){
        if(abs(maxi/2 - second) > abs(maxi/2 - V[i])){
            second = V[i];
        }
    }
    for(int i = 0;maxi == second;i++)second = V[i];
    cout << maxi << " " << second << endl;
}

Measured memory_bytes: 640
class Acc2D:
    def __init__(self, a):
        h, w = len(a), len(a[0])
        self.acc2D = self._build(h, w, a)

    def _build(self, h, w, a):
        ret = [[0] * (w + 1) for _ in range(h + 1)]
        for r in range(h):
            for c in range(w):
                ret[r + 1][c + 1] = ret[r][c + 1] + ret[r + 1][c] - ret[r][c] + (1 if a[r][c] == '#' else 0)
                # 末項は必要に応じて改変すること
        return ret

    def get(self, r1, r2, c1, c2):
        # [r1,r2), [c1,c2) : 0-indexed
        acc2D = self.acc2D
        return acc2D[r2][c2] - acc2D[r1][c2] - acc2D[r2][c1] + acc2D[r1][c1]


def main():
    import sys

    sys.setrecursionlimit(10 ** 7)

    def fill_cake(r1, r2, c1, c2) -> None:
        """ケーキに番号を振る"""
        nonlocal piece_number
        for r in range(r1, r2):
            for c in range(c1, c2):
                ret[r][c] = piece_number
        piece_number += 1

    def cut_cake(r1, r2, c1, c2, rest) -> None:
        """[r1,r2),[c1,c2)の範囲にrest個ケーキがある状態からのカット"""
        if rest == 1:
            fill_cake(r1=r1, r2=r2, c1=c1, c2=c2)
            return  # これ以上カットする必要がないので、番号を振る

        for r in range(r1 + 1, r2):
            piece_count = acc2D.get(r1=r1, r2=r, c1=c1, c2=c2)
            if 0 < piece_count < rest:  # restが減ることを保証する
                cut_cake(r1=r1, r2=r, c1=c1, c2=c2, rest=piece_count)
                cut_cake(r1=r, r2=r2, c1=c1, c2=c2, rest=rest - piece_count)
                return  # ケーキを一つ以上含むように水平カットする

        for c in range(c1 + 1, c2):
            piece_count = acc2D.get(r1=r1, r2=r2, c1=c1, c2=c)
            if 0 < piece_count < rest:  # restが減ることを保証する
                cut_cake(r1=r1, r2=r2, c1=c1, c2=c, rest=piece_count)
                cut_cake(r1=r1, r2=r2, c1=c, c2=c2, rest=rest - piece_count)
                return  # ケーキを一つ以上含むように垂直カットする

    h, w, k = map(int, input().split())
    s = [input() for _ in range(h)]

    acc2D = Acc2D(s)
    # usage: acc2D.get(r1,r2,c1,c2)
    # ケーキ個数の二次元累積和

    ret = [[-1] * w for _ in range(h)]
    piece_number = 1

    cut_cake(r1=0, r2=h, c1=0, c2=w, rest=k)

    for row in ret:
        print(*row)


if __name__ == '__main__':
    main()


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

int main(){

    ll n;
    string s;
    cin >> s;

    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<unsigned long> p(A), q(B), r(C);
    copy_n(istream_iterator<unsigned long>(cin), A, p.begin());
    copy_n(istream_iterator<unsigned long>(cin), B, q.begin());
    copy_n(istream_iterator<unsigned long>(cin), C, r.begin());
    nth_element(p.begin(), p.end() - X, p.end());
    nth_element(q.begin(), q.end() - Y, q.end());
    copy(p.end() - X, p.end(), back_inserter(r));
    copy(q.end() - Y, q.end(), back_inserter(r));
    nth_element(r.begin(), r.end() - X - Y, r.end());
    cout << accumulate(r.end() - X - Y, r.end(), 0UL) << endl;
    return 0;
}

Measured memory_bytes: 6384
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	m := stdin.ReadInt()
	x := n*(n-1)/2 + m*(m-1)/2
	stdout.Println(x)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
const long long int mod = 1e9+7;
long long int power(long long int x,long long int y){  
    long long int res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % mod;  
        y = y>>1;
        x = (x*x) % mod; 
    }  
    return res;
}  
long long int inv(long long int a){return power(a,mod-2);}
long long int add(long long int a,long long int b){return (a+b)%mod;}
long long int sub(long long int a,long long int b){return (a-b+mod)%mod;}
long long int mul(long long int a,long long int b){return (a*b)%mod;}
long long int divi(long long int a,long long int b){return (a*inv(b))%mod;}
ll fact[2000001];
void pre(){
    fact[0]=1;
    for(int i=1;i<=2000000;i++) fact[i]=mul(fact[i-1],i);
}
ll ncr(ll n,ll r){
    return divi(fact[n],mul(fact[n-r],fact[r]));
}
void solve(){
    ll k;cin>>k;
    string s;cin>>s;
    ll ans = 0;
    for(int i=0;i<=k;i++)
        ans += mul(power(26,k-i),mul(ncr(s.size()+i-1,s.size()-1),power(25,i)));
    cout<<ans%mod<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 19872
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 hh, ww, ans = 0, tmp;
	int64 xfil[] = {-1, 1, 0, 0}, yfil[] = {0, 0, -1, 1};
	char cc;
	cin >> hh >> ww;
	vector<vector<bool>> table(hh + 10, vector<bool> (ww + 10, false));
	for(int64 ii = 1;ii <= hh;ii++)
	{
		for(int64 jj = 1;jj <= ww;jj++)
		{
			cin >> cc;
			if(cc == '.')
			{
				table[ii][jj] = true;
			}
		}
	}
	for(int64 ii = 1;ii <= hh;ii++)
	{
		for(int64 jj = 1;jj <= ww;jj++)
		{
			if(!table[ii][jj])
			{
				continue;
			}
			tmp = 0;
			queue<pair<int64, int64>> qq;
			vector<vector<int64>> memo(hh + 10, vector<int64> (ww + 10, 1000000000));
			qq.push(make_pair(ii, jj));
			memo[ii][jj] = 0;
			while(!qq.empty())
			{
				int64 xx, yy;
				xx = (qq.front()).first;
				yy = (qq.front()).second;
				qq.pop();
				for(int64 kk = 0;kk < 4;kk++)
				{
					if(table[xx + xfil[kk]][yy + yfil[kk]] && memo[xx + xfil[kk]][yy + yfil[kk]] == 1000000000)
					{
						memo[xx + xfil[kk]][yy + yfil[kk]] = memo[xx][yy] + 1;
						qq.push(make_pair(xx + xfil[kk], yy + yfil[kk]));
						tmp = max(tmp, memo[xx][yy] + 1);
					}
				}
			}
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble();      
		
      	if(a / c <= b){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 37284
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

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

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

struct Info
{
	ll a, b;
	bool operator<(const Info& another) const
	{
		ll c = another.a * (b + 1) - a * (another.b + 1);
		if (c != 0) { return c < 0; }
		return b < another.b;
	};
};

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

	vector <Info> temp;
	vector<ll> z;
	for (int i = 0; i < N; i++) {
		ll a, b; cin >> a >> b;
		if (a == 0) { z.push_back(b + 1); continue; }
		temp.push_back({ a,b });
	}
	sort(temp.begin(), temp.end());
	sort(z.begin(), z.end());

	vector<pair<ll, ll>> v;
	for (int i = 0; i < temp.size(); i++) {
		v.push_back({ temp[i].a, temp[i].b });
	}
	for (int i = 1; i < z.size(); i++) {
		z[i] += z[i - 1];
		chmin(z[i], T + 100);
	}

	N = v.size();

	if (N == 0) {
		ll ans = 0;
		for (int i = 0; i < z.size(); i++) {
			if (z[i] <= T) { chmax(ans, i + 1LL); }
		}
		cout << ans << endl;
		return 0;
	}

	ll** dp = new ll * [N];
	for (int i = 0; i < N; i++) {
		dp[i] = new ll[40];
		for (int j = 0; j < 40; j++) {
			dp[i][j] = T + 100000;
		}
	}
	dp[0][0] = 0;
	dp[0][1] = v[0].first + v[0].second + 1;
	for (int i = 1; i < N; i++) {
		dp[i][0] = 0;
		dp[i][1] = min(dp[i - 1][1], v[i].first + v[i].second + 1LL);
		for (int j = 2; j < 40; j++) {
			dp[i][j] = dp[i - 1][j];
			if (dp[i - 1][j - 1] + 1 <= T) {
				chmin(dp[i][j], dp[i - 1][j - 1] + 1 + (dp[i - 1][j - 1] + 1) * v[i].first + v[i].second);
			}
		}
	}

	ll ans = 0;
	for (ll i = 0; i < 40; i++) {
		ll t = dp[N - 1][i];
		if (t <= T) {
			chmax(ans, i);
			for (int j = 0; j < z.size(); j++) {
				if (t + z[j] <= T) {
					chmax(ans, i + j + 1);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 75004
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*8
    red=0
    for i in range(N):
        if a[i]<3200:
            l[a[i]//400]=1
        else:
            red+=1
    if sum(l)>=1:
        print(sum(l),sum(l)+red)
    else:
        print(1,sum(l)+red)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> B(N-1);
  for (int i=0;i<N-1;i++){
    cin >> B[i];
  }
  int ans=B[0]+B[N-2];
  for (int i=0;i<N-2;i++){
    ans+=min(B[i],B[i+1]);
  }
  cout << ans << endl;
}

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

int main() {
    int N,Q;
    cin >> N >> Q;
    vector<int> a(N-1),b(N-1),pre(N,0),ans(N,0),root(N,0);
    vector<int> p(Q),x(Q);
    for (int i=0;i<N-1;i++){
        cin >> a.at(i) >> b.at(i);
    }
    for (int i=0;i<Q;i++){
        cin >>p.at(i) >> x.at(i);
    }
    for (int i=0;i<Q;i++){
        pre.at(p.at(i)-1) += x.at(i);
    }
    for (int i=0;i<N-1;i++){
        root.at(b.at(i)-1) = a.at(i)-1;
    }
    
    for (int i=0;i<N;i++){
        ans.at(i) = ans.at(root.at(i)) + pre.at(i);
    }
    for (int i=0;i<N;i++){
        cout << ans.at(i) << " ";
    }
    
cout << "" << endl;
}



Measured memory_bytes: 7936
#include <iostream>
#define INF 1000000
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int r[10][10];
		int m = 0;
		for(int i = 0; i < 10;++i)for(int j = 0; j < 10; ++j){
			r[i][j] = INF;
		}
		for(int i = 0; i < n; ++i){
			int a,b,c;
			cin >> a >> b >> c;
			r[a][b] = r[b][a] = c;
			m = max(max(a,b),m);
		}
		++m;
		for(int i = 0; i < m; ++i)r[i][i] = 0;
		for(int k = 0; k < m; ++k){
			for(int i = 0; i < m; ++i){
				for(int j = 0; j < m; ++j){
					r[i][j] = min(r[i][k]+r[k][j],r[i][j]);
				}
			}
		}
		int ans = INF;
		int t = 0;
		for(int i = 0; i < m; ++i){
			int tmp = 0;
			for(int j = 0; j < m; ++j){
				tmp += r[i][j];
			}
			if(ans > tmp){
				ans = tmp;
				t = i;
			}
		}
		cout << t << " " << ans << endl;
	}
}

Measured memory_bytes: 1156
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def distance2_nd(p, q):
    return sum((px - qx) ** 2 for px, qx in zip(p, q))


def isqrt(n):
    if n > 0:
        x = 1 << (n.bit_length() + 1) // 2
        y = (x + n // x) // 2
        while y < x:
            x = y
            y = (x + n // x) // 2
        return x
    elif n == 0:
        return 0
    else:
        raise ValueError("isqrt() argument must be nonnegative")


def main():
    N, D = map(int, readline().split())
    X = [list(map(int, readline().split())) for _ in range(N)]

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            d2 = distance2_nd(X[i], X[j])
            di = isqrt(d2)
            if di * di == d2:
                ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9252
N=int(input())
l=list(int(input()) for i in range(N))
l.sort()
m=l[:]
a=b=l.pop(0)
ansA=0
for i in range(0,len(l)):
    if i%4==0:
        ansA+=l[-1]-a
        c=l.pop(-1)
    elif i%4==1:
        ansA+=l[-1]-b
        d=l.pop(-1)
    elif i%4==2:
        ansA+=c-l[0]
        a=l.pop(0)
    else:
        ansA+=d-l[0]
        b=l.pop(0)
c=d=m.pop(-1)
ansB=0
for i in range(0,len(m)):
    if i%4==2:
        ansB+=m[-1]-a
        c=m.pop(-1)
    elif i%4==3:
        ansB+=m[-1]-b
        d=m.pop(-1)
    elif i%4==0:
        ansB+=c-m[0]
        a=m.pop(0)
    else:
        ansB+=d-m[0]
        b=m.pop(0)
print(max([ansA,ansB]))

Measured memory_bytes: 7896
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		int n = int.Parse(Console.ReadLine());
		var d = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		Array.Sort(d);
		int counter = d[n/2]-d[(n/2)-1];
		Console.WriteLine(counter);
		
	}
}

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

using namespace std;

const int N = 1017;
const int MOD = 1000 * 1000 * 1000 + 7;

using vec = vector<int>;

int n, m;
vec x[N];

bool read() {
    if (!(cin >> n >> m))
        return false;

    for (int i = 0; i < n; ++i) {
        x[i].resize(m);

        for (auto& j : x[i])
            cin >> j;
    }

    return true;
}

int ok(const vec& A, const vec& B) {
    long long sqsum = 0;

    for (int i = 0; i < m; ++i)
        sqsum += (A[i] - B[i]) * (A[i] - B[i]);

    auto sq = static_cast<long long>(sqrtl(sqsum));
    return sq * sq == sqsum;
}

void solve() {
    int ans = 0;

    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            ans += ok(x[i], x[j]);

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
const int MAX=1e6+10;
const int modn=1e9+7;
typedef long long ll ;
#define int ll
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
int n,x,t;
string a,b;
int p[MAX];
void solve(){
    cin>>n>>x>>t;
    ll q=ceil(n*1.0/x)*t;
    cout<<q;
}
signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <algorithm>

int main()
{
	int linecount = 0;
	std::scanf("%d", &linecount);

	std::vector<int> result(linecount);
	for (int i = 0; i < linecount; ++i) {
		result[i] = i + 1;
	}

	int swapcount = 0;
	std::scanf("%d", &swapcount);
	for (int i = 0; i < swapcount; ++i) {
		int swap1, swap2;
		if (std::scanf("%d,%d", &swap1, &swap2) == 2) {
			std::swap(result[swap1 - 1], result[swap2 - 1]);
		}
	}

	for (int i = 0; i < linecount; ++i) {
		std::printf("%d\n", result[i]);
	}

	return 0;
}

Measured memory_bytes: 1024
CHARACTER(100) S,T
CHARACTER AKI
READ*,S,T
!バブルソート
do i=1,LEN_TRIM(S)-1
  do j=i+1,LEN_TRIM(S)
    if(ICHAR(S(I:I)) .gt. ICHAR(S(J:J)) )then
      AKI=S(I:I)
      S(I:I)=S(J:J)
      S(J:J)=AKI
    end if
  end do
end do
!もう一回バブルソート
do i=1,LEN_TRIM(T)-1
  do j=i+1,LEN_TRIM(T)
    if(ICHAR(T(I:I)) .LE. ICHAR(T(J:J)) )then
      AKI=T(I:I)
      T(I:I)=T(J:J)
      T(J:J)=AKI
    end if
  end do
end do
PRINT"(A)",MERGE("Yes"," No",LLT(S,T))
END

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sqr(x) ((x)*(x))
const int N=505;
int n,m,ans,x[N][N];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)scanf("%lld",&x[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			int sum=0;
			for(int k=1;k<=m;k++)
				sum+=sqr(x[i][k]-x[j][k]);
			int x=sqrt(sum);
			if(x*x==sum)ans++;
		}
	cout<<ans;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    const A = parseInt(arg[1].split(" ")[0]);
    const B = parseInt(arg[1].split(" ")[1]);
    
    for(let i=A; i<=B; i++) {
        if(i % K === 0) {
            console.log("OK");
            return;
        }
    }
    
    console.log("NG");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

typedef complex<double> ci;
typedef pair<double,pair<double,int> > pdd;
pint fg[400];
bool used[400];
double eps=1e-8;
int main(){
    int n;
    while(cin>>n,n){ 
        rep(i,n) cin>>fg[i].first>>fg[i].second;
        sort(fg,fg+n);
        memset(used,0,sizeof(used));
        ci ppr(0,0),pre(0,0),cur(fg[0].first,fg[0].second);
        double sum=abs(cur-pre);
        used[0]=true;
        ppr=pre;pre=cur;
        FOR(i,1,n){
            vector<pdd> vp;
            double mxag=10;
            rep(j,n){
                if(used[j]) continue;
                ci c(fg[j].first,fg[j].second);
                ci scur=c-pre;
                double prag=arg(pre-ppr)+M_PI;
                double cuag=arg(scur)+M_PI;
                cuag=prag-cuag;
                if(cuag<0) cuag+=2*M_PI;
                mxag=mxag-cuag>eps?cuag:mxag;
                if(abs(mxag-cuag)<eps){
                    cuag=mxag;
                    vp.pb(mp(cuag,mp(abs(scur),j)));
                }
            }
            pdd p=*min_element(vp.begin(),vp.end());
            used[p.second.second]=true;
            sum+=p.second.first;
            ppr=pre;
            pre=ci(fg[p.second.second].first,fg[p.second.second].second);
        }
        cout<<fixed<<setprecision(1)<<sum<<endl;
    }
    return 0;
}

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

typedef vector<int> vi;
typedef bitset<22> MASK;
#define ll long long
#define PI 3.14159265359
#define x first
#define y second
#define point pair<int,int>
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
int n;
int a[25][25];

int dp[25][2100000];
int mod = 1e9 + 7;
int solve(int i, MASK mask){
    if(i == n)
        return 1;

    int &ret = dp[i][mask.to_ulong()];
    if(ret != -1)
        return ret;

    ret = 0;
    for(int k = 0; k < n; k++){
        if(!a[i][k] || mask[k])
            continue;

        MASK msk = mask;
        msk[k] = 1;
        ret = (ret + solve(i + 1, msk))%mod;
    }

    return ret;
}

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

    clr(dp, -1);
    cin>>n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin>>a[i][j];


    cout<<solve(0, 0);
}


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

int main()
{
  int a,b,c;
  std::vector<int> list;
  std::cin >> a >> b >> c;
  list.push_back(a);
  list.push_back(b);
  list.push_back(c);
  std::sort(list.begin(), list.end());
  std::cout << list[0] << " " << list[1] << " " << list[2] << std::endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
string a, s;
  cin >>a>>s;
  cout << s << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int i = 1;
  int K2 = K;
  while(N >= K2){
    K2 = K2 * K;
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

vi graph[200007];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int n; cin >> n;
	FOR(i, n-1){
		int x; cin >> x;
		graph[x-1].PB(i+1);
	}

	FOR(i, n)
		cout << graph[i].size() << "\n";
 
	return 0;
}

Measured memory_bytes: 14492
N, K = map(int, input().split())
input()
if N == K:
    print(1)
elif K == 2:
    print(N - 1)
else:
    tmp = (N - 1) // (K - 1)
    if (N - 1) % (K - 1) != 0:
        tmp += 1
    print(tmp)



Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	long long mn = 1000000, mx = -1000000, sum = 0;
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		mn = min(mn, a);
		mx = max(mx, a);
		sum += a;
	}
	cout << mn << " " << mx << " " << sum << endl;

	return 0;
}


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

struct node {
	int a, b;
};
bool operator<(node a, node b) {
	if (a.a == b.a)return a.b > b.b;
	return a.a < b.a;
}

int cnt[1000001];
int main() {
	priority_queue<node> que;
	int n, q; scanf("%d%d", &n, &q);
	rep(i, q) {
		int a, v; scanf("%d%d", &a, &v);
		cnt[a] += v;
		que.push({ cnt[a],a });
		for (; cnt[que.top().b] != que.top().a; que.pop());
		printf("%d %d\n", que.top().b, que.top().a);
	}
}

Measured memory_bytes: 7760
def mod2019(x, y)
  ((x % 2019) * (y % 2019)) % 2019
end

L, R = gets().split(" ").map(&:to_i)

if (R - L) > 2019 then
  puts 0
  exit
end

r =  R < (L + 2019) ? R : (L + 2019)
minMod = 2019
(L..r).each { |i|
  ((i+1)..r).each { |j|
    modIJ = mod2019(i, j)
    if modIJ < minMod then
      minMod = modIJ
    end
  }
}

puts minMod


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

int main() {
  long N,W;
  cin>>N>>W;
  vector<long> w(N);
  vector<long> v(N);
  long sum=0;
  for(int i=0;i<N;i++) cin>>w[i]>>v[i],sum+=v[i];
  vector<vector<long>> dp(N+1,vector<long>(sum+1));

  for(int i=0;i<N;i++){
    for(int j=0;j<=sum;j++){
      dp[i][j]=1e15;
    }
  }
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=sum;j++){
      if(j-v[i]>=0) dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  long ans=0;
  //for(int i=0;i<=N;i++){
    for(long j=0;j<=sum;j++){
      //cout<<dp[i][j]<<" ";
      if(dp[N][j]<=W) ans=max(ans,j);
    }
    //cout<<endl;
//  }
cout<<ans<<endl;
}


Measured memory_bytes: 83208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll neg = 0;
    rep(i, 0, n){
        cin >> a[i];
        if(a[i] < 0) neg++;
    }
    if(neg % 2 == 1){
        ll ans = 0, mn = 1e18;
        rep(i, 0, n){
            ans += abs(a[i]);
            mn = min(mn, abs(a[i]));
        }
        cout << ans - 2*mn << endl;
    } else {
        ll ans = 0;
        rep(i, 0, n) ans += abs(a[i]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3976
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(X: int):
    print( (X//500)*1000+((X%500)//5)*5 )
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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

def resolve():
    N, X = LI()
    x = LI()

    d = list(set([abs(i - X) for i in x]))
    gcd = d[0]
    for i in d:
        gcd = math.gcd(i, gcd)

    print(gcd)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 24292
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
abc = [tuple(na()) for i in range(m)]

dp = [float('inf')]*n
dp[0] = 0

for i in range(n):
    for a,b,c in abc:
        a,b,c = a-1,b-1,-c
        if dp[a] != float('inf') and dp[b] > dp[a] + c:
            dp[b] = dp[a] + c
            if i == n-1 and b == n-1:
                print('inf')
                exit()

print(-dp[-1])


Measured memory_bytes: 44684
package main
 
import (
	"fmt"
)

func gcd(a int,b int) int{
    if (a < b){
        tmp := a
        a = b
        b = tmp
    }
    
    var r int = a%b
    for r != 0 {
        a = b
        b = r
        r = a%b
    }
    
    return b
}
 
func main() {
	var a,b,c,d int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)

    total := b-a+1
    
    if (c == 1 || d == 1){
        fmt.Printf("%d", 0)
        return
    }
    
    var c_start int = (a-1)/c
    var c_end int = b/c


    var d_start int = (a-1)/d
    var d_end int = b/d

    var cnt int = (c_end - c_start) + (d_end - d_start)
    if (cnt > 0){
        ggg := gcd(c,d)
        var baisu int = (c*d)/ggg
        
        cnt -= (b/baisu - (a-1)/baisu)
    } else {
        cnt = 0
    }
    
    fmt.Printf("%d",total-cnt)
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <list>
#include <vector>
#include <iterator>
#include <ctime>
#include <iomanip>
#include <cstdlib>
#include <random>
#include <cstdio>
#include <sstream>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <chrono> 
#include <numeric> 

using llong = long long;
using ullong = unsigned long long;
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define FORD(i, s, n) for (int i = (s); i > (n); i--)
#define FORW(i, s, n, p) for (int i = (s); i < (n); i += p)
#define FORDW(i, s, n, p) for (int i = (s); i > (n); i -= p)

using namespace std;

int main()
{

	int a, b, c;

	cin >> a >> b >> c;
	(a == b) + (b == c) + (a == c) == 1 ? cout << "Yes" : cout << "No";

}

Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>		
using namespace std;
typedef long long ll;

int main()
{
	int x;
	scanf("%d", &x);
	if (x % 1000) {
printf("%d", 1000 - (x % 1000));
	}
	else {
		puts("0");
	}
	return 0;
}

Measured memory_bytes: 3824
A,B,C=map(int,input().split())

if A==B and B==C and A%2==0:
    print(-1)

else:
    for i in range(1000000):
        if A%2==1 or B%2==1 or C%2==1:
            print(i)
            exit()
        else:
            a=int((B+C)/2)
            b=int((C+A)/2)
            c=int((A+B)/2)
            A=a
            B=b
            C=c

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

int main() {
  int x;cin>>x;
  int ans=1;
  for(int i=2;i<=sqrt(x);i++){
    int a=1;
    while(a<=x){
      ans=max(ans,a);
      a*=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    double a, b, x;    cin >> a >> b >> x;
    
    if (x >= b*a*a/2)
        cout << fixed << setprecision(12) <<  atan(2.0*(b-x/(a*a))/a) * 180 / M_PI << endl;

    else {
        double y = 2*x/a/b;
        cout << fixed << setprecision(12) <<  atan(b/y) * 180 / M_PI << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    ios
    int n,m,q,x,y;
    cin>>n>>m>>q;

    vector<pii> v;
    int dp[505][505]={0};

    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        v.pb(make_pair(x,y));
        for(int j=1;j<=x;j++)
        dp[j][y]++;
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            dp[i][j]+=dp[i][j-1];
        }
    }

    for(int i=1;i<=q;i++)
    {
        cin>>x>>y;
        cout<<dp[x][y]<<endl;
    }
}

Measured memory_bytes: 7408
package main

import("fmt")

func main(){
  var n int
  fmt.Scan(&n)
  
  a:=make([]int,n)
  for i:=0; i<n; i++{
    fmt.Scanf("%d",&a[i])
  }
  
  b:=make([]int,n)
  ans:=0
  for i:=0; i<n; i++{
    fmt.Scanf("%d",&b[i])
    ans+=b[i]
  }
  
  c:=make([]int,n-1)
  for i:=0; i<n-1; i++{
    fmt.Scanf("%d",&c[i])
  }
  
  for i:=0;i<n-1;i++{
    if a[i+1]-a[i]==1 {
      x:=a[i]-1
      ans+=c[x]
    }
  }
  fmt.Print(ans)
}

Measured memory_bytes: 512
#include <stdio.h>


int main(void){
long long a,b,c;
long long e,f,g;
long long res = 0;
 scanf("%lld%lld%lld",&a,&b,&c);
 if(a==b&&b==c&&(a%2)==0) printf("-1");
 else{
        while((a%2)==0&&(b%2)==0&&(c%2)==0)
    {
        e=a;f=b;g=c;
        a = (f+g)>>1;
        b = (e+g)>>1;
        c = (e+f)>>1;
     ++res;
    }
    printf("%lld",res);
 }
return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	int n ; cin >> n;
	if(n % 2 == 1){
		n ++ ;
	}
	cout << (n)/2 - 1 << endl;
}


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

int main() {
	int r, c, k;
	cin >> r >> c >> k;
	int arr[r][c];
	for(int i = 0; i < r; i++)
		for(int j = 0; j < c; j++) {
			char ch;
			cin >> ch;
			arr[i][j] = (ch == '1');
		}
	int sol = 100000;
	for(int i = 0; i < (1 << r - 1); i++) {
		string s = "";
		for(int i = 0; i < r - 1; i++)
			s += "0";
		int temp = i, cnt = 0, cut_cnt = 0;
		while(temp > 0) {
			s[cnt] = (temp&1 ? '1' : '0');
			cut_cnt += temp&1;
			temp /= 2;
			++cnt;
		}
		s += "1";
		vpi v;
	//	error(s);
		//int cut_cnt = 0;
		int lo = 0, hi = 0;
		for(int i = 0; i < r; i++) {
			if(s[i] == '1') {
				v.pb({lo,i});
				lo = i + 1;
			}
		}
		set<int> cuts;
		bool ok = 1;
		int w[sz(v)] = {0};
		int wcnt[sz(v)] = {0};
		//	error(lo, hi);
			// if(s[i] == '1') {
			// 	int cut = 0, w = 0;
			// 	hi = i;
			// 	error(lo, hi);
				for(int j = 0; j < c; j++) {
					bool b = 0;
					for(int i = 0; i < sz(v); i++) {
					lo = v[i].fs, hi = v[i].sd;
					int ww = 0;
					for(int k = lo; k <= hi; k++)
						ww += (arr[k][j] == 1);
					wcnt[i] = ww;
					if(ww > k) {
						ok = 0;
						break;
					}
					if(w[i] + ww > k) {
						cuts.insert(j);
						b = 1;
						w[i] = ww;
						//error(i,j);
						// /
						//cuts.insert(j);
					}
					else 
						w[i] += ww;
				}
				for(int z = 0; b && z < sz(v); z++) {
					w[z] = wcnt[z];
				}
				//lo = hi + 1;
				//cut_cnt += cut;
			
		}
		//error(sz(cuts));
		if(ok)
			sol = min(sol, sz(cuts) + cut_cnt);
	}
	cout << sol;
}


/*

111 0010 010
100 0101 110
	
001 1101 001
110 1000 111

*/

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;



int main() {
    fast

    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes";
    else cout<<"No";


	return 0;
}


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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  string s;
  cin >> s;
  if(s[1]=='B') s[1]='R';
  else s[1] = 'B';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3564
import sys,queue,math,copy,itertools,bisect,collections
LI = lambda : [int(x) for x in sys.stdin.readline().split()]

N,M = LI()
data = [LI() for _ in range(N)]
# dp = [0] * (M+1)
# data.sort(key=lambda x:x[1], reverse=True)
#
# N0 = 2 ** M.bit_length()
# seg = [0] * (2*N0)
#
# def seg_set(i,x):
#     i = i + N0- 1
#     seg[i] = x
#     while i > 0:
#         i = (i-1) // 2
#         seg[i] = max(seg[i*2+1],seg[i*2+2])
#
# def seg_query(i):
#     i = i + N0 - 1
#     ret = seg[i]
#     while i ^ (i+1) < i+1:
#         i = (i-2) // 2
#         ret = max(ret,seg[i])
#     return ret
#
# for i in range(M+1):
#     seg_set(i,i)
#
# for a,b in data:
#     if a <= M:
#         i = seg_query(M-a+1)
#         if i > 0:
#             dp[i] = b
#             seg_set(i,0)
# print(sum(dp))
data.sort()
p = 0
q = queue.PriorityQueue()
ans = 0
for i in range(1,M+1):
    while p < N:
        if data[p][0] > i : break
        q.put(-data[p][1])
        p += 1
    if not q.empty():
        ans -= q.get()
print (ans)



Measured memory_bytes: 26416
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 string a,b,c;
cin>>a>>b>>c;
if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0))
cout<<"YES"<<endl;
else 
cout<<"NO"<<endl;
 
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=9999999999999999;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll f,l1,l2,n,i;
        char s1[15]={'\0'},s2[15]={'\0'};
        cin>>s1>>s2;
        f=1;
        l1=strlen(s1);
        l2=strlen(s2);
        if(l2==l1+1)
        {
        	for(i=0;i<l1;i++)
        	{
        		if(s1[i]!=s2[i])
        		{
        			f=0;
        			break;
        		}
        	}
        	n=(ll)s2[l1];
        	if((n>=65 && n<=90) || (n>=97 && n<=122))
        	{

        	}
        	else
        	{
        		f=0;
        	}
        }
        else
        {
        	f=0;
        }
        if(f==0)
        {
        	cout<<"No\n";
        }
        else
        {
        	cout<<"Yes\n";
        }
        return 0;
}


Measured memory_bytes: 3596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VI a(n);
    REP(i,n){
        cin >> a[i];
    }

    SORT(a);
    if(n%2==0){
        REP(i,n){
            if(a[i]!=(i/2)*2+1){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        REP(i,n){
            if(a[i]!=((i+1)/2)*2){
                cout << 0 << endl;
                return 0;
            }
        }
    }

    int ans = 1;
    REP(i,n/2){
        ans *= 2;
        ans %= MOD;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024