akhauriyash/Code-Regression huggingface dataset:
#include	<bits/stdc++.h>
using	namespace	std;
typedef	long long ll;

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M;
  int S=0;
  cin>>N;
  vector<int>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  M=vec.at(0);
  for(int X=1;X<N;X++){
    if(M>=vec.at(X)){
      M=vec.at(X);
      S++;
    }
  }
  cout<<S+1<<endl;
}

Measured memory_bytes: 4056
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <queue>

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n, sr, sc;
    cin >> h >> w >> n >> sr >> sc;
    --sr;
    --sc;
    string s, t;
    cin >> s >> t;

    auto drops = [&]() {
        for (auto &setup : {
            make_tuple('R', 'L', sc, w, 1),
            make_tuple('L', 'R', sc, w, -1),
            make_tuple('D', 'U', sr, h, 1),
            make_tuple('U', 'D', sr, h, -1)
        }) {
            char dir, counterdir;
            int start, cap, dx;
            tie(dir, counterdir, start, cap, dx) = setup;
            for (int i = 0; i < n; ++i) {
                if (s[i] == dir) {
                    start += dx;
                }
                if (start < 0 || start >= cap) {
                    return false;
                }
                int undo = start;
                if (t[i] == counterdir) {
                    start -= dx;
                }
                if (start < 0 || start >= cap) {
                    start = undo;
                }
            }
        }
        return true;
    };
    cout << (drops() ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 920
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  string S;
  cin >> S;
  int s[S.size()-1];
  for(int i = 0 ; i < S.size(); i++){
    s[i] = S[i] - '0';
  }
  int ans = 642;
  for(int i = 0; i < S.size()-2; i++){
    int suji = s[i]*100+s[i+1]*10+s[i+2];
    int gap = abs(suji-753);
    ans = min(gap,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  long long N, K, tmp, ans;
  cin >> N >> K;
  ans = N / K;
  tmp = ans * K;
  ans = N - tmp;
  tmp = abs(ans - K);
  ans = min(ans, tmp);
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
s = str(input())
t = str(input())

sl = len(s)
tl = len(t)

out = tl
for i in range(sl - tl + 1):
    sub = s[i:i + tl]
    d = 0
    for j, k in zip(sub, t):
        if j != k:
            d += 1
    out = min(out, d)
print(out)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> A(N);
  if(S[0] == 'E') {
    A[0] = 1;
  } else {
    A[0] = 0;
  }
  REP(i, N - 1) {
    if(S[i + 1] == 'E') {
      A[i + 1] = A[i] + 1;
    } else {
      A[i + 1] = A[i];
    }
  }
  int ans = A[N - 1];
  REP(i, N) {
    int tmp = i - A[i - 1] + A[N - 1] - A[i];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1812
from collections import deque
k = int(input())
Q = deque(range(1, 10))
for _ in range(k):
  x = Q.popleft()
  y = x % 10
  z = 10*x + y
  if y != 0:
    Q += [z-1]
  Q += [z]
  if y != 9:
    Q += [z+1]
print(x)

Measured memory_bytes: 11880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e5+7;
const int N=1e5+5;


int main(){
    string s;cin>>s;
    int cnt=0;
    for(int i=0;i<=2;i++)
        if(s[i]=='R')
        cnt++;
    if(cnt==3||cnt==0||cnt==1)
        cout<<cnt<<endl;
    else if(s[1]=='R')
        cout<<cnt<<endl;
    else
        cout<<'1'<<endl;
	return 0;
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#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 vl = vector<ll>;
using vvl = vector<vl>;


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

int main(){
  ll n; cin >> n; ll sum = 0;
  
  for(ll i=1; i <= n; i++){
    for(ll j=1; j <= n; j++){
      for(ll k=1; k <= n; k++){
        sum += gcd(gcd(i,j),k);
      }
    }
  }
  
  cout << sum << endl;
}
  

Measured memory_bytes: 3600
import sys
import math

N = int(input())
F = []
for i in range(N):
    F.append(list(map(int, input().split(' '))))
P = []
for i in range(N):
    P.append(list(map(int, input().split(' '))))
maxprofit = None 
for i in range(1, 1024):
    binstr = bin(i) 
    original = list(map(int, binstr[2:]))
    original = [0]*(10-len(original)) + original
    profit = 0
    for j in range(N):
        s = [a+b for (a, b) in zip(original, F[j])]
        dup = len([a for a in s if a == 2])
        profit += P[j][dup]
    if not maxprofit or maxprofit < profit:
        maxprofit = profit
print(maxprofit)


Measured memory_bytes: 3064
N = int(input())
A = [int(v) for v in input().split()]
L, R = {}, {}
for i,a in enumerate(A):
  l,r = i+a,i-a
  if l not in L: L[l]=0
  if r not in R: R[r]=0
  L[l]+=1
  R[r]+=1

count = 0
for X in L:
  if X not in R: continue
  count += L[X]*R[X]
print(count)

Measured memory_bytes: 56764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[110];

int main(void) {
  int n;
  cin >> n >> buf;
  int x = 0;
  int maxi = 0;
  REP(i, n) {
    x += buf[i] == 'I' ? 1 : -1;
    maxi = max(maxi, x);
  }
  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

// Answer is struct
type Answer struct {
	isAC       bool
	penaltyNum int
}

func main() {
	n, _ := strconv.Atoi(input())
	m, _ := strconv.Atoi(input())
	a := make([]Answer, n)
	for i := 0; i < m; i++ {
		p, _ := strconv.Atoi(input())
		p--
		s := input()

		if s == "AC" {
			a[p].isAC = true
		} else if !a[p].isAC {
			a[p].penaltyNum++
		}
	}

	acNum := 0
	waNum := 0
	for i := 0; i < n; i++ {
		if a[i].isAC {
			acNum++
			waNum += a[i].penaltyNum
		}
	}

	fmt.Println(acNum, waNum)
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define re return
#define ull unsigned long long
#define ll long long
#define ld long double
#define mid (l+r)/2
#define f first
#define s second
#define oo 1e9
#define pi acos(-1)
#define OO 1e18
#define EPS 1e-12
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define Hossam_Yehia ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,arr[100005],ans;
int main(){
    Hossam_Yehia;
    cin >> n;
    for(int i=1;i<=n;++i)
        cin >> arr[i];
    for(int i=1;i<=n;++i){
        if(arr[i]!=i)continue;
        swap(arr[i],arr[i+1]);
        ++ans;
    }
    cout<<ans<<endl;
    re 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int H, W, N, dist[409][409];
char c[29][29];

int main() {
	cin >> H >> W; N = H * W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cin >> c[i][j];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) dist[i][j] = (1 << 29);
		dist[i][i] = 0;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			if (c[i][j] == '.' && c[i][j + 1] == '.') {
				int s1 = i * W + j;
				int s2 = i * W + (j + 1);
				dist[s1][s2] = 1;
				dist[s2][s1] = 1;
			}
		}
	}
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W; j++) {
			if (c[i][j] == '.' && c[i + 1][j] == '.') {
				int s1 = i * W + j;
				int s2 = (i + 1) * W + j;
				dist[s1][s2] = 1;
				dist[s2][s1] = 1;
			}
		}
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
		}
	}
	
	int maxn = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (dist[i][j] != (1 << 29)) maxn = max(maxn, dist[i][j]);
		}
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N;
	int R;
	cin >> N>>R;
	int i;
	i = 0;
	while (pow(R,i)<=N){
		i++;
	}
	cout << i << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int a, b; cin >> a >> b;

    cout << a * b - a - b + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void selectionSort(int A[], int n) {
  int i, count_swap = 0;
  for (i = 0; i < n; i++) {
    int minj = i, j, temp;
    for (j = i; j < n; j++) {
      if (A[j] < A[minj])
        minj = j;
    }
    if (i != minj) {
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      count_swap++;
    }
    printf("%d", A[i]);
    if (i != (n - 1))
      printf(" ");
    else
      printf("\n");
  }
  printf("%d\n", count_swap);
}

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

Measured memory_bytes: 604
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2==0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a = N % 10;
    if (a == 3){
    cout << "bon" << endl;
  }else if ((a == 0)||(a==1)||(a==6)||(a==8)){
    cout << "pon" << endl;
  }
 else{
   cout << "hon" << endl;
 }
return 0;
}

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

#define fin stdin
#define fout stdout
//FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w");

#define MAXN 200009

int n, heap[MAXN], v[MAXN], a[MAXN], k;

inline void prost() {
    fprintf(fout, "-1\n");
    exit(0);
}

inline void coborare(int p) {
    int q;
    bool f = 1;
    while (f && (q = 2 * p) <= k) {
        if (q < k && v[heap[q + 1]] > v[heap[q]]) q++;
        if (v[heap[q]] > v[heap[p]]) {
            std::swap(heap[p], heap[q]);
            p = q;
        } else f = 0;
    }
}

inline int vezi(int p) {
    int A = v[n - 1], b = v[0];
    if (p > 0)
        A = v[p - 1];
    if (p < n - 1)
        b = v[p + 1];
    int cat = (v[p] - a[p]) / (A + b);
    if (cat == 0)
        prost();
    v[p] -= cat * (A + b);
    return cat;
}

int main() {
    fscanf(fin, "%d", &n);

    for (int i = 0; i < n; i++)
        fscanf(fin, "%d", &a[i]);

    for (int i = 0; i < n; i++) {
        fscanf(fin, "%d", &v[i]);
        if (v[i] < a[i])
            prost();
        else if (v[i] != a[i])
            heap[++k] = i;
    }

    for (int i = k / 2; i > 0; i--)
        coborare(i);

    long long ans = 0;
    while (k) {
        int x = heap[1];
        ans += vezi(x);
        if (v[x] == a[x]) {
            std::swap(heap[1], heap[k]);
            k--;
        }
        coborare(1);
    }

    fprintf(fout, "%lld\n", ans);

    fclose(fin);
    fclose(fout);
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <algorithm>

using namespace std;

int partition(int A[],int p,int r){
	int x = A[r];
	int i = p-1;
	for(int j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

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

	partition_point = partition(A,0,n-1);

	for(int i = 0; i < n-1; i++){
		if(i == partition_point){
			printf("[%d] ",A[i]);
		}else{
			printf("%d ",A[i]);
		}
	}
	if(partition_point == n-1){
		printf("[%d]\n",A[n-1]);
	}else{
		printf("%d\n",A[n-1]);
	}
}


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

using namespace std;

int main(void) {
  string s;
  int n;
  long long m = 0, a = 0, r = 0, c = 0, h = 0;
  long long D[5];
  int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> s;
    if(s[0] == 'M')m++;
    if(s[0] == 'A')a++;
    if(s[0] == 'R')r++;
    if(s[0] == 'C')c++;
    if(s[0] == 'H')h++;
  }
  D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
  long long res = 0;
  for(int d = 0; d < 10; d++) {
    res += D[P[d]] * D[Q[d]] * D[R[d]];
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int main(){

  string S;

  int a,z=1,b[5];

  cin >> S;

  a=stoi(S);



b[0]=a/1000;
b[1]=(a-b[0]*1000)/100;
b[2]=(a-b[0]*1000-b[1]*100)/10;
b[3]=(a-b[0]*1000-b[1]*100-b[2]*10);




  for(int i=0;i<3;i++){

      if(b[i]==b[i+1]){
        z=0;
      }
  }
if(z==0){

  cout << "Bad"<<endl;}
  else{


    cout <<"Good"<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	string s;
	cin >> s;
	if (s[0] == 'S') {
		cout << "Cloudy\n";
	} else if (s[0] == 'C') {
		cout << "Rainy\n";
	} else {
		cout << "Sunny\n";
	}
}



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

vector<vector<pair<ll,ll>>> to(200000);
vector<ll> dis(200000);

void dfs(ll a,ll c,ll p = -1){
    dis[a] = c;
    for(auto r:to[a]){
        if(r.first == p) continue;
        dfs(r.first,c+r.second,a);
    }
}

int main(){
    ll n;
    cin >> n;
    for(ll i = 0; i < n-1; i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        to[a].push_back({b,c});
        to[b].push_back({a,c});
    }
    ll q,k;
    cin >> q >> k;
    k--;
    dfs(k,0);
    vector<ll> ans(q);
    for(ll i = 0; i < q; i++){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        ans[i] = dis[x]+dis[y];
    }
    for(ll i = 0; i < q; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 19328
n, k = gets.chomp.split(' ').map(&:to_i)

if k == 1
  ans = 0
elsif n % k == 0
  ans = 0
else
  ans = n
  diff = ans >= k ? (ans % k).abs : (k - ans)
  while ans >= diff
    diff = ans >= k ? (ans % k).abs : (k - ans)
    ans = diff if ans > diff
  end
end

puts ans

Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {

    int i, j, k;
    int n, m;

    scanf("%d%d", &n, &m);
    int matA[n][m], vecb[m], vecc[n];
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            matA[i][j] = 0;
            vecb[j] = 0;
            vecc[i] = 0;
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &matA[i][j]);
        }
    }
    for (j = 0; j < m; j++) {
        scanf("%d", &vecb[j]);
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            vecc[i] = vecc[i] + matA[i][j]*vecb[j];
        }
    }

    for (i = 0; i < n; i++) {
        printf("%d\n", vecc[i]);
    }

    return 0;

}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <complex>
#include <vector>
#include <utility>

const double PI=3.14159265358979323846264;
const double EPS=1e-9;
const double INF=1e12;

using Point=std::complex<double>;
using LineSeg=std::pair<Point, Point>;

double dot(const Point &a, const Point &b) {
    return a.real()*b.real() + a.imag()*b.imag();
}

double cross(const Point &a, const Point &b) {
    return a.real()*b.imag() - a.imag()*b.real();
}

enum CCWise {
    ONLINE_FRONT=-2,
    CLOCKWISE,
    ON_SEGMENT,
    COUNTER_CLOCKWISE,
    ONLINE_BACK,
};

CCWise ccw(Point a, Point b, Point c) {
    b -= a;
    c -= a;
    if (cross(b, c) > EPS) return COUNTER_CLOCKWISE;
    if (cross(b, c) < -EPS) return CLOCKWISE;
    if (dot(b, c) < 0) return ONLINE_BACK;
    if (norm(b) < norm(c)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool crossed(const LineSeg &s, const LineSeg &t) {
    const Point &s1=s.first, &s2=s.second, &t1=t.first, &t2=t.second;
    if (ccw(s1, s2, t1) * ccw(s1, s2, t2) > 0)
        return false;

    return ccw(t1, t2, s1) * ccw(t1, t2, s2) <= 0;
}

double dist_sp(const LineSeg &s, const Point &p) {
    const Point &s1=s.first, &s2=s.second;
    if (dot(s2-s1, p-s1) < EPS) return std::abs(p-s1);
    if (dot(s1-s2, p-s2) < EPS) return std::abs(p-s2);
    return std::abs(cross(s2-s1, p-s1)) / std::abs(s2-s1);
}

struct Star {
    Point p;
    double angle, radius;
    Point pts[5];
    Star(double x, double y, double a, double r):
        p(x, y), angle(a), radius(r)
    {
        pts[0] = p + std::polar(r, (90+angle)*PI/180);
        Point q=std::polar(2*r*std::cos(18*PI/180), (108+angle)*PI/180);
        for (int i=1; i<5; ++i) {
            q *= std::polar(1.0, 144*PI/180);
            pts[i] = pts[i-1] + q;
        }
    }
    double howfar(const Star &other) const {
        double res=INF;

        for (size_t i=0; i<5; ++i)
            for (size_t j=0; j<5; ++j) {
                LineSeg s(pts[i], pts[(i+1)%5]);
                LineSeg t(other.pts[j], other.pts[(j+1)%5]);
                if (crossed(s, t))
                    return 0.0;

                res = std::min(res, dist_sp(s, other.pts[j]));
                res = std::min(res, dist_sp(t, pts[i]));
            }

        return res;
    }
};

int testcase_ends() {
    size_t N, M, L;
    scanf("%zu %zu %zu", &N, &M, &L);

    if (N == 0 && M == 0 && L == 0)
        return 1;

    std::vector<Star> s;
    s.reserve(N);
    for (size_t i=0; i<N; ++i) {
        int x, y, a, r;
        scanf("%d %d %d %d", &x, &y, &a, &r);
        s.emplace_back(x, y, a, r);
    }

    std::vector<std::vector<double>> dist(N, std::vector<double>(N));
    for (size_t i=0; i<N; ++i)
        for (size_t j=i+1; j<N; ++j)
            dist[i][j] = dist[j][i] = s[i].howfar(s[j]);

    for (size_t k=0; k<N; ++k)
        for (size_t i=0; i<N; ++i)
            for (size_t j=0; j<N; ++j)
                if (dist[i][j] > dist[i][k] + dist[k][j])
                    dist[i][j] = dist[i][k] + dist[k][j];

    printf("%.12f\n", dist[--M][--L]);
    return 0;
}

int main() {
    while (true)
        if (testcase_ends()) break;

    return 0;
}

Measured memory_bytes: 3332
#include <cassert>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    vector<pair<int, int> > ans;
    for (int i = 1; i <= n; i++)
        for (int j = i+1; j <= n; j++) {
            if (n % 2 && i + j == n) continue;
            if (n % 2 == 0 && i + j == n + 1) continue;
            ans.push_back({i, j});
        }
    int sum[n+1]= {};
    for (auto e : ans) {
        sum[e.first] += e.second;
        sum[e.second] += e.first;
    }
    for (int i = 2; i <= n; i++) assert(sum[i-1] == sum[i]);

    cout << ans.size() << endl;
    for (auto e : ans) cout << e.first << ' ' << e.second << endl;
}


Measured memory_bytes: 384
dance=list(input())
count=0
for i in range(len(dance)):
  if i%2==0:
    if dance[i] =="L":
      print("No")
      count=1
      break
  if i%2==1:
    if dance[i]=="R":
      print("No")
      count=1
      break
if count==0:
  print("Yes")

Measured memory_bytes: 3064
def main():

    N = int(input())
    T = list(map(int, input().split()))
    A = list(map(int, input().split()))
    mod = pow(10, 9) + 7

    heightT = []
    for i in range(N):
        if i == 0:
            heightT.append([T[i], "exact"])
        else:
            if T[i] > T[i-1]:
                heightT.append([T[i], "exact"])
            elif T[i] == T[i-1]:
                heightT.append([T[i], "bound"])
            else:
                return 0
    heightA = []
    for i in range(N-1, -1, -1):
        if i == N-1:
            heightA.append([A[i], "exact"])
        else:
            if A[i+1] < A[i]:
                heightA.append([A[i], "exact"])
            elif A[i+1] == A[i]:
                heightA.append([A[i], "bound"])
            else:
                return 0
    heightA = heightA[::-1]

    ans = 1
    for i in range(N):
        if heightT[i][1] == "exact" and heightA[i][1] == "exact":
            if heightT[i][0] != heightA[i][0]:
                return 0
        elif heightT[i][1] == "exact" and heightA[i][1] == "bound":
            if heightT[i][0] > heightA[i][0]:
                return 0
        elif heightT[i][1] == "bound" and heightA[i][1] == "exact":
            if heightT[i][0] < heightA[i][0]:
                return 0
        else:
            ans *= min(heightT[i][0], heightA[i][0])
            ans %= mod
    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 32428
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb; 

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


int main() {
    string S;
    cin >> S;
    ll ans = LLONG_MAX;
    rep(i,S.size()-2){
        ll n = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
        ans = min(ans,abs(n-753));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int i;
    double s[1000]={},sum=0,a=0;
    for(i=0;i<n;i++){
      cin >> s[i];
      sum+=s[i];
    }
    for(i=0;i<n;i++){
      a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
    }
    printf("%.5f\n",sqrt(a));
    cin >> n;
  }
  
  return 0;
}



Measured memory_bytes: 3288
#include<stdio.h>
int search(int A[],int n,int key){
  int l=0;
  int r=n;
  int mid;
  while(l<r){
    mid=(l+r)/2;
    if(key==A[mid])return 1;
    if(key>A[mid])l=mid+1;
    else if(key<A[mid])r=mid;
  }
  return 0;
}

int main(){
  int A[1000000],n;
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(search(A,n,k))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 2836
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  string n;
  cin >> n;
  bool ans = n[2] == n[3] && n[4] == n[5];
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =100001;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}

int main()
{
 
  IOS
  ll n,k;
  cin>>n>>k;
  ll f[n+1];
  f[0]=1;
  for(ll i=1;i<=n;i++)
  {
    f[i]=(f[i-1]*i)%mod;
  }
  ll a[n+1];
  ll dp[n+1];
  dp[0]=0;
  for(ll i=k-1;i<=n;i++)
  {
    dp[i]=(f[i]*(power(f[k-1],mod-2)*(power(f[i-k+1],mod-2))%mod)%mod)%mod;
   // trace(i,dp[i]);
  }
  for(ll i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  sort(a+1,a+n+1);
  ll ans=0;
  for(ll i=k;i<=n;i++)
  {
    ans=(ans+(a[i]*dp[i-1])%mod+mod)%mod;
    //cout<<ans<<endl;
  }
  for(ll i=1;i<=n-k+1;i++)
  {
    ans=(ans-(a[i]*dp[n-i])%mod+mod)%mod;

  }
  
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 2176
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int h, w;
    while (cin >> h >> w && h){
        REP(i,h){
            REP(j,w){
                if (i == 0 || j == 0 || i == h-1 || j == w-1)
                    cout << '#';
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

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

int n;
int a[100005],b[100005];
ll cnt[100005];
ll fac[345678],rfac[345678];

ll mod_pow(ll x,ll y){
    ll a=1LL;
    while(y){
        if(y%2) a=1LL*a*x%MOD;
        x=x*x%MOD;
        y/=2;
    }
    return a;
}
 
ll mod_reverse(ll x,ll mod){
    return mod_pow(x,mod-2LL);
}

ll comb(int n,int r){
    if(n<r) return 0LL;
    return 1LL*fac[n]*rfac[n-r]%MOD*rfac[r]%MOD;
}

int main(){

cin>>n; 

for(int i=0; i<=n; i++){
    scanf("%lld",&a[i]); 
    cnt[a[i]]++; b[a[i]]=i;
}
int s,t;
for(int i=0; i<=n; i++){
    if(cnt[a[i]]==2){
        s=i; break;
    }
}
for(int i=1; i<=n; i++){
    if(cnt[i]==2) t=b[i];
}
int p=n-t+s; 

fac[0]=1LL; rfac[0]=1LL;
for(int i=0; i<300000; i++){
    fac[i+1]=(fac[i]*(i+1LL))%MOD;
    rfac[i+1]=mod_reverse(fac[i+1],MOD);
}

for(int i=1; i<=n+1; i++){
    ll ans=comb(n+1,i)-comb(p,i-1);
    if(ans<0) ans+=MOD;
    //cout<<comb(n+1,i)<<" "<<comb(p,i-1)<<endl;
    printf("%lld\n",ans);
}

}

Measured memory_bytes: 8192
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    string ans = "No";
    for (int i = 0; i < s.size(); ++i) {
        if (s == t) {
            ans = "Yes";
            break;
        }
        char c = s[s.size()-1];
        s.pop_back();
        s.insert(0, 1, c);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);

ll n,k;

bool use(ll ind,vector<ll> v){

  vector<vector<int>> dp(n,vector<int>(k+1,0));
  if(n-1!=ind)swap(v.at(ind),v.at(n-1));

  dp[0][0]=1;
  rep(i,0,n-1){
    rep(j,0,k+1){
      if(j+v.at(i)>=k)dp[i+1][k]|=dp.at(i).at(j);
      else dp[i+1][j+v.at(i)]|=dp.at(i).at(j);

      dp[i+1].at(j)|=dp.at(i).at(j);
    }
  }
  //if(n-1!=ind)swap(v.at(ind),v.at(n-1));

  rep(j,max(k-v.at(n-1),0ll),k){//
    if(dp.at(n-1).at(j))return true;
  }

  return false;
}

signed main(){
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,0,n){
    cin>>a.at(i);
  }
  sort(all(a));

  ll need=n,no=-1;

  while(abs(need-no)>1){
    ll mid=(need+no)/2;

    if(use(mid,a)){
      need=mid;
    }else{
      no=mid;
    }
  }

  cout<<no+1<<endl;
}

Measured memory_bytes: 98248
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	vector<vector<int>> g=vector<vector<int>>(n+1,vector<int>(0));
	vector<LL> c(n+1,0);
	vector<int> used(n+1,0);
	FOR(i,0,n-1){
		int a,b;
		cin>>a>>b;
		g[a].PB(b);
		g[b].PB(a);
	}
	FOR(i,0,n)cin>>c[i];
	sort(c.rbegin(),c.rend());
	cerr<<c[0]<<endl;
	int root=0,mx=0;
	FOR(i,0,n){
		int ss=g[i].size();
		if(ss>mx){
			mx=ss;
			root=i;
		}
	}
	queue<int> q;
	LL m=0;
	int idx=0;
	q.push(root);
	while(q.size()){
		int nw=q.front();
		q.pop();
		if(used[nw]!=0){
			continue;
		}
		used[nw]=c[idx];
		if(idx!=0)m+=c[idx];
		idx++;
		int sz=g[nw].size();
		FOR(i,0,sz){
			int nx=g[nw][i];
			if(used[nx]==0)q.push(nx);
		}
	}

	cout<<m<<endl;
	FORQ(i,1,n-1){
		cout<<used[i]<<" ";
	}
	cout<<used[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 1e5;
set<int> e[N];
int c[N], dead[N];

int main() {
    int n;
    cin >> n;
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].insert(v);
        e[v].insert(u);
    }
    string s;
    cin >> s;
    REP(i,n) if (s[i] == 'W') c[i] = 1;

    queue<int> que;
    REP(i,n){
        if (e[i].size() <= 1) que.push(i);
    }

    int m = n;

    while (!que.empty()){
        int x = que.front();
        que.pop();
        if (c[x] == 0){
            m--;
            dead[x] = 1;
            for (int y : e[x]){
                e[y].erase(x);
                if (e[y].size() == 1) que.push(y);
            }
            e[x].clear();
        }
    }

    if (m <= 1){
        cout << m << endl;
        return 0;
    }

    int ans = 2 * (m - 1);
    REP(i,n){
        if (dead[i]) continue;
        ans += c[i] ^ (e[i].size() % 2);
    }

    VI a(n);
    REP(i,n){
        if (dead[i]) continue;
        if (c[i] ^ (e[i].size() % 2)) a[i] = 1;
    }

    int root = -1;
    REP(i,n){
        if (!dead[i]){
            root = i;
            break;
        }
    }

    VI cnt(n);
    function<void (int, int)> dfs = [&](int now, int past){
        for (int next : e[now]){
            if (dead[next] || next == past) continue;
            cnt[next] = cnt[now] + a[next];
            dfs(next, now);
        }
    };

    cnt[root] = a[root];
    dfs(root, -1);

    int ma = -1;
    REP(i,n){
        if (!dead[i] && cnt[i] > ma){
            root = i;
            ma = cnt[i];
        }
    }

    cnt.assign(n, 0);
    cnt[root] = a[root];
    dfs(root, -1);

    ans -= 2 * *max_element(ALL(cnt));
    cout << ans << endl;

    return 0;
}


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

int x[10][10];

int main() {
	int n, d;
	cin >> n >> d;
	for(int i=0;i<n;i++) for(int j=0;j<d;j++) {
		cin >> x[i][j];
	}
	int ans = 0;
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) {
		int p = 0;
		for(int k=0;k<d;k++) p += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
		int q = 0;
		while(p > q * q) q++;
		if(q*q == p) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,y;
    int b=-1,a=-1,c=-1;
    cin >> N >> y;
    for (int i = 0; i < N+1; i++) {
        for (int j = 0; j < N+1; j++) {
            if((N-i-j)>=0&&1000*(N-i-j)==y-10000*i-5000*j){
                a=i;
                b=j;
                c=N-i-j;
            }
        } 
    }    
    cout << a << ' ' << b << ' ' << c << endl;
}

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

int main() {

  int N; cin >> N;
  set<int> st;
  int count = 0;
  rep(i, N) {
    int a; cin >> a;
    if (a >= 3200) {
      count++;
    } else {
      st.insert(a / 400);
    }
  }

  if (st.size() == 0) {
    cout << "1 ";
  } else {
    cout << st.size() << " ";
  }
  cout << st.size() + count << "\n";
  
  return 0;
}

Measured memory_bytes: 3636
module Main where

newtype Ball = Ball (String, Int) deriving (Show)

choice :: Ball -> String -> Bool
choice (Ball (b, _)) b' | b == b'   = True
                        | otherwise = False

decNum :: Ball -> Ball
decNum (Ball (b, n)) = Ball (b, n-1)

ballNum :: Ball -> Int
ballNum (Ball (_, n)) = n

main :: IO ()
main = do
  bs <- getLine
  ns <- getLine
  b  <- getLine
  let nn    = map read $ words ns :: [Int]
  let balls = zipWith (curry Ball) (words bs) nn
  putStrLn $ unwords $ map (show . (\x -> if choice x b then ballNum $ decNum x else ballNum x)) balls


Measured memory_bytes: 508
#include <iostream>
using namespace std;
typedef long long LL;

int main() {
    LL k;
    scanf("%lld", &k);
    LL n = 50;
    LL base = k / n;
    int need = n - (k % n);
    cout << n << endl;
    for (int i = 0; i <= n; i++) {
        if (i == need) continue;
        cout << base + i << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    int a[5],b,i,j,k,l;
    for(i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    for(j=0;j<4;j++){
        for(k=0;k<4;k++){
            for(l=0;l<4;l++){
                for(i=0;i<4;i++){
                    if(a[i]<a[i+1]){
                        b=a[i+1];
                        a[i+1]=a[i];
                        a[i]=b;
                    }
                }
            }
        }
    }
    for(i=0;i<5;i++){
        printf("%d",a[i]);
        if(i==4){
            printf("\n");
        }
        else{
            printf(" ");
        }
    }
return 0;
}

Measured memory_bytes: 600
n = int(input())
t,a=map(int,input().split())
h = list(map(int,input().split()))
kouho = 0
min_ = 10**18
for i in range(n):
  ondosa = abs(a-t+h[i]*0.006)
  if min_ > ondosa:
    kouho = i+1
    min_ = ondosa
print(kouho)

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

string t, temp1, temp2, temp3, ans;

int main() {
  cin >> t;
  reverse(t.begin(), t.end());
  while (!t.empty()) {
    ans = "NO";
    temp1 = t.length() >= 5 ? t.substr(0, 5) : "aaaaa";
    temp2 = t.length() >= 6 ? t.substr(0, 6) : "aaaaaa";
    temp3 = t.length() >= 7 ? t.substr(0, 7) : "aaaaaaa";
    if (temp1 == "maerd" || temp1 == "esare") {
      t.erase(0, 5);
      ans = "YES";
    }
    if (temp2 == "resare") {
      t.erase(0, 6);
      ans = "YES";
    }
    if (temp3 == "remaerd") {
      t.erase(0,7);
      ans = "YES";
    }
    if (ans == "NO") break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
import math
import time
ts=time.time()
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
t=[]
d=[]
nx=[0]*n
for i in range(n):
    a=[i-1 for i in LI()[::-1]]
    nx[i]=a.pop()
    t.append(a)
    d.append([-1]*(n))

flg=True
ans=0
MacthNum=0
yet=set(range(n))
n_yet=set(range(n))
while flg and MacthNum<n*(n-1)//2:
    elp=time.time()-ts
    if elp>1.8:
        ans=n*(n-1)//2
        break
    ans+=1
    IsMatch=False
    done=set()
    for i in yet:
        if (i in done) or (nx[i] in done) or nx[i]==n:
            continue
        c1=i
        c2=nx[i]
        if c1==nx[c2]:
            IsMatch=True
            MacthNum+=1
            if t[c1]:
                n_i=t[c1].pop()
            else:
                n_i=n
                n_yet.remove(c1)
            if t[c2]:
                n_n_i=t[c2].pop()
            else:
                n_n_i=n
                n_yet.remove(c2)
            nx[nx[i]],nx[i]=n_n_i,n_i
            done.add(c1)
            done.add(c2)
    yet=[i for i in n_yet]
    ans=ans if IsMatch else -1
    flg=True if IsMatch else False

print(ans)


Measured memory_bytes: 72792
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;
	long D, N; cin >> D >> N;

	res = pow(100, D) * N;

    if(N == 100) res += pow(100, D);
	cout << res << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        String s = br.readLine().trim();
        int c =0;
        for (int i=0; i<s.length(); i++){
            if (s.charAt(i) == '1'){
                c++;
            }
        }

        System.out.println(c);
    }

}



Measured memory_bytes: 25316
# Primality test
import numpy as np

n = 100003 # limit

primes = np.ones((n + 1,), dtype=int)
primes[0] = 0
primes[1] = 0
primes[2*2::2] = 0
primes[3*2::3] = 0
m = 5
l = n ** 0.5
while m <= l:
    if primes[m]:
        primes[m * 2::m] = 0
    if m % 6 == 5:
        m += 2
    else:
        m += 4

primes = primes.nonzero()[0]

# solve
X = int(input())
idx = np.where(primes >= X)[0][0]
print(primes[idx])

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

#define N 200000
#define MINDIFF -1000000000

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

    int n, array[N], diff = MINDIFF;
    cin>>n>>array[0];  //入力
    int min = array[0];

    for (int i = 1; i < n; i++) {
        cin>>array[i]; //入力
        if(array[i] - min > diff) diff = array[i] - min;
        if(min > array[i]) min = array[i];
    }

    cout<<diff<<endl; //出力
    return 0;
}



Measured memory_bytes: 4008
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  vector <int> L(n);
  vector <int> R(n);
  for (int i = 0; i < n; i++){
    if (i == 0){
      L.at(0) = a.at(0);
      R.at(n-1) = a.at(n-1);
    }
    else{
      L.at(i) = gcd(a.at(i), L.at(i-1));
      R.at(n-1-i) = gcd(a.at(n-1-i), R.at(n-i));
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (i == 0){ans = max(R.at(1), ans);}
    else if (i == n-1){ans = max(L.at(n-2), ans);}
    else{ans = max(ans, gcd(L.at(i-1), R.at(i + 1)));}
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
template<typename T> using Graph = vector<vector<T>>;

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

    int n, d;
    cin >> n >> d;

    int ans;
    if (d == 1) {
        ans = n * (n - 1) / 2;
    } else {
        ans = (n - 1) + (n - d - 1) * n - (n - d - 1) * (n + d - 2) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10;

int n,L[maxn],R[maxn];

int32_t main(){
    scanf("%d",&n);
    rep(i,0,n){
	scanf("%d%d",L+i,R+i);
    }
    n++;
    L[n]=0;
    R[n]=0;
    sort(L,L+n);
    sort(R,R+n);
    int pos[2]={0,0};
    num ans=0;
    rep(i,-maxn,maxn){
	//[i,i+1)
	while(pos[0]<n && L[pos[0]]<=i) pos[0]++;
	while(pos[1]<n && R[pos[1]]<=i) pos[1]++;
	int s=min(n-pos[0],pos[1]);
	ans+=s*2;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1152