akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// requiredstring contains stringlist ?(yes:1,no:0)
template <class T>
bool strcontain(const string stringlist,
                const T& requiredstring) {
  return stringlist.find(requiredstring) != string::npos;
}
void prians(bool answer) {
  if(answer)
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

string s = "aiueo";
char x;

int main() {
  cin >> x;
  prians(strcontain(s, x));
  return 0;
}

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

long long gcd(long long a,long long b){
  while(true){
  if(a < b) swap(a,b);
  if(!b) break;
  a %= b;
  }
  return a;
}

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

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


Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
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;}
//fixed<< setprecision(2)
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n;
    while(cin >> n){
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += i * (n / i) * (n / i + 1) / 2;
    }
    cout << ans << endl;
    }
}

Measured memory_bytes: 3140
N, M = map(int, input().split())
C = [0]*M
for i in range(N):
    _, *A = map(int, input().split())
    for a in A:
        C[a-1] += 1
ans = 0
for i in range(M):
    if C[i] == N:
        ans += 1
print(ans)

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<uint_fast64_t modulus>
class modInt{
    using u64 = uint_fast64_t;

private:
    u64 num;

    u64 _power(u64 _x, u64 _n){
        u64 res = 1;
        while(_n > 0){
            if(_n & 1){
                res = res * _x % modulus;
            }
            _x = _x * _x % modulus;
            _n >>= 1;
        }
        return res;
    }

public:
    modInt(){
        num = 0;
    }

    modInt(u64 x){
        num = x % modulus;
    }

    u64 get(void){
        return num;
    }

    modInt &operator+=(const modInt &rhs){
        num += rhs.num;
        if(num >= modulus){
            num -= modulus;
        }
        return *this;
    }

    modInt &operator-=(const modInt &rhs){
        if(num < rhs.num){
            num += modulus;
        }
        num -= rhs.num;
        return *this;
    }

    modInt &operator*=(const modInt &rhs){
        num = num * rhs.num % modulus;
        return *this;
    }

    modInt &operator/=(const modInt &rhs){
        num = num * _power(rhs.num, modulus - 2) % modulus;
        return *this;
    }

    modInt operator+(const modInt &rhs){
        return modInt(*this) += rhs;
    }

    modInt operator-(const modInt &rhs){
        return modInt(*this) -= rhs;
    }

    modInt operator*(const modInt &rhs){
        return modInt(*this) *= rhs;
    }

    modInt operator/(const modInt &rhs){
        return modInt(*this) /= rhs;
    }
};

using mint = modInt<1000000007>;

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

    int n;
    cin >> n;

    mint dp[101][4][4][4];
    dp[0][3][3][3] = 1;

    rep(i, n){
        rep(j, 4){
            rep(k, 4){
                rep(l, 4){
                    rep(m, 4){
                        if((j == 0 && m == 1 && (k == 2 || l == 2)) || (k == 0 && l == 2 && m == 1) || (k == 0 && l == 1 && m == 2) || (k == 2 && l == 0 && m == 1)){
                            continue;
                        }
                        dp[i + 1][k][l][m] += dp[i][j][k][l];
                    }
                }
            }
        }
    }

    mint ans;
    rep(j, 4){
        rep(k, 4){
            rep(l, 4){
                ans += dp[n][j][k][l];
            }
        }
    }

    cout << ans.get() << endl;

    return 0;
}

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

#define A first
#define B second

const int MAXN = 1e5+5;

ll n, m, ans;
vector<int> g[MAXN];
bool isc[MAXN];
int deg[MAXN];
int p[MAXN];
vector<int> gg[MAXN];
vector<int> c, d;

pii dfs(int v, int f = -1) {
	pii tot = pii(0, 0);
	for (int u : g[v]) {
		if (isc[u] || u == f)
			continue;
		pii t = dfs(u, v);
		tot.A += t.A;
		tot.B += t.B;
	}

	if (tot.A >= tot.B)
		tot.A -= tot.B, tot.B = 0;
	else
		tot.B -= tot.A, tot.A = 0;

	if (tot.B >= 1)
		tot.B--;
	else
		tot.A++;

	if (!isc[v])
		ans += (tot.A + tot.B);
	swap(tot.A, tot.B);
	return tot;
}

void findc() {
	set<pii> s;
	for (int i = 0; i < n; ++i) {
		deg[i] = g[i].size();
		s.insert(pii(deg[i], i));
		// cout << i << ' ' << deg[i] << endl;
	}

	while (!s.empty()) {
		pii t = (*s.begin());
		// cout << t.B << endl;
		if (t.A == 2)
			break;
		s.erase(t);
		for (int u : g[t.B]) {
			s.erase(pii(deg[u], u));
			deg[u]--;
			if (deg[u] != 0)
				s.insert(pii(deg[u], u));
		}
	}

	for (pii t : s)
		isc[t.B] = 1;
}

void dfsc(int v, int f = -1) {
	d.push_back(v);
	if (gg[v][0] != f && gg[v][0] != d[0]) {
		dfsc(gg[v][0], v);
	} else if (gg[v][1] != f && gg[v][1] != d[0]) {
		dfsc(gg[v][1], v);
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	if (m == n-1) {
		g[0].push_back(g[0][0]);
		g[g[0][0]].push_back(0);
	}

	if (n%2 == 1) {
		cout << "-1\n";
		return 0;
	}

	findc();

	for (int i = 0; i < n; ++i)
		if (isc[i]) {
			c.push_back(i);
			pii t = dfs(i, -1);
			p[i] = t.A - t.B;
		}

	for (int i : c)
		for (int j : g[i])
			if (isc[j])
				gg[i].push_back(j);

	dfsc(c[0]);
	c = d;

	if (c.size()%2 == 1) {
		ll x = 0;
		for (int i : c)
			x = -x + p[i];
		x /= 2;
		ans += abs(x);
		for (int i = 0; i < c.size()-1; ++i) {
			x = -x + p[c[i]];
			ans += abs(x);
		}

		cout << ans << endl;
	} else {
		ll s1 = 0, s2 = 0;
		for (int i = 0; i < c.size(); i += 2)
			s1 += p[c[i]], s2 += p[c[i+1]];
		if (s1 != s2) {
			cout << "-1\n";
			return 0;
		}

		vector<int> b;
		b.push_back(0);
		ll x = 0;

		for (int i = 0; i < c.size()-1; ++i) {
			x = -x + p[c[i]];
			if (i%2 == 0)
				b.push_back(-x);
			else
				b.push_back(x);
		}

		sort(b.begin(), b.end());
		for (int i = 0; i < c.size()/2; ++i)
			ans += b[i+c.size()/2] - b[i];
		cout << ans << endl;
	}
}

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

int main()
{
    int n, sum = 0;
    cin >> n;
    vector<int> l(n), r(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l.at(i) >> r.at(i);
        sum += r.at(i) - l.at(i) + 1;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int h,w,k;cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    int ans = INF;
    for (int bit = 0; bit < 1<<(h-1); bit++) {
        int p = __builtin_popcount(bit);
        vector<int> v;
        for (int i = 0; i < (h-1); i++) {
            if((bit >> i)&1) v.pb(i);
        }
        v.pb(h-1);
        vector<vector<int>> x(p+1,vector<int>(w,0));
        int l = 0,r = 0;
        for (int i = 0; i < v.size(); i++) {
            r = v[i];
            for (int j = l; j <= r; j++) {
                for (int l = 0; l < w; l++) {
                    x[i][l] += s[j][l] - '0';
                }
            }
            l = v[i] + 1;
        }
        int cnt = p;
        vector<int> t(x.size(),0);
        bool f = true;
        for (int j = 0; j < w; j++) {
            bool q = false;
            for (int i = 0; i < x.size(); i++) {
                t[i] += x[i][j];
                if(t[i] > k){
                    q = true;
                }
            }
            if(q){
                cnt++;
                for (int i = 0; i < x.size(); i++) {
                    t[i] = x[i][j];
                    if(t[i] > k){
                        f = false;
                        break;
                    }
                }
            }
        }
        if(f) chmin(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF=1LL<<60;
const int nmax=200005;
int par[nmax];
void init(int x){
    for(int i=0;i<x;i++){
        par[i]=i;
    }
}
int root(int x){
    if(par[x]==x){
        return x;
    }
    return par[x]=root(par[x]);
}
void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y){
        return ;
    }
    par[y]=x;
}
int main(){
    int n,k,l;cin >> n >> k >> l;
    init(n);
    vector<int> a(n,-1),b(n,-1);
    for(int i=0;i<k;i++){
        int p,q;cin >> p >> q;
        p--,q--;
        unite(p,q);
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[root(i)]==-1){
            a[root(i)]=cnt;
            cnt++;
        }
        a[i]=a[root(i)];
    }
    init(n);
    for(int i=0;i<l;i++){
        int r,s;cin >> r >> s;
        r--,s--;
        unite(r,s);
    }
    cnt=0;
    for(int i=0;i<n;i++){
        if(b[root(i)]==-1){
            b[root(i)]=cnt;
            cnt++;
        }
        b[i]=b[root(i)];
    }
    map<pair<int,int>,int> m;
    for(int i=0;i<n;i++){
        m[{a[i],b[i]}]++;
    }
    for(int i=0;i<n;i++){
        cout << m[{a[i],b[i]}] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 14336
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        if(N<1000){
            System.out.println("ABC");
        }else{
            System.out.println("ABD");
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
typedef long long ll;
const ll INF=1ll<<60;
template<class T>inline bool chmin (T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<class T>inline bool chmax(T& a, T b){if(a<b){a=b;return 1;} return 0;}

int main(){
  ll dp[100010];
  ll h[100010];
  int N;
  cin >> N;
  FOR(i,0,N){
    cin >> h[i];
  }
  dp[0]=0;
  FOR(i,1,100010){dp[i]=INF;}
  FOR(i,1,N){
    chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1)
      chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N-1] << endl;
}



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

int main () {
  string s; cin >> s;
  if(s.at(0) == 'S')
    cout << "Cloudy";
  else if(s.at(0) == 'C')
    cout << "Rainy";
  else if (s.at(0) == 'R') 
    cout << "Sunny";
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    int a, b;
    cin >> a >> b;
  	int ans = a - 2*b;
	if(ans<0) ans = 0;
  	cout << ans << endl;   	 
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	long long i,sum=0;
	cin>>s;
	for(i=1;i<s.length();i++)
	{
		if(s[i]!=s[i-1])
		{
			sum++;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  for(int i=1;i<=B;i++){
    if((i*A-C)%B==0){
cout<<"YES"<<endl;
      break;
    }
    
    if(i==B&&(i*A-C)%B!=0){
cout<<"NO"<<endl;
    }
  }
  
}
  
    
    
    

  

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue> 
using namespace std;
#define INF 0x3f3f3f3f
char a[15],b[15],c[15];
int n,m,k;
int main()
{
	while(~scanf("%d%d%d",&n,&m,&k))
	{
		if(k>=n&&k<=m) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys

#0:上面 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]  #[0, 1, 2, 3, 4, 5]
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
    
    def equal(self, dice):  # 自分と引数のサイコロが同一か判定
        directions = "EEEENEEEENEEEENEEEEWSEEEESSEEEE"  # サイコロの向きの全通りを試すための転がす命令（余分な転がしも含む）
        for d in directions:
            self.roll(d)
            for i in range(6):
                if self.number[i] != dice.number[i]:
                    break
                if i == 5:
                    return True
        return False

n = int(input())
dice_list = []
for i in range(n):
    dice_num = list(map(int, input().split()))
    dice = Dice()
    dice.setNumber(dice_num[0], dice_num[1], dice_num[2], dice_num[3], dice_num[4], dice_num[5])
    dice_list.append(dice)

for i in range(n):
    for j in range(i + 1, n):
        if dice_list[i].equal(dice_list[j]):  # 同じのが見つかった
            print("No")
            sys.exit()
print("Yes")


Measured memory_bytes: 5628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] data = line.split(" ");
		int W = Integer.parseInt(data[0]);
		int H = Integer.parseInt(data[1]);
		int x = Integer.parseInt(data[2]);
		int y = Integer.parseInt(data[3]);
		int r = Integer.parseInt(data[4]);
		boolean judgment = false;

		if ((-100 <= x && x <= 100) && (-100 <= y && y <= 100)
				&& (0 < W && W <= 100) && (0 < H && H <= 100)
				&& (0 < r && r <= 100)) {

			if ((x + r) <= W) {
				if ((x - r) >= 0) {
					if ((y + r) <= H) {
						if ((y - r) >= 0) {
							judgment = true;
						}
					}
				}

			}

			if (judgment) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}

}



Measured memory_bytes: 26276
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#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;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e5+4;

int main()
{
	ll lim=LLONG_MAX;

	set<ll> st;

	vector<ll> v;

	map<ll,ll> ma;

	v.pb(0); st.insert(0); ma[0]=0;


	for(ll i=1;i<10000LL;i++)
	{
		ll temp=i*i*i*i;

		if(temp<=lim/i)
		st.insert(temp*i),v.pb(temp*i),ma[temp*i]=i;
	}

	ll n;

	lscn(n);

	rep(i,0,v.size())
	{
		//sum
		if(v[i]<=n)
		{
			if(st.find(n-v[i])!=st.end())
			{
				cout<<ma[n-v[i]]<<" "<<-ma[v[i]]; return 0;
			}
		}

		//subtract
		if(v[i]>=n)
		{
			if(st.find(v[i]-n)!=st.end())
			{
				cout<<ma[v[i]]<<" "<<ma[v[i]-n]; return 0;
			}
		}
	}

    return 0;
}

Measured memory_bytes: 4432
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, w = ns()
    d = []
    for _ in range(n):
        vi, wi = ns()
        d.append([wi, vi])

    def allcase(array):
        res = [[0, 0]]
        for wi, vi in array:
            nxt = [[wi + wt, vi + vt] for wt, vt in res]
            res += nxt
        res.sort(key=lambda x: x[1])
        res.sort()

        maximum = -1
        tres = []

        for wi, vi in res:
            if vi > maximum:
                tres.append([wi, vi])
                maximum = vi

        return tres

    a = allcase(d[:n // 2])
    b = allcase(d[n // 2:])

    a_idx = len(a) - 1
    b_idx = 0
    ans = 0
    while a_idx > -1:
        a_idx -= 1
        b_idx = max(0, b_idx - 1)
        while len(b) > b_idx > -1:
            if a[a_idx][0] + b[b_idx][0] <= w:
                ans = max(ans, a[a_idx][1] + b[b_idx][1])
                b_idx += 1
            else:
                break

    print(ans)


if __name__ == '__main__':
    main()



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<double> a(n);
  REP (i, n) {
    scanf("%lf", &a[i]);
  }

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

  double ans = a[0];
  double now = double(INF);
  REP (i, n) {
    if (now > abs(a[n - 1] / 2 - a[i])) {
      now = a[n - 1] / 2 - a[i];
      ans = a[i];
    }
  }

  cout << int(a[n - 1]) << " " << int(ans) << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long k,i,j,l,m,n,x,y,z;
	cin>>k>>n;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	x=k-arr[n-1]+arr[0];
	for (i=0;i<n-1;i++)
	{
		y=arr[i+1]-arr[i];
		x=max(x,y);
	}
	cout<<k-x<<endl;
}

Measured memory_bytes: 1792
def d_SnukeColoring(H, W, N, A):
    from collections import Counter
    # 要素(p,q)は、(p,q)を左上とする3x3正方形の中に黒マスを1つ含むことを意味する
    # (p,q)が複数回存在した場合は、正方形の中にその回数だけ黒マスを含むことを意味する
    c = []
    for a, b in A:
        a -= 1
        b -= 1
        for k in range(3):
            for l in range(3):
                p = a - k
                q = b - l
                # この2つの条件文を通った場合、3x3正方形が盤の外に出てしまっている
                if p < 0 or p > H - 3:
                    continue
                if q < 0 or q > W - 3:
                    continue
                c.append((p, q))
    # Counter(c).values():(p,q)を左上とする正方形の中に含まれている黒マスの個数
    # これをCounter()に通すと、黒マスをj個含む正方形の個数が得られる
    c = Counter(Counter(c).values())
    c[0] = (H - 2) * (W - 2) - sum(c.values())  # 黒マスがない正方形の個数
    ans = ''
    for i in range(0, 10):
        ans += str(c[i]) + '\n'
    return ans[:-1]

H,W,N=[int(i) for i in input().split()]
A=[[int(i) for i in input().split()] for j in range(N)]
print(d_SnukeColoring(H, W, N, A))

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

#define INF 1234567890
#define ll long long

int N;
int v[200201];
ll cnt[200201];

int main()
{
	scanf("%d", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &v[i]);
		cnt[v[i]]++;
	}
	ll sum = 0;
	for(int i=1; i<=N; i++)
		sum += (cnt[i]*(cnt[i]-1))/2;

	for(int i=1; i<=N; i++)
	{
		ll val = sum;
		val -= (cnt[v[i]]*(cnt[v[i]]-1))/2;
		cnt[v[i]]--;
		val += (cnt[v[i]]*(cnt[v[i]]-1))/2;
		printf("%lld\n", val);

		cnt[v[i]]++;
	}
	return 0;
}

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

#define int long long


int func(int n){
    int ret = 0;
    while(n%100==0)
    {
        n/=100;
        ret++;
    }
    return ret;
}

signed main() {
    
    int d, n;
    cin >> d >> n;
    
    int i;
    int cnt = 0;
    for(i=1;;i++){
        if(func(i)==d){cnt++;}
        if(cnt==n) break;
//        cerr << i << " " << func(i) << endl;
    }
    cout << i << endl;
    
    return 0;
}


Measured memory_bytes: 256
ac = 0
wa = 0
tle = 0
re = 0

n = int(input())

for _ in range(n):
    result = input()
    if result == "AC":
        ac += 1
    if result == "WA":
        wa += 1
    if result == "TLE":
        tle += 1
    if result == "RE":
        re += 1
    
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9208
package main

import(
  "fmt"
)

func main() {
  var x string
  fmt.Scan(&x)
  if x[:1] != x[1:2] {
    fmt.Print("Yes")
  }else if x[:1] != x[2:] {
    fmt.Print("Yes")
  }else {
    fmt.Print("No")
  }
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();

        if (Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

}


Measured memory_bytes: 21332
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    string S;
    cin >> S;


    int max = 0;
    int counter = 0;
    for (int i = 0; i < S.size(); ++i) {

        string str = S.substr(i, 1);
        if (str == "A" || str == "T" || str == "C" || str == "G") {
            ++counter;
        } else {
            counter = 0;
        }
        if (counter > max) {
            max = counter;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
n,bod = map(int,input().split())
points = []
x = []
y = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
    points.append([a,b])

x.sort()
y.sort()


ans = 1e20

for i in range(n):
    for j in range(1,n-i):
        for k in range(n):
            for l in range(1,n-k):
                lef = x[i]
                rig = x[-j]
                bot = y[k]
                top = y[-l]

                cnt = 0
                for m in range(n):
                    if lef <= points[m][0] <= rig and bot <= points[m][1] <= top:
                        cnt += 1
                if cnt >= bod:
                    area = (rig-lef)*(top-bot)
                    if area < ans:
                        ans = area


print(ans)

Measured memory_bytes: 47068
#include <bits/stdc++.h>
#define oo 0x3f3f3f3f
using namespace std;

const int N = 100005;
int path[N], dp[N];
pair < int, int >st[N << 2];

void update(int p, int l, int r, int pos, int val){
	if(pos > r || pos < l) return ;
	if(l == r){
		st[p] = {val, l};
		return ;
	}
	int mid = (l + r) >> 1;
	update(p << 1, l, mid, pos, val);
	update(p << 1|1, mid+1, r, pos, val);
	if(st[p << 1].first <= st[p << 1|1].first) st[p] = st[p << 1];
	else st[p] = st[p << 1|1];
}

pair < int, int > query(int p, int l, int r, int a, int b){
	if(a > r || b < l) return {oo, oo};
	if(l >= a && r <= b){
		return st[p];
	}
	int mid = (l + r) >> 1;
	pair < int, int > x = query(p << 1, l, mid, a, b), y = query(p << 1|1, mid+1, r, a, b);
	if(x.first <= y.first) return x;
	return y;
}

int main(){
	int n, m;
	cin >> n >> m;
	string str;
	cin >> str;
	memset(st, oo, sizeof st);
	dp[n] = (str[n] == '0') ? 0 : oo;
	path[n] = -1;
	update(1, 0, n, n, dp[n]);
	for (int i=n-1; i>=0; i--){
		pair < int, int > nxt = query(1, 0, n, i+1, i+m);
		if(str[i] == '1' || nxt.first == oo){
			dp[i] = path[i] = oo;
		}
		else {
			dp[i] = nxt.first+1;
			path[i] = nxt.second;
		}
		update(1, 0, n, i, dp[i]);	
	}
	if(dp[0] != oo){
		int now = 0;
		while (path[now] != -1){
			printf("%d", path[now] - now);
			if(path[path[now]] != -1) printf(" ");
			else printf("\n");
			now = path[now];
		}
	}
	else printf("-1\n");
}


Measured memory_bytes: 4608
import java.util.*

fun main(args: Array<String>) {

    var sc = Scanner(System.`in`)

    val s = sc.nextLine()

    val n = s.length


    if(isKaibun(s) && isKaibun(s.slice(0 until (n-1)/2)) && isKaibun(s.slice((n+3/2 until n)))) {
        println("Yes")
    } else {
        println("No")
    }



}

public fun isKaibun(s:String): Boolean{
    return s.equals(s.reversed())
}

Measured memory_bytes: 31264
n = int(input())
buildings = []
for b in range(4):
    floors = []
    for f in range(3):
        rooms = []
        for r in range(10):
            rooms.append(0)
        floors.append(rooms)
    buildings.append(floors)

for _ in range(n):
    b, f, r, v = (int(x) for x in input().split())
    buildings[b-1][f-1][r-1] += v

for b in range(4):
    if b > 0 and b < 4:
        print("#"*20)
    for f in range(3):
        line = ""
        for r in range(10):
            v = buildings[b][f][r]
            line += " " + str(v)
        print(line)


Measured memory_bytes: 5604
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	int n;
	int h[30];

	//よく使う変数
	int i,j,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	int dummy;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);



	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
//		scanf_s("%d",&h[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	temp=0;
	for(i=0;i<n;i++){
		temp=max(temp,h[i]);
		if(temp<=h[i]){
			ans++;
		}
	}


	//	printf("計算部分終了\n");

	//出力
	printf("%d\n",ans);

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define yes "YES"
#define no "NO"
#define rsort(a) sort(a.rbegin(),a.rend())
const int mod=1000000007;
//void dfs(int i);
long long modular_expo(long long x,long long y);

bool cmp(pair<double,int>p1,pair<double,int>p2)
{
    if(p1.first>p2.first)
        return true;
    else
    {
        if(p1.first<p2.first)
            return false;
        else if(p1.first==p2.first)
        {
            if(p1.second<p2.second)
                return true;
            else
                return false;
        }
    }
}
/*bool cmp1(map<int,int>a,map<int,int>b)
{
    if(a.first<b.first)
        return true;
    else
        return false;
}*/
//ll m;


/*
void bsf(int t)
{
    queue<int>q;
    visited[t]=true;
    q.push(t);
    while(!q.empty())
    {
        int temp=q.front();
        //cout<<temp<<" ";
        if(temp==n)
            {
                vector<int>ans;
    ans.pb(n);
        int tttt=n;
    for(int i=0;i<tttt;i++)
    {
        ans.pb(parent[n]);
        n=parent[n];
        if(n==1)
            break;
    }
    if(n!=1)
    {
        break;
    }
    cout<<ans.size()<<endl;
    for(int i=ans.size()-1;i>=0;i--)
        cout<<ans[i]<<" ";
        f=1;

            }
        q.pop();
        //cout<<temp<<" ";
        for(auto i=l[temp].begin();i!=l[temp].end();i++)
        {
            if(!visited[*i])
            {
                q.push(*i);
                parent[*i]=temp;
                visited[*i]=true;
            }
        }
    }
}
*/
long long modular_expo(long long x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return (modular_expo((x*x),y/2));
    if(y%2==1)
        return ((x)*modular_expo((x*x),(y-1)/2));


}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    string s;
    cin>>s;
    ll sum=0;
    int i;
    for(i=0;i<s.length();i++)
    {
        sum+=(s[i]-'0');
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}




Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n - 1); 0 <= i; --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

template <typename ArrayT>
void DumpArray(const ArrayT &arr)
{
	for (auto it = arr.begin(); it != arr.end(); ++it) {
		cerr << *it << " ";
	}
	cerr << endl;
};
template <typename T>
bool ChMin(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
bool ChMax(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

// 繰り下がり有無
static const int DESC = 1;
static const int NONE = 0;

const int ILEN = 10000005;
const int KLEN = 2;

int DP[ILEN][KLEN];

class Solver
{
	void InitDP()
	{
		REP (i, ILEN)
			REP (k, KLEN) {
				DP[i][k] = INT_MAX;
			}
	}

  public:
	Solver() {}
	void Solve(istream &cin, ostream &cout)
	{
		string S;
		cin >> S;

		// 桁DP
		// dp[桁（下位から）]
		//   [前の桁からの繰り下がりなし/あり]
		//   = 使用した紙幣枚数

		SolveDP(S);

		// 結果を計算
		// ※ 配るDPの場合、結果は S.Length(＝最後のi + 1) に格納されている
		// ※ 整数問題の場合、all 0
		// の分を1個マイナスするのを忘れずに！先行0にも要注意！ ※
		// MOD系は、最後のMODを忘れないことと、MODの前処理で負数にしないこと
		int ans = min(DP[S.length()][DESC]+1, DP[S.length()][NONE]);

		DumpDP(S.length());

		cout << ans << endl;
	}

	void SolveDP(string s)
	{
		InitDP();
		DP[0][NONE] = 0;

		// ※loopはいつも昇順にしたほうが良さそう
		// ※逆順にすると、遷移も逆方向にしないといけないので
		// ※桁数を逆にする方が簡単
		REP (i, s.size()) {
			auto ni = i + 1;
			auto x = s[i] - '0';

			// ■繰り下がりなし
			if (INT_MAX != DP[i][NONE]) {
				// x を出す
				ChMin(DP[ni][NONE], DP[i][NONE] + x);
				// 繰り下がって0を出す
				ChMin(DP[ni][DESC], DP[i][NONE] + (10 - x));
			}

			// ■繰り下がりあり
			if (INT_MAX != DP[i][DESC]) {
				if (x == 9) {
					// 0を出して、更に繰り下がりするしかない
					ChMin(DP[ni][DESC], DP[i][DESC]);
				} else {
					// x + 1 を出す
					ChMin(DP[ni][NONE], DP[i][DESC] + x + 1);
					// 0 を出して、更に繰り下がらせる
					ChMin(DP[ni][DESC], DP[i][DESC] + (9 - x));
				}
			}
		}
	}

	void DumpDP(int len)
	{
		REP (i, len + 1) {
			cerr << DP[i][0] << "-" << DP[i][1] << " ";
		}
		cerr << endl;
	}
};

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 80412
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string s = Console.ReadLine();
		int ans = 0;
		for(int i = 0; i < 3; i++)
		{
			if(s[i] == '1')
				ans++;
		}

		Console.WriteLine(ans);
	}
}





Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
int n,m,i,j,a[100005],s;
vector<pair<int,int> > ans;
void print()
{
	printf("%d\n",s);
	ff(ans,it){
		printf("%d %d\n",it->first,it->second);
	}exit(0);
}
int main()
{
	scanf("%d",&n);
	fz1(i,n) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(a[1]>=0){
		s=a[1];fz(i,3,n){
			ans.push_back(make_pair(s,a[i]));
			s-=a[i];
		}ans.push_back(make_pair(a[2],s));s=a[2]-s;
		print();
	}
	if(a[n]<=0){
		s=a[n];
		fz1(i,n-1){
			ans.push_back(make_pair(s,a[i]));
			s-=a[i];
		}
		print();
	}
	j=1;while(a[j]<=0)j++;
	fz(i,j+1,n){
		ans.push_back(make_pair(a[1],a[i]));
		a[1]-=a[i];
	}
	fz1(i,j-1){
		ans.push_back(make_pair(a[j],a[i]));
		a[j]-=a[i];
	}s=a[j];print();
	return 0;
}

Measured memory_bytes: 3188
import itertools
n,m=map(int,input().split())
N=[i for i in range(1,n+1)]
M=[i for i in range(1,m+1)]
n_com=itertools.combinations(N,2)
m_com=itertools.combinations(M,2)
print(len(list(n_com))+len(list(m_com)))

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

int main(){
    int A, B, C, N, M ,K;

    cin >> N >>A>>B;

    C = min(A, B);
    if(A+B-N>0) K = A+B-N;
    else K = 0;

    cout << C << " " << K << endl;

}

Measured memory_bytes: 256
N = gets.to_i
a = gets.split(" ").map(&:to_i)
num = Array.new(N, 0)
ans = 0

a.each do |x| 
    num[x - 1] += 1 
end

num.each do |x|
    if x > 1 
        ans += x * (x - 1) / 2
    end
end

N.times do |i|
    puts ans - (num[a[i] - 1] * (num[a[i] - 1] - 1) / 2) + ((num[a[i] - 1] - 1) * (num[a[i] - 1] - 2) / 2)
end


Measured memory_bytes: 23180
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	char c[9];
	for (int i = 0; i < 9; i++)cin >> c[i];
	cout << c[0] << c[4] << c[8] << endl;
	int x;
	cin >> x;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define     uniq(x)         sort(x.begin(),x.end());x.erase(unique(x.begin(),x.end()),x.end())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)

using ll = long long int;


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

    vector<double>vv;
    ll sum=0;
    while(n--)
    {
        double a;cin>>a;
        vv.emplace_back(a);
        sum+=a;
    }
    int flag=0;
    double xx = 1.0/(4*m);
    //cout<<xx<<endl;
    for(int i=0;i<vv.size();i++)
    {
        double yy = (double)(vv[i]/sum*1.0);
        //cout<<yy<<endl;
        if(yy>=xx) flag++;
    }
    //cout<<flag<<' '<<m<<endl;
    if(flag<m) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0 ; i < n ; ++i)

using namespace std;

#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif

int main()
{
	debug_io
	int w, h;
	while (cin >> w >> h, w + h) {
		int tile[55][55];
		REP(i, h) {
			REP(j, w) {
				cin >> tile[i][j];
			}
		}

		int dx[8] = { 0,0,1,-1,1,1,-1,-1 };
		int dy[8] = { 1,-1,0,0,1,-1,1,-1 };

		int ans = 0;
		REP(i, h) {
			REP(j, w) {
				if (tile[i][j] == 1) {
					vector<pair<int, int>> bfs;
					bfs.push_back({ i,j });

					while (bfs.size()) {
						auto now = bfs.front();
						bfs.erase(bfs.begin());
						int x = now.second;
						int y = now.first;
						if (tile[y][x] == 2) {
							continue;
						}
						tile[y][x] = 2;
						REP(k, 8) {
							int nx = max(0,min(x + dx[k],w-1));
							int ny = max(0, min(y + dy[k], h - 1));
							if (tile[ny][nx] == 1) {
								bfs.push_back({ ny,nx });
							}
						}
					}
					ans++;
					
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353
using namespace std;


int main() {
    

    ll n;
    cin >> n;
    vector <ll> a;
    for(ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    reverse(a.begin(), a.end());
    vector <ll> v;
    if(n%2 == 0){
        for(ll i=0;i<n;i++){
            if(i < 2){
                v.push_back(a[i]);
            }else{
                if(i%2 == 0){
                    v.push_back(a[i] + v[i-2]);
                }else{
                    v.push_back(a[i] + max(v[i-2], v[i-3]));
                }
            }
        }
        reverse(v.begin(), v.end());
        cout << max(v[0], v[1]) << endl;
    }else{
        for(ll i=0;i<n/2 * 3;i++){
            if(i < 3){
                v.push_back(a[i]);
            }else{
                if(i%3 == 0){
                    v.push_back(a[i - i/3] + v[i-3]);
                }else if(i%3 == 1){
                    v.push_back(a[i - i/3] + max(v[i-3], v[i-4]));
                }else{
                    v.push_back(a[i-i/3] + max(v[i-3], max(v[i-4], v[i-5])));
                }
            }
        }
        reverse(v.begin(), v.end());
        cout << max(v[0], max(v[1], v[2])) << endl;
    }



}

Measured memory_bytes: 8944
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
t=x
for i in range(n):
    if i!=n-1:
        t-=a[i]
        if t<0:
            break
        ans+=1
    else:
        if t==a[i]:
            ans+=1
        break
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string a, b, c;
    cin>>a>>b>>c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
void main()
{
    string s = rdStr;

    writeln(s == "ABC" ? "ARC" : "ABC");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2700
n=int(input())
b=list(map(int,input().split()))
c=0
d=0
while c<=n-3 :
    if (b[c+1]>b[c] and b[c+1]<b[c+2]) or (b[c+1]<b[c] and b[c+1]>b[c+2]):
        d +=1
        c +=1
    else:
        c+=1

print(d)


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

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

    int A[m], B[m];
    for(int i = 0; i < m; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    int cnt = 0;
    for(int c = 0; c < m; c++){
        int G[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == j) G[i][j] = 0;
                else G[i][j] = 1e9;
            }
        }

        for(int i = 0; i < m; i++){
            if(i == c) continue;
            else{
                G[A[i]][B[i]] = 1;
                G[B[i]][A[i]] = 1;
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                for(int k = 0; k < n; k++){
                    G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
                }
            }
        }

        bool f = false;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(G[i][j] == 1e9){
                    f = true;
                    break;
                }
            }
            if(f) break;
        }
        if(f) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >> N >> M;
  cout << (N+M)*(N+M-1)/2 - N*M << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=110;
int n;
int a[N][2],b[N][2];
namespace BG{
	const int S=N*2;
	int h[S],tot;
	struct Edge{
		int v,next;
	}e[(N*N)*2];
	void addEdge(int u,int v){
		e[++tot]=(Edge){v,h[u]}; h[u]=tot;
		e[++tot]=(Edge){u,h[v]}; h[v]=tot;
	}
	int match[S];
	bool vis[S];
	bool HungaryDfs(int u){
		for(int i=h[u],v;i;i=e[i].next)
			if(!vis[v=e[i].v]){
				vis[v]=true;
				if(!match[v]||HungaryDfs(match[v])){
					match[u]=v;
					match[v]=u;
					return true;
				}
			}
		return false;	
	}
	int Hungary(){
		int res=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n*2;j++) vis[j]=false; // !!
			if(HungaryDfs(i))
				res++;
		}
		return res;	
	}
}
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i][0],&a[i][1]);
	for(int i=1;i<=n;i++) scanf("%d%d",&b[i][0],&b[i][1]);
}
void link(){
	for(int i=1;i<=n;i++) // blue(bigger)
		for(int j=1;j<=n;j++) // red
			if(a[j][0]<b[i][0]&&a[j][1]<b[i][1])
				BG::addEdge(i,n+j);
}
int main(){
	readData();
	link();
	printf("%d\n",BG::Hungary());
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        int N = Integer.parseInt(sc.next());
        for(int i=0;i<N;i++){
            run();
        }
        
    }
    
    static void run(){
        String strA = sc.next();
        BigInteger A = new BigInteger(strA);
        String strB = sc.next();
        BigInteger B = new BigInteger(strB);
        String o = "overflow";
        if(A.add(B).toString().length()>80){
            System.out.println(o);
        }else{
            System.out.println(A.add(B));
        }
        
    }
}

Measured memory_bytes: 18384