akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int   ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N,M,X;
        cin>>N>>M>>X;
        ll ar[N][M];
        ll cost[N];
        for(ll i=0;i<N;i++)
        {
            cin>>cost[i];
            for(ll j=0;j<M;j++)
                cin>>ar[i][j];
        }
        ll po=power(2,N);
        ll ans=1e18;
        for(ll i=0;i<po;i++)
        {
            ll copy=i;
            ll amt=0;
            ll fr[M]={};
            for(ll j=0;j<N;j++)
            {
                ll sel=(copy&1);
                copy=copy>>1;
                if(sel==0)
                    continue;
                amt+=cost[j];
                for(ll k=0;k<M;k++)
                    fr[k]+=ar[j][k];
            }
            ll f=0;
            for(ll j=0;j<M;j++)
                if(fr[j]<X)
                    f=1;
            if(f)
                continue;
            ans=min(ans,amt);
        }   
        if(ans!=1e18)
            cout<<ans<<endl;
        else
            cout<<-1<<endl;
    }
}

Measured memory_bytes: 3652
x,y = (int(i) for i in input().split())

list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]

if (x in list1 and y in list1) or (x in list2 and y in list2) or (x in list3 and y in list3):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
namespace IO{
	const int maxn(1<<21|1);
	char ibuf[maxn],*iS,*iT,obuf[maxn],*oS=obuf,*oT=obuf+maxn-1,_c,_st[55];
	int _f,tp;
	char Getc(){return (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,maxn,stdin),(iS==iT?EOF:*iS++)):*iS++);}
	void Flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}
	void Putc(char x){*oS++=x;if(oS==oT)Flush();}
	template<class Int>void Input(Int &x){
		for(_f=0,_c=Getc();_c<'0'||_c>'9';_c=Getc())_f=_c=='-';
		for(x=0;_c<='9'&&_c>='0';_c=Getc())x=(x<<3)+(x<<1)+(_c^48);
		if(_f)x=-x;
	}
	template<class Int>void Print(Int x){
		if(!x)Putc('0');
		if(x<0)Putc('-'),x=-x;
		while(x)_st[++tp]=x%10+'0',x/=10;
		while(tp)Putc(_st[tp--]);
	}
}
using namespace IO;
using namespace std;
const int _=2e5+5;
struct Line{int v,next,w;}e[_<<1];
struct Edge{int u,v;ll w;}E[_*50];
int operator<(Edge a,Edge b){return a.w<b.w;}
int Size,mx,rt,h[_],size[_],cnt,vis[_],n,m,W[_];
void Getroot(int u,int ff){
    int ret=0;size[u]=1;
    for(int i=h[u];i;i=e[i].next){
        int v=e[i].v;if(vis[v]||v==ff)continue;
        Getroot(v,u);size[u]+=size[v];
        ret=max(ret,size[v]);
    }
    ret=max(ret,Size-size[u]);
    if(ret<mx)mx=ret,rt=u;
}
int P;ll Val;
void dfs(int u,int ff,ll dep){
    if(dep+W[u]<Val)Val=dep+W[u],P=u;
    for(int i=h[u];i;i=e[i].next)
        if(!vis[e[i].v]&&e[i].v!=ff)
            dfs(e[i].v,u,dep+e[i].w);
}
void Link(int u,int ff,ll dep){
    E[++m]=(Edge){u,P,Val+dep+W[u]};
    for(int i=h[u];i;i=e[i].next)
        if(!vis[e[i].v]&&e[i].v!=ff)
            Link(e[i].v,u,dep+e[i].w);
}
void Divide(int u){
    vis[u]=true;
    Val=1e18;P=0;dfs(u,0,0);Link(u,0,0);
    for(int i=h[u];i;i=e[i].next){
        int v=e[i].v;if(vis[v])continue;
        Size=mx=size[v];Getroot(v,u);
        Divide(rt);
    }
}
int f[_];ll ans;
int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}
int main(){
	Input(n);
    for(int i=1;i<=n;++i)Input(W[i]);
    for(int i=1;i<n;++i){
        int u,v,w;Input(u);Input(v);Input(w);
		e[++cnt]=(Line){v,h[u],w};h[u]=cnt;
		e[++cnt]=(Line){u,h[v],w};h[v]=cnt;
    }
    Size=mx=n;Getroot(1,0);Divide(rt);
    sort(&E[1],&E[m+1]);
    for(int i=1;i<=n;++i)f[i]=i;
    for(int i=1;i<=m;++i){
        int u=getf(E[i].u),v=getf(E[i].v);
        if(u==v)continue;
        ans+=E[i].w;f[u]=v;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define endl '\n'
#define ll long long

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe";
	else cout << "safe";

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
namespace Computational_Geometry
{
	const long double eps=1e-10;
	struct Vector2
	{
		long double x,y;
		Vector2(long double X=0.0,long double Y=0.0):x(X),y(Y) {}
		Vector2 *read() {scanf("%Lf%Lf",&x,&y); return this;}
		void print() {printf("%.10Lf %.10Lf",x,y); return;}
		inline Vector2 operator - () const{return Vector2(-x,-y);}
		inline Vector2 operator + (const Vector2 &A) const{return Vector2(x+A.x,y+A.y);}
		inline Vector2 operator - (const Vector2 &A) const{return Vector2(x-A.x,y-A.y);}
		inline Vector2 operator * (const long double &k) const{return Vector2(x*k,y*k);}
		inline Vector2 operator / (const long double &k) const{return Vector2(x/k,y/k);}
		inline long double operator * (const Vector2 &A) const{return x*A.x+y*A.y;}
		inline long double operator ^ (const Vector2 &A) const{return x*A.y-y*A.x;}
		inline long double norm2() const{return x*x+y*y;}
		inline long double norm() const{return sqrtl(x*x+y*y);}
		inline bool operator < (const Vector2 &A) const{return (x<A.x-eps)||(x<=A.x+eps)&&(y<A.y-eps);}
		inline bool operator == (const Vector2 &A) const{return fabsl(x-A.x)<=eps&&fabsl(y-A.y)<=eps;}
		inline bool operator << (const Vector2 &A) const{return (y<-eps)^(A.y<-eps)?A.y<-eps:((*this^A)>eps)||((*this^A)>=-eps)&&(x>=-eps)&&(A.x<-eps);}
		inline Vector2 trans(long double a_11,long double a_12,long double a_21,long double a_22) const{return Vector2(x*a_11+y*a_12,x*a_21+y*a_22);}
	};
	#define Point Vector2
	Point Projection(Point P,Point L1,Point L2)
	{
		long double k1=(L2-L1)*(P-L1),k2=(L2-L1).norm2();
		return L1+((L2-L1)*(k1/k2));
	}
	Point Reflection(Point P,Point L1,Point L2)
	{
		long double k1=(L2-L1)*(P-L1),k2=(L2-L1).norm2();
		Point mid=L1+(L2-L1)*(k1/k2);
		return mid*2-P;
	}
/*
	COUNTER_CLOCKWISE 1
	CLOCKWISE 2
	ONLINE_BACK 3
	ONLINE_FRONT 4
	ON_SEGMENT 5
*/
	int Counter_Clockwise(Point S,Point T1,Point T2)
	{
		if(((T1-S)^(T2-S))>eps) return 1;
		else if(((T1-S)^(T2-S))<-eps) return 2;
		else if(((T1-S)*(T2-S))<-eps) return 3;
		else if(((T2-S).norm2()-(T1-S).norm2())>eps) return 4;
		else return 5;
	}
	int IsParallel(Point S1,Point T1,Point S2,Point T2)
	{
		return fabs((T1-S1)^(T2-S2))<=eps;
	}
	int IsOrthogonal(Point S1,Point T1,Point S2,Point T2)
	{
		return fabs((T1-S1)*(T2-S2))<=eps;
	}
/*
	PARALLEL 1
	ORTHOGONAL 2
	OTHER 3
*/
	int Parallel_Orthogonal(Point S1,Point T1,Point S2,Point T2)
	{
		if(IsParallel(S1,T1,S2,T2)) return 1;
		else if(IsOrthogonal(S1,T1,S2,T2)) return 2;
		else return 3;
	}
};
using namespace Computational_Geometry;
Point P,P0,P1,S0,S1,T0,T1;
int Q;
int main()
{
	scanf("%d",&Q);
	while(Q--)
	{
		S0.read(),T0.read(),S1.read(),T1.read();
		printf("%d\n",3-Parallel_Orthogonal(S0,T0,S1,T1));
	}
	return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

int main()
{
	INT n, m;
	cin >> n >> m;
	/*vector<INT> l(m), r(m);
	for (size_t i = 0; i < m; i++)
	{
		cin >> l[i] >> r[i];
	}*/
	INT l = 0, r = n;
	for (size_t i = 0; i < m; i++)
	{
		INT tl, tr;
		cin >> tl >> tr;
		l = max(l, tl);
		r = min(r, tr);
	}
	cout << max(r - l + 1, 0LL) << endl;

}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>

int main()
{   
    int i,n,t[100002],x[100002],y[100002],flag=0;
    scanf("%d",&n);
        for(i=1;i<=n;i++){
            scanf("%d%d%d",&t[i],&x[i],&y[i]);
        }
        t[0]=0;x[0]=0;y[0]=0;
    for(i=1;i<=n;i++){
        if((abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2==(t[i]-t[i-1])%2&&(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))<=(t[i]-t[i-1])){
        }else{
            flag=1;
        }
    }
    if(flag==0)
    printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 1280
#include <iostream> 
#include<vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
typedef long long int ll;
const ll INF = (1 << 29);
ll h, m, n; string s;
const int Max = 1000100;
int main() {
    vector<int> dp(Max, INF), odp(Max, INF);
    dp[0] = odp[0] = 0;
    req(i, 175) {
        ll num = i * (i + 1) * (i + 2) / 6;
        if (num >= Max) break;
        for (int j = num; j < Max; j++) {
            dp[j] = min(dp[j], dp[j - num] + 1);
            if (num & 1) odp[j] = min(odp[j], odp[j - num] + 1);
        }
    }while (cin >> n, n) {
        cout << dp[n] << " " << odp[n] << endl;
    }
}


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

#define N 8

class P{
    public:
    int id;
    double score;
    P( int i=0, double s=0):id(i), score(s){}

    bool operator < ( const P &p ) const{
	return score < p.score;
    }
};

main(){
    P A[N], B[N], C[N], D[3*N];
    int n;
    for ( int i = 0; i < N; i++ ) {cin >> A[i].id >> A[i].score; }
    for ( int i = 0; i < N; i++ ) {cin >> B[i].id >> B[i].score; }
    for ( int i = 0; i < N; i++ ) {cin >> C[i].id >> C[i].score; }
    sort( A, A + N );
    sort( B, B + N );
    sort( C, C + N );
    int k = 0;
    for ( int i = 2; i < N; i++ ) D[k++] = A[i];
    for ( int i = 2; i < N; i++ ) D[k++] = B[i];
    for ( int i = 2; i < N; i++ ) D[k++] = C[i];
    sort( D, D + k );	      

    for ( int i = 0; i < 2; i++ ) cout << A[i].id << " " << A[i].score <<endl;
    for ( int i = 0; i < 2; i++ ) cout << B[i].id << " " << B[i].score <<endl;
    for ( int i = 0; i < 2; i++ ) cout << C[i].id << " " << C[i].score <<endl;
    for ( int i = 0; i < 2; i++ ) cout << D[i].id << " " << D[i].score <<endl;


    
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,k,d;
	cin>>n>>k;
	bool b[n]={};
	int ans=n;
	for(int i=0;i<k;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			int a;
			cin>>a;
			if(b[a-1]==false){
				ans--;
			}
			b[a-1]=true;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] v = new int[N];
		Arrays.fill(v, -1);
		
		for(int i=0; i<M; i++) {
			int s = sc.nextInt()-1;
			int c = sc.nextInt();
			
			if(v[s]<0) {
				v[s] = c;
			} else if(v[s]!=c) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		if(N>1 && v[0]==0) {
			System.out.println(-1);
			sc.close();
			return;
		}
		for(int i=0; i<N; i++) {
			System.out.print(v[i]>=0 ? v[i] : (i==0 ? (N==1 ? 0 : 1) : 0));
		}
		System.out.println();
		sc.close();
	}
}


Measured memory_bytes: 22868
from itertools import permutations
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

P,Q,R=LI()
print(min(P+Q,Q+R,R+P))


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

const long long mod=998244353;

int main()
{
  int n;
  static char s[200010];
  scanf("%d%s",&n,s);
  vector<bool> X(n);
  for(int i=0;i<n;i++){
    X[i]=(s[i]=='1');
  }
  vector<int> ds;
  for(int t=1;t*t<=n;t++){
    if(n%t==0){
      ds.push_back(t);
      if(n/t!=t){
	ds.push_back(n/t);
      }
    }
  }
  sort(ds.begin(),ds.end());
  int dn=ds.size();
  vector<long long> C(dn,0ll);
  long long ans=0ll;
  for(int t=0;t<dn;t++){
    int d=ds[t];
    if(d%2==0)
      continue;
    long long c=0;
    for(int i=0;i<n/d;i++){
      c=(2*c+X[i])%mod;
    }
    bool F=true;
    for(int i=n/d;i<n;i++){
      int x=(i/(n/d))%2==1?1-X[i%(n/d)]:X[i%(n/d)];
      if(X[i]!=x){
	F=(X[i]>x);
	break;
      }
    }
    if(F){
      c=(c+1)%mod;
    }
    C[t]=2*(n/d);
    for(int tt=0;tt<t;tt++){
      if(ds[t]%ds[tt]==0){
	C[t]=(C[t]+mod-C[tt])%mod;
      }
    }
    //printf("%d %lld %lld %lld\n",d,C[t],C[t]-mod,c);
    ans=(ans+C[t]*c%mod)%mod;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 512
if __name__ == '__main__':
    n = int(input())
    (a, b) = [int(x) for x in input().split()]
    u1 = u2 = u3 = 0
    for s in input().split():
        x = int(s)
        if x <= a:
            u1 += 1
        elif a < x <= b:
            u2 += 1
        else:
            u3 += 1
    print(min(min(u1,u2),u3))


Measured memory_bytes: 3060
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, s: [Chars; n]};
    let s: Vec<Vec<char>> = s;
    let mut v: Vec<String> = vec![];

    for i in s.iter() {
        let mut c = i.clone();
        c.sort();
        v.push(c.iter().collect::<String>());
    }

    v.sort();

    let mut index = 0;
    let mut count = 0;
    let mut result: u128 = 0;

    for i in 1..n {
        if v[i] == v[index] {
            count += 1;
        } else {
            index = i;
            if count > 0 {
                for j in 1..=count {
                    result += j;
                }
            }
            count = 0;
        }

        if i == n - 1 {
            if count > 0 {
                for j in 1..=count {
                    result += j;
                }
            }
        }
    }

    println!("{}", result);
}


Measured memory_bytes: 19612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(n); ++i)

int main()
{
	int N, K; cin >> N >> K;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	sort(A.begin(), A.end());

	ll ans = 1;
	int l = 0, r = N - 1;
	if (K % 2) {
		ans *= A[r]; --r; --K;
		if (ans < 0) {
			while (K > 0) {
				ans = ans * A[r] % MOD;
				--r; --K;
			}
			cout << (MOD + ans) % MOD << endl;
			return 0;
		}
	}
	while (K > 0) {
		ll x = (ll)A[l] * A[l + 1];
		ll y = (ll)A[r] * A[r - 1];
		if (x > y) {
			ans = ans * (x % MOD) % MOD;
			l += 2;
		}
		else {
			ans = ans * (y % MOD) % MOD;
			r -= 2;
		}
		K -= 2;
	}
	cout << (MOD + ans) % MOD << endl;
	return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int x_diff = x2 - x1, y_diff = y2 - y1;

    cout << (x2 - y_diff) << " " << (y2 + x_diff) << " ";
    cout << (x1 - y_diff) << " " << (y1 + x_diff) << "\n";

    return 0;
}


Measured memory_bytes: 256
a=int(input())
while True:
    op=input()
    if op=="=":
        break
    b=int(input())
    if op=="+":
        a+=b
    elif op=="-":
        a-=b
    elif op=="*":
        a*=b
    elif op=="/":
        a//=b
    else:
        break
print(a)


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

using namespace std;


#define PI 3.14159265
#define int long long

const int MAXN = 2e5 + 1;
const int MOD = 1e9 + 7;

int fak[MAXN], inv[MAXN];


int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}


int C(int k, int n){
	return fak[n] * inv[k] * inv[n - k];
}

void calc(){
	fak[0] = fak[1] = 1;
	for(int i = 2; i < MAXN; i++){
		fak[i] = fak[i - 1] * i;
		fak[i] %= MOD;
	}

	for(int i = 0; i < MAXN; i++){
		inv[i] = binpow(fak[i], MOD - 2);
	}
}


main(){


	calc();

	int n, k; cin >> n >> k;

	vector <int> dp(n + 2), sum(n + 1);

	for(int i = 0; i <= n; i++) sum[i] = i;
	for(int i = 1; i <= n; i++) sum[i] += sum[i - 1];
	for(int i = 0; i <= n; i++) sum[i] %= MOD;

	dp[n + 1] = 1;

	for(int i = n; i > 0; i--){
		dp[i] = (sum[n] - sum[n - i] - sum[i - 1] + 1 + 2 * MOD);
		dp[i] %= MOD;
 	}

	// for(int i = n; i > 0; i--){
	// 	cout << dp[i] << ' ';
	// }
	// cout << endl;

	for(int i = n; i > 0; i--){
		dp[i] += dp[i + 1];
		dp[i] %= MOD;
	}

	cout << dp[k] << endl;


	
	
	return 0;
}

Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
// const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int h, a;
  cin >> h >> a;
  cout << h / a + !!(h % a) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
int main()
{
    int n;
    cin>>n;
    int dp[n+5]={};
    for(int i=1,x;i<n;i++)
    {
        cin>>x;
        dp[x]++;
    }
    for(int i=1;i<=n;i++)cout<<dp[i]<<" \n"[i==n];
}


Measured memory_bytes: 4304
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


int fact(int x)
{
	int ret=1;

	for(int i=1;i<=x;i++) ret*=i;
	return ret;
}


int vec2per(vi&a)
{
	int n=a.size();
	int ret=0;

	for(int i=0;i<n;i++)
	{
		int x=0;
		for(int j=i+1;j<n;j++)
		{
			if(a[i]>a[j]) x++;
		}
		ret+=x*fact(n-1-i);
	}
	return ret;
}


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi p(n);
		for(auto&m:p) scanf("%d", &m);
		vi q(n);
		for(auto&m:q) scanf("%d", &m);

		int ans=abs(vec2per(p)-vec2per(q));
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

mat(bri,0,0);
vec(vis_t,0);
vec(vis_a,0);

void dfs(ll now,ll dis,vector<ll> &V){
    V[now]=dis;
    rep(i,bri[now].size()){
        if(V[bri[now][i]]==0){
            dfs(bri[now][i],dis+1,V);
        }
    }
    return;
}


//
void solve(long long N, long long u, long long v, std::vector<long long> A, std::vector<long long> B){
    dfs(u-1,1,vis_t);
    dfs(v-1,1,vis_a);
    ll Max=0;
    rep(i,N){
        if(vis_a[i]>=vis_t[i])
        Max=max(vis_a[i],Max);
    }
    op(Max-2)
    
    
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    bri.resize(N);
    vis_t.resize(N);
    vis_a.resize(N);
    long long u;
    scanf("%lld",&u);
    long long v;
    scanf("%lld",&v);
    std::vector<long long> A(N-1);
    std::vector<long long> B(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        A[i]--;B[i]--;
        bri[A[i]].push_back(B[i]);
        bri[B[i]].push_back(A[i]);

    }
    solve(N, u, v, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <stdlib.h>

typedef struct dice{
  int pip[6];
  int top, front, right;
}Dice;

Dice *createDice(int *a);             /* ?????????????????? */
int DiceRight(Dice D, int t, int f);  /* ????????????????????´?????°??? */
int checkDice(Dice D1, Dice D2);      /* ?????????????????????????????? */


int main(void){
  Dice *D1, *D2;
  int i, a[6];

  for(i = 0; i< 6; i++){
    scanf("%d", &a[i]);
  }
  D1 = createDice(a);
  for(i = 0; i< 6; i++){
    scanf("%d", &a[i]);
  }
  D2 = createDice(a);
  
  if(checkDice(*D1, *D2) != 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  free(D1);
  free(D2);
  return 0;
}


Dice *createDice(int *a){
  Dice *p;
  int i;

  p = (Dice *)malloc(sizeof(Dice));
  if(p == NULL){
    printf("?????¢????¢??????¨??????\n");
    return NULL;
  }
  for(i = 0; i < 6; i++){
    p->pip[i] = a[i];
  }
  p->top = 0;
  p->front = 1;
  p->right = 2;
  return p;
}

int DiceRight(Dice D, int t, int f){
  static int check[6][6] = {{-1, 2, 4, 1, 3, -1},
			    {3, -1, 0, 5, -1, 2},
			    {1, 5, -1, -1, 0, 4},
			    {4, 0, -1, -1, 5, 1},
			    {2, -1, 5, 0, -1, 3},
			    {-1, 3, 1, 4, 2, -1}};
  return D.pip[check[t][f]];
}


int checkDice(Dice D1, Dice D2){
  int i, j, s = 0, c[6] = {-1,-1,-1,-1,-1,-1};

  for(i = 0; i < 3; i++){
    for(j = 0; j < 6; j++){
      if(c[j] == -1 && c[5-j] == -1){
        if(D1.pip[i] == D2.pip[j] && D1.pip[5-i] == D2.pip[5-j]){
	  s++;
	  c[j] = i;
	  c[5-j] = 5-i;
	  break;
        }
      }
    }
  }
  if(s != 3){
    return 0;
  }
  if(DiceRight(D2, c[0], c[1]) != D2.pip[c[2]]){
    return 0;
  }
  return 1;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    vector<Int> a(n);
    for(Int i=0;i<n;i++){
      char c;
      cin>>c;
      a[i]=c-'A';
    }
    vector<Int> cnt(26,0);
    auto check=[&](Int c,Int t){
      Int rest=n-t;
      Int ok=1;
      for(Int i=0;i<26;i++){
	if(i==c) continue;
	ok&=cnt[c]>cnt[i]+rest;
      }
      //if(c=='U'-'A') cout<<rest<<" "<<ok<<endl;
      return ok;
    };
    
    Int flg=0;
    for(Int i=0;i<n;i++){
      cnt[a[i]]++;
      for(int j=0;j<26;j++){
	if(check(j,i+1)){
	  cout<<char('A'+j)<<" "<<i+1<<endl;
	  flg=1;
	  break;
	}
      }
      if(flg) break;	
    }
    if(!flg) cout<<"TIE"<<endl;
  }
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int R, G; cin >> R >> G;

	cout << R+(G-R)*2 << endl;

	return 0;

}


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

char c[55][55]; 
int H, W, cnt;

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> c[i][j];
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') cnt++;
		}
	}
  
	if (cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int a[3][3];
    bool h[3][3];
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) cin >> a[i][j];
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) h[i][j] = false;
    int n;
    cin >> n;
    for (int i = 0, b; i < n;++i){
        cin >> b;
        for (int j = 0; j < 3; ++j) for (int k = 0; k< 3; ++k)
                if (a[j][k] == b) h[j][k] = true;
    }
    bool bingo = true;
    if (!h[0][0]) bingo = false;
    if (!h[1][1]) bingo = false;
    if (!h[2][2]) bingo = false;
    if (bingo) return cout << "Yes",0;
    bingo = true;
    if (!h[0][2]) bingo = false;
    if (!h[1][1]) bingo = false;
    if (!h[2][0]) bingo = false;
    if (bingo) return cout << "Yes",0;
    for (int i = 0; i < 3;++i){
        bingo = true;
        if (!h[i][0]) bingo = false;
        if (!h[i][1]) bingo = false;
        if (!h[i][2]) bingo = false;
        if (bingo) return cout << "Yes", 0;
    }
    for (int i = 0; i < 3;++i){
        bingo = true;
        if (!h[0][i]) bingo = false;
        if (!h[1][i]) bingo = false;
        if (!h[2][i]) bingo = false;
        if (bingo) return cout << "Yes", 0;
    }
    cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N;
vector<vector<int> > G;
map<PP, int> R;

int cal(int a, int b) {
	PP p = make_pair(a, b);
	if (R.find(p) != R.end()) return R[p];
	if (G[b].size() > 2) {
		R[p] = 0;
		return 0;
	}
	if (G[b].size() == 1) {
		R[p] = 1;
		return 1;
	}
	int c = G[b][0] + G[b][1] - a;
	for (int i = 0;i < G[c].size();i++) {
		if (G[c][i] == b) continue;
		if (cal(c, G[c][i]) == 1) {
			R[p] = 1;
			return 1;
		}
	}
	R[p] = 0;
	return 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    G.resize(N);
    for (int i = 1;i < N;i++) {
    	int a, b;
    	cin >> a >> b;
    	a--;
    	b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }
    bool ok = 0;
    for (int i = 0;i < N;i++) {
    	int crt = 0;
    	for (int j = 0;j < G[i].size();j++) {
    		int k = cal(i, G[i][j]);
    		if (k > 0) crt++;
    	}
    	if (crt > 1) ok = 1;
    }
    for (int i = 0;i < N && ok == 0;i++) {
    	bool x = 1;
    	for (int j = 0;j < G[i].size() && x == 1;j++) {
    		bool y = 0;
    		int t = G[i][j];
    		for (int k = 0;k < G[t].size() && y == 0;k++) {
    			if (G[t][k] == i) continue;
    			if (cal(t, G[t][k]) == 1) y = 1;
    		}
    		if (y == 0) x = 0;
    	}
    	if (x == 1) ok = 1;
    }
    if (ok || N % 2) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;

    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 != 0 && i % 5 != 0) ans += (long long)i;
    }

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

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i, j, k;
		int floor1[][];
		int floor2[][];
		int floor3[][];
		int floor4[][];
		floor1 = new int[3][10];
		floor2 = new int[3][10];
		floor3 = new int[3][10];
		floor4 = new int[3][10];
		
		int n = scan.nextInt();
		int v;
		int w;
		
	
	
		for (k = 1; k <= n; k++) {
			
			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			v = scan.nextInt();
			w = v;
		
if(b == 1 && v <= 9){
	floor1[f-1][r-1] += v;
}else if(b == 2 &&  v <= 9){
	floor2[f-1][r-1] += v;
}else if(b == 3 &&  v <= 9){
	floor3[f-1][r-1] += v;
}else if(b == 4 &&  v <= 9){
	floor4[f-1][r-1] += v;
}


		}
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				
				System.out.print(" "+floor1[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
		System.out.println("####################");
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				System.out.print(" "+floor2[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
		System.out.println("####################");
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				System.out.print(" "+floor3[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
		System.out.println("####################");
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				System.out.print(" "+floor4[j][i]);
				if(i >= 9){
					System.out.println();
				}
				
			}
		}
	}

}

Measured memory_bytes: 29396
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  ll n;
  cin>>n;

  vector<ll> a(n, 0);
  for (ll i=0; i<n; i++)
    cin>>a[i];
  sort(a.rbegin(), a.rend());

  ll ans = 0;
  priority_queue<pair<ll, pair<ll, ll>>> data;
  ans += a[0];
  data.push({min(a[0], a[1]), {a[0], a[1]}});
  data.push({min(a[0], a[1]), {a[0], a[1]}});
  for (ll i=2; i<n; i++) {
    auto p = data.top();
    data.pop();

    ans += p.first;
    data.push({min(p.second.first, a[i]), {p.second.first, a[i]}});
    data.push({min(p.second.second, a[i]), {p.second.second, a[i]}});
  }

  cout<<ans<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 11064
N, M = gets.split.map(&:to_i)
XYZs = readlines.map{|l| l.split.map(&:to_i)}

puts [1, -1].repeated_permutation(3).map{|a, b, c| XYZs.map{|x, y, z| a*x + b*y + c*z}.sort.last(M).inject(:+)}.max || 0

Measured memory_bytes: 2040
import heapq
from collections import defaultdict
N = int(input())
nums  = list(map(int, input().split(" ")))
# 正の数、負の数の個数で操作をコントロール？
p_count = 0
m_count = 0
pos = []
minus = []
for num in nums:
    if num < 0:
        m_count += 1
        minus.append(num)
    else:
        p_count += 1
        pos.append(num)
pos.sort()
minus.sort() #小さい順番
途中式 = []
if N == 2:
    x = max(nums) 
    y = min(nums)
    print(max(nums) - min(nums))
    print(x, y)
else:
    #正の数を一つにして、そこから引きまくる
    if m_count == 0: #マイナスが無かったら作る
        x = min(pos)
        y = max(pos)
        途中式.append((x, y))
        minus.append(x - y)
        pos.remove(x)
        pos.remove(y)
        p_count -=2
        m_count += 1

    if p_count > 1: # 正が複数あったら、マイナスから引くことで減らしていく
        for i in range(p_count - 1):
            #マイナスから正が1個になるまで引いていく
            x = minus.pop()
            y = pos.pop()
            途中式.append((x,y))
            minus.append(x- y)
    elif p_count == 0 : #正が一つも無かったら、作る
        x = minus.pop()
        y = minus.pop()
        途中式.append((x, y))
        pos.append(x - y)

    x = pos.pop()
    for i in minus:
        y = i
        途中式.append((x, y))
        x -=y
    print(x)
    for temp in 途中式:
        x,y = temp
        print(x,y)

Measured memory_bytes: 62780
#include <stdio.h>
int SIX[]  = {6*6*6*6*6*6, 6*6*6*6*6, 6*6*6*6, 6*6*6, 6*6, 6};
int NINE[] = {9*9*9*9*9, 9*9*9*9, 9*9*9, 9*9, 9};
	     
int search(int n) {
  //printf("hoge: %d\n", n);
  if(n == 0) return 0;

  // 6
  int ret0 = n;
  for(int i = 0; i < 6; i++) {
    if(n >= SIX[i]) {
      ret0 = search(n - SIX[i]) + 1;
      break;
    }
  }

  // 9
  int ret1 = n;
  for(int i = 0; i < 5; i++) {
    if(n >= NINE[i]) {
      ret1 = search(n - NINE[i]) + 1;
      break;
    }
  }
  int ret = (ret0 < ret1) ? ret0 : ret1;
  return ret;
}

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

  int Ans = search(N);
  printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 128
function Main(input){
    input = input.split("\n");

    var k = 0;
    while(true){
        input[k] = input[k].split(" ");
        var n = parseInt(input[k][0],10);
        var r = parseInt(input[k][1],10);

        if(n == 0 && r == 0)
            break;

        k++;

        var card = [];

        for(var i = 1;i <= n;i++){
            card[i] = n - i + 1;
        }
        for(var i = 0;i < r;i++){
            input[k] = input[k].split(" ");
            var p = parseInt(input[k][0],10);var c = parseInt(input[k][1],10);
            var a = [];
            for(var j = 1;j < p;j++)
                a[j] = card[j];
            for(var j = 1;j <= c;j++)
                card[j] = card[j + p - 1];
            for(var j = 1;j < p;j++)
                card[j + c] = a[j];
            k++;
        }
        console.log(card[1]);
    }

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

Measured memory_bytes: 18008
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>

using namespace std;

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

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

int main() {
	int H,W;
	cin >> H >> W;

	int h,w;
	cin >> h >> w;

	int ans;

	ans = H*W;
	ans -= h*W+w*H-h*w;

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 753;
  int sub;
  int N = S.size();
  for(int i = 0; i < N - 2; i++) {
    int num = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');
    if(num > 753) {
      sub = num - 753;
    }
    else {
      sub = 753 - num;
    }
    if(ans > sub) {
      ans = sub;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;

    string unk;
    cin >> unk;

    if (s == unk)
        --a;
    else
        --b;

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void)
{
	int n, d, x;
	cin >> n >> d >> x;
	int sum = x;
	for (int i = 0; i < n; i++) {
		int a = 0;
		cin >> a;
		
		if (d % a == 0)
			sum += d / a;
		else
			sum += d / a + 1;
	}
	cout << sum << endl;
	return 0;
}

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

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

    for(int i = 0; i < b; i++) {
        int res = (a * i) - (i - 1);
        if(b <= res) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   int i,n,x;
   long long max,min,sam;
   sam = 0;

   cin >> n;

   cin >> x;

   sam += x;
   min = x;
   max = x;

   for(i=1; i<n; i++){
	cin >> x;

	sam += x;

	if(x <= min){
		min = x;
	}else if(x >= max){
		max = x;
	}
   }

   cout << min << " " << max << " " << sam << endl;

   return 0;
}

	

Measured memory_bytes: 1164
s = int(input())
f = lambda n: n/2 if n%2==0 else 3*n+1
se = [s]
while True:
  a = int(f(se[-1]))
  se.append(a)
  if a in se[:-1]:
    le = len(se[:se.index(a)+1])
    print(le+se[le:].index(a)+1)
    break

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[] l = sc.nextLine().toCharArray();
            char a = 'd';
            for (int i = 0; i < 3; i++) {
                int n = i * 3;
                if (l[n] != 's' && l[n] == l[n + 1] && l[n] == l[n + 2]) {
                    a = l[n];
                    break;
                }
                if (l[i] != 's' && l[i] == l[i + 3] && l[i] == l[i + 6]) {
                    a = l[i];
                    break;
                }
            }
            if (l[4] != 's' && (l[0] == l[4] && l[4] == l[8] || l[2] == l[4] && l[4] == l[6])) {
                a = l[4];
            }
            System.out.println(a);
        }
    }
}



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

int main(){
  int A, B;
  cin >> A >> B;
  
  for(int i = 0; i < 3; i++) {
    if(A == i + 1 || B == i + 1) {
      
    } else {
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
balls = []

# 初期位置を覚えておく
placeB = [0] * N
placeW = [0] * N

# 入力処理 & 初期位置処理
for i in range(2*N):
    c, a = input().split()
    a = int(a)
    balls.append([c, a])
    if c == "B":
        placeB[a-1] = i
    else:
        placeW[a-1] = i


costB = [[0]*(2*N+1) for i in range(N+1)]  # i番目まででjより大きいB
costW = [[0]*(2*N+1) for i in range(N+1)]  # i番目まででjより大きいW

for i in range(N):
    for j in range(2*N):
        if balls[j][1] > i:
            if balls[j][0] == "B":
                costB[i][j+1] = 1
            else:
                costW[i][j+1] = 1

# 累積和
costB = [list(accumulate(cB)) for cB in costB]
costW = [list(accumulate(cW)) for cW in costW]

# dp
dp = [[float('inf')]*(N+1) for i in range(N+1)]
dp[0][0] = 0
for b in range(N+1):
    for w in range(N+1):
        if b > 0:
            dp[b][w] = min(dp[b][w], dp[b-1][w] + costB[b][placeB[b-1]] + costW[w][placeB[b-1]])
        if w > 0:
            dp[b][w] = min(dp[b][w], dp[b][w-1] + costW[w][placeW[w-1]] + costB[b][placeW[w-1]])

print(dp[N][N])


Measured memory_bytes: 407044
value = [tuple(map(int,input().split())) for i in range(2)]
lis = []
new_v = 0

for i in range(value[0][0]):
    lis.append(value[1][i])

for i in range(len(lis)):
    i = 1 / lis[i]
    new_v += i

print(1 / new_v)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b; cin>>n>>a>>b;
	cout << ((a*n<b)?a*n:b) << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Coloring Colorfully
	var S string
	fmt.Scanf("%s", &S)

	var A string
	var countA, countB int
	for i := 0; i < len(S); i++ {
		if i%2 == 0 {
			A = string('0')
		} else {
			A = string('1')
		}

		if A[0] != S[i] {
			countB++
		} else {
			countA++
		}
	}

	fmt.Println(math.Min(float64(countA), float64(countB)))
}


Measured memory_bytes: 2576
import sys
input = sys.stdin.readline

n, u, v = [int(x) for x in input().split()]

import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

################################
n, w = n, n - 1 #n:頂点数　w:辺の数

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y = map(int,input().split())
    z = 1
    edge[x - 1].append([z,y - 1])
    edge[y - 1].append([z,x - 1]) 

takahashi = dijkstra_heap(u - 1)
aoki = dijkstra_heap(v - 1)

ans = takahashi[v - 1] - 1 # 高橋君がいもる

idx = 0
for i, j in zip(takahashi, aoki):
    if idx == u - 1 or idx == v - 1:
        idx += 1
        continue
    if j - i > 0:
        ans = max(ans, j - 1)
    idx += 1

print(ans)

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

if C <= A:
     if D <= A:
          print(0)
     elif D < B:
          print(D - A)
     else:
          print(B - A)

else:
     if C >= B:
          print(0)
     elif D < B:
          print(D - C)
     else:
          print(B - C) 



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

int main() {
  string s;
  cin >> s;
  vector<int> ss(1);
  for(int i = 0; i < s.size(); i++){
    if((ss.size()%2 == 1 && s.at(i) == 'R') || (ss.size()%2 == 0 && s.at(i) == 'L'))
      ss.at(ss.size()-1) ++;
    else
      ss.push_back(1);
  }
  /*
  for(int i = 0; i < ss.size(); i++){
    cout << ss.at(i) << endl;
  }
  */
  
  vector<vector<int>> sss(1,vector<int> (3));
  int sum = 0;
  for(int i = 0; i < ss.size()/2; i++){
    if(i > 0)
      sss.push_back({0,0,0});
    sss.at(i).at(0) = sum;
    sss.at(i).at(1) = ss.at(2*i);
    sss.at(i).at(2) = ss.at(2*i+1);
    sum += (ss.at(2*i)+ss.at(2*i+1));
  }
  vector<int> ans(s.size());
  for(int i = 0; i < sss.size(); i++){
    int p = sss.at(i).at(0);
    int r = sss.at(i).at(1);
    int l = sss.at(i).at(2);
    ans.at(p+r-1) = r-r/2+l/2;
    ans.at(p+r) = l-l/2+r/2;
  }
  for(int i = 0; i < s.size(); i++){
    if(i < s.size()-1)
      cout << ans.at(i) << " ";
    else
      cout << ans.at(i) << endl;
  }
    
}


Measured memory_bytes: 4080
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int N;
vector<string> W;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  W.resize(N);
  char last;
  rep(n,N){
    cin >> W[n];
    if(n != 0){
      if(W[n][0] != last){
        cout << "No" << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      if(W[n].compare(W[i]) == 0){
        cout << "No" << endl;
        return 0;
      }
    }
    last = W[n][W[n].size()-1];
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split())), reverse=True))
s = A.sum()
l = -1
r = 10**12 # 取りうる最大は10**6 * 10**6 で10**12
# 全てのa*fが答えとなる数以下にできるかを10**12から二分探索
while l+1 < r:
    m = (l+r) // 2 # こここそが二分探索の肝で、ありえん小さい数とありえん大きい数から始めて半分にして狭めていく
    # 全てのA、Fにつき、Aとm//Fで小さい方の合計がK以下
    # m//Fは修行したあとの消化コスト
    # mが大きすぎてnp.minimum(A, m//F)がすべてAを選ぶならその合計は0なのでK以下が成り立つ
    # その場合、r=mとしてrを減らして再計算
    # K以下は修行に余力を残した状態か、修行できてないか。それより上のmはありえないのでr = mとする
    if s - np.minimum(A, m//F).sum() <= K:
        r = m
    # 修行ポイント以上に修行してしまった場合、それ未満のmはありえないのでl = mとする
    else:
        l = m
print(r)


Measured memory_bytes: 37272
#include <stdio.h>

int main(void)

{

  int a,b ;


  scanf("%d %d",&a,&b);


  if(a<b){

       printf("a < b\n");

  }

  else if(a>b){

         printf("a > b\n");

  }

  else{

         printf("a == b\n");

  }

 return 0;

}

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

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

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

int main(){
    int N;
    cin >> N;
    int h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    int dp[N]={};
    dp[1]=abs(h[1]-h[0]);
    for(int i=0;i<N-2;i++){
        dp[i+2] =abs(h[i+2]-h[i+1])+dp[i+1];
        chmin(dp[i+2],abs(h[i+2]-h[i])+dp[i]);
    }
    cout << dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

use rand::prelude::*;

const CN: usize = 26;

fn calc(cv: &[isize], sv: &[Vec<isize>], tv: &[usize]) -> isize {
    let mut last = vec![0; CN];
    let mut res = 0;
    for i in 0..sv.len() {
        let t = tv[i];
        res += sv[i][t];
        last[t] = i + 1;
        for j in 0..CN {
            res -= cv[j] * (i + 1 - last[j]) as isize;
        }
    }
    res
}

fn solve() {
    input! {
        d: usize,
        cv: [isize; CN],
        sv: [[isize; CN]; d],
    };

    let mut rng = rand::thread_rng();
    let mut tv = (0..d)
        .into_iter()
        .map(|_| rng.gen::<usize>() % CN)
        .collect::<Vec<_>>();
    let mut res = calc(&cv, &sv, &tv);
    for _ in 0..25 {
        let di = rng.gen::<usize>() % d;
        let q = rng.gen::<usize>() % CN;
        let old = tv[di];
        tv[di] = q;
        let p = calc(&cv, &sv, &tv);
        if p > res {
            res = p;
        } else {
            tv[di] = old;
        }
    }
    println!("{}", tv.into_iter().map(|x| x + 1).join("\n"));
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2840