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

#define rep(i,n) for(int i = 0; i < (n); i++ )

using namespace std;

int box[5][5][5];
int ne[5][5][5];

int main(){
    int casenum = 0;
    int n;
    while(cin >> n, n){
        if(casenum++) cout << endl;
        rep(i, 5) rep(j, 5) rep(k, 5) {
            char c;
            cin >> c;
            box[i][j][k] = c-'0';
        }
        vector<int> a(27, 0), b(27, 0);
        int m1, m2;
        cin >> m1;
        rep(i, m1){
            int ai;
            cin >> ai;
            a[ai] = 1;
        }
        cin >> m2;
        rep(i, m2){
            int bi;
            cin >> bi;
            b[bi] = 1;
        }
        while(n--){
            memset(ne, 0, sizeof(ne));
            rep(z, 5) rep(y, 5) rep(x, 5){
                for(int i = -1; i <= 1; i++) {
                    for(int j = -1; j <= 1; j++) {
                        for(int k = -1; k <= 1; k++) {
                            if(i == 0 && j == 0 && k == 0) continue;
                            int nx = x+k;
                            int ny = y+j;
                            int nz = z+i;
                            if(nx < 0 || nx >= 5 || ny < 0 || ny >= 5 || nz < 0 || nz >= 5) continue; 
                            ne[z][y][x] += box[nz][ny][nx];
                        }
                    }
                }
            }
            rep(z, 5) rep(y, 5) rep(x, 5){
                if(box[z][y][x]){
                    box[z][y][x] = b[ne[z][y][x]];
                }else{
                    box[z][y][x] = a[ne[z][y][x]];
                }
            }
        }
        cout << "Case " << casenum << ':' << endl;
        rep(z, 5) {
            if(z) cout << endl;
            rep(y, 5){
                rep(x, 5){
                    cout << box[z][y][x];
                }
                cout << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n;
    cin >> n;
    set<string> st;
    string s;
    for (Int i = 0; i < n; ++i) {
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 19204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
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;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int a,b,c; cin>>a>>b>>c;
    cout<<max(0LL,c-(a-b))<<endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#define N 3000
struct set{
    int x;
    int y;
};
int main(){
    struct set p[N];
    int idx=-1;
    do{
        idx++;
        scanf("%d%d",&p[idx].x,&p[idx].y);
    }while(p[idx].x!=0 || p[idx].y!=0);
    for(int i=0;i<idx;i++){
        if(p[i].x>=p[i].y) printf("%d %d\n",p[i].y,p[i].x);
        else printf("%d %d\n",p[i].x,p[i].y);
}
    return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main()
{
	int n,k,sum,t;
	while(scanf("%d", &n)!=EOF&n>0)
	{
		scanf("%d", &k);
		sum=0;
		while(n--)
		{
			scanf("%d", &t);
			if(k-t<t)
				sum+=2*(k-t);
			else
				sum+=2*t;
		}
		printf("%d\n",sum);
	}
	
	
	return 0;
}

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

using namespace std;

const int N = 105;

int a[N];

int main() {

    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i ++) {
        if (a[i] * 4 * m >= sum) {
            ans ++;
        }
    }
    if (ans >= m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
int main() {
  int n;
  cin >> n;
  int ans = 1;
  while (n--) {
    int t;
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;

  return 0;
}


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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

void printVector(vector<int> A, int N){
    for(int i = 0; i < N-1; i++)
        cout<<A[i]<<" ";
    cout<<A[N-1]<<endl;
}

void swap(int& a, int& b){
    int tmp = b;
    b = a;
    a = tmp;
}

void bubbleSort(vector<int>& A, int N){
    bool bEnd = true;
    int c=0;
    while(bEnd){
        bEnd = false;
        for(int i = 0; i < N-1; i++){
            if(A[i]>A[i+1]){
                swap(A[i], A[i+1]);
                bEnd = true;
                c++;
            }
        }
    }
    printVector(A, N);
    cout<<c<<endl;
}

int main(void){
    cin.sync_with_stdio(false);
    int N; cin>>N;
    vector<int> nums;
    for(int i = 0; i < N; i++){
        int tmp; cin>>tmp;
        nums.push_back(tmp);
    }

    bubbleSort(nums, N);

    return 0;
}


Measured memory_bytes: 3180
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll a,b,c;cin>>a>>b>>c;
	ll x=min(c,a+b+1);
	ll ans=x+b;
	cout<<ans<<endl;
}

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

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

	for (int  i = 0; i <= N; i++)
	{
		for (int j = 0; j <= (N-i); j++)
		{
			int result = Y - i * 10000 - j * 5000;
			if ((result / 1000) + i + j == N) {
				cout << i << " " << j << " " << result / 1000 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		String ans = "ABD";
		if (N < 1000) {
			ans = "ABC";
		}
		

		System.out.print(ans);
		reader.close();
	}
}


Measured memory_bytes: 23124
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	READV(M);
	cout<<((N*(N-1))/2+(M*(M-1))/2)<<endl;

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

swi = []
for _ in range(M):
    k, *s_list = list(map(int, input().split()))
    temp_num = 0
    for s in s_list:
        temp_num += 1 << (s-1)
    swi.append(temp_num)

p_list = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    for s, p in zip(swi, p_list):
        swi_on = i & s
        if bin(swi_on).count('1') % 2 != p:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
char field[12][12];
int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0};

void dfs(int x,int y){
    field[x][y]='0';
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<12&&0<=ny&&ny<12&&field[nx][ny]=='1')dfs(nx,ny);
    }
    return;
}

int main(void){
    char a;
    while(cin>>a){
        int ans=0;
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                if(i==0&&j==0)field[0][0]=a;
                else cin>>field[i][j];
            }
        }
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                if(field[i][j]=='1'){
                    dfs(i,j);ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
}


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

int main(){
    int n; cin >> n;
    int d[26];
    for(int i = 0; i < 26; i++) d[i] = 1000000;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int a[26] = {};
        for(int j = 0; j < s.size(); j++){
            a[s[j] - 'a']++;
        }
        for(int j = 0; j < 26; j++){
            d[j] = min(d[j], a[j]);
        }
    }    
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < d[i]; j++) putchar('a'+i);
    }

    return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    string s;
    cin >> s;
    rep(i, s.size() - 1) {
        if(s[i] == 'A' && s[i + 1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int is_prime[10000001];
int prime[10000001];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i < 10000001; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j <= 10000001; j += i)is_prime[j] = false;
		}
	}
	int i;
	while (scanf("%d", &i), i) {
		int j = lower_bound(prime, prime + p, i) - prime;
		for (int ans = j;; ans--) {
			if (prime[ans] <= i&&prime[ans] - prime[ans - 3] == 8) {
				printf("%d\n", prime[ans]); break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 44896
using System;
using System.Collections.Generic;
using System.Linq;

namespace E
{
    class Program
    {
        static List<int> min_factor = new List<int>();
        static void Main(string[] args)
        {
            var n = Int32.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(" ").Select(s => Int32.Parse(s)).ToList();

            min_factor = new List<int>();
            for(var i=0;i<=1000000;i++){
                min_factor.Add(i); 
            }
            for(int i=2; i*i<=1000000; i++){
                if(min_factor[i] < i) continue;
                for(int j=i*i; j<=1000000; j+=i){
                    if(min_factor[j] == j) min_factor[j] = i;
                }
            }
            var values = new Dictionary<int, int>();
            foreach (var val in a)
            {
                var facts = PrimeFactors(val);
                foreach (var hoge in facts.Distinct())
                {
                    if(!values.ContainsKey(hoge)) values[hoge] = 0;
                    values[hoge]++;
                }
            }



            bool flag1 = true;
            var f2 = true;
            foreach(var v in values){
                if(v.Key == 1) continue;
                if(v.Value > 1) {
                    flag1 = false;
                }
                if(v.Value >= n) {
                    f2 = false; 
                }
            }
            if(flag1) {
                Console.WriteLine("pairwise coprime");
                return;
            }
            else if(f2) {
                Console.WriteLine("setwise coprime");
                return;
            }
            Console.WriteLine("not coprime");
        }
        public static IEnumerable<int> PrimeFactors(int n)
        {
            int tmp = n;

            while (tmp > 1)
            {
                yield return min_factor[tmp];
                tmp = tmp / min_factor[tmp];
            }
            yield return 1;
        }
    }
}

Measured memory_bytes: 125016
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::vector<long long> x){
  REP(5){
    if(x[i]==0){
      cout<<i+1<<endl;
      return;
    }
  }
}

int main(){
  cout<<setprecision(1000);
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n;std::cin>>n;
    std::vector<int>X(n),Y(n),H(n);
    for(int i=0;i<n;i++){
        std::cin>>X.at(i)>>Y.at(i)>>H.at(i);
    }
    int x0,y0,h0;
    for(int i=0;i<n;i++){
        if(H.at(i)!=0){
            x0=X.at(i);
            y0=Y.at(i);
            h0=H.at(i);
        }
    }
    for(int cx=0;cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            int ch=h0+std::abs(cx-x0)+std::abs(cy-y0);
            for(int i=0;i<=n;i++){
                if(i==n){
                    std::cout<<cx<<" "<<cy<<" "<<ch<<'\n';
                    return 0;
                }
                if(H.at(i)!=std::max(ch-std::abs(cx-X.at(i))-std::abs(cy-Y.at(i)),0))break;
            }
        }
    }
}


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

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
/////////////////

int cnt[3], n;

string yes = "Yes";
string no = "No";

void print(string s){
	cout << s << endl;
	exit(0);
}

void solve(){
	cin >> n;
	fr(i, 0, n){
		int v;
		cin >> v;
		v %= 4;
		if(v == 3) v = 1;
		++cnt[v];
	}
	if(cnt[1] - 2 >= cnt[0]) print(no);
	if(cnt[1] - 1 >= cnt[0] && cnt[2] > 0) print(no);
	if(cnt[1] - 1 >= cnt[0] && cnt[0] == 0) print(no);
	print(yes);

}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  float a[1000];

  scanf("%d",&n);

  for(int i = 0; i < n; ++i){
    scanf("%f", &a[i]);
  }
  double sita = 1/a[0];

  for(int i = 1; i < n; ++i){
    sita+= 1/a[i];
  }

  double result = 1/sita;

printf("%lf\n", result);

return 0;
}


Measured memory_bytes: 128
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>d>>a>>b;

    for(ll i=a;i<=b;i++){
    if(i%d==0) {cout<<"OK";return 0;}
    }

    cout<<"NG";


    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int M = 2005;
bitset<M*M>f;

int main(){
	int n;
	scanf("%d",&n);
	int sum=0;
	f.set(0);
	for(int i=1,x;i<=n;++i){
		scanf("%d",&x);
		sum+=x;
		f|=f<<x;
		//f[i]|=f[i-x]
	}
	int ans=sum;
	for(int i=1;i<=sum;++i)if(f.test(i)){
		if(i>=sum-i){
			ans=i;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
typedef long long ll;
using namespace std;
     
int h, w, dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
string s[400];
bool visited[400][400];
ll ans, bk, wt;

void dfs(int sy, int sx, bool isWhite) {
    visited[sy][sx] = true;
    if (isWhite) wt++;
    else bk++;
    
    rep(i, 4) {   
        int ny = sy + dy[i], nx = sx + dx[i];
        if (ny < 0 || ny >= h || nx < 0 || nx >= w || visited[ny][nx]) continue;
        if ( isWhite && s[ny][nx] == '#') dfs(ny, nx, false);
        if (!isWhite && s[ny][nx] == '.') dfs(ny, nx, true);
    }
}
     
int main() {
    cin >> h >> w;
    rep(i, h) cin >> s[i];
    REP(i, 0, h) {
        REP(j, 0, w) {
            if (s[i][j] == '#') {
                bk = wt = 0;
                dfs(i, j, false);
                ans += bk * wt;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13056
#pragma GCC optimize ("O3")
#include <iostream>
#include <algorithm>
 
inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

inline void fastout(int64_t n) {
    int64_t N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}
     
int main(){
    int N; fastin(N);
    int A[N]; int64_t s[N] = {};
    fastin(A[0]); s[0] = A[0];
    for (int i = 1; i < N; ++i){
      fastin(A[i]); s[i] = A[i] + s[i - 1];
    }
     
    std::sort(s, s + N);
     
    int64_t ans = 0;
    int beg = 0;
     
    for (int i = 0; i < N; ++i) {
        if (s[i] == 0) ++ans;
    }
     
    while (beg < N){
        int end = beg;
        while (end + 1 < N && s[end + 1] == s[beg]) ++end;
        int64_t len = end - beg + 1;
        ans += len * (len - 1) / 2;
        beg = end + 1;
    }
    fastout(ans);         
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
//import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int m = 700;
        
        for(int i=0; i<3; i++){
            if(str.charAt(i)=='o'){
                m += 100;
            }
        }
        System.out.println(m);
    }
}


Measured memory_bytes: 35672
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,a=0,b=0,t1=0,x,y,t; cin>>n; 
    bool ok=true;
    while (n--){
        cin >> t >> x >> y ; 
        int d=abs(a-x)+abs(b-y); 
        int td=t-t1; 
        t1 = t,a = x,b = y; 
        if ((td<d) or (d%2 != td%2)) { ok=false; break; }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
  

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

int main() {
	int N;
	cin >> N;
	int t[N], x[N], y[N];
	t[0]=x[0]=y[0]=0;
	for (int i=0; i<N; i++){
	    cin >> t[i+1] >> x[i+1] >> y[i+1];
	}
	bool can=true;
	for (int i=0; i<N; i++){
	    int dt=t[i+1]-t[i];
	    int dist=abs(x[i+1]-x[i]+y[i+1]-y[i]);
	    if (dt<dist){
	        can=false;
	    }
	    if (dist%2!=dt%2){
	        can=false;
	    }
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
string s,s1;
int ss[30],ss1[30];
int main()
{

cin>>s>>s1;
int a,b;a=s.size();
 for(int i=1;i<=a;i++)
    ss[s[i]-'a']++,ss1[s1[i]-'a']++;
    for(int i=1;i<=a;i++)
    if(s[i]!=s1[i]&&ss[s[i]-'a']!=ss1[s1[i]-'a']){cout<<"No\n";return 0;}
    cout<<"Yes\n";
return 0;
}



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

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}
int Mod(int a) {
	return a%mod;
}
int Mul(int a, int b) {
	return Mod(Mod(a) * Mod(b));
}
int Add(int a, int b) {
	return Mod(Mod(a) + Mod(b));
}

signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n;
        cin>>n;
        int ip[n];
        int ans = 0;
        for(int i = 0; i < n; i++) cin>>ip[i];
        int cs[n+1];
        cs[0] = 0;
        for(int i = 1; i <= n; i++) {
			cs[i] = cs[i-1] + ip[i-1];
		}
		for(int i = 0; i < n; i++) {
			ans = Add(ans , Mul(ip[i],(cs[n] - cs[i+1])));
		}
		cout<<ans<<endl;
        
    }



return 0;
}


Measured memory_bytes: 6728
#include <stdio.h>

int main(){

  int t,n,sum,i;
  for(i=0;i<4;i++){
    sum=0;
    scanf("%d%d",&t,&n);
    if(t==1)sum=6000*n;
    if(t==2)sum=4000*n;
    if(t==3)sum=3000*n;
    if(t==4)sum=2000*n;
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 600
import qualified Data.Array as A
import Data.Array ((//), (!), listArray)
import Data.Functor
import Data.List
import Control.Monad
import System.IO

main :: IO ()
main = do
  eof <- isEOF
  if eof then return () else solve >> main

solve :: IO ()
solve = do
  xs <- getDegrees
  putStrLn $ if ok xs then "OK" else "NG"

getDegrees :: IO [Int]
getDegrees = rec $ listArray (0, 100) $ replicate 101 0
  where rec arr = do
          [x, y] <- map readInt . words <$> getLine
          if x == 0 && y == 0 then return $ A.elems arr
          else rec $ arr // [(x, (arr ! x) + 1), (y, (arr ! y) + 1)]

ok :: [Int] -> Bool
ok (_:x0:x1:xs) = odd x1 && odd x1 && all even xs

readInt :: String -> Int
readInt = read

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const ll INF = numeric_limits<ll>::max();
class union_find_tree {
private:
	vector<int>par, rank_;
public:
	union_find_tree(int n) :par(n), rank_(n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank_[i] = 0;
		}
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) {
			return;
		}
		if (rank_[x] < rank_[y]) {
			par[x] = y;
		}
		else if (rank_[x] == rank_[y]) {
			par[y] = x;
			rank_[x]++;

		}
		else if (rank_[y] < rank_[x]) {
			par[y] = x;
		}
	}
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		return par[x] = root(par[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};
int main() {
	int n, k, l;
	cin >> n >> k >> l;
	union_find_tree road(n), train(n);
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (!road.same(a, b)) {
			road.unite(a, b);
		}
	}
	for (int i = 0; i < l; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (!train.same(a, b)) {
			train.unite(a, b);
		}
	}
	vector<pair<int, int>>com(n);//各頂点の道、鉄道における親をpairで持つvector
	map<pair<int, int>, int>s;
	for (int i = 0; i < n; i++) {
		com[i].first = road.root(i);
		com[i].second = train.root(i);
		s[com[i]]++;
	}
	for (int i = 0; i < n; i++) {
		cout << s[com[i]] << " ";//「道路においてある集合に属し、かつ鉄道においてある集合に属する」ことをキーにしている
	}
	cout << endl;
}


Measured memory_bytes: 16640
import sys
import math
def rishi(n,a):
    if(n>0):
        a=a*1.05
        a1=a%1000
        if(a1 != 0):
            a=a-a1+1000
        n=n-1
        return (rishi(n,a))
    else:
        return a

a=100000
n=int(input())
n_sum=rishi(n,a)
print(round(n_sum))


Measured memory_bytes: 5676
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	x1,y1,x2,y2=map(int,input().split())
	x=x2-x1
	y=y2-y1
	x3=x2-y
	y3=y2+x
	x4=x1-y
	y4=y1+x
	
	
	print(x3,y3,x4,y4)
	
	
	
	
	
	
	


if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


int main(){
    ll N, K; cin >> N>>K;
    vll rec(N, 0);
    REP(i, K){
        ll d; cin >> d;
        ll a;
        REP(j, d){
            cin >> a;
            a --;
            rec[a]++;
        }
    }
    ll ans = 0;
    REP(i, N){
        if(rec[i]==0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
vector<vector<bool>> done;
int main(){
    string s=stin();
    ll n=s.length();
    vec a(n);
    rep(i,n)a[i]=s.at(i)=='0'?0:1;
    if(n%2==0){
        ll ml=n/2-1,mr=n/2;
        if(a[ml]!=a[mr])cout<<n/2<<endl;
        else{
            int k=0;
            while((a[ml-k]==a[ml])&(a[mr]==a[mr+k])&(ml-k>=0))k++;
            cout<<mr+k<<endl;
        }
    }else{
        ll mid=n/2;
        int k=0;
        while(a[mid-k]==a[mid]&a[mid]==a[mid+k]&mid>=k)k++;
        cout<<mid+k<<endl;
    }
}

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

int main() {
	int N, M;
	long long int ans = 0;
	cin >> N>> M;
	//vector< long int >L;
	vector<pair<int, int >>pairs(N);
	vector<int> A(N), B(N);
	for (long  int i = 0; i < N; i++) {
		//long  int A,B;
		cin >> A[i];
		cin >> B[i];
		//pairs[i] = make_pair(A, B);
		/*for ( long int k = 0; k < B; k++) {
			L.push_back(A);
		}*/
	}
	for (int i = 0; i < N; i++) {
		pairs[i] = make_pair(A[i], B[i]);
	}
	sort(pairs.begin(), pairs.end());

	for ( int i = 0; i < N; i++) {
		//cout << L[j] << endl;
		//ans += L[j];
		int buy = min(M, pairs[i].second);

		ans += (long long)buy * pairs[i].first;
		M -= buy;

	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int64_t LINF = 1LL << 62;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, E, T;
    cin >> n >> E >> T;

    vector<int> X(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> X[i];
    }

    vector<int64_t> dp(n + 1, 0);
    deque<pair<int, int64_t>> d;
    for (int i = 1; i <= n; ++i) {
        dp[i] = LINF;
        int j = i - 1;
        int64_t time = -LINF;
        int64_t cval = dp[j] + X[j + 1] - X[j] + 
                3LL * (X[i] - X[j + 1]) +
                max((int64_t) 0, (int64_t) (T - 2LL * (X[i] - X[j + 1])));
        int64_t currSteady = T + 2 * X[j + 1];
        while (!d.empty()) {
            int p = d.back().first;
            int64_t pval = dp[p] + X[p + 1] - X[p] + 
                    3LL * (X[i] - X[p + 1]) +
                    max((int64_t) 0, (int64_t) (T - 2LL * (X[i] - X[p + 1])));
            if (cval <= pval) {
                d.pop_back();
                continue;
            }
            int64_t prevSteady = T + 2 * X[p + 1];
            time = max(prevSteady, (int64_t) (2 * X[i])) + cval - pval;
            if (time > currSteady) {
                time = LINF;
            }
            if (time <= d.back().second) {
                d.pop_back();
            } else {
                break;
            }
        }
        if (d.empty()) {
            time = -LINF;
        }
        d.push_back(make_pair(j, time));
        while (SZ(d) > 1 && 2 * X[i] >= d[1].second) {
            d.pop_front();
        }
        d.front().second = -LINF;
        int p = d.front().first;
        int64_t pval = dp[p] + X[p + 1] - X[p] + 
                3LL * (X[i] - X[p + 1]) +
                max((int64_t) 0, (int64_t) (T - 2LL * (X[i] - X[p + 1])));
        dp[i] = pval;
    }
    int64_t ans = dp[n] + E - X[n];
    cout << ans << '\n';
}

Measured memory_bytes: 1408
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-05-30 20:05:51
 * @LastEditTime: 2020-05-30 20:07:51
 * @FilePath: \VSC\C++\Public\Nomura2020 A.cpp
 */ 
#include<bits/stdc++.h>
using namespace std;

int h1,m1,h2,m2;
int K;

signed main(){
    scanf("%d%d%d%d",&h1,&m1,&h2,&m2);
    scanf("%d",&K);

    int time=(h2-h1)*60+m2-m1;
    printf("%d\n",time-K);

    return 0;
}

Measured memory_bytes: 3816
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        a:[usize;n-1],
    }
    let mut employee_map = HashMap::new();
    employee_map.insert(1, 0);
    for (i, ai) in a.iter().enumerate() {
        let i = i + 2;
        employee_map.insert(i, 0);
        *employee_map.get_mut(ai).unwrap() += 1;
    }
    let mut employees = employee_map.iter().collect::<Vec<_>>();
    employees.sort_by_key(|(&k, _)| k);
    let mut s = String::with_capacity(employees.len() * 2);
    for (_, v) in employees.iter() {
        s.push_str(&format!("{}\n", v));
    }
    s
}
test! {
    include_str!("c1_in.txt") => include_str!("c1_out.txt"),
    include_str!("c3_in.txt") => include_str!("c3_out.txt"),
}


Measured memory_bytes: 13700
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな　オーバーフローする
//開区間と閉区間どうにかしろ
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグりがち
//切り上げ：(a + (b - 1)) / b
const ll MOD = 1000000007;
const ll MAX = 10010010010;

int main(){
    int q,w,e; cin >> q >>w>>e;
    if(q+w+e>=22) cout << "bust";
    else cout << "win";
}


Measured memory_bytes: 256
n,m = map(int,input().split())
Ship = [list(map(int,input().split())) for i in range(m)]

Ship1 = []
Ship2 = []

for i in Ship:
    if i[0] == 1:
        Ship1 += [i[1]]
    elif i[1] == n:
        Ship2 += [i[0]]
if set(Ship1) & set(Ship2):#set型のShip1とShip2の積集合を求めて、もし積集合が存在するならばPOSSIBLE、存在しないならIMPOSSIBLEを表示させる
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 61016
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
  int main(){      
      string s;
      lint k,n;
      cin>>s>>k;
       n=s.size();
     
      set<string> st;
      rep(i,n){
            string an="";
            repp(j,i,min(n,i+5)){
                an+=s[j];
             st.emplace(an);
            }
      }
      lint count=0;
     for(auto x:st){
         count++;
        if(count==k){ cout<<x<<endl;
        return 0;
        }
     }
  }
          
  

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  int n;
  scanf("%d",&n);
  long int a[n];
  long int d[n];
  for(int i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  d[0]=0;
  long int ans=0;
  for(int i=1;i<n;i++){
    if(a[i-1]<=a[i]){
      d[i]=0;
    }else{
      d[i]=a[i-1]-a[i];
      a[i]+=d[i];
    }
    ans+=d[i];
  }
  printf("%ld\n",ans);
  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N;
    cin >> N;
    if (N >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
 
int main(){
    int n,q;
    int S[10000],T[500];
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> S[i];
    }
    cin >> q;
    for (int i = 0; i < q ; ++i) {
        cin >> T[i];
    }
 
    int count = 0;
    for (int i = 0; i < q ; ++i) {
        for (int j = 0; j < n ; j++) {
            if(T[i] == S[j]) {
                count++;
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}
 

Measured memory_bytes: 3132
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int counter = 0;
        counter = h / a;
        if (h % a != 0) {
            counter++;
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long
#define inf 100000000000000000ll
using namespace std;
int n;
ll mem[200005][3], ara[200005];
bool vis[200005][3];
ll dp(int pos, int skip)
{
    if(pos>=n || (pos==n-1 && skip==2))return 0;
    if(vis[pos][skip])return mem[pos][skip];
    vis[pos][skip]= 1;
    mem[pos][skip]= -inf;
    if(skip)mem[pos][skip]= dp(pos+1, skip-1);
    mem[pos][skip]= max(mem[pos][skip], ara[pos]+dp(pos+2, skip));
    return mem[pos][skip];
}
int main()
{
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%lld", &ara[i]);
    ll res= -inf;
    if(!(n&1))
    {
        memset(vis, 0, sizeof vis);
        res= max(res, ara[0]+dp(2, 1));
        memset(vis, 0, sizeof vis);
        res= max(res, ara[1]+dp(3, 0));
    }
    else
    {
        memset(vis, 0, sizeof vis);
        res= max(res, ara[0]+dp(2, 2));
        memset(vis, 0, sizeof vis);
        res= max(res, ara[1]+dp(3, 1));
        memset(vis, 0, sizeof vis);
        res= max(res, ara[2]+dp(4, 0));
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 16772
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair< int, int> P;
struct edge{ll to, cost; };

static const double EPS = 1e-8;
static const double PI = 3.141592653589;
static ll INF = 999999999999;
int mod = 1000000007;

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define MIN(a,b)    (a) < (b) ? (a):(b)
#define MAX(a,b)    (a) > (b) ? (a):(b)
#define debug(x) cerr << #x << " = " << x << endl;
int dx[] = {1,-1,0,0,1,-1,1,-1};
int dy[] = {0,0,1,-1,-1,1,1,-1};

using namespace std;


int main() {
    int N;
    int A[103];
    cin >> N;


    int max = -1000;
    int min = 999;
    REP(i, N){
        cin >> A[i];
        max = MAX(max, A[i]);
        min = MIN(min, A[i]);
    }

    int ans = 111111111;
    for(int i = min; i <= max; i++){
        int sum = 0;
        for(int j = 0;j < N; j++){
            sum += (A[j] - i) * (A[j] - i);
        }
        ans = MIN(ans, sum);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
import heapq
cou=Counter(a)
c=[]
for k in cou.keys():
    c.append((-cou[k], k))
heapq.heapify(c)
v1,k1=heapq.heappop(c)
while v1<-1:
    if v1<-2:
        v1+=2
        heapq.heappush(c, (v1,k1))
    else:
        v2,k2=heapq.heappop(c)
        if v2<0:
            v1+=1
            v2+=1
            heapq.heappush(c, (v1,k1))
            heapq.heappush(c, (v2,k2))
    v1,k1=heapq.heappop(c)
    #print(v1,k1,c)
c.append((v1,k1))
cnt=0
for v,k in c:
    if v==-1:
        cnt+=1
print(cnt)

Measured memory_bytes: 73580