akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/ruby
# -*- coding: utf-8 -*-

=begin
Circumscribed Circle of A Triangle.

?????¢????????? (x1, y1) (x2, y2) (x3, y3) ???????????¨??????????§???¢????????\??????????????§?¨? (px, py) ??¨?????? r ???????????????????????????????????°????????????????????????????????????
Input

?????°??????????????????????????????????????????????????????????????????????????° n ???????????????????????????????????????????????????????????\????????¢?????§??????

x1 y1 x2 y2 x3 y3

????????§?????????????????°??¨????????????
Output

????????????????????????????????????px, py, r ??????????????????????????§????????£?????????????????????????????????????°???°?????\????¬¬???????????§?????????????????????????°???°????¬¬??????????????¨?????\??????????????????
Constraints

    -100 ??? x1, y1, x2, y2, x3, y3 ??? 100
    n ??? 20

Sample Input

1
0.0 0.0 2.0 0.0 2.0 2.0

Output for the Sample Input

1.000 1.000 1.414
=end
=begin
(%i2) solve([(px-x1)^2+(py-y1)^2=(px-x2)^2+(py-y2)^2,(px-x1)^2+(py-y1)^2=(px-x3)^2+(py-y3)^2],[px,py]);
                      2     2     2     2            2     2     2      2
(%o2) [[px = - (y2 (y3  - y1  + x3  - x1 ) + y1 (- y3  - x3  + x2 ) + y1  y3
     2        2        2
 - x2  y3 + x1  y3 + y2  (y1 - y3))/(2 x2 y3 - 2 x1 y3 + (2 x1 - 2 x3) y2
                                  2     2     2            2     2
 + (2 x3 - 2 x2) y1), py = (x2 (y3  + x3  - x1 ) + x1 (- y3  - x3 )
               2               2     2        2
 + (x1 - x3) y2  + (x3 - x2) y1  + x1  x3 + x2  (x1 - x3))
/(2 x2 y3 - 2 x1 y3 + (2 x1 - 2 x3) y2 + (2 x3 - 2 x2) y1)]]
(%i3) 
=end

def solve(x1,y1,x2,y2,x3,y3)
  px = - ( y2*(y3**2-y1**2+x3**2- x1**2) + y1*(-y3**2-x3**2+x2**2) + y1**2*y3 \
            - x2**2*y3 + x1**2*y3 + y2**2*(y1 - y3)) \
  / (2*x2*y3-2*x1*y3 + (2*x1 - 2*x3)*y2 + (2*x3-2*x2)*y1)

  py = (x2*(y3**2+ x3**2 - x1**2) + x1*(-y3**2 - x3**2) \
 + (x1 - x3)*y2**2 + (x3 - x2)*y1**2  + x1**2*x3 + x2**2*(x1 - x3)) \
  / (2*x2*y3 - 2*x1*y3 + (2*x1 - 2*x3)*y2 + (2*x3 - 2*x2)*y1)

  r = Math.sqrt((px- x1)**2 + (py- y1)**2)

  return [px,py,r]
end

def rnd3(x)
  return (x*1000).round/1000.0
end
def dist(x, p)
  x1,y1 = x
  px,py = p
  return Math.sqrt((x1-px)**2 + (y1-py)**2)
end

n = gets.to_i
0.upto(n-1){|i|
  x1,y1,x2,y2,x3,y3 = gets.chomp.split.map{|x| x.to_f}
  px,py,r = solve(x1,y1,x2,y2,x3,y3)
  #printf("%.3f %.3f %.3f\n", rnd3(px), rnd3(py), rnd3(r))
  printf("%.3f %.3f %.3f\n", px, py, r)
}

Measured memory_bytes: 8716
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main(){
  long long N,Z,W;cin >>N>>Z>>W;
  vector<long long>a(N);
  for (int i=0;i<=N;i++)cin >>a[i];
  vector<vector<long long>> dp(N+1,vector<long long>(2));
  for (int i=N-1;i>=0;--i){
    dp[i][0]=-INF;
    long long Y = (i ? a[i-1]:W);
    chmax(dp[i][0],abs(Y-a[N-1]));
    for (int j=i+1;j<N;j++)chmax(dp[i][0],dp[j][1]);
    dp[i][1]=INF;
    long long X =(i ? a[i-1]:Z);
    chmin(dp[i][1],abs(X-a[N-1]));
    for (int j = i+1; j < N; ++j) chmin(dp[i][1], dp[j][0]);
    
  }
  cout<<dp[0][0]<<endl;

}

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

using namespace std;

typedef long long ll;

int num[100005];

int main() {
  int n,m,k,p;
  scanf("%d%d%d%d",&n,&m,&k,&p);
  for(int i=1;i<=n;i++) scanf("%d",&num[i]);
  sort(num+1,num+n+1);
  int ans=p;
  ll s=num[n-p+1];
  for(int i=n-p;i>0;i--) {
  	if (num[i]+m<num[n-p+1]) break;
  	s+=num[i];
  	int t=k-(p+i-2);
  	if (t<=0||(ll)(num[i]+m)*(n-p-i+2)-s>=(ll)m*t) ans++;
  	else break;
  }
  printf("%d\n",ans);
  return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   cin>>n;

   map<string, int> M;
   for (int i = 0; i < n; ++i)
   {
      string s;
      cin >> s;
      M[s]++;
   }

   int maxx = 0;
   for(auto it: M){
      smax(maxx, it.second);
   }

   for(auto it: M){
      if(it.second == maxx){
         cout<<it.first<<endl;
      }
   }
   
   

   return 0;
}

Measured memory_bytes: 23808
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 10000000

int min(int a, int b) {
	return a < b ? a : b;
}

int min_cost(int *height, int n, int i, int *dp) {
	if (i == n-1) return 0;
	if (i >= n) return MAX;

	if (dp[i] != -1) return dp[i];

	int one_step = abs(height[i] - height[i+1]) + min_cost(height, n, i+1, dp);
	int two_step = abs(height[i] - height[i+2]) + min_cost(height, n, i+2, dp);
	dp[i] = min(one_step, two_step);
	return dp[i];
}

int main() {
	int n, i;
	scanf("%d", &n);

	int height[n], dp[n];
	memset(dp, -1, n*sizeof(int));
	for (i = 0; i < n; i++) scanf("%d", &height[i]);

	printf("%d\n", min_cost(height, n, 0, dp));
	return 0;
}


Measured memory_bytes: 8704
#include <iostream>
#include <vector>
#include <queue>

#define fi first
#define se second
#define eb emplace_back
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string w;
	cin >> w;
	if (w == "Sunny") cout << "Cloudy" << '\n';
	if (w == "Rainy") cout << "Sunny" << '\n';
	if (w == "Cloudy") cout << "Rainy" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    double x[N], y[N];
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];

    vector<int> a(N);
    for(int i = 0; i < N; i++) a[i] = i;

    double sum = 0.0;
    int n = 0;
    do{
        n++;
        double tmp = 0;
        for(int i = 0; i < N - 1; i++){
            tmp += sqrt((x[a[i]] - x[a[i+1]]) * (x[a[i]] - x[a[i+1]]) + (y[a[i]] - y[a[i+1]]) * (y[a[i]] - y[a[i+1]]));
        }
        sum += tmp;
    } while(next_permutation(a.begin(), a.end()));

    //cout << n << endl;
    printf("%.10lf\n", sum / (double)n);
    //cout << sum / (double)n << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
L=list(map(int,input().split()))

L.sort()
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if L[i]+L[j]<=L[j+1]:
            continue
        if L[i]+L[j]>L[n-1]:
            cnt+=n-j-1
            continue
        left=j+1
        right=n-1
        while right-left>1:
            mid=left+(right-left)//2
            if L[mid]<L[i]+L[j]:
                left=mid
            else:
                right=mid
        cnt+=left-j
print(cnt)

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

int main (){
  string s,t;
  cin >> s >> t;
  
  int ans = 0;
  if(s[0]==t[0]) ans++;
  if(s[1]==t[1]) ans++;
  if(s[2]==t[2]) ans++;
  
  cout << ans << endl;
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    map<int,int> A;
    int ac = 0;
    int wa = 0;
    rep(i,b){
        int c;
        string d;
        cin >> c >> d;
        if(A[c] == 0 && d == "AC"){
            ac++;
            A[c] = -1;
        }
        else if(A[c] == 0 && d == "WA"){
            A[c]++;
        }
        else if(A[c] > 0 && d == "WA")
            A[c]++;
        else if(A[c] > 0 && d == "AC"){
            ac++;
            wa += A[c];
            A[c] = -1;
        }
    }
    cout << ac << ' ' << wa << endl;
}
    

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
string s;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s;
	for(ri i=1;i<=s.length();++i)
		cout<<'x';
	return 0;
}

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

const int non = 0x0fffffff;
int N, M, D[1<<12], P[1<<12];

int main()
{
	scanf ("%d %d", &N, &M);

	for (int i = 1; i < (1 << N); i++) D[i] = P[i] = non;
	while (M--){
		int a, b, c = 0;
		scanf ("%d %d", &a, &b); while (b--){
			int x;
			scanf ("%d", &x);
			c |= 1 << (x - 1);
		}

		for (int i = 0; i < (1 << N); i++) P[i | c] = min(P[i | c], D[i] + a);
		for (int i = 0; i < (1 << N); i++) D[i] = P[i];
	}

	int ans = D[(1 << N) - 1];
	if (ans == non) ans = -1;
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
S = str(input())
if "hi" == S:
  print("Yes")
elif "hihi" == S:
  print("Yes")
elif "hihihi" == S:
  print("Yes")
elif "hihihihi" == S:
  print("Yes")
elif "hihihihihi" == S:
  print("Yes") 
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
    int x1, y1, x2, y2;
    int u, v;

    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    u = y1 - y2;
    v = x2 - x1;
    printf("%d %d %d %d\n", x2 + u, y2 + v, x1 + u, y1 + v);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

void Main(){
    ll N, l;
    sll(N);
    // vector<ll> ls(N, 0);
    map<ll, ll> counter;
    rep(i, N){
        sll(l);
        counter[l] ++;
    }

     
    ll ans = 0;
    for(auto p1:counter){
        for(auto p2:counter){
            if(p1.first >= p2.first){
                continue;
            }
            for(auto p3:counter){
                if(p1.first >= p3.first){
                    continue;
                }else if(p2.first >= p3.first){
                    continue;
                }

                if(p3.first >= p1.first + p2.first){
                    continue;
                }

                ans += (p1.second * p2.second * p3.second);

            }
        }
    }

    cout << ans <<endl;
}

int main(){
    Main();
}

Measured memory_bytes: 3228
import java.util.*;

public class Main {
    static void swap(int[] A, int i, int j) {
        int tmp = A[i];
        A[i] = A[j];
        A[j] = tmp;
    }

    static int selectionSort(int[] A, int N) {
        int count = 0;
        for(int i = 0; i < N; i++) {
            int minj = i;
            for(int j = i; j < N; j++) {
                if(A[j] < A[minj]) minj = j;
            }
            if(i != minj) {
                swap(A, i, minj);
                count++;
            }
        } 
        return count;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();

        int c = selectionSort(a, n);

        System.out.print(a[0]);
        for(int i = 1; i < n; i++) System.out.print(" " + a[i]);
        System.out.println();
        System.out.println(c);
    }
}


Measured memory_bytes: 26364
N,X = map(int,input().split())

# B[L] = 1 + B[L-1] + 1 + B[L-1] + 1
# B[0] = 1
def Ber_memo(L,memo=[0]*(N+1)):
    if L == 0:
        return 1
    if memo[L] != 0:
        return memo[L]
    memo[L] = 2*Ber_memo(L-1) + 3
    return memo[L]

# P[L] = P[L-1] + 1 + P[L-1]
# P[L] = 1
def Patty_memo(L,memo=[0]*(N+1)):
    if L == 0:
        return 1
    if memo[L] != 0:
        return memo[L]
    memo[L] = 2*Patty_memo(L-1) + 1
    return memo[L]

def rec_memo(L=N,bottom=X):
    if L == 0:
        return 1
    if bottom <= 1:
        return 0
    elif bottom <= 1 + Ber_memo(L-1):
        return rec_memo(L-1,bottom-1)
    elif bottom == 1 + Ber_memo(L-1) + 1:
        return Patty_memo(L-1) + 1
    elif bottom <= 1 + Ber_memo(L-1) + 1 + Ber_memo(L-1):
        return Patty_memo(L-1) + 1 + rec_memo(L-1,bottom-(1+Ber_memo(L-1)+1))
    elif bottom <= 1 + Ber_memo(L-1) + 1 + Ber_memo(L-1) + 1:
        return Patty_memo(L-1) + 1 + Patty_memo(L-1)

print(rec_memo())

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, m;
		
		while(!(string = reader.readLine()).equals("0 0")){
			n = Integer.valueOf(string.split(" ")[0]);
			m = Integer.valueOf(string.split(" ")[1]);
			
			int trout[] = new int[n];
			for(int i = 0; i < n; i++) trout[i] = Integer.valueOf(reader.readLine());
			
			int conflict[] = new int[m];
			for(int i = 0; i < m; i++) conflict[i] = Integer.valueOf(reader.readLine());
				
			int modern = 0;
			for(int i = 1; i <= m; i++){
				modern += conflict[i - 1];
				if(modern >= n - 1){
					System.out.println(i);
					break;
				}else{
					modern += trout[modern];
					if(modern >= n - 1){
						System.out.println(i);
						break;
					}
				}
			}
		}
		
		reader.readLine();
	}
}

Measured memory_bytes: 25332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CF
{
    class Program
    {
        static void Main(string[] args)
        {
            // var c = Console.ReadLine().Split().Select(int.Parse).ToList();
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var br= 0;
            for (int i = 0; i < n-2; i++)
            {
                if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
                    br++;

            }

            Console.WriteLine(br);
            
        }
    }
}

Measured memory_bytes: 13140
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M,K=MI()
    for i in range(N+1):
        for j in range(M+1):
            if i*(M-j)+j*(N-i)==K:
                print("Yes")
                return
    print("No")
    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 70380
table = [[0 for i in range(101)]for j in range(101)]

row,column = map(int,input().split())

for r in range(row):
    lst = list(map(int,input().split()))
    for c in range(column):
        table[r][c] += lst[c]
        
for c in range(column):#行の合計値
    total = 0
    for r in range(row):
        total += table[r][c]
    table[row][c] = total
    
for r in range(row+1):#列の合計値
    table[r][column] = sum(table[r])#1～100列目まで合計してるけどまあ良いでしょ


for r in range(row+1):
    lst = []
    for c in range(column+1):
        lst.append(table[r][c])
    lst = [str(i) for i in lst]
    print(" ".join(lst))


Measured memory_bytes: 5708
#include<iostream>
#include<stack>

using namespace std;

int main(){
	string s;cin>>s;
  	int k=s.size(),ans=0;
  	stack<char> ss;
  	for(int i=0;i<k;i++){
    	if(!ss.empty()&&ss.top()!=s[i])
        {ss.pop();ans+=2;}
      	else ss.push(s[i]);
    }
  	cout<<ans;
}

Measured memory_bytes: 512
def main():
    n = int(input())
    XYH = [[int(e) for e in input().split()] for i in range(n)]

    for xi in range(101):
        for yi in range(101):
            top = 1
            for x, y, h in XYH:
                if h > 0:
                    top = h + abs(xi - x) + abs(yi - y)
                    break

            topf = True
            for x, y, h in XYH:
                if (h == 0 and top > abs(xi - x) + abs(yi - y)) \
                        or (h > 0 and top != h + abs(xi - x) + abs(yi - y)):
                    topf = False
                    break

            if(topf):
                print(xi, yi, top)
                exit()

if __name__ == "__main__":
    main()


Measured memory_bytes: 41328
# -*- coding: utf-8 -*-


def main():
    n, a, b, c, d = map(int, input().split())
    s = input()

    if ('##' in s[a - 1:c]) or ('##' in s[b - 1:d]):
        print('No')
        exit()

    if (c > d) and ('...' not in s[b - 2: d + 1]):
        print('No')
        exit()

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
def check_road(start, road_array, mark_array):
    search_target = []
    search_target.append(start)

    while len(search_target) > 0:
        target = search_target[0]
        if len(road_array[target]) != 0:
            for road in road_array[target]:
                if road is not None and mark_array[road] is None and road != 1:
                    # 逆側の要素を返す
                    # print('{}を探している、次は{}へ移動'.format(
                    #     target, road[abs(1-road.index(target))]))
                    mark_array[road] = target
                    search_target.append(road)
        del search_target[0]


# 部屋の数 通路の数
N, M = map(int, input().split())
road_array = [[None] for i in range(N+1)]
# for i in road_array:
#     print(i)
#     print(len(road_array))
for i in range(M):
    a, b = map(int, input().split())
    tmp_a = road_array[a]
    tmp_b = road_array[b]
    # print('チェック{}'.format(i))
    # print('チェック{}'.format(tmp_a))
    # print('チェック{}'.format(tmp_b))
    tmp_a.append(b)
    tmp_b.append(a)
    road_array[a] = tmp_a
    road_array[b] = tmp_b

mark_array = [None] * (N+1)
check_road(1, road_array, mark_array)
mark_array = mark_array[2:]

if None in mark_array:
    print('No')
else:
    print('Yes')
    for mark in mark_array:
        print(mark)


Measured memory_bytes: 36012
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int a, b, c, d, n, count;
	while(scanf("%d", &n) != EOF){
		count = 0;
		for(a=0; a<=9; a++){
			for(b=0; b<=9; b++){
				for(c=0; c<=9; c++){
					for(d=0; d<=9; d++){
						if(a+b+c+d == n)
							count++;
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

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

const int maxn = 3e5+115;

int n, A, B;
int ans[maxn];
int at = 0;

void Init()
{
	scanf("%d%d%d", &n, &A, &B);
}

void Solve()
{
	if ((long long)A * B < n || A + B > n + 1) {
		puts("-1");
	}
	else if (B == 1) {
		for (int i = 1; i <= n; ++i) {
			printf("%d ", i);
		}
	}
	else {
		int N = (n - A) / (B - 1);
		for (int i = 1; i <= N; ++i) {
			for (int j = i * B; j > (i - 1) * B; --j) {
				ans[++at] = j;
			}
		}
		if (N * (B - 1) < (n - A)) {
			for (int i = N * B + 1 + (n - A) - (N * (B - 1)); i > N * B; --i) {
				ans[++at] = i;
			}
		}
		for (int i = at + 1; i <= n; ++i) ans[++at] = i;
		for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
	}
}

int main()
{
	Init();
	Solve();
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  int v=1,ans=0;
  REP(i,n){
    if(a[i]==v){
      v++;
      continue;
    }
    ans++;
  }

  cout<<((v==1)? -1:ans)<<endl;

  return 0;
}

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

int main()
{
	string a;
	int len;
	getline(cin,a);
	len=a.length();
	int x=0;
	int y=0;
	int i;
	while(i<len)
	{
		if(i%2==1)
		{
			if(a[i]=='0') x++;
			else y++;
		}
		if(i%2==0)
		{
			if(a[i]=='1') x++;
			else y++;
		}
		i++;
	}
	if(x>y) cout<<y;
	else cout<<x;
	return 0;
}

Measured memory_bytes: 512
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import Data.Char (isNumber)

isM :: String -> Bool
isM "01" = True
isM "02" = True
isM "03" = True
isM "04" = True
isM "05" = True
isM "06" = True
isM "07" = True
isM "08" = True
isM "09" = True
isM "10" = True
isM "11" = True
isM "12" = True
isM _ = False

isY :: String -> Bool
isY = all isNumber

solve :: String -> String
solve s = if isYYMM && isMMYY then
        "AMBIGUOUS"
        else if isYYMM then "YYMM"
        else if isMMYY then "MMYY"
        else "NA"
    where
    first = take 2 s
    second =  take 2 $ drop 2 s
    isYYMM = isM second && isY first
    isMMYY = isM first && isY second

main = do
    s <- getLine
    putStrLn $ solve s

Measured memory_bytes: 380
s=gets.chomp
Q=gets.to_i

cnt=0
ans=s
l=''
r=''
Q.times do |i|
    query = gets.chomp.split
    if query[0] == '1'
        cnt ^= 1
    else
        if (query[1].to_i-1) ^ cnt == 0
            l = query[2] + l
        else
            r += query[2]
        end
    end

    if (i+1) % 10000 == 0
        ans = l + ans + r
        ans.reverse! if cnt == 1
        l = ''
        r = ''
        cnt = 0
    end
end


ans = l + ans + r
ans.reverse! if cnt == 1

puts ans


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;
void solve(){
    int a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<min(a,b)+min(c,d);
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input!(
        s: String
    );
    let s: String = s;
    let date: Vec<usize> = s.split("/").map(|c| c.parse::<usize>().unwrap()).collect();
    let ans = if let [y, m, _d] = date[..] {
        if y > 2019 || (y == 2019 && m > 4) {
            "TBD"
        } else {
            "Heisei"
        }
    } else {
        ""
    };
    println!("{}", ans);
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

    string str;cin >> str;
    if(str == "SAT")cout << 1 << endl;
    if(str == "FRI")cout << 2 << endl;
    if(str == "THU")cout << 3 << endl;
    if(str == "WED")cout << 4 << endl;
    if(str == "TUE")cout << 5 << endl;
    if(str == "MON")cout << 6 << endl;
    if(str == "SUN")cout << 7 << endl;

	return 0;
}


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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

string SD, T;

/*==================================================*/

/*==================================================*/

int main() {
    cin>>SD>>T;
    for(int i = SD.size()-T.size(); i >= 0; i--){
        bool flag = false;
        REP(j,0,T.size()){
            if(SD[i+j] != T[j] && SD[i+j] != '?'){
                flag = true;
                break;
            }
        }
        if(!flag){
            REP(j,0,SD.size()){
                if(i <= j && j < i + T.size()){
                    cout<<T[j - i];
                }else if(SD[j] == '?'){
                    cout<<"a";
                }else{
                    cout<<SD[j];
                }
            }
            cout<<endl;
            return 0;
        }
    }

    cout<<"UNRESTORABLE"<<endl;

    return 0;
}


Measured memory_bytes: 768
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v[200001];

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,m,j,a,b;
            cin>>n>>m;
            int ar[n+1];
            for(i=1;i<=n;++i)
                cin>>ar[i];
            for(i=1;i<=m;++i)
            {
                cin>>a>>b;
                v[a].pb(b);
                v[b].pb(a);
            }
            int ans=0,ct;
            for(i=1;i<=n;++i)
            {
                ct=0;
                for(j=0;j<v[i].size();++j)
                {
                    if(ar[i]<=ar[v[i][j]])
                    {
                        ct=1;
                        break;
                    }
                }
                if(ct==0)
                    ++ans;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 11512
namespace ABC131.A
{
    using static System.Console;

    public class Program
    {

        public static void Main(string[] args)
        {
            var input = ReadLine();

            WriteLine(IsEasyToInput(input) ? "Good" : "Bad");
        }

        public static bool IsEasyToInput(string s)
        {
            return s[0] != s[1] && s[1] != s[2] && s[2] != s[3];
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k, l;
  
  ll N, x;
  cin >> N >> x;
  ll a[2222], b[2222];
  
  for(i=0; i<N; i++) cin >> a[i];
  for(i=0; i<N; i++) b[i]=INF;
  
  ll ans=INF;
  for(k=0; k<N; k++) {
    ll t=k*x;
    
    for(i=0; i<N; i++) chmin(b[i], a[(i-k+N)%N]);
    for(i=0; i<N; i++) t+=b[i];
    
    chmin(ans, t);
  }
  
  pt(ans);
  
  
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
  long long t;
  long long count=0;
  cin>>t;
  count+=floor(t/500)*1000;
  t-=floor(t/500)*500;
  count+=floor(t/5)*5;
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
 getLine
 as <- getLine
 putStrLn (ins as)

ins as = replicate nbl '(' ++ as ++ replicate nbr ')'
 where
  asum = scanl (\acc c -> if c==')' then acc+1 else acc-1) 0 as
  nbl = maximum asum
  nbr = let (ls,rs) = partition (=='(') as in length ls + nbl - length rs

Measured memory_bytes: 508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            boolean flg = true;
            while (flg) {
                flg = false;
                for (int i = 2; i <= Math.sqrt(x); i++) {
                    if (x % i == 0) {
                        x++;
                        flg = true;
                        break;
                    }
                }
            }
            out.println(x);
        }
    }

    static boolean permutation_2(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }

        int[] letters = new int[256];

        char[] s_array = s.toCharArray();
        for (char c : s_array) {
            letters[c]++;
        }

        for (int i = 0; i < t.length(); i++) {
            int c = (int) t.charAt(i);
            if (--letters[c] < 0) {
                return false;
            }
        }
        return true;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
    cin>>a>>b>>c>>d;
    for(int i=1;i<=a;i++){
        if(i<=b)
            e+=c;
        else
            e+=d;
    }
    cout<<e<<endl;
    return 0;
}

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

using namespace std;
const int maxn = 100000 + 100;
typedef long long int lli;
typedef pair<lli, lli> pii;
pii a[maxn];
bool isPrime[maxn];
int plist[maxn], pnum = 0;

map<lli, int> mp;

int main() {
//    freopen("xx/01.in", "r", stdin);
    isPrime[0] = 1;
    isPrime[1] = 1;
    for (int i = 2; i <= 4000; i++) {
        if (!isPrime[i]) {
            pnum++;
            plist[pnum] = i;
        }
        for (int j = 1; j <= pnum; j++) {
            if (i * plist[j] > 4000)
                break;
            isPrime[i * plist[j]] = 1;
            if (!(i % plist[j]))
                break;
        }
    }
    int n, ans = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i].first);
        lli tmp = a[i].first;
        a[i].first = 1;
        a[i].second = 1;
        for (int j = 1; j < pnum && 1ll * plist[j] * plist[j] * plist[j] <= tmp; j++) {
            int cnt = 0;
            while (tmp % (1ll * plist[j] * plist[j] * plist[j]) == 0) {
                tmp /= (1ll * plist[j] * plist[j] * plist[j]);
            }
            while (tmp % plist[j] == 0) {
                tmp /= plist[j];
                cnt++;
            }
            if (cnt == 1) {
                a[i].first *= plist[j];
                a[i].second *= (1ll * plist[j] * plist[j]);
            } else if (cnt == 2) {
                a[i].first *= (1ll * plist[j] * plist[j]);
                a[i].second *= plist[j];
            }
        }
        if (tmp != 1) {
            a[i].first *= tmp;
            lli x = (lli) sqrt(tmp);
            if (x * x == tmp) {
                a[i].second *= x;
            } else if (tmp <= 100000) {
                a[i].second *= (tmp * tmp);
            } else {
                a[i].second = 0;
            }
        }
        mp[a[i].first]++;
    }
    if(mp[1]) ans ++, mp[1] = 0;
    for(int i = 0; i < n; i ++){
        ans += max(mp[a[i].first],mp[a[i].second]);
        mp[a[i].first] = mp[a[i].second] = 0;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int A, B; cin>>A>>B;
    cout << (A<10 and B<10 ? A*B : -1) << endl;
    return 0;
}

Measured memory_bytes: 256
n, l = [int(x) for x in input().split()]

d_list = [l + i - 1 for i in range(1, n + 1)]
d_sum = sum(d_list)

ans = 0
temp = abs(d_sum)
for d in d_list:
    if abs(d) < temp:
        ans = d_sum - d
        temp = abs(d)
print(ans)

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    static final int MAX = (int)1e5+5;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int q = Integer.parseInt(sc.next());
        int r = 0;
        StringBuffer[] z = new StringBuffer[2];
        for(int i=0; i<2; i++){
            z[i] = new StringBuffer();
        }
        
        for(int i=0; i<q; i++){
            int t = Integer.parseInt(sc.next());
            if(t==1){
                r ^= 1;
            }else{
                int f = Integer.parseInt(sc.next());
                String c = sc.next();
                z[(r+f)%2].append(c);
            }
        }
        
        if(r==0){
            System.out.print(z[1].reverse().toString());
            System.out.print(s);
            System.out.print(z[0].toString());
        }else{
            System.out.print(z[0].reverse().toString());
            System.out.print(reverse(s));
            System.out.print(z[1].toString());
        }
        
        System.out.println();
    }
    
    public static String reverse(String s){
        StringBuffer sb = new StringBuffer(s);
        return sb.reverse().toString();
    }
    
}


Measured memory_bytes: 91948
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

int main()
{
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    reverse(x.begin(), x.end());
    vector<ll> xsum(N);
    xsum[0] = x[0];
    for (int i = 1; i < N; i++)
    {
        xsum[i] += xsum[i - 1] + x[i];
    }
    ll energy = 9223372036854775807;
    for (int i = 1; i <= N; i++)
    {
        ll cost = (i + N) * X;
        cost += 5 * xsum[i - 1];
        ll num = 2 * i - 1;
        ll cnt = 1;
        while (num < N)
        {
            cost += (2 * cnt + 3) * (xsum[num] - xsum[num - i]);
            cnt++;
            num += i;
        }
        cost += (2 * cnt + 3) * (xsum[N - 1] - xsum[num - i]);
        energy = min(energy, cost);
    }
    cout << energy << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
using namespace std;
long long n,ans,p=1e9+7,f[300300],pre[300300][80][2];
long long pow(long long x,long long y)
{
	long long ans=1;
	while(y)
	{
		if(y&1)
			ans=ans*x;
		x=x*x;
		y>>=1;
	}
	return ans;
}
int main()
{
	cin>>n;
	for(long long i=1; i<=n; i++)
		cin>>f[i];
	for(long long i=1; i<=n; i++)
		for(long long j=0; j<=62; j++)
		{
			long long x= f[i]/pow(2,j);
			if(x%(long long)2)	pre[i][j][1] = pre[i-1][j][1]+1 , pre[i][j][0] = pre[i-1][j][0];
			else				pre[i][j][1] = pre[i-1][j][1] , pre[i][j][0] = pre[i-1][j][0]+1;
		}
	for(long long i=1; i<n; i++)
		for(long long j=0; j<=62; j++)
		{
			long long x= f[i]/pow(2,j);
			if(x%(long long)2)	ans = ( ans+ (pre[n][j][0]-pre[i][j][0]) * (pow(2,j)%p) )%p;
			else            	ans = ( ans+ (pre[n][j][1]-pre[i][j][1]) * (pow(2,j)%p) )%p; 
		}
	cout<<ans%p;
	return 0;
}

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

int main() {
	ll x,k,d;
	cin >> x >> k >> d;
	if (x < 0) {
		x = -x;
	}
	ll kadv = x / d;
	if (kadv > k) {
		x -= k*d;
		k = 0;
	} else {
		x -= kadv*d;
		k -= kadv;
		if (k % 2 == 1) 
			x -= d;
	}
	cout << abs(x) << endl;
	return 0;
}


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

using namespace std;

long long n,i,j,v[3010],d[3010][3010];
int main()
{
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>v[i];
        d[i][i]=v[i];
    }

    for(i=n; i>=1; i--)
    {
        for(j=i+1; j<=n; j++)
        {
            if(i+1<=n)d[i][j]=max(-d[i+1][j]+v[i],-d[i][j-1]+v[j]);
            else d[i][j]=-d[i][j-1]+v[j];
        }
    }

    cout<<d[1][n];
    return 0;
}


Measured memory_bytes: 70016
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, r = 0, b = 0;
    scanf("%d", &n);
    vector<char> s(n);
    scanf("%s", s.begin());
    for (int i = 0; i < n; ++i) switch (s.at(i)) {
            case 'R': ++r; break;
            case 'B': ++b; break;
    }
    printf("%s\n", r > b ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 100000000099;

int n;

vector<vector<pair<ll,ll>>> v;
vector<bool> b;
vector<int> g;
void dfs(ll x){
    b.at(x)=true;
    for(int i=0;i < (ll)v.at(x).size();i++)
    {
        b.at(x)=true;
        if(b.at(v.at(x).at(i).fi)==false){
        if(v.at(x).at(i).se%2==0){
            g.at(v.at(x).at(i).fi)=g.at(x);
        }else{
            g.at(v.at(x).at(i).fi) = (1-g.at(x));//こうすれば1→0.0→1にできる
        }
        b.at(v.at(x).at(i).fi)=true;
        dfs(v.at(x).at(i).fi);
        }
    }
}

signed main(){
    cin>>n;
    
    b.resize(n,false);
    g.resize(n,0);
    v.resize(n,vector<pair<ll,ll>>());

    for(int i=0;i < n-1;i++)
    {
        ll u,w,z;
        cin>>u>>w>>z;
        
        v.at(u-1).pb({w-1,z});
        v.at(w-1).pb({u-1,z});
    }

    dfs(0);
    
    for(int i : g)
    {
        cout << i<< endl;
    }
    
}

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

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

	if (a == b && b == c && a%2==0) {
		cout << -1 << endl;
		return 0;
	}

	
	int res = 0;
	while (true) {
		if (a%2==1 || b%2==1 || c%2==1) break;

		int aa = a/2;
		int bb = b/2;
		int cc = c/2;
		a = bb+cc;
		b = aa+cc;
		c = aa+bb;
		res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    A= IL(int)
    print(A.index(0) + 1)


solve()


Measured memory_bytes: 9184
N, W = map(int,input().split())

cost = [list(map(int,input().split())) for i in range(N)]
dp = [[0] * (W+1) for i in range(N)]


for i in range(N):
    for sum_w in range(0,W+1):
        if sum_w - cost[i][0] >= 0:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w - cost[i][0]] + cost[i][1])
        dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])

print(dp[N-1][W])

Measured memory_bytes: 121324
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N,K; cin>>N>>K;
    int ans = 1;
    for(int i = 0; i < N; i++)
        ans = min(ans*2,ans+K);
    cout<<ans<<endl;
    return 0;
}

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

const int maxn=2e5+10;
int a[maxn];
int b[maxn];

int n;

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&a[i]);
    for(int i=0;i<n;++i) scanf("%d",&b[i]);
    int ans=0;
    for(int v=(1<<28);v;v>>=1){
        int tp=0;
        for(int i=0;i<n;++i){
            a[i]&=((v<<1)-1);
            b[i]&=((v<<1)-1);
        }
        sort(a,a+n);
        sort(b,b+n);
        for(int i=n-1,j=0,k=0,l=0;i>=0;--i){//枚举a
//            int v1=lower_bound(b,b+n,v-a[i])-b;
//            int v2=lower_bound(b,b+n,2*v-a[i])-b;
//            int v3=lower_bound(b,b+n,3*v-a[i])-b;
            while(j<n && a[i]+b[j]<v) j++;
            while(k<n && a[i]+b[k]<2*v) k++;
            while(l<n && a[i]+b[l]<3*v) l++;
            tp+=k-j+n-l;
            tp&=1;
        }
        if(tp) ans|=v;
    }
    printf("%d\n",ans);
    return 0;
}


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

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


int n;
int p[200020];
bool use[200020];
int v[200020];


signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n;
    int ans=0;
    rep(i,1,n+1){
        int x;
        cin>>x;
        v[x]=v[x-1]+1;
    }
    rep(i,1,n+1)ans=max(ans,v[i]);
    cout<<n-ans<<endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 1792
Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(int, input().split())))
k = 0
flag = False
for i in range(Row):
  if List[i][0] == List[i][1]:
    k += 1
  else:
    k = 0
  if k == 3:
    flag = True
    break
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9192
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn a() {
    let N: usize = read!(usize);

    if N == 1 {
        println!("{}", 1.0);
    }

    if N % 2 == 0 {
        println!("{}", 0.50);
    } else {
        println!("{}", (N + 1) as f64 / (2.0 * N as f64));
    }
}

fn b() {
    let (n, k) = read!(usize, usize);
    let mut h: Vec<usize> = read![[usize]];
    h.sort();
    h.reverse();

    let mut ans = 0;
    for hh in h {
        if hh >= k {
            ans += 1;
        } else {
            println!("{}", ans);
            return;
        }
    }
    println!("{}", ans);
}

fn c() {
    unimplemented!();
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    b();
}


Measured memory_bytes: 6396