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

int main(){
  int color[8] = {};
  int n;
  cin >> n;
  int tmp;
  int big = 0;
  for(int i = 0;i < n;i++){
    cin >> tmp;
    if(tmp < 3200){
      color[tmp/400]++;
    }else{
      big++;
    }
  }

  int ans = 0;
  for(int i = 0;i < 8;i++){
    if(color[i] != 0) ans++;
  }

  if(ans == 0 && big != 0){
    cout << 1 << " " << big << endl;
  }else{
    cout << ans << " " << ans+big << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import itertools
def solve(A):
    x = []
    for i in range(len(A)):
        comb = list(itertools.combinations(A, i))
        for c in comb:
            x.append(sum(c))
    return x
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
s = solve(A)
for i in m:
    if i in s:
        print("yes")
    else:
        print("no")


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

int gcd(int a, int b, int step);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		gcd(a, b, 0);
	}

	return (0);
}

int gcd(int a, int b, int step)
{
	if (b == 0){
		cout << a << " " << step << endl;
	}
	else if (a < b){
		return (gcd(a, b % a, step + 1));
	}
	else {
		return (gcd(b, a % b, step + 1));
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
using namespace std;
int main() 
{
	long n,m,i,cnt=0,ans=0;
  	cin >> n >> m;
  	long l[m],r[m];
  
	for(i=0;i<m;i++){
		cin >> l[i] >> r[i];
	} 
	sort(l, l+m);
	sort(r, r+m);
	
	if(r[0]-l[m-1]>=0){
		cout << r[0]-l[m-1]+1 << endl;
	}
	else{
		cout << '0' << endl;
	}	
	return 0;
}


Measured memory_bytes: 1792
import sys
import heapq
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = (-1)*A[i]

heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, int(a/2))

print(abs(sum(A)))

Measured memory_bytes: 86456
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=-1,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+ch-48,ch=getchar();
	return x*f;
}
int n,k;
LL ans=0;
int main(){
	n=read(),k=read();
	ans=1LL*(n/k)*(n/k)*(n/k);
	if (k%2==0){
		k/=2;
		int s=n/k;
		if (s%2==0)
			if ((s+1)*k<=n)
				s++;
			else
				s--;
		s=(max(s,0)+1)/2;
//		printf("%d\n",s);
		ans+=1LL*s*s*s;
	}
	printf("%lld",ans);
	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 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 n,x,y;
    cin >> n >> x >> y;
    
    VL D(n-1,0);

    VVL G(n);
    rep(i,n-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x-1].push_back(y-1); G[y-1].push_back(x-1);

    rep(i,n){
        VL dist(n,-1);
        queue<ll> q;
        dist[i] = 0;
        q.push(i);

        while(!q.empty()){
            ll v = q.front();
            q.pop();

            for(auto w : G[v]){
                if(dist[w] != -1) continue;
                dist[w] = dist[v] + 1;
                q.push(w);
            }
        }

        rep(v,n){
            if(dist[v] > 0){
                D[dist[v]-1]++;
            }
        }
    }

    rep(k,n-1){
        cout << D[k]/2 << endl;
    }

    return 0;
}

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

int main()
{
	string input;
	string fes = "FESTIVAL";
	cin >> input;

	int inputsize = input.size();
	int fessize = fes.size();

	for(int i=0; i<inputsize-fessize; i++)
		cout << input[i];
	
	return 0;
}

Measured memory_bytes: 256
judge :: (Fractional a, Ord a) => a -> String
judge w
    | w <= 48.00 = "light fly"
    | w <= 51.00 = "fly"
    | w <= 54.00 = "bantam"
    | w <= 57.00 = "feather"
    | w <= 60.00 = "light"
    | w <= 64.00 = "light welter"
    | w <= 69.00 = "welter"
    | w <= 75.00 = "light middle"
    | w <= 81.00 = "middle"
    | w <= 91.00 = "light heavy"
    | otherwise  = "heavy"

main :: IO ()
main = putStr . unlines . map judge . map read . lines =<< getContents

Measured memory_bytes: 4024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
long long n;
struct Edge{
	long long u,v,w,next;
}e[2000000];
struct node{
	long long maxx_1,maxx_2;
}tr[600000];
long long dep[600000];
long long h[600000];
void make(long long st,long long nd,long long w){
	long long temp=tr[nd].maxx_1+w;
	if(temp>tr[st].maxx_1){
		tr[st].maxx_2=tr[st].maxx_1;
		tr[st].maxx_1=temp;
	}
	else if(temp>=tr[st].maxx_2){
		tr[st].maxx_2=temp;
	}
	return ;
}
void dfs(long long x){
	for(long long i=h[x];i;i=e[i].next){
		long long v=e[i].v,w=e[i].w;
		if(!dep[v]){
			dep[v]=dep[x]+1;
			dfs(v);
			make(x,v,w);
		}
	}
}
long long cnt=0;
int main(){
	cin>>n;
	memset(tr,0,sizeof(tr));
	for(long long i=1;i<n;i++){
		long long u,v,w;
		scanf("%lld%lld%lld",&u,&v,&w);
		u++;v++;
		e[++cnt]=(Edge){u,v,w,h[u]};h[u]=cnt;
		e[++cnt]=(Edge){v,u,w,h[v]};h[v]=cnt;
	}
	dep[1]=1;
	dfs(1);
	long long ans=0;
	for(long long i=1;i<=n;i++){
		ans=max(ans,tr[i].maxx_1+tr[i].maxx_2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 25020
# DP

# https://atcoder.jp/contests/abc044/tasks/arc060_a

from itertools import combinations


n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(max(x), a)


# dp[j][k][s] (0 <= j <= N, 0 <= k <= N, 0 <= s <= NX)
# dp[j][k][s] = x1,...,xjまでからk枚使って，合計をsにする選び方の総数
# dp[0][0][0] = 1
# j >= 1, s < xjのとき，dp[j][k][s] = dp[j-1][k][s] (xjは使わない)
# j >= 1, k >= 1, s >= xjのとき，dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-xj]
# ... 1枚少なく使ってxjを入れる + 使わない
# それ以外 0

dp = [
    [[0 for _ in range(n * X + 1)] for _ in range(n + 2)]
    for _ in range(n + 2)
]

dp[0][0][0] = 1
for i in range(n):
    for j in range(n+1):
        for k in range(n * X + 1):
            if k < x[i]:
                dp[i + 1][j][k] = dp[i][j][k]
            else:
                dp[i + 1][j][k] = dp[i][j][k] + dp[i][j-1][k-x[i]]
ans = 0
for i in range(1, n + 1):
    ans += dp[n][i][i*a]
print(ans)

Measured memory_bytes: 98780
////   template  ///////////////////////////////////////////////////////
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <sys/resource.h>
#include <iostream>
using namespace std;

class timer{
	enum KIND{ REAL, CPU }; // real_time or cpu_time
	double t0; // start
	double t1; // end
	KIND kind_of_time; // default is real_time
	double get_realtime(){struct timeval tv; gettimeofday(&tv, NULL);
		return tv.tv_sec + (double)tv.tv_usec*1e-6;}
	double get_cputime(){struct rusage RU; getrusage(RUSAGE_SELF, &RU); 
		return RU.ru_utime.tv_sec + (double)RU.ru_utime.tv_usec*1e-6;}
public:
	timer(){kind_of_time = REAL;}
	void set(KIND k){kind_of_time = k;}
	void start(){t0 = get_realtime();}
	void stop(){t1 = get_realtime();}
	void print(){printf("TotalTime : %.3fsec\n", t1-t0);}
};
////////////////////////////////////////////////////////////////////////

/*
  v = 9.8t
  y = 4.9t*t
*/

int main()
{
	double v;
	while(cin>>v)
	{
		double y = v*v/19.6;
		int n = (int)(y/5.0) + 2 ;
		cout << n << endl;
	}

    return 0;
}

Measured memory_bytes: 1224
import java.util.*;
import java.lang.*;

public class Main {
    
    static int n;
    static int k;
    
    public static void main (String args[]) {

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        int ans = 0;
        int num = 1;
        
        for (int i = 0; i < n; i++) {
            if (num * 2 < num + k) {
                num *= 2;
            } else {
                num += k;
            }
        }
        
        ans = num;
        
        System.out.println(ans);
    }
}



Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
    int N,K; cin >> N >> K;
    vector<int> V(N);
    rep(i,N) cin >> V[i];
    int ans = 0;
    for(int i = 0; i <= min(N,K); i++){
      for(int j = 0; i+j <= min(N,K); j++){
        vector<int> now;
        int sum = 0;
        rep(k,i){
          now.push_back(V[k]);
        }
        rep(k,j){
          now.push_back(V[N-1-k]);
        }
        sort(now.begin(),now.end());
        rep(k,min(K-i-j,(int)now.size())){
          if(now[k] < 0) now[k] = 0;
        }
        rep(k,now.size()) sum += now[k];
        
        ans = max(ans,sum);
      }
    }
    cout << ans << endl;

}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

string s[4] = {"AC", "WA", "TLE", "RE"};
vector<int> ans(4, 0);

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string t;
		cin >> t;
		for (int j = 0; j < 4; j++) {
			if (t == s[j]) ans[j]++;
		}
	}
	for (int i = 0; i < 4; i++) {
		cout << s[i] << " x " << ans[i] << endl;
	}
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
	int n,m,j,b,ai,l;
	unsigned long long int  a[101][101], gh[101][101],ans[101][101];
	
	scanf("%d %d %d",&n,&m,&l);
	for(j=0;j<101;j++){
		for(b=0;b<101;b++){
			ans[j][b]=0;
			a[j][b]=0;
			gh[j][b]=0;
		}
	}
	for(j=0;j<n;j++){
		for(b=0;b<m;b++){
			scanf("%d",&a[j][b]);
		}
	}
	for(j=0;j<m;j++){
		for(b=0;b<l;b++){
			scanf("%d",&gh[j][b]);
		}
	}
	for(j=0;j<n;j++){
		for(b=0;b<l;b++){
			for(ai=0;ai<m;ai++){
				ans[j][b]+=a[j][ai]*gh[ai][b];
			}
		}
	}
		for(j=0;j<n;j++){
			for(b=0;b<l;b++){
				if(b==0){printf("%llu",ans[j][b]);
				}
				else{
					printf(" %llu",ans[j][b]);
				}
			}printf("\n");
		}
		scanf("%d",&n);
	return 0;
}

Measured memory_bytes: 848
#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 / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B)
  {
    cout << C << endl;
  }
  else if(B==C)
  {
    cout << A << endl;
  }
  else
  {
    cout << B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define ll long long
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 15
int g[MN+5][MN+5],F[1<<MN][MN+5];
ll f[1<<MN][MN+5];
vector<int> v[1<<MN];
inline void rw(ll&a,ll b){if(b>a)a=b;}
int main()
{
	int n,m,i,j,k,x,y,s=0;
	n=read();m=read();
	while(m--)x=read(),y=read(),s+=g[x][y]=g[y][x]=read();
	for(i=1;i<1<<n;++i)for(j=1;j<=n;++j)if(i&(1<<j-1))
	{
		v[i].push_back(j);
		i^=1<<j-1;
		for(x=0;x<v[i].size();++x)
		{
			F[i^(1<<j-1)][j]+=g[v[i][x]][j];
			for(y=0;y<x;++y)F[i^(1<<j-1)][j]+=g[v[i][x]][v[i][y]];
		}
		i^=1<<j-1;
	}
	memset(f,200,sizeof(f));
	for(i=1;i<1<<n;++i)if(i&1)f[i][1]=F[i][1];
	for(i=1;i<1<<n;++i)for(j=0;j<v[i].size();++j)
		for(x=i^(1<<v[i][j]-1);x&=i^(1<<v[i][j]-1);--x) 
			for(y=0;y<v[x].size();++y)if(g[v[i][j]][v[x][y]])
				rw(f[i][v[i][j]],f[x][v[x][y]]+g[v[i][j]][v[x][y]]+F[i^x][v[i][j]]);
	printf("%d",s-f[(1<<n)-1][n]);
}

Measured memory_bytes: 10496
#include<iostream>
  
int main() {
  int N; std::cin >> N;
  for(int i = 0; i < N; ++i) {
    int A; std::cin >> A;
    if(A%2==1) continue;
    if(A%3==0) continue;
    if(A%5==0) continue;
    std::cout << "DENIED" << std::endl;
    return 0;
  }
  std::cout << "APPROVED" << std::endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var S = ReadText();
            var T = ReadText();

            var t2 = T.Substring(0, T.Length - 1);
            return t2 == S ? "Yes" : "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 25896
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	int w, h; cin >> h >> w;
	int a[100][100];
	for (int y = 0; y < h; ++y) {
		for (int x = 0; x < w; ++x) {
			cin >> a[y][x];
		}
	}
	int b[100];
	for (int i = 0; i < w; ++i) {
		cin >> b[i];
	}

	for (int i = 0; i < h; ++i) {
		int sum = 0;
		for (int j = 0; j < w; ++j) {
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1196
main :: IO ()                                                                                                              
main = do                                                                                                                  
  a <- readLn :: IO Int                                                                                                    
  b <- readLn                                                                                                              
  c <- readLn                                                                                                              
  d <- readLn                                                                                                              
  print $ (min a b) + (min c d)

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

int main() {
  long long a, b;
  cin >> a >> b;
  
  if (a <= 0 && b >= 0){
    cout << "Zero" << endl;
  }
  else {
    if (a > 0){
      cout << "Positive" << endl;
    }
    if (b < 0){
      if ((b - a) % 2 == 0) cout << "Negative" << endl;
      else cout << "Positive" << endl;
    }
  }
}

Measured memory_bytes: 3624
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
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']
YNeos='YNeos'
mo=10**9+7
imp='IMPOSSIBLE'


def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(num_v)]
  dist[source-1]=0
  
  #辺の緩和
  for i in range(num_v):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
        if i==num_v-1 and ans!=dist[n-1]:
            0#return 'neg'
    ans=dist[n-1]
  return dist

def shortest_path(s,n,w,es):
    #s→iの最短距離
    # s:始点, n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    d = [float("inf")] * n
    #d[i] : s→iの最短距離
    d[s] = 0
    while True:
        updata = False
        for i in range(w):
            e = es[i]
            ans=d[n-1]
            # e: 辺iについて [from,to,cost]
            if d[e[0]] != float("inf") and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                updata = True
        if not updata:
            break
    return d

n,m,p=MI()
g=[]
for i in range(m):
    a,b,c=MI()
    #g.append((a-1,b-1,p-c))
    g.append((a,b,p-c))
    

di=BellmanFord(g,n,1)
ans=di[n-1]
di_2=BellmanFord(g,n*2,1)

if ans!=di_2[n-1]:
    print(-1)
else:
    print(max(0,-di[n-1]))

Measured memory_bytes: 51308
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
    #pragma GCC target("sse,sse2,avx,avx2,popcnt,tune=native")
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define db double
    #define sht short
    #define MB template <class T>
    #define Fur(i,x,y) for(auto i=x;i<=y;i++)
    #define Fdr(i,x,y) for(auto i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define fcin ios::sync_with_stdio(false)
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 1003
int n,mx=0,x,ans=0;
int main(){
    in>>n;
    Fur(i,1,n)in>>x,ans+=(x>=mx),mx=MAX(mx,x);
    out<<ans<<ln;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

using namespace std;
using ll = long long;
const ll kInf = 1e18;

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

template<class T>bool chmax(T &a, const T &b) {
   if (a < b) {
      a = b;
      return 1;
   }
   return 0;
}
template<class T>bool chmin(T &a, const T &b) {
   if (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
   const ll kMod = 1000000007;
   string s;
   cin >> s;
   ll cnt = 0;
   int n = SZ(s);
   ll dp[2][13];
   FILL(dp, 0);
   dp[0][0] = 1;

   REP(i, s.size()) {
      int sint = (int)s[i]-'0';
      REP(j, 13) {
         REP(k, 10) {
            if (sint>=0 && sint<10 && sint!=k) continue;
            dp[1][(10*j+k)%13] += dp[0][j];
         }
      }
      REP(j, 13) {
         dp[1][j] %= kMod;
         dp[0][j] = dp[1][j];
         dp[1][j] = 0;
         eprintf("%d,%d,%lld\n", i, j, dp[0][j]);
      }
   }
   cout << dp[0][5] << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n+2];
    for(int i=0;i<n;i++)cin>>a[i];
    ll cnt=1;
    ll mx=-1;
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1])cnt++;
        else{
            mx=max(mx,cnt);
            cnt=1;
        }
    }
    mx=max(mx,cnt);
    if(mx==-1)cout<<0<<endl;
    else cout<<mx-1<<endl;
}


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

using namespace std;

int fun(int n)
{
	int s=0;
	while(n!=0)
	{
		s+=(n%10);
		n/=10;
	}
	return s;
}
int main()
{
	int n;
	cin>>n;

	int ans=999999;
	for(int i=1;i<=n/2;i++)
	{
		ans=min(ans,fun(i)+fun(n-i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int w = in.nextInt();
        int[] weights = new int[n];
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = in.nextInt();
            values[i] = in.nextInt();
        }
        int vMax = Arrays.stream(values).max().orElse(0);

        // value -> min weight
        int[] minWeight = new int[n * vMax + 1];
        Arrays.fill(minWeight, Integer.MAX_VALUE / 2);
        minWeight[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = n * vMax - values[i]; j > -1; j--) {
                minWeight[j + values[i]] = Math.min(minWeight[j + values[i]], minWeight[j] + weights[i]);
            }
        }

        int maxValue = 0;
        for (int i = minWeight.length - 1; i >= 0; i--) {
            if (minWeight[i] <= w) {
                maxValue = i;
                break;
            }
        }
        out.println(maxValue);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 26708
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // int Nを受け取る
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt(); // int A[i]を受け取る
		}
		sc.close(); // 標準入力を終了

		int shift = 0; // 操作を行える回数
		boolean odd = false; // 奇数フラグ

		// 奇数が見つかるまで操作を繰り返す
		while(!odd) {
			for(int i = 0; i < N; i++) {
				if(A[i] % 2 != 0) {
					//奇数が見つかったら終了
					odd = true;
					break;
				}else {
					A[i] = A[i] / 2;
				}
			}
			// 奇数フラグが無ければshift+1
			if(!odd)shift += 1;
		}

		// shiftを出力
		System.out.println(shift);
	}

}

Measured memory_bytes: 36044
#include<iostream>
#include<cmath>
#include<string>
#define ll long long 
using namespace std;

int main()
{
    double i,j,k,l,n,a,b;
    cin>>a>>b>>k;
    if(a>b)cout<<ceil(k/a);
    else cout<<ceil(k/b);
     
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(void){
    string s;
    int k;
    cin >> s >> k;
    
    set<string> st;
    int i, j;
    for(i = 0; i < s.length(); i++){
        for(j = 0; j < 5; j++){
            if(i + j < s.length()){
                st.insert(s.substr(i, j + 1));
            }
        }
    }
    
    if(k == 1){
        cout << *st.begin() << endl;
    }else{
        int cnt = 1;
        int i = 1;
        string fw = *st.begin();
        string now;
        while(cnt != k){
            now = *next(st.begin(), i);
            if(now != fw){
                cnt++;
            }
            i++;
        }
        cout << now << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>

const int N = 100;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int n, adj_mat[N][N];
int color[N], d[N], f[N], tt;

int Next(int node_id)
{
    for (int i = 0; i < n; i++) {
        if (adj_mat[node_id][i] == 1 && color[i] == WHITE) {
            return i;
        }
    }
    return -1;
}

void DFS(int node_id)
{
    std::stack<int> S;
    S.push(node_id);
    color[node_id] = GRAY;
    d[node_id] = tt++;

    while(!S.empty()) {
        int target = S.top();
        int next = Next(target);
        if (next != -1) {
            color[next] = GRAY;
            d[next] = tt++;
            S.push(next);
        } else {
            S.pop();
            color[target] = BLACK;
            f[target] = tt++;
        }
    }
}

void Init(int n)
{
    tt = 1;
    for (int i = 0; i < n; i++) {
        d[i] = 0;
        f[i] = 0;
        color[i] = WHITE;
        for (int j = 0; j < n; j++) {
            adj_mat[i][j] = 0;
        }
    }
}

int main(int argc, char *argv[])
{
    scanf("%d", &n);

    Init(n);    

    // make adj matrix
    for (int i = 0; i < n; i++) {
        int node_id, adj_num;;
        scanf("%d", &node_id);
        scanf("%d", &adj_num);
        node_id--;
        for (int j = 0; j < adj_num; j++) {
            int adj_id;
            scanf("%d", &adj_id);
            adj_id--;
            adj_mat[node_id][adj_id] = 1;
        }
    }

    // depth search
    for (int i = 0; i < n; i++) {
        if (color[i] == WHITE) DFS(i);
    }

    // dump adj matrix
    for (int i = 0; i < n; i++) {
        fprintf(stdout, "%d %d %d\n", i+1, d[i], f[i]);
    }

    return 0;
}


Measured memory_bytes: 3256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct DSU{
	int S;
	struct node{
		int parent; ll sum;
	};
	vector<node> dsu;
	DSU(int n){
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	void reset(int n){
		dsu.clear();
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	int root(int u){
		if(dsu[u].parent == u) return u;
		dsu[u].parent = root(dsu[u].parent);
		return dsu[u].parent;
	}
	void merge(int u, int v){
		u = root(u); v = root(v);
		if(u == v) return;
		if(getsum(u) < getsum(v)) swap(u, v);
		dsu[v].parent = u;
		dsu[u].sum += dsu[v].sum;
	}
	bool sameset(int u, int v){
		if(root(u) == root(v)) return true;
		return false;
	}	
	ll getsum(int u){
		return dsu[root(u)].sum;
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	DSU dsu(n + m);
	rep(i, n){
		int k;
		cin >> k;
		while(k--){
			int l;
			cin >> l;
			l--;
			dsu.merge(l, i + m);
		}
	}
	repn(i, m + 1, n + m) if(!dsu.sameset(i, i - 1)){
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5616
a,b,c = list(map(int,input().split()))                                                                                                                                                                          
d = int(input())                                                                                                                                                                                                
e = max([a,b,c])                                                                                                                                                                                                
s  = sum([a,b,c])                                                                                                                                                                                                
ans = e * (2 ** d) + s -e                                                                                                                                                                                       
print(ans)        

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(3e5) + 5;
const double EPS = 1e-8;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

ull n, x, a[MAX_N], cum[MAX_N]{};

int main() {
    cin >> n >> x;
    REP(i,n){
        cin >> a[i];
        cum[i+1] += cum[i]+a[i];
    }
    ull ans = LLINF;
    for(ull i=1ull;i<=n;i++){
        ull tmp = 5ull*cum[n], k = n - i;
        while(1){
            if(k<=i)break;
            k -= i;
            tmp += 2*cum[k];
        }
        tmp += (n+i)*x;
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3840
(defun moge (n)
  (let ((ls nil))
    (dotimes (i n)
      (push (read) ls))
    ls))

(defun hoge ()
  (let* ((n (read))
         (lst (moge n))
         (max1 (apply #'max lst))
         (min1 (apply #'min lst)))
    (format t "~D~%" (- max1 min1))))

(hoge)


Measured memory_bytes: 12516
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
vector<string> M,A,R,C,H,FAL;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
        string a;
        cin>>a;
        switch(a[0])
        {
        case 'M':
            M.push_back(a);
            break;
        case 'A':
            A.push_back(a);
            break;
        case 'R':
            R.push_back(a);
            break;
        case 'C':
            C.push_back(a);
            break;
        case 'H':
            H.push_back(a);
        default:
            FAL.push_back(a);
            break;
        }
    }
    long long sm=M.size();
    long long sa=A.size(),sr=R.size(),sc=C.size(),sh=H.size();
    cout<<sm*sa*(sr+sc+sh)+sm*sr*(sc+sh)+sm*sc*sh+sa*sr*(sc+sh)+sr*sc*sh+sa*sc*sh;
}


Measured memory_bytes: 6892
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main() {
	int a[] = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000}, i, x;
	scanf("%d", &x);
	for(i = sizeof(a)/4; a[i] > x; i--);
	printf("%d", a[i]);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int b = sc.nextInt();
		if(n*b%2==0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a,b,c,sum,ans,total,cnt,n,m,k,p,kase,i;
string s1,s2;
#define N 100001
#define MX 1000000001



int main()
{

    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;

    return 0;
}
// Happy Coding  (:


Measured memory_bytes: 3596
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []
for u in range(N):
    v = P[u] - 1
    cnt = C[v]
    val = cnt
    jump = 1

    # Jump to limit or loop
    while v != u and jump < K:
        v = P[v] - 1
        cnt += C[v]
        val = max(val, cnt)
        jump += 1

    # Reduce residual to < K
    if jump < K:
        res = max(0, K // jump - 2)
        cnt += cnt * res
        val = max(val, cnt)
        jump += jump * res

    # Residual steps
    while jump < K:
        v = P[v] - 1
        cnt += C[v]
        val = max(val, cnt)
        jump += 1

    ans.append(val)

print(max(ans))


Measured memory_bytes: 68396
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
const long  maxn = 1e5+7;
long long n;
long long a[maxn];
long long b[maxn];
long long i,j;
long long count = 0;
int main(void)
{
	scanf("%d",&n);

	for(i = 0;i<=n;i++)
		scanf("%ld",&a[i]);
	for(i = 0;i<n;i++)
		scanf("%ld",&b[i]);
	
	for(i = 0;i<n;i++)
	{
		long long temp = b[i] - a[i];
		if(temp >= 0)
		{
			count += a[i];
			b[i] = temp;
			temp = b[i] - a[i+1];
			if(temp >= 0)
			{
				count += a[i+1];
				a[i+1] = 0;
			}
			else{
					count += b[i];
					b[i] = 0;
					a[i+1] = abs(temp);
				}
		}
		else 
		{
			count += b[i];
			a[i] -= b[i];
		}
	}
	printf("%ld",count);
	return 0;
}

Measured memory_bytes: 1792
import math
import sys
a,b,x = map(int,input().split())
if a*a*b == x:
    print(0)
    sys.exit()
tan = a**3/(2*(a**2*b-x))
if tan<=(a/b):
    tan = 2*x/(b**2*a)
rad = math.atan(tan)
deg= 90- (rad * 180/math.pi)
print(deg)

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    string s, t; cin >> s >> t;
    int ns = s.length(), nt = t.length();

    vector<vector<int>> dp(ns + 1, vector<int>(nt + 1));
    for (int i = 0; i <= ns; i++) dp[i][0] = i;
    for (int j = 0; j <= nt; j++) dp[0][j] = j;
    for (int i = 0; i < ns; i++) {
        for (int j = 0; j < nt; j++) {
            dp[i + 1][j + 1] = min({dp[i][j + 1] + 1, dp[i + 1][j] + 1, dp[i][j] + (s[i] != t[j])});
        }
    }
    cout << dp[ns][nt] << endl;
    return 0;
}


Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k-1]<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ref(i,x,y)for(int i=x;i<=y;++i)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int mod=998244353;
int n,a[200010],b[200010],L[200010],R[200010];
queue<int> S;
bool inq[200010];
void upd(int p){
	if(inq[p])return;
	if(b[p]<=a[p])return;
	int d=b[L[p]]+b[R[p]];
	if(b[p]-d>=a[p]){
		inq[p]=1;
		S.push(p);
	}
}
int main(){
	scanf("%d",&n);
	ref(i,1,n)scanf("%d",&a[i]);
	ref(i,1,n)scanf("%d",&b[i]);
	ref(i,1,n)L[i]=i-1;L[1]=n;
	ref(i,1,n)R[i]=i+1;R[n]=1;
	ref(i,1,n)upd(i);
	long long ans=0;
	while(!S.empty()){
		int p=S.front();
		S.pop();inq[p]=0;
		if(b[p]<=a[p])continue;
		int d=b[L[p]]+b[R[p]];
		if(b[p]-d<a[p])continue;
		int yuanlai=b[p];
		b[p]%=d;
		if(b[p]<a[p])b[p]+=a[p]/d*d;
		if(b[p]<a[p])b[p]+=d;
		ans+=(yuanlai-b[p])/d;
		upd(L[p]);upd(R[p]);
	}
	ref(i,1,n)if(a[i]!=b[i]){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl;
}

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

int main() {
	int N;
	int c;
	cin >> N;
	vector<int> A(N+1);
	vector<int> B(N+1);
	for(int i=1; i<=N;i++){
		cin >> A.at(i);
	}
	for(int i=N;i>=1;i--){
		c=0;
		for(int j=2;j<=N/i;j++){
			c+=B.at(i*j);
		}
		if(c%2==A.at(i)){
			B.at(i)=0;
		}
		else{
			B.at(i)=1;
		}
	}
	c=0;
	for(int i=1;i<=N;i++){
		if(B.at(i)==1){
			c++;
		}

	}
	if(c>0){
		cout <<c<<endl;
		for(int i=1;i<=N;i++){
			if(B.at(i)==1){
				cout <<i<<" ";
			}

		}
	}

	else{
		cout <<0;
	}
	cout <<endl;

}

Measured memory_bytes: 2432
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <deque>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i > 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;


class E {
	static const int MAX_N = 1001;
	static const int MAX_V = MAX_N * (MAX_N - 1) / 2;
	int id[MAX_N][MAX_N];
	int n;
	int n_vertices{ 0 };
	vector<vector<int>> a;
	vector<int> G[MAX_V];
	int visited[MAX_V];
	int distance[MAX_V];

	int getID(int i, int j) { return (i > j) ? id[j][i] : id[i][j]; }

	int dfs(int v)
	{
		if (visited[v])
			return (visited[v] == 1) ? -1: distance[v];
		visited[v]++;

		distance[v] = 1;
		for (int u : G[v])
		{
			int depth = dfs(u);
			if (depth == -1)
				return -1;
			distance[v] = max(distance[v], depth + 1);
		}

		visited[v]++;
		return distance[v];
	}

public:
	E()
	{
		memset(visited, 0, sizeof visited);
		cin >> n;
		a.resize(n, vector<int>(n - 1));

		REP(i, n)
		{
			REP(j, n - 1)
			{
				cin >> a[i][j];
				--a[i][j];
			}
		}

		REP(i, n)
			REP(j, n)
		{
			if (i < j)
				id[i][j] = n_vertices++;
		}

		REP(i, n)
		{
			REP(j, n - 1)
				a[i][j] = getID(i, a[i][j]);

			REP(j, n - 2)
				G[a[i][j]].PB(a[i][j + 1]);
		}
	}

	void solve()
	{
		int ans = 0;
		REP(i, n_vertices)
		{
			int depth = dfs(i);
			if (depth == -1)
			{
				cout << "-1" << endl;
				return;
			}
			ans = max(ans, depth);
		}
		cout << ans << endl;
	}
};


int main()
{
	E solution;
	solution.solve();

	return 0;
}


Measured memory_bytes: 39424
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <tuple>
#include <set>
#include <functional> 
#include <string.h>
//#include <assert.h>
//#include <typeinfo.h>
#include <time.h>

#define X first
#define Y second
#define MP make_pair
#define MT make_tuple
#define FOR(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll > pll;
using namespace std;

const int INIT_SIZE_MAX = (1 << 29) + 10;
const int INIT_SIZE_MIN = -(1 << 29) - 10;
const int INIT_SIZE = 0;
const int MAX = 8;
const int DIR_SIZE = 12;
const double PI = 3.1415926535897932384;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

int main(){
	int n;
	double a, b;
	char c;
	while (cin >> n >> c >> a >> c >> b){
		if (cin.eof()) break;

		if (a / (b * b) >= 25.0){
			cout << n << endl;
		}
	}
}

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



int main(){
 
  ll n;
  string s,t;
  cin>>s>>t;

  n=s.length();
  ll ans=0;

  for(ll i=0;i<n;i++)
  {
      if(s[i]!=t[i])
      ans++;
  }
 cout<<ans;

    return 0;
}
    


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define display(v) for (auto x : v) cout << x << ", "
#define dbg(x) cout << (#x) << " = " << (x) << "\n"
#define dbgp(x) cout << (#x) << " = {" << (x.first) << ", " << (x.second) << "}\n";
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

int main()
{
	fastio;

    int n;
    cin >> n;
    vector <ll> arr(n);
    for (auto &x : arr)
    cin >> x;
    vector <ll> temp = arr;
    sort(temp.begin(), temp.end());
    int c = 0;
    for (int i = 0; i < n; i++)
    {
        if (temp[i] != arr[i])
        c++;
    }
    if (c == 0 or c == 2)
    cout << "YES";
    else cout << "NO";
    return 0;
}


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

using namespace std;

int main(){
    long long a, b;
    cin >> a >> b;
    string x = to_string(a), y = to_string(b);
    for(long long i = 0; i < b - 1; i++){
        x += to_string(a);
    }
    for(long long i = 0; i < a - 1; i++){
        y += to_string(b);
    }
    long long r = stoll(x);
    long long s = stoll(y);
    cout << max(r, s) << endl;
    return 0;
}

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

const int maxn = 100001;

int par[maxn];
int ranks[maxn];
int club[maxn];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        ranks[i] = 0;
        club[i] = -1;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

bool unite(int x,int y){
    x = find(x);
    y = find(y);
    if(club[x] != club[y] && club[x] != -1 && club[y] != -1){
        return true;
    }
    if(x==y) return false;

    if(ranks[x] < ranks[y]){
        par[x] = y;
        if(club[x] != -1)
            club[y] = club[x];
    }
    else{
        par[y] = x;
        if(club[y] != -1)
            club[x] = club[y];
        if(ranks[x] == ranks[y]) ranks[x]++;
    }
    return false;
}

int main() {

    int n,m,k;

    cin >> n >> m >> k;

    init(n);

    for(int i=0; i<k; i++){
        int select,a,b;
        //cin >> select >> a >> b;
        scanf("%d %d %d",&select,&a,&b);

        if(select == 1){
            if(unite(a,b)){
                cout << i+1 << endl;
                return 0;
            }
        }
        else{
            int p = find(a);
            if(p  == -1){
                cout << i+1 << endl;
                return 0;
            }
            if(club[p] != -1 && club[p] != b){
                cout << i+1 << endl;
                return 0;
            }
            club[a] = b;
            club[p] = b;
        }
    }

    cout << "0" << endl;

    return 0;
}

Measured memory_bytes: 4320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		int diff = b - a;
		int height = 0;
		for(int cnt = 1; cnt <= diff ; cnt++){
			height = height + cnt;
		}
		System.out.println(height-b);
	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N,A,B, ans=0;

int digitSum(int N){
    int sum = 0;
    while(N!=0){
        sum += N % 10;
        N = N / 10;
    }
    return sum;
}

int main(){
    cin >> N >> A >> B;

    rep(i,N){
        int buff = digitSum(i+1);
        if(A <= buff && buff <= B) ans += i + 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n;cin >> n;
  int t = 0;
  for(int i = 1;i<=n;i++){
    if(i%2!=0) t++;
  }
  printf("%.7f\n",(double)t/n);
}

Measured memory_bytes: 256
def LI():return list(map(int,input().split()))
def yes():return print("Yes")
def no():return print("No")
from collections import deque, defaultdict, Counter
from heapq import heappop, heappush
import math
from decimal import Decimal
# pi=math.pi
# print(pi)
# yes()
# no()
# n=int(input())

# s=input()
a,b=map(Decimal,input().split())
a=100*a
b=100*b
# print(type(a),type(b))
print(a*b//10000)

Measured memory_bytes: 77644