akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
int cmp2(Pin a,Pin b){
    if(a.se!=b.se)
        return a.se<b.se;
    else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<Pin>ab(n);
    vector<Pin>cd(n);
    for(int i=0;i<n;i++){
        cin>>ab[i].fi>>ab[i].se;
    }
    for(int i=0;i<n;i++){
        cin>>cd[i].fi>>cd[i].se;
    }
    sort(all(ab));sort(all(cd));
    bool usedcd[100];
    int ans=0;
    
    int ans2=0;
    memset(usedcd,0,sizeof(usedcd));
    for(int i=0;i<n;i++){
        bool abc=0;
        int maxy=-1;
        int usei=0;
        for(int j=0;j<n;j++){
            if(usedcd[j])
                continue;
            if(ab[j].fi>=cd[i].fi)
                continue;
            if(ab[j].se<cd[i].se){
                abc=1;
                if(ab[j].se>maxy){
                    maxy=ab[j].se;
                    usei=j;
                }
            }
        }
        if(abc==1){ans2++;
            usedcd[usei]=1;}
    }
    chmax(ans,ans2);
    
    cout<<ans<<Endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;
    int num = 0;
    vector<int> accum_num(n+1);
    accum_num[0] = 0;
    accum_num[1] = 0;
    for (int i = 1; i <= n; ++i) {
        if (s[i-1] == 'A' && s[i] == 'C') {
            accum_num[i+1] = accum_num[i] + 1;
        }
        else {
            accum_num[i+1] = accum_num[i];
        }
    }
    //for (auto p: accum_num) {
    //    cout << p << " ";
    //}
    //cout << endl;
    vector<int> l(q);
    vector<int> r(q);
    rep(i, q) {
        cin >> l[i] >> r[i];
    }
    rep(i, q) {
        int ans;
        ans = accum_num[r[i]] - accum_num[l[i]-1];
        //cout << s[l[i]-1] << " " << s[l[i]] << endl;
        if (l[i] >= 2 && s[l[i]-1] == 'C' && s[l[i]-2] == 'A') --ans;
        cout << ans << endl;
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

void solve(){
    int v=10;
    int h,w;cin>>h>>w;
    int ans=0;
    int c[v][v];
    fol(i,v){
        fol(j,v){
            cin>>c[i][j];
        }
    }
    fol(k,v){
        fol(i,v){
            fol(j,v){
                c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    int l;
    fol(i,h){
        fol(j,w){
            cin>>l;
            if (l!=-1){
                ans += c[l][1];
            }
        }
    }

    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
def f(a, b)
    return f(b, a) if a.size > b.size
    return b.inject(0, :+) if a.empty?
    return a[0] + f(a[1..-1], b[1..-1]) if a[0] == b[0]
    return a[0] + f(a[1..-1], b) if a[0] < b[0]
    return b[0] + f(a, b[1..-1])
end

while 0
    w, d = gets.split.map(&:to_i)
    break if w == 0
    a = gets.split.map(&:to_i).sort
    b = gets.split.map(&:to_i).sort
    p f(a, b)
end



Measured memory_bytes: 6872
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

S = input()
x, y = reads()
qs = [len(s) for s in S.split('T')]

def knapsack(xs, target):
  es = {0}
  for x in xs:
    es = {e - x for e in es} | {e + x for e in es}
  return target in es

ans = knapsack(qs[2::2], x-qs[0]) and knapsack(qs[1::2], y)
print("Yes" if ans else "No")

Measured memory_bytes: 67036
n = int(input())
p = [int(i) for i in input().split()]
p_asc = [i for i in range(1, n + 1)]
p_diff = [pi - p_asci for pi, p_asci in zip(p, p_asc)]
if (p_diff.count(0) == n) or (p_diff.count(0) == n - 2):
    print('YES')
else:
    print('NO')

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

using namespace std;

#define ll long long 

const int N = 10;
int id[N];
int x[N],y[N];
int n;
double dis(int a,int b){
	return sqrt( (x[id[a]] - x[id[b]]) * (x[id[a]] - x[id[b]]) *1.0 +(y[id[a]] - y[id[b]]) * (y[id[a]] - y[id[b]])) ;
}

int main(){
	cin >> n;
	for(int i=1;i<=n;++i){	cin >> x[i] >>y[i]; id[i] = i;}

	double tot = 0;
	int cnt = 0;
	do{
		cnt ++;
		double tmp = 0;
		for(int i=2;i<=n;++i){
			tmp += dis(i,i-1);
		}
//	cout <<tmp << '\t';
		tot += tmp;
	}while(next_permutation(id+1,id+1+n));
	printf("%.10lf\n",tot/cnt);
} 	

Measured memory_bytes: 256
//Code taken from geeksforgeeks

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// int fact(int n);
// int nCr(int n, int r) 
// { 
//     return fact(n) / (fact(r) * fact(n - r)); 
// } 
  
// // Returns factorial of n 
// int fact(int n) 
// { 
//     int res = 1; 
//     for (int i = 2; i <= n; i++) 
//         res = res * i; 
//     return res; 
// } 

int main()
{
	string s, str, a1, a="", b1, b="";
	cin>>s;
	str=s;

	reverse(str.begin(), str.end()); 
	for(int i = 0; i < (s.size()-1)/2; i++)
	{
		a+=s[i];
	}
	a1=a;
	reverse(a1.begin(), a1.end());

	for(int i = (s.size()+3)/2 -1; i < s.size(); i++)
	{
		b+=s[i];
	}
	b1=b;
	reverse(b1.begin(), b1.end());
	if(s==str and b1==b and a1==a)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	// int n, m;
	// cin>>n>>m;
	// cout << nCr(n, 2)+nCr(m, 2); 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include<string>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+4;
int main(){
    ll x;
    while(cin>>x){
    	if(x&1)
    		printf("%lld\n",2*x);
    	else
    		printf("%lld\n",x);
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int[] array = new int[num];

		for(int i = 0; i < num; i++){
			array[i] = sc.nextInt();
		}
		for(int i = 0; i < num/2;i++){
			int j = array[i];
			array[i] = array[num - 1 - i];
			array[num - 1 - i] = j;
		}
		for(int v = 0;v < num; v++){
			if(v != 0){
				System.out.print(" ");
			}

			System.out.print(array[v]);
		}
		System.out.println();
	}

}


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

int main(){
  int N, K;
  
  cin >> N >> K;
  int H_data[N];
  
  int H;
  for(int i=0;i<N;i++){
  	cin >> H;
    H_data[i] = H;
  }
  
  int rem = N - K;
  if(rem <= 0){
    cout << "0" << endl;
  }
  else{
	sort(H_data, H_data+N);
    
    long long int count = 0;
    for(int i=0;i<rem;i++){
      count += H_data[i];
    }
    
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int a,b,k;
    int c[200];
    scanf("%d%d%d",&a,&b,&k);
    int j=0;
    int d=min(a,b);
    for(int i=1;i<=d;i++)
    {
        if(a%i==0&&b%i==0)
        {
            c[j]=i;
            j++;
        }
    }
    sort(c,c+j,cmp);
    printf("%d\n",c[k-1]);
}


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


int main() {
	
	int N;
	cin >> N;
	multiset<int> s;
	for(int i=0; i<N; i++){
		int a;
		cin >> a;
		s.insert(a);
	}
	
	int xmax = 0;
	for(int i=0; i<pow(10,5); i++){
		xmax = max( xmax, (int)s.count(i-1) + (int)s.count(i) + (int)s.count(i+1) );
	}
	cout << xmax << endl;
	
	
	return 0;
}

Measured memory_bytes: 4992
fun main(args: Array<String>) = IO().exec {
    val n = int()
    val l = long()
    val a = LongArray(n){long()}
    var k = -1
    for (i in n-1) if (a[i] + a[i+1] >= l) {
        k = i
        break
    }
    if (k == -1) println("Impossible")
    else {
        println("Possible")
        for (i in k) println(i+1)
        for (i in n-2 downTo k+1) println(i+1)
        println(k+1)
    }
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 38520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int c[2],k;
    cin>>c[0]>>c[1]>>k;
    rep(i,k){
        if(c[i%2]&1){
            c[i%2]--;
        }
        c[(i+1)%2] += c[i%2]/2;
        c[i%2]/=2;
    }
    cout<<c[0]<<" "<<c[1]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

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

int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int ans = min(K, N) * X + max(0, (N - K)) * Y;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int go(int a, int b, int c) {
	if(a % c == 0) {
		return 2 * a;
	}
	int ans = 0;
	ans += a / c * 2 * c + c;
	ans += go(c-a%c, c, a%c) + a % c;
	return ans;
}

signed main()
{
	IO_OP;
	
	int n, x;
	cin >> n >> x;
	cout << x + go(x, n, n-x) << endl;
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

	char letter = s.front();
	int sum = 0;
	for (char c : s)
	{
		if (c != letter)
		{
			++sum;
			letter = c;
		}
	}
	++sum;
	cout << sum << endl;
}

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

int main()
{
    //long long H;
    //int t;
    //queue<int> H;
    //priority_queue<int> H;
    long long res = 0;
    long long t;
    long long a;

    res = 1;
    t = 1;

    cin >> a;
    //cout << t << endl;
    //a = log2(t);
    //cout << a << endl;
    while (a != 1)
    {
        a /= 2;
        res += t;
        t *= 2;
    }
    res += t;

    cout << res - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;

    int ans=0;

    for(int i = 1; i<n+1;i++){
        string s;
        s = to_string(i);
        int res =0;
        for(int j=0;j<s.size();j++){
            int m;
            m = s[j] - '0';
            res += m;
        }
        if (a<=res&&res<=b){
            ans +=i;
        }
    }


    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >>H >>W;
  vector<string>v(H+2);
  for(int i=0;i<H+2;i++){
    if(i==0||i==H+1)
      for(int j=0;j<W+2;j++)
        v[i]+='.';
    else{
    cin >>v[i];
    v[i]="."+v[i]+".";
    }
  }
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      if (v[i][j]=='.')
      cout <<(v[i-1][j-1]=='#')+(v[i][j-1]=='#')+(v[i+1][j-1]=='#')
        +(v[i-1][j]=='#')+(v[i+1][j]=='#')
        +(v[i-1][j+1]=='#')+(v[i][j+1]=='#')+(v[i+1][j+1]=='#');
      else
        cout <<'#';
      if (j==W)
        cout <<endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include <string>
#include <utility>
#define EPS (1e-7)
using namespace std;




int main() {

	int N;
	cin >> N;
	vector<int> a;
	a.resize(N);
	int mx = -1000;
	int mn = 1000;
	int ans = 1000000000;
	
	for (auto i = 0; i < N; i++) {
		cin >> a[i];
		mx = max(a[i], mx);
		mn = min(a[i], mn);
	}
	vector<int> cost(mx - mn + 1, 0);


	for (auto i = mn; i < mx + 1; i++) {
		for (auto j = 0; j < N; j++) {
			cost[i-mn] += abs(i - a[j])*abs(i - a[j]);
		}

	}

	for (auto i = 0; i < mx-mn+1; i++) {
		ans = min(ans, cost[i]);
	}


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll gcd(long long a,long long b) {
    return b ? gcd(b,a%b) : a;
}

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

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for (int i = 1;i <= n;i++){
        string s = to_string(i);

        char Head = s[0];
        char Back = s.back();
        s.clear();
        s += Head;
        s += Back;

        mp[s]++;
    }

    long long ans = 0;

    for (pair<string,int> p : mp){
        string s  = p.first;
        swap(s[0],s[1]);
        ans += p.second * mp[s];
    }

    cout << ans << endl;
    

}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n-1);
	for(int& x : a) { cin >> x; x--; }
	for(int& x : b) cin >> x;
	for(int& x : c) cin >> x;
	
	int ans = 0;
	
	for(int i = 0; i < n; i++) {
		ans += b[a[i]];
	}
	cerr << ans << endl;
	for(int i = 0; i < n-1; i++) {
		if(a[i]+1 == a[i+1]) {
			ans += c[a[i]];
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		char[] c = N.toCharArray();
		int s = 1;
		int t = 1;
		for(int i=0;i<N.length();i++){
			if(s==1){
				if(c[i]=='L'){t*=0;}
			}
			if(s==-1){
				if(c[i]=='R'){t*=0;}
			}
			s *= -1;
		}
		System.out.println((t==1)?"Yes":"No");
		sc.close();
	}
	
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  int x = 0;
  for (int i=0; i<s.size(); i++) {
    if (s.at(i) == 'I') {
      x++;
    } else {
      x--;
    }
    ans = max(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N,M,X  = map(int, input().split()) 
    C = []
    for _ in range(N):
        c=list(map(int, input().split()))
        C.append(c)
    
    min = -1

    for i in range(2 ** N):
        bag = []
        OK = False
        for j in range(N):  
            if ((i >> j) & 1):  
                bag.append(C[j])
        sumlist=[0]*(M+1)
        for j in range(len(bag)):
            for k in range(M+1):
                sumlist[k] += bag[j][k]
        for j in range(M):
            if(sumlist[j+1] < X):
                OK = False
                break
            else:
                OK = True
        if OK and (min==-1 or min > sumlist[0]):
            min = sumlist[0]

    print (min)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9240
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
    int a,b,c,d;
	cin>>a>>b>>c>>d;
	int a1,a2;
	a1=a*b;
	a2=c*d;
	if(a1<=a2)
	cout<<a2;
	else
	cout<<a1; 
   return 0; 
} 

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define npos std::string::npos
typedef long long ll;
using namespace std;
int main()
{
	int N, M;
  	cin >> N >> M;
  	int maxL = 1, maxR = N;
  	for (int i = 0; i < M; i++){
    	int L, R;
      	cin >> L >> R;
      	if (maxL < L){
        	maxL = L;
        }
      	if (maxR > R){
        	maxR = R;
        }
    }
  	cout << max(0, maxR - maxL + 1) << endl;
}



Measured memory_bytes: 256
S = input()

alpha2num = lambda c: ord(c) - ord('a') + 1
num2alpha = lambda c: chr(c+96)

snum = list(map(alpha2num, list(S)))

def next_snum(snum):
    if len(snum) <26:
        for i in range(1,27):
            if not i in snum:
                snum.append(i)
                return snum
    else:
        for i in range(25,0,-1):
#             print("hoge")
            # 後ろから見ていき、左より右が大きいことがあれば、
            if snum[i-1] < snum[i]:
                # i-1番目は消す。i番目以降で、i-1より大きく、もっとも小さい数を足す
                # snum[i]は必ず該当するので、そのようなminnumが1つ以上存在する
                minnum = 27
                for nxt in snum[i:]:
                    if minnum > nxt and nxt > snum[i-1]:
                        minnum = nxt
                        
#                 print("nxt:",nxt)
                snum = snum[:i-1] + [minnum]
#                 print(snum)
                return snum
        # 1つも上記のようなものがなければ、次のSは存在しない
        return -1

result_num = next_snum(snum)

if result_num == -1:
    print(-1)
else:
    print("".join(list(map(num2alpha,result_num))))

Measured memory_bytes: 38384
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n ,m;
    cin >> n >> m;

    map<int,int> mp;

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }

    for(auto &i : mp){
        if(i.second % 2 != 0){
            cout << "NO" << endl;
            return 0; 
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 4352
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
i = 1
t = s[0]
c = 1
while i < len(s):
#    print(i,t,c)
    if s[i] == t:
        t = s[i:i+2]
        i += 1
    else:
        t = s[i]
    if i >= len(s):
        break
    c += 1
    i += 1
print(c)

Measured memory_bytes: 5148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int K = sc.nextInt();
    	int[] ary = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    	sc.close();
    	System.out.println(ary[K-1]);
    }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  ld w, h, x, y; cin >> w >> h >> x >> y;
  cout << w * h / 2.0 << " ";

  if (x + x == w && y + y == h) cout << 1 << endl;
  else cout << 0 << endl;

  return (0);
}


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

int main() {
	int N; cin >> N;
	vector<int> W(N);
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += W[i];
	}

	int ans = 100000;

	for (int t = 0; t < N; t++) {
		int l = 0; int r = 0;
		for (int i = 0; i <= t; i++) {
			l += W[i];
		}
		r = sum - l;

		if (ans > abs(r - l)) {
			ans = abs(r - l);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#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 whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,m;cin>>n>>m;
	map<ll,ll> wrong;
	map<ll,ll> cor;
	vector< pair<ll,pii > > a;

	ll pn=0,sc=0;
	rep(i,0,m)
	{
		ll p;cin>>p;
		string s;cin>>s;

		if(cor[p]==1) continue;

		if(s=="WA") wrong[p]++;
		if(s=="AC") sc++,cor[p]=1;
	}
	all(it,cor) if(cor[it->F]==1) pn+=wrong[it->F];
	cout<<sc<<" "<<pn<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 12800
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

NUM = [-1]*N
K = int(input())
for _ in range(K):
    a, b = map(int, input().split())
    NUM[a-1] = b
    root = a-1

MIN = [None]*N
MAX = [None]*N

rootnum = NUM[root]
checked = [False]*N
def dfs(p, d):
    checked[p] = True
    minnum, maxnum = rootnum-d, rootnum+d
    ok = True
    for np in graph[p]:
        if not checked[np]:
            ok = dfs(np, d+1) and ok
            if MIN[np]%2 == minnum%2 or MAX[np]%2 == minnum%2:
                ok = False
            minnum = max(minnum, MIN[np]-1)
            maxnum = min(maxnum, MAX[np]+1)
    if maxnum < minnum:
        ok = False
    if NUM[p] != -1:
        if not (minnum <= NUM[p] <= maxnum):
            ok = False
        MAX[p] = NUM[p]
        MIN[p] = NUM[p]
    else:
        MAX[p] = maxnum
        MIN[p] = minnum
    return ok

if not dfs(root, 0):
    print("No")
else:
    print("Yes")
    checked = [False]*N
    q = [root]
    while q:
        qq = []
        for p in q:
            pnum = NUM[p]
            for np in graph[p]:
                if not checked[np]:
                    if NUM[np] == -1:
                        if MIN[np] <= pnum+1 <= MAX[np]:
                            NUM[np] = pnum+1
                        else:
                            NUM[np] = pnum-1
                    qq.append(np)
                    checked[np] = True
        q = qq
    
    print(*NUM, sep="\n")

Measured memory_bytes: 125236
import java.io.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * @see format
 */
public class Main {

    private static BufferedReader br;
    private static StreamTokenizer st;
    private static PrintWriter pw;

    static final int INF = 1000000007;
    static int MOD = (int) (1e9 + 7);


    private static void solve() throws IOException {
        long w = nextInt();
        long h = nextInt();
        long x = nextInt();
        long y = nextInt();
        double res = w * h / 2.0;
        int res2 = (x * 2 == w && y * 2 == h) ? 1 : 0;
        pw.println(res + " " + res2);
    }

    public static void main(String args[]) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(br);
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        st.ordinaryChar('\''); //指定单引号、双引号和注释符号是普通字符
        st.ordinaryChar('\"');
        st.ordinaryChar('/');

        solve();
        pw.flush();
    }

    static String next(int len) throws IOException {
        int b = br.read();
        while (b == '\n' || b == ' ' || b == '\r' || b == '\t') {
            b = br.read();
        }
        char ch[] = new char[len];
        ch[0] = (char) b;
        int idx = 1;
        while (idx < len && (b = br.read()) != ' ' && b != '\n' && b != '\r' && b != '\t') {
            ch[idx++] = (char) b;
        }
        return String.valueOf(ch).trim();
    }

    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    private static double nextDouble() throws IOException {
        st.nextToken();
        return st.nval;
    }

    private static String[] nextSS(String reg) throws IOException {
        return br.readLine().split(reg);
    }

    private static String nextLine() throws IOException {
        return br.readLine();
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

struct A {
    int l;
    int r;
    int length;
};


int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> a;
    vector<A> b;
    int cnt = 0;
    s.push_back('0');

    int tl = -1;
    int tr = -1;
    int tlen = 0;
    b.push_back({tl, tr, tlen});
    
    REP(i,n) {
        if (s[i] == '1' && s[i+1] == '1') {
            if (cnt == 0) {
                cnt++;
            }
            cnt++;
        } 
        else if (s[i] == '1' && s[i+1] == '0') {
            if (cnt == 0) {
                ++cnt;
            }
            int l = i+1-cnt;
            int r = i;
            int len = cnt;
            b.push_back({l, r, len});
            cnt = 0;
        }
    }
    if (s[n-1] == '0') {
        int l = n;
        int r = n;
        int len = 0;
        b.push_back({l, r, len});
    }

    /*std::sort(b.begin(), b.end(), [](const A &x, const A &y) {
        return x.length > y.length;
    });*/
    /*for (auto &&e: b) {
        printf("%d, %d, %d\n", e.l, e.r, e.length);
    }*/
    /*
    for (auto && e: b) {
        if (e.length == 1)
        for (int i = e.l; i < e.r; ++i) {
            s[i] = '1';
            cntk++;
        }
        if (cntk == k) {
            REP(i,n) {
                if (s[i] == '1') ++ans;
            }
            break;
        }
    }
    */

   int ans = 0;
   for (int i = 0; i < b.size(); ++i) {
       int tmp = b[i].length;
       for (int j = 1; j <= k; ++j) {
           if (i+j == b.size()) {
               break;
           }
           tmp += b[i+j].l-b[i+j-1].r-1;
           tmp += b[i+j].length;
       }
       ans = max(tmp, ans);
   }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){
    
    int a,b,c,d,e,k;

    cin >> a >> b >> c >> d >> e >> k;

    if((e-a)<=k){
        cout << "Yay!";
    }else{
        cout << ":(";
    }

    return 0;
}

Measured memory_bytes: 256
class DisjointSet():
    def __init__(self, size):
        self.rank = [None] * size
        self.p = [None] * size
        for i in range(size):
            self.makeSet(i)

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def same(self,x,y):
        return self.findSet(x) == self.findSet(y)

    def unite(self,x,y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

n,q = map(int, input().split())
ds = DisjointSet(n)
for i in range(q):
    t,a,b = map(int, input().split())
    if t == 0:
        ds.unite(a,b)
    elif t == 1:
        if ds.same(a,b):
            print("1")
        else:
            print("0")

Measured memory_bytes: 8060
W, H, N = map(int, input().split())
xya = [tuple(map(int, input().split())) for _ in range(N)]

top = H
bottom = 0
left = 0
right = W
for x, y, a in xya:
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        bottom = max(bottom, y)
    elif a == 4:
        top = min(top, y)

if right-left < 0 or top-bottom < 0:
    print(0)
else:
    print((right-left)*(top-bottom))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<string,string> P;


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

  vector<string> A[101];
  for(int i=0,m;i<n;i++) {
    cin>>m;
    A[i].resize(m);
    for(int j=0;j<m;j++)cin>>A[i][j];
  }

  map<P,int> M;
  for(int i=0;i<n;i++)
    for(int j=0;j<A[i].size();j++)
      for(int k=j+1;k<A[i].size();k++){
	string a = A[i][j],b = A[i][k];
	if(a>b) swap(a,b);
	M[P(a,b)]++;
      }


  
  map<P,int>::iterator it = M.begin();
  vector<P> ans;
  for(;it!=M.end();it++){
    string a = it->first.first;
    string b = it->first.second;
    if(it->second>=K)ans.push_back(P(a,b));
  }

  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++)cout<<ans[i].first<<" "<<ans[i].second<<endl;
  
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int &x: a) cin>>x;
  set<int> b;
  for(int i=0;i<N;i++){
  b.insert(a[i]);
  }
  cout<<b.size()<<endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
 
int v[60],tp[60],ans,N,K;
 
int main()
{
	cin >> N >> K;
	for(int i = 1; i <= N; i++) cin >> v[i];
	for(int i = 1; i <= K && i <= N; i++){
		for(int l = 0; l <= i; l++){
			int cnt = 0, sum = 0;
			for(int j = 1; j <= l; j++) tp[++cnt] = v[j];
			for(int j = N; j > N-i+l; j--) tp[++cnt] = v[j];
			sort(tp+1,tp+cnt+1);
			for(int j = 1; j <= K-i; j++)
				if(tp[j]>0) break;
					else tp[j]=0;
			for(int j = 1; j <= cnt; j++) 
				sum += tp[j];
			ans = max(ans,sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())


def prime_numbers(n):
    """
    n以下の素数列挙
    O(n)
    """
    eratosthenes = [2] * (n + 1)
    eratosthenes[1] = 1
    num_sum = 1
    for i in range(2, n // 2 + 1):
        k = 2
        while True:
            if i * k < n + 1:
                eratosthenes[i * k] += 1
                k += 1
            else:
                break

    return eratosthenes, num_sum


eratos, num_sum = prime_numbers(N)
ans = 0
for i in range(N):
    ans += eratos[i+1]*(i+1)
print(ans)

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b; cin >> a >> b;
    if(a*b%2) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	ll q, h, s, d,n;
	cin >> q >> h >> s >> d;
	cin >> n;
	ll bestprice1 = min({ q * 4,h * 2,s });
	ll bestprice2 = min({ q * 8,h * 4,s * 2,d });
	if (bestprice1*2>=bestprice2) {
		cout << n / 2 * bestprice2 + n % 2 * bestprice1 << endl;
	}
	else {
		cout << n * bestprice1 << endl;
	}
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main() {
  int n, x;
  cin >> n >> x;
  vl a(n + 1);
  rep1 (i, n) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] + a[i + 1] > x) {
      ans += a[i] + a[i + 1] - x;
      a[i + 1] = a[i + 1] - (a[i] + a[i + 1] - x);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>
using namespace std;
int dx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
int dy[] = { -1, -1, -1, 0, 1, 1, 1, 0 };

int main(){
	int w, h;
	while( cin >> w >> h && w && h ){
		int field[50][50];
		stack< pair<int, int> > st;
		for( int i = 0; i < h; i++ ){
			for( int j = 0; j < w; j++ ){
				cin >> field[i][j];
			}
		}
		int sum = 0;
		for( int i = 0; i < h; i++ ){
			for( int j = 0; j < w; j++ ){
				if( field[i][j] == 1 ){
					sum++;
					field[i][j] = 0;
					st.push( pair<int, int>(i, j) );
					//cout << i << ' ' << j << endl;
					while( !st.empty() ){
						//cout << st.top().second << ' ' << st.top().first << endl;
						int x0 = st.top().second;
						int y0 = st.top().first;
						st.pop();
						for( int k = 0; k < 8; k++ ){
							int x = x0 + dx[k];
							int y = y0 + dy[k];
							if( 0 <= x && x < w && 0 <= y && y < h && field[y][x] == 1 ){
								st.push( pair<int, int>(y, x) );
								field[y][x] = 0;
								//cout << y << ' ' << x << endl;
							}
						}
					}
				}
			}
		}
		cout << sum << endl;
	}
}

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

const int N = 200005;
typedef long long ll;


int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	string s;
	cin>>s;
	int n = s.size();
	string t = "keyence";
	if(s == t){
		cout<<"YES";
		return 0;
	}
	
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			string hano = "";
			for(int k=0;k<i;k++){
				hano += s[k];
			}
			for(int k=j+1;k<n;k++){
				hano += s[k];
			}
			if(hano == t){
				cout<<"YES";
				return 0;
			}
		}
	}
	
	cout<<"NO";
	
	return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(101);
    for(int i=0;i<n;i++){
       cin>>a[i];
    }
    vector<bool> dp(k+1,0);
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(a[j]>i){continue;}
            if(dp[i-a[j]] == 0){
                dp[i]=1;
            }
        }
    }
    if(dp[k] == 1){
        cout<<"First";
    }else{
        cout<<"Second";
    }
    return 0;
    
}

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

int main(){
	char s[256];
	int line=0,length;
	while(~scanf("%s",s)){
		length=strlen(s);
		int i=0;
		for(;i<length/2;i++){
			if(s[i]!=s[length-1-i]) break;
		}
		if(i==length/2) line++;
	}
	printf("%d\n",line);
	return 0;
}

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

using ll= long long;           
#define vl vector<ll>               //vector 1D
#define all(v) (v).begin(),(v).end()    

#define pb(x) push_back(x)
#define Blegh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ugh ll z;cin>>z;while(z--){solve();}
#define nummy ll n;cin>>n;
#define inf 1e9
#define rep(i,n) for(ll i=0;i< (n) ;++i)
#define repb(i,n) for(ll i=n-1;i>=0 ;--i)
#define ff(i,k,n) for (ll i = k; i <= n; ++i) 
#define fb(i,k,n) for (ll i = k; i >= n; --i) 
////////////////////////////////////////////////////////////////////////////////

int main() {
    ll A,B;
    cin>>A>>B;
    cout<<A*B;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
const int MAXN = 105;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
int a[MAXN][MAXN];
int color[MAXN];
int d[MAXN];
int f[MAXN];
int n, tt = 0;
using namespace std;

void dfs(int u)
{
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	for(v = 0; v < n; v++)
	{
		if(a[u][v] == 0)
			continue;
		if(color[v] == WHITE)
		{
			dfs(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs_init()
{
	int u;
	for(u = 0; u < n; u++)
		color[u] = WHITE;
	
	for(u = 0; u < n; u++)
	{
		if(color[u] == WHITE)
			dfs(u);
	}
	
	for(u = 0; u < n; u++)
	{
		cout << u+1 << " " << d[u] << " " << f[u] << endl;	
	}	
} 

int main ()
{
	int k, u, temp;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> u >> k;
		u--;
		for(int j = 0; j < k; j++)
		{
			cin >> temp;
			temp--;
			a[u][temp] = 1;
		}
	}
	dfs_init();
	return 0;
} 


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x < y) x = y;}
template<class T> void chmax(T& x, T y){if(x > y) x = y;}
db L;
int main(){
    cin >> L;
    cout << fixed << setprecision(15) << L * L * L / (db)27 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def solve(N, H, A, B):
    a_max = max(A)
    ans = 0
    for b in sorted(B, reverse=True):
        if H <= 0:
            break

        if b > a_max:
            H -= b
            ans += 1
        else:
            break
    if H > 0:
        ans += ceil(H, a_max)
    return ans


def main():
    N, H = map(int, input().split())
    A, B = [], []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    print(solve(N, H, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 12852
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[];j=0
 for l in L:
  while j-len(R)and R[j]<l:T+=[R[j]];j+=1
  T+=[l]
 while j-len(R):T+=[R[j]];j+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 61868