akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>

using namespace std;

int main(void)
{
    std::array<bool, 100000> is_good_list;
    std::array<int, 100000> height_list;
    int n, m;
    cin >> n;
    cin >> m;
    is_good_list.fill(true);

    // 展望台の高さを登録
    for(int s = 0;s < n;s++)
    {
        int h;
        cin >> h;
        height_list[s] = h;
    }
    
    for (int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a;
        cin >> b;
        a--;b--;
        if(height_list[a] <= height_list[b])
        {
           is_good_list[a] = false; 
        }
        if(height_list[a] >= height_list[b])
        {
            is_good_list[b] = false; 
        }
    }
    int good_num = 0;
    for(int i = 0;i < n;i++)
    {
        if(is_good_list[i])
        {
            good_num++;
        }
    }
    cout << good_num;
}

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

int a[12];
int udo[12];
int n;

void cp(void){
	for(int i=0;i<12;i++){
		udo[i]=a[i];
	}
}

bool check(void){
	for(int i=0;i<12;i++){
		if(udo[i]!=a[i])return false;
	}
	return true;
}

int main(void){
	int c;
	while(cin>>n,n){
		for(int i=0;i<n;i++){cin>>a[i];udo[i]=0;}
		for(c=0;!check();c++){
			map<int,int> m;
			for(int i=0;i<n;i++){
				m[a[i]]++;
			}
			cp();
			for(int i=0;i<n;i++){
				a[i]=m[a[i]];
			}
			if(check())break;
		}
		cout<<c<<endl;
		for(int i=0;i<n;i++){
			if(i!=n-1)cout<<a[i]<<" ";
			else cout<<a[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3064
s = list(input())
n = int(input())
ans = 0
if s[0] != s[-1]:
    cnt = 1
    tmp = ''
    for i in range(len(s)):
        if i == 0:
            tmp = s[i]
            continue
        if tmp == s[i]:
            cnt += 1
        else:
            ans += cnt // 2
            cnt = 1
            tmp = s[i]
    ans += cnt // 2
    print(ans*n)
else:
    cnt = 1
    tmp = ''
    f = 0
    for i in range(len(s)):
        if i == 0:
            tmp = s[i]
            continue
        if tmp == s[i]:
            cnt += 1
        else:
            if f == 0:
                f = cnt
            ans += cnt // 2
            cnt = 1
            tmp = s[i]
    ans += cnt // 2
    if f == 0:
        print((cnt*n)//2)
    else:
        m = ans - f//2 - cnt//2
        ans = f // 2 + cnt // 2
        # print(m,ans)
        ans += m * n
        # print(m*n)

        ans += (n-1) * ((f+cnt) // 2)
        # print((n-1)*((f+cnt)//2))
        print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9


int main()
{
    fastio;
    int x,y;
    cin >> x >> y;
    int f=0;
    for(int i=0;i<=x and f==0;i++)
    {
        if(i*2+(x-i)*4==y)
            f=1;
    }
    if(f==1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3640
function main(input){
  var n = parseInt(input[0]);
  var arr = Array(n);
  for (var i=0;i<n;i++){
    var cost = input[i+1].split(' ');
    if (i==0) {
      arr[0] = [parseInt(cost[0]), parseInt(cost[1]), parseInt(cost[2])];
    } else {
      for (var j =0; j<3; j++) {
        var max = null;
        for (var m =1; m<3; m++) {
          var other = (j+m)%3;
          var newMax = arr[i-1][other] + parseInt(cost[j]);
          if (max == null || max < newMax) max = newMax;
        }
        if(!arr[i]) arr[i] = [];
        arr[i][j] = max;
      }
    }
  }

  console.log(Math.max(...arr[n-1]));
}


var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 56500
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

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

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

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

int main(){
    int k; cin >> k;
    ll ans = 0;
    repr(i,1,k+1)repr(j,1,k+1)repr(l,1,k+1){
        ans += gcd(gcd(i,j),l);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}


int main(){
  char s ;cin>>s ;
  if(isupper(s)) cout<<'A'<<endl ;
  else cout<<'a'<<endl ;
  return 0;
  }

Measured memory_bytes: 3616
#include <iostream>
#include <limits.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
 
int main(){
	int n,a,b,c;
	int mi,mx,t_num,now;
 
	int t[10][10];
	while(cin >> n && n){
		/*ú»*/
		REP(i,10)
		 REP(j,10)
		  if(i!=j)t[j][i] = INT_MAX/2; //WFÌZpI[o[t[h~
		  else t[i][j]=0;
		mx=0;mi=INT_MAX;
 
		/*üÍ*/
		REP(i,n){
			cin >> a >> b >> c;
			t[a][b]=t[b][a]=c;
			mx = max(mx,max(a,b)); //XÌÅåðmxÉãü
		}
 
		/*S_ÎÅZoHðßé([VtCh@)*/
		REP(k,mx+1) // k<mx+1 Í k<=mxÆ¿ (®¾©ç)
		 REP(i,mx+1)
		  REP(j,mx+1)
		   t[i][j]=t[j][i]=min(t[i][k]+t[k][j],t[i][j]);
 
		/*S_ÔË»Ìn_ÖÌ£aªÅà¬³¢àÌðL^*/
		REP(i,mx+1){
			now=0;
			REP(j,mx+1)now+=t[j][i];
			if(mi>now){
				t_num=i;
				mi=now;
			}
		}
 
		/*oÍ*/
		cout << t_num << " " << mi << endl;
	}
}

Measured memory_bytes: 0
using System;

using System.Collections.Generic;

class Program {
    static void Main(string[] args) {

        int N = int.Parse(Console.ReadLine());


        string result = "No";

        for(int a = 1; a <= 9; a++) {
            for(int b = 1; b <= 9; b++) {
                if (N == a * b) {
                    result = "Yes";
                }
            }
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092
use std::io;
use std::io::BufRead;
use std::io::BufReader;

fn main() {
    let reader = io::stdin();
    let mut reader = BufReader::new(reader.lock());

    let mut s = String::new();
    let _ = reader.read_line(&mut s);

    let n: usize = s.trim().parse().unwrap();
    let mut words = Vec::with_capacity(n);
    let mut ans = true;

    for i in 0..n {
        let mut s = String::new();
        let _ = reader.read_line(&mut s);

        let s = s.trim();

        for i in 0..i {
            if s == words[i] {
                ans = false;
                break;
            }
        }
        words.push(s.to_string());
    }

    for i in 0..n - 1 {
        if words[i].chars().last().unwrap() != words[i + 1].chars().nth(0).unwrap() {
            ans = false;
            break;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
N = int(input())
res_list=[]
for i in range(N):
    a,b = input().split()
    b = int(b)
    res_list.append([i+1,a,b])
res_list =sorted(res_list, key=lambda x: x[1])
tes_list=[]
for i in range(N):
    if tes_list == []:
        tes_list.append(res_list[i])
    if i == N-1:
        tes_list = sorted(tes_list, key=lambda x: x[2],reverse=True)
        for j in range(len(tes_list)):
            print(tes_list[j][0])
    else:
        if res_list[i][1] == res_list[i+1][1]:
            tes_list.append(res_list[i+1])
        else:
            tes_list = sorted(tes_list, key=lambda x: x[2],reverse=True)
            for j in range(len(tes_list)):
                print(tes_list[j][0])
            tes_list=[]

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    string s;
    cin >> s;

    if (s.front() == s.back()) {
        if (s.size() % 2 == 0) {
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        }
    } else {
        if (s.size() % 2 == 0) {
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    }
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] X = sc.next().toCharArray();
		StringBuffer buf = new StringBuffer();

		//int count = 0;

		for (int i = 0; i < X.length; i++) {
			if (X[i] == 'T' && buf.length() != 0) {
				if (buf.charAt(buf.length() - 1) == 'S') {
					buf.deleteCharAt(buf.length() -1);

					continue;
				}
			}


			buf.append(X[i]);



		}

		System.out.println(buf.length());

		sc.close();
	}
}


Measured memory_bytes: 16176
#include <iostream>

using namespace std;

int main()
{
    int n, t;
    int minCost = 1001;

    cin >> n >> t;

    for(int i = 0; i < n; ++i)
    {
        int ci, ti;

        cin >> ci >> ti;

        if(ti <= t) {
            minCost = min(minCost, ci);
        }
    }

    if(minCost == 1001)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << minCost << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N;
    int atti=0;
    string S;
    cin >>N >>S;
    FOR(i,1,N){
        if(S[i] =='E') {
            atti++;
        }
    }
    int min =atti;
    FOR(i,1,N){
        if(S[i-1] == 'W')
            atti++;
        if(S[i] == 'E')
            atti--;
        if(min > atti)
            min = atti;
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if((x>=r&&x<=w-r)&&(y>=r&&y<=h-r)) {
  cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
}


Measured memory_bytes: 3100
def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

def exp2(k):
    p = 0
    while k % 2 == 0:
        k //= 2
        p += 1
    return p

N, M = map(int, input().split())
A = [int(a)//2 for a in input().split()]
l = 1
flg = 0
already = set()
for a in A:
    already.add(exp2(a))
    if len(already) > 1:
        flg = 1
        break
    l = lcm(l, a)
if flg == 1:
    ans = 0
else:
    ans = (M // l + 1)//2
print(ans)


Measured memory_bytes: 15060
MOD = 998244353
N, K = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(K)]

dp = [0]*(N+1)
acc = [0]*(N+1) # acc[i] = dp[1] + ... dp[i]

dp[1] = 1
acc[1] = 1
for i in range(2, N+1):
    for lr in LR:
        l = lr[0]
        r = lr[1]

        dp[i] += (acc[max(0, i - l)] - acc[max(0, i - r - 1)] + MOD)
        dp[i] %= MOD
    acc[i] = (acc[i-1] + dp[i]) % MOD
    
    

print(dp[N])
# print(acc)
# print(dp[N])

Measured memory_bytes: 24488
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC100.C
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            var n = sc.Nextint ();
            var a = sc.Arrayint (n);
            var cnt = a.Select (val => CountTwo (val)).Sum ();
            Console.WriteLine (cnt);
        }

        static Dictionary<int, int> memo = new Dictionary<int, int> ();
        static int CountTwo (int n)
        {
            if (memo.ContainsKey (n)) return memo[n];
            if (n % 2 == 0)
            {
                if ((n / 2) % 2 == 0) return memo[n] = CountTwo (n / 2) + 1;
                return memo[n] = 1;
            }
            return memo[n] = 0;
        }
    }

    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 19168
#include <cstdio>

int a, b;

int main(){
	scanf("%d %d", &a, &b);
	if(a == 1) a += 13;
	if(b == 1) b += 13;
	if(a < b) printf("Bob\n");
	else if(a == b) printf("Draw\n");
	else printf("Alice\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
const int Max = 1E5 + 10;
using namespace std;
int N,t[Max],x[Max],y[Max];
int main()
{
    int T,X,Y,S,f=0;
    cin>>N;
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(int i=1;i<=N;i++)
    	cin>>t[i]>>x[i]>>y[i];
    for(int i=1;i<=N;i++)
    {
    	T=t[i]-t[i-1];
    	X=x[i]-x[i-1];
    	Y=y[i]-y[i-1];
    	S=T-(X+Y);
    	if(S<0)
    	{
    		f=1;
		}
		else
		{
			if(S&1) 
			{
				f=1;
			}
			else
			    f=0;
		}
		if(f==1) break;
	}
	if(f==1) cout<<"No"<<endl;
	else if(f==0) cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1408
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    MOD = 10**9 + 7
    count = 0
    for i in range(N-1):
        for j in range(i, N):
            if A[i] == A[j]:
                continue
            elif K == 1 and A[i] > A[j]:
                count += 1
            else:
                if A[i] > A[j]:
                    count += K + K*(K-1) // 2
                else:
                    k = K - 1
                    count += k + k*(k-1) // 2

    print(count % MOD)
    



main()

Measured memory_bytes: 3188
#include<iostream>

using namespace std;
int ans = 0;
void swap(int* x, int* y){
    *x += *y;
    *y = *x - *y;
    *x = *x - *y;
}

void trace(int A[], int n){
    cout << A[0];
    for (int i = 1; i < n; i++)
    {
        cout << " " << A[i];
    }
    cout << endl;
}
void bubble_sort(int A[], int n){
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int i = n-1; i > 0; i--)
        {
            if (A[i] < A[i-1])
            {
                swap(A+i, A+i-1);
                ++ans;
                flag = true;
            }   
        }   
    }
}
int main(){
    int n, A[105]; cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    bubble_sort(A, n);
    trace(A, n);
    cout << ans << endl;
}


Measured memory_bytes: 3084
#include<stdio.h>
int data[100000];
int main(void)
{
	int n,l,i,j;
	int tura;
	int max;
	int suu;
	int muki;
	
	scanf("%d %d",&n,&l);
	for(i=0;i<n;i++)	{
		scanf("%d",&tura);
		data[i]=l-tura;
	}
	if(data[0]>data[1])	{
		muki=-1;
	}
	else {
		muki=1;
	}
	suu=data[0];
	max=-1;
	for(i=0;i<n-1;i++)	{
		if((data[i+1]-data[i])*muki>0)	{
			suu+=data[i+1];
		}
		else {
			if(max<suu)	max=suu;
			suu=data[i+1]+data[i];
			muki=muki*-1;
		}
	}
	if(suu>max)	max=suu;
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 984
#include<stdio.h>
#include<string.h>
#define L 100005

typedef struct pp{
  char name[100];
  int t;
}A;

A deq();
void enq(A x);
A Q[L];
int t,h, n;

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

int main(){

  int elaps=0, c;
  int i, q;
  A u;

  scanf("%d %d", &n, &q);

  for(i=1;i<=n;i++){
    
    scanf("%s",Q[i].name);

    scanf("%d",&Q[i].t);

  }
  
  h=1; t=n+1;

  while(h !=t){

    u=deq();
    c=min(q, u.t);
    u.t -=c;
    elaps+=c;
    if(u.t>0) enq(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }

  return 0;
}



A deq(){
  A x =Q[h];
  h = (h+1)%L;
  return x;
}

void enq(A x){
  Q[t]=x;
  t=(t+1)%L;
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,a;cin>>n>>a;
    cout<<n*n-a<<endl;
}


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

using namespace std;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
int n,k,nmax;cin >> n>>k;
int h[n];
nmax=1000000100;
for (int i = 0; i < n; ++i)
{
    cin >> h[i];
}

ll dp[n+k];
for (int i = 0; i < n; ++i)
{
    dp[i] = nmax;
}
dp[0]=0;
for (int i = 0; i < n; ++i)
{
    for (int j = 1; j <= k; ++j)
    {
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
}

cout << dp[n-1];
 return 0;

}




Measured memory_bytes: 1408
#include<stdio.h>
#define N 1000

int main(void){
	int i,n;
	double xa[N],ya[N],
		xb[N],yb[N],
		xc[N],yc[N],
		xd[N],yd[N];
	double incAB,incCD;	//inclinataion:katamuki

	for(i=0;scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
			&xa[i],&ya[i],
			&xb[i],&yb[i],
			&xc[i],&yc[i],
			&xd[i],&yd[i])==8;i++){}
	n=i;
	for(i=0;i<n;i++){
		if((xb[i]-xa[i]==0 && yb[i]-ya[i]==0) ||
			(xd[i]-xc[i]==0 && yd[i]-yc[i]==0)){
			printf("NO\n");
		}else{ 
			if((xa[i]==xb[i] && yc[i]==yd[i]) || 
				(ya[i]==yb[i] && xc[i]==xd[i])){
				printf("YES\n");
			}else{
				incAB=(yb[i]-ya[i])/(xb[i]-xa[i]);
				incCD=(yd[i]-yc[i])/(xd[i]-xc[i]);
				if(incAB*incCD==-1){
					printf("YES\n");
				}else{
					printf("NO\n");
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
 char T[11],W[1001];
 char F[12]="END_OF_TEXT";
 int count=0,a;
 scanf("%s",T);
 for(a=0;T[a]!='\0';a++) T[a]=tolower(T[a]); 
 while(1){
   scanf("%s",W);
   if(strcmp(W,F)==0) break;
   for(a=0;W[a]!='\0';a++) W[a]=tolower(W[a]);
   if(strcmp(W,T)==0) count++;
  }
    printf("%d\n",count);
return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=1e3+5, S=2e4+5;
struct Block{
	int w,s;ll val;
	bool operator<(const Block &o)const{
		if(s+w==o.s+o.w)return tie(w,s,val) > tie(o.w,o.s,o.val);
		return s+w>o.s+o.w;
	}
};
vector<Block> bs;
int n;
ll dp[N][S];

int main(){FIN;
	cin >> n;
	fore(x,0,n){
		int w,s;ll v; cin >> w >> s >> v;
		bs.pb({w,s,v});
	}
	sort(ALL(bs));
	for(int x=n-1; x>=0; x--){
		for(int y=0; y<S; y++)dp[x][y]=dp[x+1][y];
		for(int y=0; y<=bs[x].s && y+bs[x].w<S; y++){
			dp[x][y+bs[x].w]=max(dp[x][y+bs[x].w],dp[x+1][y]+bs[x].val);
		}
	}
	
	cout << *max_element(dp[0],dp[0]+S) << "\n";
}

Measured memory_bytes: 156544
<?php
  $n = trim(fgets(STDIN));
  if($n[0] == $n[1] && $n[1] == $n[2] ||
     $n[1] == $n[2] && $n[2] == $n[3] ||
     $n[0] == $n[1] && $n[1] == $n[2] && $n[2] == $n[3]){
    echo "Yes\n";
  }else{
    echo "No\n";
  }

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int h, w;
int step[50][50] = {};
char s[50][50];
int x[4] = {1, 0, -1, 0};
int y[4] = {0, 1, 0, -1};

void bfs()
{
    queue<pii> q;
    step[0][0] = 1;
    q.push(pii(0, 0));
    while (!q.empty())
    {
        pii t = q.front();
        q.pop();
        rep(i, 4)
        {
            int nx = t.first + x[i], ny = t.second + y[i];
            if (!(0 <= nx && nx < h && 0 <= ny && ny < w))
                continue;
            if (s[nx][ny] == '.' && step[nx][ny] == 0)
            {
                step[nx][ny] = step[t.first][t.second] + 1;
                q.push(pii(nx, ny));
            }
        }
    }
}

int main()
{
    int cnt = 0;

    cin >> h >> w;

    rep(i, h)
    {
        rep(j, w)
        {
            cin >> s[i][j];
            if (s[i][j] == '.')
                cnt++;
        }
    }

    bfs();

    if (step[h - 1][w - 1] == 0)
        OP(-1);
    else
        OP(cnt - step[h - 1][w - 1]);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define INF (1<<21)
const int maxn=1400+10;
int H,W;
int g[maxn][maxn];
int dp[maxn][maxn];
void solve()
{
    memset(dp,0,sizeof(dp));
    int max_width=0;
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            dp[i][j]=(g[i][j]+1)%2;
            max_width|=dp[i][j];
        }
    }
    for(int i=1; i<H; i++)
    {
        for(int j=1; j<W; j++)
        {
            if(g[i][j]==1)
            {
                dp[i][j]=0;
            }
            else
            {
                dp[i][j]=min(min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])+1;
                max_width=max(max_width,dp[i][j]);
            }
        }

    }
    printf("%d\n",max_width*max_width);


}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&H,&W);
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            scanf("%d",&g[i][j]);
        }
    }

    solve();

    return 0;
}

Measured memory_bytes: 18588
#include <stdio.h>

int strlen(char *s)
{
	int i = 0;
	while (s[i]) i++;
	return i;
}

int cheackstr(char *s)
{
	for (int i = 3, cnt = 0; cnt < 2; i += 2, cnt++)
	{
		if (s[i] != s[i - 1])
			return 0;
	}
	return 1;
}

int main(void)
{
	char s[7] = {};
	scanf("%s", s);
	if (strlen(s) != 6) return 0;
	if (cheackstr(s)) puts("Yes");
	else puts("No");
	return 0;
}

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

void solve(int X)
{
    if (X < 600)
        cout << 8 << endl;
    else if (X < 800)
        cout << 7 << endl;
    else if (X < 1000)
        cout << 6 << endl;
    else if (X < 1200)
        cout << 5 << endl;
    else if (X < 1400)
        cout << 4 << endl;
    else if (X < 1600)
        cout << 3 << endl;
    else if (X < 1800)
        cout << 2 << endl;
    else
        cout << 1 << endl;
}

int main()
{
    int X;
    cin >> X;
    solve(X);
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    long double L;
    cin >> L;
    L /= 3.0;
    cout.precision(30);
    cout << L*L*L << endl;
    return 0;
}

Measured memory_bytes: 256
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}



ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}



ll n, k;
ll p[5010];
ll c[5010];

ll sub(ll s){
  ll sum = c[p[s]];
  ll cnt = 1;
  ll now = p[s];
  while(now != s){
    sum += c[p[now]];
    cnt++;
    now = p[now];
  }
  ll res = -INFL;
  now = s;
  ll S = 0;
  for(int i = 0; i <= min(cnt, k); i++){
    ll loop = (k - i) / cnt;
    if(i == 0){
      if(loop != 0){
        res = max(res, max(sum, loop * sum));
      }
    }else{
      res = max(res, max(S, S + loop * sum));
    }
    S += c[p[now]];
    now = p[now];
  }
  return res;
}

void solve(){
  cin >> n >> k;
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> c[i];
  rep(i, n) p[i]--;
  ll ans = -INFL;
  rep(i, n){
    ans = max(ans, sub(i));
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3740
let [| n; k; |] = stdin.ReadLine().Split() |> Array.map int
let hs = seq{ for i in 1..n -> stdin.ReadLine() |> int}

let sorted = hs |> Seq.sort |> Seq.toArray
[0..n-k] |> Seq.map (fun i -> sorted.[i+k-1] - sorted.[i])
|> Seq.min |> stdout.WriteLine

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    int cnt[9]; REP(i,9) cnt[i]=0;
    REP(i,N) {
        int a;
        cin>>a;
        if (a<3200) cnt[a/400]++;
        else cnt[8]++;
    }
    int ans = 0;
    REP(i,8) if (cnt[i]>0) ans++;
    if (ans==0) {
        cout<<1<<" "<<cnt[8];
        return 0;
    }
    cout<<ans<<" ";
    ans += cnt[8];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define err(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);



using namespace std;
int main()
{


    FASTIO
    string s;
    cin>>s;
    bool ok = false;
    for(ll i=0;i<4ll;i++)
    {
        if(s[i]==s[i+1])
        ok=true;
    }
    if(ok)
    cout<<"Bad";
    else
    cout<<"Good";



cout << endl ;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll h, w;
ll f(ll i, ll j) { return w * i + j; }

const ll INF = 1e18;
void warshall_floyd(vector<vector<ll>>& d) {
  ll n = SZ(d);
  REP(i, n) REP(j, n) REP(k, n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) { cin >> s[i]; }
  ll n = h * w;
  vector<vector<ll>> to(n, vector<ll>(n, INF));
  REP(i, n) { to[i][i] = 0; }
  vector<ll> d = {-1, 0, 1, 0};
  REP(i, h) REP(j, w) {
    if (s[i][j] == '#') continue;
    ll cur = f(i, j);
    REP(k, 4) {
      ll x = i + d[k];
      ll y = j + d[k ^ 1];
      if (x < 0 || x >= h) continue;
      if (y < 0 || y >= w) continue;
      if (s[x][y] == '#') continue;
      ll nxt = f(x, y);
      to[cur][nxt] = 1;
      to[nxt][cur] = 1;
    }
  }
  warshall_floyd(to);
  ll ans = 0;
  REP(i, n) REP(j, n) {
    if (to[i][j] == INF) continue;
    ans = max(ans, to[i][j]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,n);
  int ans = 1;
  REP(i,3){
    ans *= n;
  }
  OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
 
int main(void){
   int a,p;
   std::cin >> a>>p;
   std::cout << (3*a+p)/2 << std::endl;
   
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    string s;
    cin >> s;
    REP(i,100000){
        if(i==s.length()){
            break;
        }else if(i%2==0){
            cout << s[i];
        }
    }
}

Measured memory_bytes: 512
N,K = map(int, input().split())
D = list(map(int, input().split()))
nums = set([0,1,2,3,4,5,6,7,8,9])
nums -= set(D)
#print(nums)

ans = []
def func(s, nums):
    global ans
    if len(s) >= len(str(N)):
        if int(s) >= N:
            ans.append(int(s))

        
    if len(s) > len(str(N))+1:
        return

    for i in nums:
        func(s[:] + str(i), nums)


func("", nums)
ans.sort()
print(ans[0])

Measured memory_bytes: 90588
from collections import Counter

n = int(input())
A = list(map(int,input().split()))

cnt = Counter(A)

if len(cnt) == 1:
    if cnt[0] == n:
        print('Yes')
    else:
        print('No')
elif len(cnt) == 2:
    if cnt[0] == n/3:
        print('Yes')
    else:
        print('No')
elif len(cnt) == 3:
    test = 0
    for p in cnt.keys():
        if cnt[p] != n/3:
            print('No')
            break
        test ^= p
    else:
        if not test:
            print('Yes')
        else:
            print('No')
else:
    print('No')

Measured memory_bytes: 94068
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    map<ll,ll> mp;
    rep(i,n) mp[a[i]]++;
    ll sum = 0;
    rep(i,n) sum += a[i];
    int q; cin >> q;
    rep(_, q){
        int b,c; cin >> b >> c;
        ll cnt = mp[b];
        mp[b] = 0;
        mp[c] += cnt;
        sum += cnt*(c-b);
        cout << sum << endl;
    }
}


Measured memory_bytes: 9880
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
#define ex(k) (a*(b-n)+(a-b)*(k)-(k)*(k))
using namespace std;

int dsu[MAX];
int sz[MAX];

int search(int a)   {
    if(dsu[a]==a)   return a;
    return dsu[a]=search(dsu[a]);
}

void join(int a, int b)  {
    a = search(a);
    b = search(b);
    if(sz[a]>sz[b]) {
        dsu[b]=a;
        sz[a]+=sz[b];
    }
    else {
        dsu[a]=b;
        sz[b]+=sz[a];
    }
}

void solve()	{
    int n,m;
    cin >> n >> m;
    for(int i=1; i<=n; i++) {
        dsu[i]=i;
        sz[i]=1;
    }
    while(m--)  {
        int x,y;
        cin >> x >> y;
        if(search(x)!=search(y))    join(x,y);
    }
    int ans=-1;
    for(int i=1; i<=n; i++) {
        ans=max(ans,sz[search(i)]);
    }
    cout << ans << endl;
}

int main()	
{
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  const string vw = "aiueo";
  while (true) {
    int n; cin >> n;
    if (!n) break;
    V<string> s(n), t(n);
    for (int i = 0; i < n; ++i) {
      cin >> s[i];
      int m = s[i].size();
      t[i] = s[i][0];
      for (int j = 0; j < m - 1; ++j) if (vw.find(s[i][j]) != string::npos) {
        t[i] += s[i][j + 1];
      }
    }
    [&] {
      for (int k = 1; k <= 50; ++k) {
        set<string> se;
        for (const auto& e : t) {
          se.insert(e.substr(0, k));
        }
        if ((int)se.size() == n) {
          cout << k << '\n';
          return;
        }
      }
      cout << -1 << '\n';
    }();
  }
}


Measured memory_bytes: 3148
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args)  {
        try {
            Scanner scanner = new Scanner(System.in);
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if((a * b) % 2 == 0) {
                System.out.println("Even");
            } else {
                System.out.println("Odd");
            }
        } catch (InputMismatchException e) { 
              System.out.println("整数を入力してください。");
        }
    }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	VI s(n), t(m);
	rep(i, n) cin >>s[i];
	rep(i, m) cin >>t[i];
/*	
	vector<VL> dp(n+2, VL(m+2)), sm(n+2, VL(m+2));
	dp[0][0] = sm[1][1] = 1;
	rep(i, n+1) rep(j, m+1) if(i+j !=0){
		if(i && j && s[i-1] == t[j-1]) dp[i][j] = sm[i][j] % MD;
		sm[i+1][j+1] = (sm[i+1][j] + sm[i][j+1] - sm[i][j] + dp[i][j]+MD)%MD;
	}
	cout << sm[n+1][m+1] <<"\n";
*/
	vector<VL> dp(n+2, VL(m+2)); dp[0][0] =1;
	rep(i, n+1) rep(j, m+1){
		if(i>0 && j>0 && s[i-1]==t[j-1]) dp[i][j] += dp[i-1][j-1];
		dp[i][j] += (i>0? dp[i-1][j]: 0) + (j>0? dp[i][j-1]: 0);
		dp[i][j] += ((i>0 && j>0)? MD - dp[i-1][j-1]: 0);
		dp[i][j] %=MD;
	}
	cout << dp[n][m] <<"\n";
	//for(auto xl: dp){for(auto x :xl) cerr<<x<<" ";dbg("lcs");}

	return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
	if(!n1)return n2;
	if(!n2)return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
	base%=mod;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	ans%=mod;
	return ans;
}
int arr[3];
int main()
{
	for(int i=0;i<3;i++)sd(arr[i]);
	sort(arr,arr+3);
	if(arr[1]!=arr[0])cout<<arr[0]<<endl;
	else cout<<arr[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

    double total = accumulate(a.begin(), a.end(), 0);

    int po = 0;
    for (int i = 0; i < a.size(); i++)
    {
        if (a[i] >= total / (4.0 * m))
        {
            po++;
        }
    }

    if (po >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

//　if文
// if (num == 0)
// {
//     cout << "0";
// }
// else if (num == 1)
// {
//     cout << "1"; // 1が表示される
// }
// else
// {
//     cout << "01以外";
// }

Measured memory_bytes: 256
// code author: Dhruva Mahajan
 
// Ideas are cheap, execution is everything.
 
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long  
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define testcase(t) int t;cin>>t;while(t--)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

int main(){
	
	fastio;

	int a,b;
	cin>>a>>b;
	// char x=static_cast<char>(a), y=static_cast<char>(b);
	// string s1=string(b, x), s2=string(a, y);

	string s1="", s2="";
	for(ll i=0;i<a;i++){
		s1+=to_string(b);
	}
	for(ll i=0;i<b;i++){
		s2+=to_string(a);
	}

	if(b<a){
		cout<<s1<<endl;
		exit(0);
	}
	else if(b>a){
		cout<<s2<<endl;
		exit(0);
	}	

	else if(a==b){
		for(ll i=0;i<a;i++){
			if(s1[i]<s2[i]){
				cout<<s1<<endl;
				exit(0);
			}
			else if(s1[i]>s2[i]){
				cout<<s2<<endl;
				exit(0);
			}
		}
		cout<<s1<<endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
double dp[302][302][302];
int N;

double dfs(int a, int b, int c) {
	if (a==0 && b==0 && c==0)
		return 0;
	if (dp[a][b][c] > 0)
		return dp[a][b][c];
	int k = a + b + c;
	double ans = N*1.0;
	if (a) {
		ans += a * dfs(a-1, b, c);
	}
	if (b) {
		ans += b * dfs(a+1, b-1, c);
	}
	if (c) {
		ans += c * dfs(a, b+1, c-1);
	}
	return dp[a][b][c] = ans/k;
}

int main() {
	memset(dp, -1, sizeof(dp));
	std::cin>>N;
	std::vector<int> a(N+1);
	for (int i = 0; i < N; ++i) {
		int ai;
		std::cin>>ai;
		a[ai]++;
	}
	printf("%.10lf\n", dfs(a[1], a[2], a[3]));
	return 0;
}


Measured memory_bytes: 216056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const ll inf = 1e9+10;
 
 
int a[maxN];
int b[maxN];
int n,k,Q;
int main() {
	scanf("%d%d%d",&n,&k,&Q);
	for(int i=1;i<=n;i++)
	{
		a[i] = k;
	}
	for(int i=1;i<=Q;i++)
	{
		int x;
		scanf("%d",&x);
		a[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		a[i]-=Q;
		if(a[i]<=0)
		{
			puts("No");
		}
		else
		{
			puts("Yes");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

//The Genome Database of All Space Life
public class Main{

	static char[] s;
	static int id;
	static int len;

	static String msg(){
		StringBuilder sb = new StringBuilder();
		int x = 1;
		while(true){
			char ch = s[id++];
			if(Character.isDigit(ch)){
				id--;
				x = num();
			}
			else if(ch=='('){
				String t = msg();
				while(sb.length() <= len && x--!=0){
					for(int i=0;i<t.length();i++){
						if(sb.length() > len)break;
						sb.append(t.charAt(i));
					}
				}
				x = 1;
			}
			else if(Character.isUpperCase(ch)){
				while(sb.length() <= len && x--!=0)sb.append(ch);
				x = 1;
			}
			else break;
		}
		return sb.toString();
	}

	static int num(){
		char ch = s[id++];
		int x = ch - '0';
		while(true){
			ch = s[id++];
			if(!Character.isDigit(ch))break;
			x *= 10;
			x += ch - '0';
		}
		id--;
		return x;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String ss = sc.next();
			len = sc.nextInt();
			if(ss.equals("0") && len == 0)break;
			s = (ss+"#").toCharArray();
			id = 0;
			len++;
			String genom = msg();
			System.out.println(genom.length() >= len ? genom.charAt(len-1) : "0");
		}
	}
}

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

const int MAXN=305;
int n,m;
int tmp[MAXN][MAXN];
long long ans;
long long graph[MAXN][MAXN];

struct node{
	int u,v,w;
	node(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
	friend bool operator< (const node &a,const node &b){
		return a.w<b.w;
	}
}ed[MAXN*MAXN];

bool jud(node &e){
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i==j) continue;
			graph[i][j]=min(graph[i][j],graph[i][e.u]+e.w+graph[e.v][j]);
			graph[j][i]=graph[i][j];
			graph[i][j]=min(graph[i][j],graph[i][e.v]+e.w+graph[e.u][j]);
			graph[j][i]=graph[i][j];
			if(graph[i][j]<tmp[i][j]) return false;
		}
	}
	return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)
			scanf("%d",&tmp[i][j]);
	}
	for(int i=1;i<n;++i){
		for(int j=i+1;j<=n;++j)
			ed[++m]=node(i,j,tmp[i][j]);
	}
	sort(ed+1,ed+m+1);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)
			graph[i][j]=1e12;
	}
	for(int i=1;i<=n;++i) graph[i][i]=0;
	for(int i=1;i<=m;++i){
		if(graph[ed[i].u][ed[i].v]==ed[i].w) continue;
		graph[ed[i].u][ed[i].v]=ed[i].w;
		graph[ed[i].v][ed[i].u]=ed[i].w;
		ans+=ed[i].w;
		if(!jud(ed[i])){
			ans=-1;
			break;
		}
	}
	cout<<ans;
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int a,b;
    REP(i,7){
        cin >> a >> b;
        cout << a-b << endl;
    }
}



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

using namespace std;

int gcd(int a,int b){
    if(a>b)return gcd(b,a);
    int x = b%a;
    if(x==0){
        return a;
    }else{
        return gcd(x,a);
    }
}

int main(){
    int a,b;
    cin >> a >> b;
    cout << gcd(a,b) << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
map<ll, ll> mp;
int main(){
    int n; cin >> n;
    rep(i,n){
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    for(map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++){
        if(it->first <= it->second)ans += it->second - it->first;
        else ans += it->second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6272