akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll H, W,K;
	cin >> H >> W>>K;

	ll S[20][2000];

	repn(i, H) {
		string s;
		cin >> s;

		repn(j, W) {
			S[i][j] = s[j - 1]-'0';
		}
	}

	ll ans = INF;

	ll p = 1;

	rep(i, H-1) { p *= 2; }

	rep(c, p) {
		vector<ll> a(H);
		repn(i, H - 1) { a[i] = (c >> (i - 1)) % 2; }
		vector<ll> cut(H+1);
		cut[1] = 1;
		repn(i, H - 1) { cut[i + 1] = cut[i] + a[i]; }

		ll M = cut[H];

		ll v = M - 1;

		vector<ll> choco(M + 1, 0);
		repn(j, W) {

			repn(i, H) {
				choco[cut[i]] += S[i][j];
			}

			ll b = 1;
			repn(i, M) {
				if (choco[i] > K) { b = 0; }
			}

			if (b == 1) { continue; }

			v++;
			repn(i, M) { choco[i] = 0; }

			repn(i, H) { choco[cut[i]] += S[i][j]; }

			b = 1;
			repn(i, M) { if (choco[i] > K) { b = 0; } }

			if (b == 0) { v = INF; break; }
		}
		
		
		ans = min(v, ans);
	}

	cout << ans;

	system("PAUSE");

}


Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;++i)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int ans = 0;
    for(int a=0;a<n;++a)
    {
        int k = a + 2;
        for(int b=a+1;b<n;b++)
        {
           
            while(k < n && v[a] + v[b] > v[k])
            {
                ++k;
            }
            if(k > b)
            {
                ans += k - b - 1;
            }
            
        }
    }
    cout<<ans<<endl;
    
    return 0;

}


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

int main() {
    int k, x;
    int count = 0;

    cin >> k >> x;

    for (int i = (x - k + 1); i < (x + k); i++) {
        cout << ((count++) ? " " : "") << i;
    }

    cout << endl;
    return 0;
}

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        vector<pair<long, long>> a(n);
        for (auto &p : a) {
            cin >> p.first >> p.second;
        }
        double sum = 0;
        for (long i = 0; i < n; i++) {
            for (long j = i+1; j < n; j++) {
                long xi = a[i].first;
                long yi = a[i].second;
                long xj = a[j].first;
                long yj = a[j].second;
                sum += sqrt(pow(xi - xj, 2) + pow(yi - yj, 2));
            }
        }
        double ans = 2 * sum / n;
        printf("%.10f\n", ans);
    }
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    int d, A;
    bool Sunuke[110] = {};
    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> A;
            Sunuke[A - 1] = true;
        }
        
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (!Sunuke[i]) ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3192
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

countA,countB = 0,0

for i in range(N):
  if A[i] <= B[i]:
    countA += (B[i]-A[i])//2
  else:
    countB += A[i]-B[i]
if countA >= countB:
  ans = "Yes"
else:
  ans = "No"

print(ans)

Measured memory_bytes: 4596
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int n;
int res;

int main()
{
	scanf("%d", &n);
	while (n--) {
		int l, r; scanf("%d %d", &l, &r);
		res += r - l + 1;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
/*
“Being happy doesn't mean that everything is perfect.
It means that you decided to look beyond the imperfections.”
*/

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


#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define ii pair<int,int>
#define fr(i,x,n) for(i = x ; i< n ; i++)
#define f(i,n) for(i = 0 ; i< n ; i++) 
#define ff first
#define ss second
#define pb push_back
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
int i, j, k, l, n, a, c, nn, t, dot=0, toko=0, x, y, z;
// void solve();



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
//	freopen("input.txt", "r",stdin);
//	freopen("output.txt", "w", stdout);
   cin >> n;
   bool b=false;
   while(n)
   {
       if(n%10 == 7) b =true;
       n/=10;
   }

   if(b) cout << "Yes";
   else cout << "No";
}







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

int main()
{
    int n, k;
    cin >> n >> k;
    if (n % k == 0)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    
    // input from txt （提出時にこの箇所は削除すること）
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    s.at(3) = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, m = LI()
    a = LI()
    if n - sum(a) >= 0:
        print(n - sum(a))
    else:
        print('-1')

    return


if __name__ == "__main__":
    solve()

Measured memory_bytes: 68280
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] al = new long[n];
        long[] cl = new long[n+1];
        long[] tl = new long[n+1];
        long total = 0;
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            al[i] = a;
            cl[a]++;
        }
        for(int i = 1; i < n+1; i++){
            tl[i] = cl[i] * (cl[i]-1) / 2;
            total += tl[i];
        }
        for(long a : al){
            int ai = (int)a;
            long alt = (cl[ai]-1)*(cl[ai]-2)/2;
            System.out.println(total - tl[ai] + alt);
        }
    }
}


Measured memory_bytes: 106132
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int dic[26];
    for (int i=0; i<26; ++i) dic[i] = 0;
    dic['I'-'A'] = 1;
    dic['V'-'A'] = 5;
    dic['X'-'A'] = 10;
    dic['L'-'A'] = 50;
    dic['C'-'A'] = 100;
    dic['D'-'A'] = 500;
    dic['M'-'A'] = 1000;
    string s;
    while (cin >> s) {
        int res = 0;
        for (int i=0; i<s.size()-1; ++i) {
            if (dic[s[i+1]-'A'] > dic[s[i]-'A'])
                res -= dic[s[i]-'A'];
            else
                res += dic[s[i]-'A'];
        }
        res += dic[s[s.size()-1]-'A'];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 0
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ll x,h=0;
    cin >> x;
    h+=(x/500)*1000;
    // x = x - (x/500)*500;
    x%=500;

    h+=(x/5)*5;
    x = x - (x/5)*5;
    cout << h << endl;
    
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

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

int main() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    if ((std::abs(a - c) <= d) || ((std::abs(a-b) <= d) && (std::abs(b-c) <= d))) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        if(s.length() <= k){
            System.out.println(s);
        }
        else{
            System.out.println(s.substring(0,k) + "...");
        }
    }
}

Measured memory_bytes: 38536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll n,a,ans=0;
    cin >> n >> a;
    ll x[n];
    for (ll i=0;i<n;i++)cin >> x[i];
    ll ave[n+2][n+2][50*n+10];
    for (ll i=0;i<=n;i++){
        for (ll j=0;j<=n;j++){
            fill(ave[i][j],ave[i][j]+(50*n)+5,0);
        }
    }
    ave[0][0][0]=1;
    for (ll i=0;i<n;i++){
        for (ll j=0;j<n;j++){
            for (ll k=0;k<=50*i;k++){
                if (ave[i][j][k]!=0){
                    ave[i+1][j+1][k+x[i]]=ave[i][j][k]+ave[i+1][j+1][k+x[i]];
                    ave[i+1][j][k]=ave[i][j][k]+ave[i+1][j][k];
                }
            }
        }
    }
    for (ll i=1;i<=n;i++){
        ans+=ave[n][i][i*a];
    }
    cout << ans << endl;
    return 0;
}



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

ll dp[3010][3010][4];
ll pt[3010][3010];

int main()
{
	ll r,c,k;
	cin >> r >> c >> k;
	for(int i = 0;i<k;i++)
	{
		ll r,c,v;
		cin >> r >> c >> v;
		r--;c--;
		pt[r][c]=v;
	}
	for(int i = 0;i<r;i++)
	{
		for(int j = 0;j<c;j++)
		{

			for(int k = 0;k<=3;k++)
			{
				if(pt[i][j])dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i][j+1][k]+pt[i][j]);
				 dp[i+1][j+1][0] = max(dp[i+1][j+1][0],dp[i][j+1][k]);
			}
			for(int k = 0;k<=3;k++)
			{
				if(pt[i][j])
				{
					if(k<3)dp[i+1][j+1][k+1] = max(dp[i+1][j+1][k+1],dp[i+1][j][k]+pt[i][j]);
				}
				dp[i+1][j+1][k] = max(dp[i+1][j+1][k],dp[i+1][j][k]);
			}
		}
	}
	ll ans = 0;
	for(int i = 0;i<=3;i++)ans = max(dp[r][c][i],ans);
	cout<<ans<<endl;

}


Measured memory_bytes: 356184
#include <iostream>

using namespace std;

void solve()
{
	int Digit;
	double weight, height;
	while(~scanf("%d,%lf,%lf", &Digit, &weight, &height))
	{
		if(weight / height / height >= 25)
		{
			cout << Digit << endl;
		}
	}
}

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

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

ll f(string s){
  int i;
  ll sum=0,cnt=0;
  ll a[s.size()-1];
  for(i=0;i<s.size();i++)a[i]=1;
  for(i=1;i<s.size();i++){
    if(s[i-1]==s[i])a[cnt]++;
    else cnt++;
  }
  for(i=0;i<=cnt;i++)sum+=a[i]/2;
  return sum;
}

int main(){
  int i,j;ll cnt=0;
  ll k;
  string s;
  cin>>s;
  cin>>k;
  if(s.size()==1){
    cout<<k/2;
    return 0;
  }
  if(f(s+s)-f(s)==f(s+s+s)-f(s+s))cout<<f(s)+(k-1)*(f(s+s)-f(s));
  else cout<<f(s)+k/2*(f(s+s)-f(s))+(k-1)/2*(f(s+s+s)-f(s+s));
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		solve(scanner);
		scanner.close();
	}
	
	public static void solve(Scanner scanner) {
		int n = scanner.nextInt();
		long[] array = new long[n];
		long max = 0;
		for (int i = 0; i < array.length; i++) {
			array[i] = scanner.nextLong();
			max += array[i];
		}
		long min = Long.MAX_VALUE;
		for (int i = 0; i < array.length-1; i++) {
			max -= array[i]*2;
			min = Math.min(Math.abs(max), min);
		}
		System.out.println(min);
	}
}


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

int main(){
	int in[3]={};
	int ary[4]={};
	while(true){
		for(int i=0;i<3;i++) cin>>in[i];
		sort(in,in+3);
		if(in[0]+in[1]<=in[2]) break;
		else if(in[0]*in[0]+in[1]*in[1]<in[2]*in[2]) ary[3]++;
		else if(in[0]*in[0]+in[1]*in[1]==in[2]*in[2]) ary[1]++;
		else ary[2]++;
		ary[0]++;
	}
	cout<<ary[0]<<" "<<ary[1]<<" "<<ary[2]<<" "<<ary[3]<<endl;
	return 0;
}

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

int MAX = 3000;
vector<vector<string>> dp(2,vector<string>(MAX+1,""));
string s,t;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s >> t;
    int u = s.size(), v = t.size();

    for(int i = 0;i < u;i++){
        for(int j = 0;j < v;j++){
            if(s[i]==t[j])
                dp[1][j+1] = dp[0][j] + s[i];
            else{
                if(dp[1][j].size() >= dp[0][j+1].size())
                    dp[1][j+1] = dp[1][j];
                else
                    dp[1][j+1] = dp[0][j+1];
            }
        }
        dp[0] = dp[1];
    }
    cout << dp[0][v] << "\n";
}

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

int main(void){
	char str[222];
	scanf("%s",str);
	int n=strlen(str);
	for(int i=n-2;i>0;i-= 2){
		if(strncmp(str,str+i/2,i/2)==0){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}
		

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long

int take()
{
    int n;
    scanf("%d",&n);
    return n;

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 200005
#define Int take()
#define LL takes()

#define fr(n) for(int i=1;i<=n;i++)
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;

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

    if((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3]))
    cout<<"Yes\n";
    else cout<<"No\n";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n;
    long long int a,b,a1,b1,t;
    bool flag1=true,flag2=false;
    cin>>n;
    long long int x[n],y[n],k[n];
    int a2[32],b2[32];
    vector<long long int> v;
    for(int i=0;i<n;i++){
        cin>>x[i];
        cin>>y[i];
        k[i]=(x[i]+y[i]+10000000000)%2;
    }

    t=1;
    for(int i=0;i<32;i++){
        v.push_back(t);
        t*=2;
    }

    for(int i=1;i<n;i++){
        if(k[0]!=k[i])flag1=false;
    }

    if(k[0]==0){
        flag2=true;
    }

    if(flag1){
        if(flag2){
            v.push_back(1);
            for(int i=0;i<n;i++){
                x[i]--;
            }
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++){
            cout<<v[i];
            if(i==v.size())cout<<endl;
            else cout<<" ";
        }
        for(int i=0;i<n;i++){
            a=x[i]+y[i];
            b=x[i]-y[i];
            a1=(v[31]*2-1-a)/2;
            b1=(v[31]*2-1-b)/2;
            for(int j=0;j<32;j++){
                a2[j]=a1%2;
                a1=a1/2;
                b2[j]=b1%2;
                b1=b1/2;
            }
            for(int i=0;i<32;i++){
                if(a2[i]==0&&b2[i]==0)cout<<"R";
                if(a2[i]==1&&b2[i]==1)cout<<"L";
                if(a2[i]==1&&b2[i]==0)cout<<"D";
                if(a2[i]==0&&b2[i]==1)cout<<"U";
            }
            if(flag2)cout<<"R";
            cout<<endl;
        }
        
    }
    else{
        cout<<-1<<endl;
    }
}

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

int main(){
    string s;
    cin >> s;
    rep(i,s.size()) cout << 'x';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
numbers = input().split()
x = input().split()
y = input().split()
z = input().split()

k = int(numbers[3])

answer = []
for i in x:
    for j in y:
        price = int(i)+int(j)
        answer.append(price)
answer.sort(reverse=True)
del answer[k::]
f_ans = []
for m in answer:
    for n in z:
        price = m + int(n)
        f_ans.append(price)

f_ans.sort(reverse=True)
del f_ans[k::]

for l in f_ans:
    print(l)


Measured memory_bytes: 144172
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	m := make(map[int]bool)
	uniq := []int{}
	for _, num := range a {
		if !m[num] {
			m[num] = true
			uniq = append(uniq, num)
		}
	}
	fmt.Println(len(uniq))
}

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


int main() {
    int a, b;
    cin >> a >> b;
    if(a>8 || b>8){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{	string s, t;
	cin >> s >> t;
	int i  =0;
	while(i<s.length())
	{
		if(s[i]!=t[i])
		{
			cout << "No";
			return 0;
		}
		i++;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String length = scan.nextLine();
        String str2 = scan.nextLine();
        String[] s = str2.split(" ");

        StringBuilder stringBuilder = new StringBuilder();
        String aaa= "";
        for (int i = 0; i < Integer.parseInt(length); i++) {
            stringBuilder.append(s[0].charAt(i));
            stringBuilder.append(s[1].charAt(i));

        }
        System.out.println(stringBuilder.toString());
    }
}

Measured memory_bytes: 21844
/**
 * File              : A.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 08.12.2019
 * Last Modified Date: 08.12.2019
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */
#include <bits/stdc++.h>
using namespace std;

int main() {
    int a,b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust";
    } else {
        cout << "win";
    }
    return 0;
}


Measured memory_bytes: 256
import bisect

N,Q = map(int,(input().split()))
S = list(input())

l = []
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        l.append(i+1.5)

for i in range(Q):
    a,b = map(int,(input().split()))
    print(bisect.bisect_left(l,b) - bisect.bisect_left(l,a))

Measured memory_bytes: 57720
#define rep(i,n) for (int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
 
 
int main(){
  
 int x;
  cin >> x;
  if(x==0)
    cout << 1 <<endl;
  else
    cout << 0 << endl;
    
  
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double s = pi * r * r;
        double c = 2 * pi * r;
        System.out.printf("%6f %6f", s, c);
    }
}


Measured memory_bytes: 28280
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;

  cout << ((N - K > 0) ? (K * X + (N - K) * Y) : N * X) << endl;
  return 0;
}


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

double N, org;
int main(){
    scanf("%lf", &N);
    org = N; N/=1.08;
    N=ceil(N);
    if((int)(N*1.08)==org) printf("%d", int(N));
    else printf(":(\n");

    return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))


    C = [0] * (N+1)
    D = [0] * (N+1)
    for i in range(N):
        C[A[i]] += 1
        D[B[i]] += 1
    for i in range(N+1):
        if C[i] + D[i] > N:
            print("No")
            return
    for i in range(N):
        C[i+1] += C[i]
        D[i+1] += D[i]
    
    x = 0
    for i in range(1, N+1):
        if x < C[i] - D[i-1]:
            x = C[i] - D[i-1]
    

    print("Yes")
    for i in range(N):
        if i != 0:
            print(" ", end="")
        print(B[(i+N-x)%N], end="")
    print("")


if __name__ == '__main__':
    main()

Measured memory_bytes: 118380
#include<bits/stdc++.h>
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define ll long long
#define MAX 100005
#define mp make_pair
const int M=1e9+7;
vector<int> adj[MAX];
bool vis[MAX];
ll qpow(ll x, ll k,ll m) {return k==0? 1: 1ll*qpow(1ll*x*x%m,k>>1,m)*(k&1?x:1)%m;}
ll modinv(ll a,ll m){ll g=__gcd(a,m);return (g==1)? qpow(a,m-2,m):-1;}

int dp[MAX];

void dfs(int i)
{
    vis[i]=1;
    for(int j=0;j<adj[i].size();j++)
    {
        if(!vis[adj[i][j]])
            dfs(adj[i][j]);
        dp[i]=max(dp[i],dp[adj[i][j]]+1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i);
    }
    for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 8320
# -*- coding: utf-8 -*-
n=int(input())
sumy=0
#nの半分より上の倍数は1個なのでそこで分ける
numhalf=int(n/2)
#nの半分までは倍数ごとに個数を求めて足していく
for i in range(numhalf):
  t=i+1
  k=int(n/t)
  sumy+=int(t*k*(k+1)/2)
#半分より上の倍数はすべて1個ずつなのでまとめて足す
sumy+=int((n+numhalf+1)*(n-numhalf)/2)
print(sumy)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll A, B;
	cin >> A >> B;
	ll N = gcd(A, B);
	
	set<ll> st;
	for (ll i = 2; i * i <= N; i++) {
		if (N % i == 0) {
			st.insert(i);
			while (N % i == 0) N /= i;
		}
	}
	if (N != 1) st.insert(N);
	cout << st.size() + 1 << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    constexpr int X = 1e9;
    IOS
    ll s; cin >> s;
    ll y3 = s / X+1;
    ll x3 = y3 * X-s;
    int y2 = 1;
    if (y3 == X+1) {
        y2 = 0;
        y3 = 1e9;
        x3 = 1e9;
    }

    cout << "0 0 " << X << " " << y2 << " " << x3 << " " << y3 << endl;


    return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int a, b, c; cin >> a >> b >> c;
    if( c - ( a - b ) < 0 ) cout << 0 << endl;
    else cout << c - ( a - b ) << endl;
}

Measured memory_bytes: 256
import sys
def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print()

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

for i in range(n):
	key = arr[i]
	j = i - 1
	while j >= 0 and arr[j] > key:
		arr[j + 1] = arr[j]
		j -= 1
	arr[j + 1] = key
	print_arr(arr)



Measured memory_bytes: 5988
import sys
from math import gcd
input = sys.stdin.buffer.readline

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


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

p = primes(1003)



g = a[0]

for e in a:
    g = gcd(g,e)


if g != 1:
    print("not coprime")
else:
    s = set()
    for e in a:
        if e == 1:
            continue
        if e in s:
            print("setwise coprime")
            exit()
        for d in p:
            if e < d:
                break
            if e%d == 0:
                d2 = e//d
                if d in s:
                    print("setwise coprime")
                    exit()
                s.add(d)
                if d2 > 1003:
                    if d2 in s:
                        print("setwise coprime")
                        exit()
                    s.add(d2)
        s.add(e)
    print("pairwise coprime")


Measured memory_bytes: 172360
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, k;
  cin >> n >> k;
  vector<int> l(n);

  REP(i,n) cin >> l[i];

  sort(RALL(l));
  int sum = 0;
  REP(i,k){
    sum += l[i];
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;

bool is_kaibun(string a){
	bool ans = true;
	REP(i, a.size()){
		// printf("%c, %c\n", a[i], a[a.size()-i-1]);
		if (a[i]!=a[a.size()-i-1]) ans = false;
	}
	return ans;
}


// 検索タグ
int main() {
	// 入力
	string S;cin>>S;
	
	// 解法
	bool ans = true;
	ll N = S.size();
	if (is_kaibun(S)==false) ans = false;
	if (is_kaibun(S.substr(0, (N-1)/2))==false) ans = false;
	if (is_kaibun(S.substr((N+3)/2-1, (N-1)/2))==false) ans = false;

	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(){

    int y,m,d;
    char x,z;

    cin >> y >> x >> m >> z >> d;


    if(m <= 4){
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }


}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd =2e5+10;
struct node
{
    int a,b;
    bool operator < (const node &other) const
    {
        if(b == other.b) return a < other.a;
        return b < other.b;
    }
}a[maxd];
int n;
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d %d",&a[i].a,&a[i].b);
    sort(a+1,a+1+n);
    int now = 0;
    for(int i=1;i<=n;i++)
    {
        if(now + a[i].a > a[i].b)
        {
            printf("No\n");
            return 0;
        }
        now += a[i].a;
    }
    printf("Yes\n");
    return 0;
}  

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define int long long
#define rep(i,n) for(re ll (i)=1;(i)<=(n);++(i))
typedef long long ll;
const int maxn=1e5+5;
ll n,m,a[maxn];
string s[maxn];
ll pre=1;
ll ans;
il ll read(){
	re char ch(getchar());
	re ll f(1),x(0);
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
signed main(){
	n=read();
	rep(i,n) cin>>s[i];
	rep(i,n) sort(s[i].begin(),s[i].end());
	sort(s+1,s+n+1);
	//rep(i,n) cout<<s[i]<<endl;
	rep(i,n){
		if(s[i]!=s[pre]){
			ans+=(i-pre)*(i-pre-1)/2;
			pre=i;
		}
	}//cout<<pre<<endl;
	ans+=(n-pre+1)*(n-pre)/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7296
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, A[SIZE];
  int step[SIZE];
  ll K;

  scanf("%d%lld", &N, &K);

  for (int i = 0; i < N; i++) {
    scanf("%d", A + i);
    A[i]--;
    step[i] = -1;
  }

  int now = 0;

  for (int i = 0;; i++) {
    if (i == K) {
      printf("%d\n", now + 1);
      return 0;
    }

    if (step[now] >= 0) {
      ll x = K - step[now];
      ll y = x % (i - step[now]);

      for (int i = 0; i < N; i++) {
        if (step[i] - step[now] == y) {
          printf("%d\n", i + 1);
          return 0;
        }
      }
    }

    step[now] = i;
    now = A[now];
  }

  return 0;
}

Measured memory_bytes: 5288
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut freq = std::collections::BTreeMap::<i64, i64>::new();
    std::iter::once(0i64)
        .chain(a.iter().scan(0i64, |state, &x| {
            *state = *state + x;
            Some(*state)
        }))
        .for_each(|x| {
            freq.insert(x, freq.get(&x).unwrap_or(&0) + 1);
        });

    let ans = freq.iter()
        .map(|(_, v)| v * (v - 1) / 2)
        .sum::<i64>();

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


Measured memory_bytes: 11300
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "LUCKYSQ"
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define fi first
#define se second
using namespace std;
const ll mod = 998244353;
const ll N = 2e5 + 5;
const ll mxn = 1e6 + 5;

ll n, m, u, v, st[N*4], t, k, T, ans, tong, a[N], b[N], d[N];
vector<ll> kq;
void build(ll id, ll l , ll r)
{
    if(l > u || u > r)return;
    if(l == r)
    {
        st[id] += 1;
        return;
    }
    ll mid = (l + r) / 2;
    if(mid >= u)build(id*2, l, mid);
    else build(id*2+1, mid+1, r);
    st[id] = st[id*2] + st[id*2+1];
}
ll get(ll id, ll l, ll r)
{
    if(u > r || l > v)return 0;
    if(u <= l && r <= v)return st[id];
    ll mid = (l + r) / 2;
    return get(id*2, l ,mid) + get(id*2+1, mid+1, r);
}
ll f(ll u)
{
    return lower_bound(kq.begin(), kq.end(), u) - kq.begin() + 1;
}
bool ck(ll x)
{
    kq.clear();
    memset(st, 0, sizeof(st));
    tong = 0;
    for(int i = 1; i <= n; i ++)
    {
        d[i] = d[i-1];
        if(a[i] >= x) ++ d[i];
        kq.pb(2*d[i] - i);
    }
    kq.pb(0);
    sort(kq.begin(), kq.end());
    kq.erase(unique(kq.begin(), kq.end()), kq.end());
    u = f(0);
    build(1, 1, n+1);
    for(int i = 1; i <= n; i ++)
    {
        u = 1, v = f(2*d[i]-i);
        tong += get(1, 1, n+1);
        u = f(2*d[i]-i);
        build(1, 1, n+1);
    }
    //cout << x <<" "<<tong<<endl;
    return tong >= ans;
}
inline void sol()
{
    cin >> n >> k;
    ll t1 = 0, t2 = 0;
    for(int i = 1; i <= n; i ++)
    {
        cin >> m;
        if(m >= 0)a[++t1] = m;
        else b[++t2] = m;
    }
    reverse(b+1, b+1+t2);
    ans = mod;
    for(int i = 0; i <= k; i ++)
    {
        if(t2 + i < k || t1 < i)continue;
        {
            //cout << a[i] <<" "<<b[k-i]<<'\n';
            ans =  min(ans, a[i] - b[k-i] + min(a[i], -b[k-i]));
        }

    }
    cout << ans;
}
int main()
{
    if(fopen(task".INP", "r")){
       freopen(task".INP", "r", stdin);
       freopen(task".OUT", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    sol();
}






Measured memory_bytes: 4448
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n = int(input())
d,x = map(int,input().split())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n):
    j = 0
    cnt = 0
    while True:
        j = cnt*a[i] + 1
        if j>d:
            break
        cnt += 1
        ans += 1
print(ans + x)

Measured memory_bytes: 12432
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm;

void main(){
  long n;
  readf("%d\n", &n);
  long[] hs = readln.strip().split().map!(to!long).array;

  long cnt = 0;
  long max = -1;
  foreach (h; hs) {
    if (max <= h) {
      cnt++;
      max = h;
    }
  }
  writeln(cnt);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <ctype.h>
using namespace std;
int n,m,a,b,c;

struct Node
{
    int x,y,z;
    Node(){}
    Node(int a,int b,int c): x(a), y(b),z(c) {}
};

bool vis[1005][1005];
int dirx[] = {0,1,0,-1};
int diry[] = {1,0,-1,0};

char ma[1005][1005];


int bfs()
{
    queue<Node>Q;
    int ans=0;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    if(ma[i][j]=='#')
    {
    	Q.push(Node(i,j,0));
    	ans++;
    	vis[i][j]=1;
    }
    
    if(ans==n*m)
    return 0;
    
    while(!Q.empty())
    {
        Node node=Q.front(); 
		Q.pop();
        int x=node.x,y=node.y,z=node.z; 
        for(int i=0;i<4;i++)//四个方向 
        {
            int nx=x+dirx[i],ny=y+diry[i],nz=z+1;
            
            if(nx<1||nx>n||ny<1||ny>m) continue;
            if(vis[nx][ny]) continue;
//            printf("%d %d",ans,nz);
            vis[nx][ny]=1;
            ans++;
            if(ans==n*m)
            return nz;
            Q.push(Node(nx,ny,nz));
        }
    }
}


int main()
{
    scanf("%d%d\n", &n,&m); 
    for(int i=1;i<=n;i++)
    scanf("%s",ma[i]+1);
    
    int t = bfs();
    printf("%d\n",t);
    return 0;
}

Measured memory_bytes: 14352
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    ll N, C, K;
    cin >> N >> C >> K;

    ll T[N];
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
    }
    sort(T, T + N);

    ll ans = 0, limit = 0, cap = 0;
    // ans   = 発車された累計バス台数
    // limit = 先頭の客の許容時間
    // cap   = 今バスに乗ってる客数

    for (int i = 0; i < N; ++i) {
        if (cap == C || T[i] > limit) { //capにしてlimitにすることでkの時間の比較をやりやすくしている
            // 制限オーバーなので新しいバスに乗せる
            ++ans;
            limit = T[i] + K;
            cap = 0;
        }
        ++cap;
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
/*てんぷれぞーん！*/
//static const int INF = 2147483647;
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o っ て 知 っ て る ゥ ！ ？ */
#define itn int
#define scnaf scanf
#define reutnr return
/*必要に応じて使ってね*/
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll
//#define INF llINF

signed main(){
    int a[3];
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);

    if(a[0]!=a[1]) printf("%d\n",a[0]);
    else printf("%d\n",a[2]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; ++i)
	{
		cout << s[i] << t[i];
	}
	return 0;
}

Measured memory_bytes: 3624
// AOJ q0038
// YAMADA Terushige
// 2013.5.6

#include<iostream>
#include<set>
#include<vector>
 
using namespace std;
 
int main(){
  int card;
  char c;
  while(cin >> card){
    string ans = "null";
    vector<int> num(15,0);
    set<int> spc;
    num[card]++;
    spc.insert(card);
    for(int i=0;i<4;i++){
      cin >> c >> card;
      num[card]++;
      spc.insert(card);
    }
    num[14]=num[1];

    int max = 0;
    for(int i=1;i<=13;i++)
      if(num[i]>max) max= num[i];

    switch(max){

    case 4:
      ans = "four card";
      break;

    case 3:
      if(spc.size()==3) ans = "three card";
      else if(spc.size()==2) ans = "full house";
      break;

    case 2:
      if(spc.size()==4) ans = "one pair";
      else if(spc.size()==3) ans = "two pair";
      break;
      
    case 1:	
      for(int i=1;i<=10;i++){
	int j;
	for(j=0;j<5;j++)
	  if(num[i+j]!=1) break;
	if(j==5){
	  ans = "straight";
	  break;
	}
      }

    }
    cout << ans << endl;	
  }
}


Measured memory_bytes: 1204
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
  char a;
  int c=0,d=0;
  for(int i=0;i<3;i++)
  {
    cin>>a;
    if(a=='A')
      c++;
    else
      d++;
  }
  if(c!=0&&d!=0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))

main :: IO ()
main = do
    d <- readDice <$> getLine
    cs <- getLine
    putStrLn $ solve d cs

solve :: Dice -> String -> String
solve d "" = top d
solve (Dice t s e w n b) ('E':cs) = solve (Dice w s t b n e) cs
solve (Dice t s e w n b) ('N':cs) = solve (Dice s b e w t n) cs
solve (Dice t s e w n b) ('S':cs) = solve (Dice n t e w b s) cs
solve (Dice t s e w n b) ('W':cs) = solve (Dice e s b t n w) cs

data Dice = Dice
    { top :: String
    , south :: String
    , east :: String
    , west :: String
    , north :: String
    , bottom :: String
    }

readDice :: String -> Dice
readDice str = Dice t s e w n b
    where (t:s:e:w:n:b:_) = words str

Measured memory_bytes: 3536
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
using namespace std;
int a[maxn], b[maxn], N, M, X, Y;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> N >> M >> X >> Y;
    for (ri i = 1; i <= N; ++i)
        cin >> a[i];
    for (ri i = 1; i <= M; ++i)
        cin >> b[i];
    sort(a + 1, a + 1 + N);
    sort(b + 1, b + 1 + M);
    for (ri i = max(X + 1, a[N] + 1); i <= Y; ++i) {
        if (b[1] >= i) {
            return cout << "No War" << endl, 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

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

using namespace std;

#define pi 3.1415926536
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bs binary_search
#define int long long
#define float double

typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<string,int> msi;
typedef map<string,string> mss;
typedef map<char,char> mcc;
typedef map<pair<int,int>,int> mpi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef set<int> si;
typedef set<string> ss;
typedef set<char> sc;
int const max1= 1e3+5;
int const mod = 1e9+7;

int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
//cin>>t;
while(t--){
    int n,x,t;
    cin>>n>>x>>t;
    int d=n/x;
    if(n%x!=0){
        d++;
    }
    cout<<d*t;
}
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
vector<int> to[100005];
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int hi=h[i];
        bool flag=true;
        for(int j:to[i]){
            if(hi<=h[j]){
                flag=false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8804
def inputs(): return [int(x) for x in input().split()]
from collections import defaultdict
k,n = inputs()
a = inputs()
ans = min(a[-1]-a[0],k-(a[1]-a[0]))
for i in range(n-1):
    if i!=0:
        ans = min(ans,min(k-abs(a[i+1]-a[i]),k-abs(a[i-1]-a[i])))
    #print(ans,i)
print(ans)



Measured memory_bytes: 77644