akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,t;
  int a;
  cin >> n >> t >> a;
  int h[n]; REP(i,n) cin >> h[i];
  t*=1000; a*=1000;

  P ans = {0, INF};
  REP(i,n) {
    int temp = t - h[i] * 6;
    int d = abs(temp - a);
    if (d < ans.second) ans = {i,d};
  }
  COUT(ans.first+1);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,w,a;
	while(1){
	    scanf("%d",&n);
		if(n==-1) break;
		w=1150;
		if(n>30){
		    w=w+(n-30)*160;
			if(n>=40) n=30;
			else n=(n/10)*10;
		}
		if(n>20){
		    w=w+(n-20)*140;
			if(n==30) n=20;
			else n=(n/10)*10;
		}
		if(n>10){
		    w=w+(n-10)*125;
		}
		a=4280-w;
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 2704
package main

import (
	"fmt"
)

func main() {
	a, b := ScanInt(), ScanInt()

	c := 0
	for i := a; i <= b; i++ {
		if (i/10000 == i%10) && (i%10000/1000 == i%100/10) {
			c++
		}
	}

	fmt.Println(c)
}

func ScanInt() (i int) {
	fmt.Scan(&i)
	return
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 998244353
#define N 4000050
using namespace std;
typedef long long LL;
inline LL rd() { LL r; cin >> r; return r; }
inline void inc(LL &x,LL y) { x = ( x + y ) % mod; }
inline void dec(LL &x,LL y) { x = ( x - y + mod ) % mod; }

LL n,m,C[N],f[N];

struct Matrix{ LL d[4][4]; }id,A,B;
Matrix operator* (Matrix p1, Matrix p2) {
	Matrix ret = id;
	for (int i=1;i<=2;i++)
		for (int j=1;j<=2;j++)
			for (int k=1;k<=2;k++) 
				inc( ret.d[i][j] , p1.d[i][k] * p2.d[k][j] % mod );
	return ret;
}

Matrix Mqp(Matrix a,LL b) {
	Matrix ret = id; ret.d[1][1] = ret.d[2][2] = 1LL;
	while (b) {
		if (b&1) ret = ret * a;
		b >>= 1, a = a * a;
	}
	return ret;
}

LL qp(LL a,LL b) {
	LL ret = 1LL;
	a %= mod;
	while (b) {
		if (b&1) ret = ret * a % mod;
		b >>= 1, a = a * a % mod;
	}
	return ret;
}

LL F(LL x) {
	if (x <= 2) return 1LL;
	A.d[1][1] = A.d[1][2] = 1LL;
	B.d[1][1] = B.d[2][1] = B.d[1][2] = 1LL;
	B = Mqp(B,x-2);
	A = A * B;
	return A.d[1][1];
}

int main() {
	n = rd(), m = rd();
	C[n-1] = 1LL;
	for (LL _=n-2;_>=1;_--) 
		C[_] = C[_+1] * ( (n+m-_-2) % mod ) % mod * qp(n-_-1,mod-2) % mod;
	
	f[1] = f[2] = 1LL;
	for (int _=3;_<=2*n;_++) f[_] = ( f[_-1] + f[_-2] ) % mod;
	
	LL ans = F(2*n+m-2);
	for (int k=1;k<=n-1;k++) 
		dec(ans, f[2*k] * C[k] % mod);
	printf("%d\n",(int)ans);
	return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int S(int N){
    int res=0;
    while(N!=0){res+=N%10;N/=10;}
    return res;
}
int N;
signed main() {
    cin>>N;
    if(N%S(N)==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	string a, b;
	cin >> a >> b;
	ll num=stoll(a + b);
	repeq(i, 1, 1000) {
		if (i * i == num) {
			cout << "Yes" << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);





int main(){
   
   int n;
   cin>>n;
   vector<ll>a(n);
   ll ans=1;
   ll LIMIT=1e18;
   for(int i=0;i<n;i++){
    cin>>a[i];
   }

   sort(a.begin(),a.end());

   if(a[0]==0){
    cout<<0<<endl;
    return 0;
   }else{
    for(int i=0;i<n;i++){
        
        if(a[i]>(LIMIT/ans)){
            cout<<-1<<endl;
            return 0;
        }
      

    ans=ans*a[i];
}
   

   cout<<ans<<endl;
}
   
    
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};
ll mod=1e9+7;
ll dp[100010];
bool ok[100010];

int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m);
    for (int i = 0; i < 100010; i++)
    {
        ok[i]=true;
    }
    
    for (int i = 0; i < m; i++)
    {
        cin>>a[i];
        ok[a[i]]=false;
    }
    m0(dp);
    dp[0]=1;
    for (int i = 0; i < n; i++)
    {
        if(ok[i+1]==true)
        {
            dp[i+1]+=dp[i];
            dp[i+1]%=mod;
        }
        if(ok[i+2]==true)
        {
            dp[i+2]+=dp[i];
            dp[i+2]%=mod;
        }
    }
    cout<<dp[n]<<endl;
    
    return 0;
}

Measured memory_bytes: 1920
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s, t;
    int cou = 0;
    cin >> s >> t;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] != t[i])
            ++cou;

    }
    cout << cou << endl;
}

Measured memory_bytes: 3808
import sys
import itertools

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    A = [[] for _ in range(N)]
    for i in range(N):
        ai = int(input())
        for j in range(ai):
            x, y = map(int, input().split())
            A[i].append((x - 1, y))

    honest = list(itertools.product([0, 1], repeat=N))
    ans = 0

    # print(honest)
    # print(A)

    for h in honest:
        h_list = list(h)
        f = True
        for i, ai in enumerate(h):
            if not f:
                break
            if ai == 0:
                continue
            for x, y in A[i]:
                if h_list[x] == y:
                    #print("OK", i, x, y)
                    continue
                else:
                    f = False
                    #print("NO", i, x, y)
                    break

        if f:
            ans = max(ans, sum(h_list))

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 47856
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
int n; string st,s[500]; int t[500];
int main(){
	cin >> n;
	for (int i = 1; i<= n; ++i) cin >> s[i] >> t[i];
	cin >> st; 
	int id = -1; long long ans = 0;
	for (int i = 1; i <= n; ++i) if (s[i] == st) id = i;
	for (int i = id+1; i <= n; ++i) ans += t[i];
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int S=(1<<20)+5,N=21;

// f[s][i][j]
// (s1<<j)+s2=s,|s1|+|s2|=i

int n,k,f[S][N*(N+1)/2];
char x[S];

int Id(int i,int j) {return i*(i+1)/2+j;}

int main() {
	scanf("%d%d",&n,&k);
	fo(i,0,n) {
		scanf("%s",x);
		fo(j,0,(1<<i)-1) f[j][Id(i,i)]=x[j]=='1';
	}
	fd(i,n,1) 
		fo(s,0,(1<<i)-1) 
			fd(j,i,0)
				if (f[s][Id(i,j)]) {
					int s1=s>>j,s2=s&((1<<j)-1);
					int l1=i-j,l2=j,tmp=f[s][Id(i,j)];
					// none
					if (l2) f[s1][Id(l1,0)]+=tmp;
					// zero
					fd(k,j-1,0) 
						if (!(s2>>k&1)) {
							f[(s1<<k+1)|(s2&((1<<k)-1))][Id(l1+1+k,k)]+=tmp;
							break;
						}
					// one
					fd(k,j-1,0)
						if (s2>>k&1) {
							f[((s1<<1|1)<<k)|(s2&((1<<k)-1))][Id(l1+1+k,k)]+=tmp;
							break;
						}
				}
	fd(i,n,0)
		fo(s,0,(1<<i)-1)
			if (f[s][Id(i,0)]>=k) {
				fd(j,i-1,0) printf("%d",s>>j&1);
				puts("");
				return 0;
			}
	return 0;
}

Measured memory_bytes: 947328
start = Time.now
D = gets.to_i
@c = gets.split.map(&:to_i)
@s = Array.new D
D.times do |i|
  @s[i] = gets.split.map(&:to_i)
end

t = Array.new D
score = 0
last = Array.new 26, 0
D.times do |i|
  best = -99999999999
  res = nil
  base_c = 0
  26.times do |t|
    base_c += (i - last[t] + 1) * @c[t]
  end
  
  26.times do |t|
    diff = @s[i][t]
    diff -= base_c
    diff += @c[t] * (i - last[t] + 1)

    if diff > best
      best = diff
      res = t
    end
  end
  score +=  best
  last[res] = i + 1
  t[i] = res
end

@q = Array.new
def calc_pena t
  kei = Array.new(26, (1+D)*D/2)
  last = Array.new(26, 0)
  t.each_with_index do |_t, i|
    kei[_t] -= (i+1 - last[_t]) * (D - i)
    last[_t] = i + 1
  end
  res = 0
  26.times do |i|
    res += kei[i] * @c[i]
  end
  res
end

pena = calc_pena(t)
base_score = score + pena

while(Time.now - start < 1.9)
  q = [rand(D), rand(26)]
  d = q[0]
  old = t[d]
  rep = q[1]
  new_t = t.dup
  new_t[d] = rep
  new_base_score = base_score - @s[d][old] + @s[d][rep]
  new_pena = calc_pena(new_t)
  if new_base_score - new_pena > base_score - pena
    t = new_t
  end
  # score = score - @s[d][old] + @s[d][rep] + calc_pena_diff(d,old,rep)
  # warn score
  # warn "---"
end

t.each do |_t|
  puts _t + 1
end

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

using namespace std;

int main(){
  int N;
  cin>>N;
  int H[16],W[16];
  for(int i=0;i<N;i++){
    cin>>H[i]>>W[i];
  }
  int g[4][4];
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      char c;
      cin>>c;
      g[i][j]=
	(c=='R')?1:
	(c=='G')?2:3;
    }
  }
  int dp[1<<16];
  fill(begin(dp),end(dp),99);
  dp[0]=0;
  for(int i=0;i<1<<16;i++){
    int cg[10][10]={};
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
	if(!(i>>j*4+k&1)){
	  cg[j+3][k+3]=g[j][k];
	}
      }
    }
    for(int j=0;j<N;j++){
      for(int k=0;k<7;k++){
	for(int l=0;l<7;l++){
	  bool c[4]={};
	  int nb=i;
	  for(int m=0;m<H[j];m++){
	    for(int n=0;n<W[j];n++){
	      int y=k+m;
	      int x=l+n;
	      c[cg[y][x]]=true;
	      if(3<=y&&y<=6&&3<=x&&x<=6){
		nb|=1<<(y-3)*4+x-3;
	      }
	    }
	  }
	  if(c[1]+c[2]+c[3]==1){
	    dp[nb]=min(dp[nb],dp[i]+1);
	  }
	}
      }
    }
  }
  cout<<dp[(1<<16)-1]<<endl;
}

Measured memory_bytes: 1416
# https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_2_A
# 最小全域木、またお前か(プリムのアルゴリズムでできるやつ)
# ここではクラスカルのアルゴリズムを用いて解く。
# アイデアとしては辺の重みの小さい順にgreedyにノード同士をつないでいけば、必ず最小全域木になるでしょうというもの
# ただし木とならないような辺は省かなければ行けない。
# 辺を追加する際に木であることを崩さないように効率よく判定するのにunion-find木を使っている


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードをしめす。負は自身が親ということ。
        self.parent = [-1] * N  # idxが各ノードに対応。
        # 本で言うrankはこの実装では扱っていない。

    def root(self, A):  # 本で言うfindset
        # print(A)
        # ノード番号を受け取って一番上の親ノードの番号を帰す
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])  # 経由したノードすべての親を上書き
        return self.parent[A]

    def size(self, A):
        # ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        A = self.root(A)
        B = self.root(B)

        # すでにくっついている場合
        if (A == B):
            return False

        # 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
        if (self.size(A) < self.size(B)):
            A, B = B, A

        # くっつける
        self.parent[A] += self.parent[B]  # sizeの更新
        self.parent[B] = A  # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる

        return True

    def is_in_same(self, A, B):
        return self.root(A) == self.root(B)


Edges = []
# load data
n_V, n_E = list(map(int, input().split()))
for _ in range(n_E):
    s, t, w = list(map(int, input().split()))
    Edges.append((w, s, t))


def kruskal(N, Edges):
    '''
    Nは頂点数、Ndgesは各要素が(w,s,t)を前提としたlist
    '''
    edges = sorted(Edges)
    ret = 0
    union = UnionFind(N)
    n_edges = 0
    for w, s, t in edges:
        if n_edges == N - 1:
            # 全域木になったら早期終了可
            break
        if union.is_in_same(s, t):
            continue
        union.unite(s, t)
        ret += w
        n_edges += 1
    return ret


print(kruskal(n_V, Edges))



Measured memory_bytes: 23976
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	ary := make([]int, n)
	for i := 0; i < n; i++ {
		ary[i] = nextInt(sc)
	}
	fmt.Println(insertionSort(ary, n))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

func trace(ary []int, n int) {
	s := strconv.Itoa(ary[0])
	for i := 1; i < n; i++ {
		s += " " + strconv.Itoa(ary[i])
	}
	fmt.Println(s)
}

func insertionSort(ary []int, n int) int {
	flag := true
	sw := 0
	for i := 0; flag; i++ {
		flag = false
		for j := n - 1; i+1 <= j; j-- {
			if ary[j] < ary[j-1] {
				ary[j], ary[j-1] = ary[j-1], ary[j]
				sw++
				flag = true
			}
		}
	}
	trace(ary, n)
	return sw
}



Measured memory_bytes: 1196
X, Y = map(int, input().split())
li = [300000, 200000, 100000]
ans = 0
for i in range(3) :
    if i + 1 == X :
        ans += li[i]
        break

for i in range(3) :
    if i + 1 == Y :
        ans += li[i]
        break
if X == 1 and Y == 1:
    ans += 400000
print(ans)


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 1

#define MAXN 100
#define MAXK 100000
int a[MAXN*2];
int b[MAXK+MAXK];

int main() {
  int n,k;
  cin >> n >> k;
  forr(i,0,n-1)
    cin >> a[i];
  forr(i,0,k) b[i] = 0;
  forr(i,0,k) {
    if (b[i] > 0) continue;
    b[i] = 2;
    forr(j,0,n-1)
      b[i+a[j]] = 1;
  }
  cout << (b[k]==1 ? "First" : "Second");

}


Measured memory_bytes: 1024
n, m = map(int, input().split())
l = []
ans = 1
if(n%m == 0):
  ans=0
else:
  for x in (0,1000000000000000000):
    n = abs(n%m)
    l.append(n)
  l.sort()
  ans = min(m-n,l[0])
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int v[100];
	int n;
	int kari;
	int counter;
	
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		counter = 0;
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}
		for (int i = n-1; i > 0; i--) {
			for (int j = 0; j < i; j++) {
				if (v[j] > v[j+1]) {
					kari = v[j];
					v[j] = v[j+1];
					v[j+1] = kari;
					counter++;
				}
			}
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pqb             	priority_queue<int>
#define pqs             	priority_queue<int,vi,greater<int> >
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)  	type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int a,b,c,k;cin>>a>>b>>c>>k;
    if(k<=a){
    	cout<<k;
    }
    else if(k<=(a+b)){
    	cout<<a;
    }
    else if(k<=(a+b+c)){
    	cout<<a-(k-a-b);
    }
    else{
    	cout<<a-c;
    }
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();cerr<<"\nExecution time: "<<(double)(clock()-beg)/1000<<" seconds\n";}
}

Measured memory_bytes: 3796
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int n; cin >> n;
    bool flag = false;
    int ans;
    for (int x = 1; x <= n; ++x) {
        if (x * 108 / 100 == n) {
            ans = x;
            flag = true;
        }
    }
    if (flag) {
        out(ans);
    }
    else {
        cout << ":(" << endl;
    }
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < (int)s.size()-1; i++) {
    if (s[i] != s[i+1]) cnt++;
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 512
_, k = map(int, input().split())
a = list(map(int, input().split()))
r = len(set(a))
d = {}
tot = 0
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
l = sorted(d.values())
if r > k:
    tot += sum(l[0:r-k])
print(tot)

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

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

int main(){
	int n;
	cin >> n;
	for(int i = 1; i < 100000; ++i){
		if(i * 108 / 100 == n){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}



Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.*;

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

	public Main(){
		new AOJ1165().doIt();
	}

	class AOJ1165{
		int n;

		void solve(){
			boolean[][] map = new boolean[1000][1000];
			Point2D p[] = new Point2D[n];
			p[0] = new Point2D.Double(500,500);
			map[500][500] = true;
			int sx[] = {-1,0,1,0};
			int sy[] = {0,1,0,-1};
			for(int i=1;i<n;i++){
				int a = in.nextInt();
				int b = in.nextInt();
				int nx = (int)p[a].getX()+sx[b];
				int ny = (int)p[a].getY()+sy[b];
				p[i] = new Point2D.Double(nx, ny);
				map[ny][nx] = true;
			}
//			System.out.println(Arrays.toString(p));
			int w=0,h=0;
			int w2=Integer.MAX_VALUE,h2=Integer.MAX_VALUE;
			for(int i=0;i<p.length;i++){
				int x = (int)p[i].getX();
				int y = (int)p[i].getY();
				w = Math.max(w, x);
				h = Math.max(h, y);
				w2 = Math.min(w2, x);
				h2 = Math.min(h2, y);
			}
//			System.out.println(w+" "+h);
//			System.out.println(w2+" "+h2);
			System.out.println((w-w2+1)+" "+(h-h2+1));
		}

		void doIt(){
			while(in.hasNext()){
				n = in.nextInt();
				if(n==0)break;
				solve();
			}
		}
	}

}

Measured memory_bytes: 60380
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
   int count=0;
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        if(temp>=k){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
        ll n,k;
        cin>>n>>k;
        map<ll,ll>lol;
        for(int i=1;i<=k;i++)
        {
        	ll d;
        	cin>>d;
        	for(int j=0;j<d;j++)
        	{
        		ll x;
        		cin>>x;
        		lol[x]++;
        	}
        }
        cout<<n-lol.size();
    }
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(void){

int i,j,x;
int n=0;
int card[4][13];
char mark;

  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      card[i][j]=0;
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d",&mark,&x);
    switch(mark){
    case 'S': card[0][x]=1;
	  break;
    case 'H': card[1][x]=1;
      break;
    case 'C': card[2][x]=1;
      break;
    case 'D': card[3][x]=1;
      break;
		}
		
	}
    for(i=0;i<4;i++){
      for(j=1;j<14;j++){
        if(card[i][j]==0){
          if(i==0)
            printf("S %d\n",j);
	      else if(i==1)
            printf("H %d\n",j);
          else if(i==2)
            printf("C %d\n",j);
          else if(i==3)
            printf("D %d\n",j);
        }
      }
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<Grid> gridList = new ArrayList<>();

        int n = in.nextInt();
        for(int i = 0; i < n; i++) {
            gridList.add(new Grid(Color.RED, in.nextInt(), in.nextInt()));
        }
        for(int i = 0; i < n; i++) {
            gridList.add(new Grid(Color.BLUE, in.nextInt(), in.nextInt()));
        }
      
        gridList.sort(Comparator.comparing(Grid::getX).thenComparing(Grid::getColor));
        List<Grid> tmp = new ArrayList<>();
        int ans = 0;
        for (Grid grid : gridList) {
            if(grid.color == Color.RED) {
                tmp.add(grid);
            } else {
                List<Grid> list = tmp.stream()
                        .filter(g -> g.getY() < grid.getY())
                        .collect(Collectors.toList());
                if(list.size() > 0) {
                    ans++;
                    list.sort(Comparator.comparing(Grid::getY));
                    tmp.remove(list.get(list.size() - 1));
                }
            }
        }
        System.out.println(ans);
    }
}

class Grid {

    Color color;
    int x;
    int y;

    public Grid(Color color, int x, int y) {
        this.color = color;
        this.x = x;
        this.y = y;
    }
    public Color getColor() { return this.color; }
    public int getX() { return this.x; }
    public int getY() { return this.y; }

    public String toString(){
        return String.format(color + " \t" + x + ", " + y);
    }
}

enum Color {
    BLUE,
    RED
}

Measured memory_bytes: 27092
#include<bits/stdc++.h>
using namespace std;
long long a[200005];
int cnt=5,nonz=4,zero=5,one=3,cc=0;
int node(){
	return ++cnt;
}
void add(int x,int y,int z){
	printf("+ %d %d %d\n",x,y,z);
	a[z]=a[x]+a[y],cc++;
}
int add(int x,int y){
	int z=node();
	printf("+ %d %d %d\n",x,y,z);
	a[z]=a[x]+a[y],cc++;
	return z;
}
void addd(int x,int y){
	printf("+ %d %d %d\n",x,y,x);
	a[x]=a[x]+a[y],cc++;
}
int les(int x,int y){
	int z=node();
	printf("< %d %d %d\n",x,y,z);
	a[z]=(a[x]<a[y]),cc++;
	return z;
}
void les(int x,int y,int z){
	printf("< %d %d %d\n",x,y,z);
	a[z]=(a[x]<a[y]),cc++;
	return ;
}
int shi(int x,int y){//a[x]<<=y
	int ret=node();
	ret=add(ret,x);
	for(int i=0;i<y;i++)addd(ret,ret);
	return ret;
}
int is0(int x){
	return les(x,one);
}
void make0(int x){
	x=les(x,x);
}
void make1(int x){
	les(zero,nonz,x);
}
int sub(int x,int y){
	int ans=node();
	x=add(x,one);
	for(int i=29;i>=0;i--){
		int power=shi(one,i);
		int should=les(add(y,power),x);
		should=shi(should,i);
		addd(ans,should),addd(y,should);
	}
	return ans;
}
int iff(int x,int y){//a[x]?a[y]:0
	return sub(y,shi(is0(x),30));
}
int mul(int x,int y){
	int ans=node(),p=node();
	x=add(x,one);
	for(int i=29;i>=0;i--){
		int power=shi(one,i);
		int should=les(add(p,power),x);
		int t=iff(should,y);
		should=shi(should,i);
		addd(p,should),addd(ans,shi(t,i));
	}
	return ans;
}
int main() {
	puts("34010");
//	cin>>a[0]>>a[1];
	add(0,1,4),make0(5);
	make1(3);
	add(mul(0,1),zero,2);
//	cout<<a[2];
	return 0;
}

Measured memory_bytes: 3768
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar(); 
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=5005;
const int mod=1e9+7;
int n;
vector<int>edge[maxn];
int fac[maxn],f[maxn],sz[maxn];
int dp[maxn][maxn][2],tmp[maxn][2];

int Add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
int Sub(int a,int b){return a-b<0?a-b+mod:a-b;}
int Mul(int a,int b){return 1LL*a*b%mod;}

int quickpow(int x,int pow){
	int res=1;
	for(;pow;pow>>=1){
		if(pow&1)res=Mul(res,x);
		x=Mul(x,x);
	}
	return res;
} 

void dfs(int x,int par){
	sz[x]=1;
	dp[x][1][0]=1;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==par)continue;
		dfs(y,x);
		REP(j,sz[x])rep(a,2){
			if(!dp[x][j][a])continue;
			REP(k,sz[y])rep(b,2){
				if(!dp[y][k][b])continue;
				tmp[j+k][(a+b)%2]=Add(tmp[j+k][(a+b)%2],Mul(dp[x][j][a],dp[y][k][b]));
				tmp[j][(a+b+1)%2]=Add(tmp[j][(a+b+1)%2],Mul(dp[x][j][a],Mul(dp[y][k][b],f[k])));
			}
		}
		sz[x]+=sz[y];
		REP(j,sz[x])rep(a,2)dp[x][j][a]=tmp[j][a],tmp[j][a]=0;
	}
}

int main(){
#ifdef FILE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	scanf("%d",&n);
	fac[0]=1;
	REP(i,n)fac[i]=Mul(fac[i-1],i);
	f[0]=1;
	REP(i,n){
		if(i&1)continue;
		f[i]=Mul(f[i-2],1LL*i*(i-1)/2%mod);
	}
	REP(i,n){
		if(i&1)continue;
		f[i]=Mul(f[i],quickpow(fac[i/2],mod-2));
	}
	rep(i,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	} 
	dfs(1,0);
	int ans[2]={};
	REP(i,n)rep(a,2)ans[a]=Add(ans[a],Mul(dp[1][i][a],f[i]));
	printf("%d",Sub(ans[0],ans[1]));
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 195328
import bisect
n=int(input())
if n%2==1:
    print(0)
    exit()
d=list(map(int,input().split()))
d=sorted(d)
cnt=0
for i in range(1,max(d)+1):
    a=bisect.bisect_left(d,i)
    if a==n//2:
        cnt+=1
print(cnt)

Measured memory_bytes: 53036
import numpy as np
N = int(input())
S = np.arange(1,N+1)

for i in range(N):
    t = S[i] % 3
    u = S[i] % 5
    if t == 0:
        S[i] = 0
    if u == 0:
        S[i] = 0

print(sum(S))


Measured memory_bytes: 34592
#include <iostream>
using namespace std;
int main(void){
  constexpr const char* kYes = "Yes\n";
  constexpr const char* kNo = "No\n";
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;
  
  if (a + b == c 
      || b + c == a
      || c + a == b) {
    cout << kYes;
  } else {
    cout << kNo;
  }
  
  return 0;
}

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

int main(){
  int N,b;
  cin >> N;
  map<int,int>a;
  for(int i=0;i<N;i++){
    cin >> b;
    a[b]++;
  }
  int ans=0;
  for(auto x:a){
    if(x.first!=x.second){
      if(x.first>x.second)
        ans+=x.second;
      else
        ans+=x.second-x.first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8004
#define rep(i,n) for(i=0;i<(n);++i)
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<utility>
#include<string>
#include<algorithm>
#include<bitset>
#include<queue>
using ll = unsigned long long int;
using namespace std;



int src(){
    int r;
    cin>>r;
    cout<<r*r;

    return 0;
}

int main(ll argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
  while(1)
    {
  char buf[128][2];
  char str[128];
  buf['A']['0']='X';
  buf['A']['1']='Y';
  buf['X']['1']='Z';
  //buf['X']['0']='n';
  buf['Y']['0']='X';
  //buf['Y']['1']='n';
  buf['Z']['0']='W';
  buf['Z']['1']='B';
  buf['W']['0']='B';
  buf['W']['1']='Y';
  buf['B']['0']='Y';
  buf['B']['1']='X';
  scanf("%s",str);
  if(str[0]=='#')break;
  int ans=strlen(str);
  
  char now='A';
  for(int i=0;i<ans;i++)
    {
      
      now=buf[now][str[i]];
      //if(now=='n')break;

    }
  if(now=='B')printf("Yes\n");
  else printf("No\n");
    }
  return 0;
}

Measured memory_bytes: 944
N=int(input())
P=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans=[]
while N>0:
  t=(N-1)%26
  ans.append(P[t])
  N=int((N-t)/26)
  continue
ans=ans[::-1]
print("".join(ans))

Measured memory_bytes: 8944
/* author   : mpily :-()
title : Competing.cpp
time :Sun Apr 26 15:01:19 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	set<string>in;
	for(int i = 0 ; i  <  n; ++i){
		string s;
		cin >> s;
		in.insert(s);
	}
	cout << (int)in.size() << "\n";
	return 0;
}

Measured memory_bytes: 19256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll N, A, B, C, D, E; cin >> N >> A >> B >> C >> D >> E;
	vector<ll> a(5); 
	a[0] = A; a[1] = B; a[2] = C; a[3] = D; a[4] = E;

	sort(ALL(a));

	ll x;
	if (N%a[0] == 0)  x = N / a[0];
	else x = N / a[0] + 1;
	if (a[0] == A) {
		cout << x + 4 << endl;
		return 0;
	}
	if (a[0] == B) {
		cout << x + 4 << endl;
		return 0;
	}
	if (a[0] == C) {
		cout << x + 4 << endl;
		return 0;
	}
	if (a[0] == D) {
		cout << x + 4 << endl;
		return 0;
	}
	if (a[0] == E) {
		cout <<x + 4<< endl;
		return 0;
	}
}

Measured memory_bytes: 384
n, m = map(int,input().split())
l = [[0]*2 for i in range(n)]
for i in range(n):
    l[i][0], l[i][1] = map(int, input().split())
l = sorted(l)
price = 0

for i in range(n):
    if l[i][1] < m:
        m = m - l[i][1]
        price = price + l[i][0]*l[i][1]
    else:
        price = price + l[i][0]*m
        break

print(price)

Measured memory_bytes: 20780
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());
        long ans = a * c;
        ans = Math.max(ans, a * d);
        ans = Math.max(ans, b * c);
        ans = Math.max(ans, b * d);
        System.out.println(ans);
    }
}

Measured memory_bytes: 35572
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> H(N), max_H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    for (int i = 0; i < N; i++) {
        max_H[i+1] = max(max_H[i], H[i]);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (max_H[i] <= H[i]) ans++;
    }

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

Measured memory_bytes: 888
a = [int(input()) for i in range(1)]
n = a[0] 
input = [list(map(str, input().split())) for i in range(n)]
#print(input)
for i in range(n):
  input[i].append(i+1)
#print(input)

input = sorted(input, reverse = True, key=lambda x: int(x[1]))
input = sorted(input, key=lambda x: x[0])

for i in range(n):
  print(input[i][2])

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

int main(){
    int N, M;  cin >> N >> M;
    map<int, int> mp;
    for(int i=0; i<M; i++){
        int a, b;  cin >> a >> b;
        a--;  b--;
        mp[a]++;
        mp[b]++;
    }

    for(auto p : mp){
        if(p.second%2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#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(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    string s;
    cin >> n >> s;

    string ans = "";
    REP(i, s.size())
    {
        char c = s[i];
        if('Z' < c + n)
        {
            char cc = (c + n - 'Z' - 1) + 'A';
            ans = ans + cc;
        }
        else
        {
            char cc = c + n;
            ans = ans + cc;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 384
N, Q = map(int,input().split())
S = input()

accum = [0]
cnt = 0
for i in range(1,N):
    if S[i-1:i+1] == "AC":
        cnt += 1
    accum.append(cnt)


for i in range(Q):
    l,r = map(int, input().split())
    print(accum[r-1]-accum[l-1])

Measured memory_bytes: 6180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a, b, k;

int main()
{
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 0; i--)
    {
        if (a % i == 0 && b % i == 0)
        {
            k--;
        }
        if (k == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
}

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

bool isok(string &a,string &b){
  rep(i,a.size()){
    if (a[i] != '*' && a[i] != b[i])return false;
  }
  return true;
}

main(){
  int n,m;
  int a[100];
  static string in[100],tar;
  while(cin>>n>>m && n){
    int ans = 0;
    rep(i,n)cin>>in[i]>>a[i];
    rep(j,m){
      cin>>tar;
      rep(i,n)if (isok(in[i],tar)){ans+=a[i];break;}
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 924
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ct=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o'){
            ct++;
        }
    }
    int rem=15-s.size();
    if(rem+ct>=8){
        cout<<"YES\n";
    }
    else{
        cout<<"NO\n";
    }



	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import permutations

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m, r = map(int, input().split())
    R = list(map(int, input().split()))
    C = [[f_inf for _ in range(n)] for _ in range(n)]
    for i in range(n):
        C[i][i] = 0

    for i in range(m):
        a, b, c = map(int, input().split())
        C[a - 1][b - 1] = c
        C[b - 1][a - 1] = c

    for k in range(n):
        for i in range(n):
            for j in range(n):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    res = f_inf
    for pattern in permutations(R):
        cost = 0
        for k in range(r - 1):
            i, j = pattern[k], pattern[k + 1]
            cost += C[i - 1][j - 1]
        res = min(res, cost)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 60760
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,unroll-all-loops")
// #pragma GCC option("arch=native","tune=native")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")

#include <bits/stdc++.h>
using namespace std;

#define f(_i, _n) for (auto _i = 0; _i < _n; _i++)
#define F(_i, _k, _n) for (auto _i = _k; _i < _n; _i++)
#define re return
#define pb push_back
#define all(_v) _v.begin(), _v.end()
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
#define fi first
#define se second

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;

int ok[100500];

int ans;

vector<int> gr[100500];

int dp[100500];
int chain[100500];

int used;

void dfs(int v, int pr, int ok = 0) {
  int leaf = 1;
  int sum = 0;
  chain[v] = 1;
  int chainCnt = 0;
  int okTo = ok || (int(gr[v].size() - (pr != -1)) > 1);
  int cnt = 0;
  for (auto to : gr[v]) {
    if (to == pr) {
      continue;
    }
    dfs(to, v, okTo);
    leaf = 0;
    sum += dp[to];
    cnt++;
    chain[v] &= chain[to];
    if (chain[to]) {
      chainCnt++;
    }
  }
  chain[v] &= (cnt <= 1);
  if (chain[v]) {
    // cerr << v << ' ' << 1 << endl;
    dp[v] = 1;
    re;
  }
  // cerr << v << ' ' << used << endl;
  if (chainCnt >= 1 && (ok || ((cnt > 2 || !used) && pr == -1))) {
    dp[v] = max(1, sum - 1);
    used = 1;
  } else {
    dp[v] = max(1, sum);
  }
  // cerr << v << ' ' << dp[v] << ' ' << chainCnt << ' ' << ok << endl;
}

int main() {
  int n;
  cin >> n;
  f(i, n - 1) {
    int a, b;
    cin >> a >> b;
    gr[a].pb(b);
    gr[b].pb(a);
  }
  dfs(0, -1);
  cout << dp[0];
}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int s[1010], p[1010], q[1010], r[1010];
    for (int i = 0; i < n; i++) {
      cin >> s[i] >> p[i] >> q[i] >> r[i];
    }
    int P, Q, R, C;
    cin >> P >> Q >> R >> C;
    int na = 0;
    for (int i = 0; i < n; i++) {
      if (p[i] > P) continue;
      if (q[i] > Q) continue;
      if (r[i] > R) continue;
      if (p[i] * 4 + q[i] * 9 + r[i] * 4 > C) continue;
      cout << s[i] << endl;
      na++;
    }
    if (!na) cout << "NA" << endl;
  }

  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int maxv = max(A, B);
  int sum = 0;
  sum += maxv;
  if(maxv == A){
    A--;
  }
  else{ B--; }

  
  maxv = max(A, B);
  sum += maxv;
  cout << sum << endl;
}

Measured memory_bytes: 256