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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100

int main()
{
    int n, m;
    cin >> n >> m;
    vll x(n), y(m);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for(int i = 0; i < m; i++)
    {
        cin >> y[i];
    }

    ll sx = 0, sy = 0;

    for(int i = 0; i < n; i++)
    {
        sx += (i - (n-1-i))*(x[i]);
        sx %= 1000000007;

    }
    for(int i = 0; i < m; i++)
    {
        sy += (i - (m-1-i))*(y[i]);
        sy %= 1000000007;
    }

    ll ans = (sx*sy)%1000000007;

    cout << ans << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=10000;i++)
	if((int)(i*0.08)==a&&(int)(i*0.1)==b){
		cout<<i<<"\n";
		return 0;
	}
	cout<<-1<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string N;
    cin >> N;
    ll sum = 0;
    int sz = N.size();
    rep(i,sz){
        sum += N[i] - '0';
        sum %= 9;
    }
    cout << ((sum%9 == 0) ? "Yes" :"No") << endl;
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int main(){
  int x,y,gx,gy;
  cin >> x >> y;
  
  if(x==2) gx = 3;
  else if(x==1 || x==3 || x==5 || x==7 ||x==8 || x==10  || x==12) gx = 1;
  else gx = 2;
  
  if(y==2) gy = 3;
  else if(y==1 || y==3 || y==5 || y==7 ||y==8 || y==10  || y==12) gy= 1;
  else gy=2;
  
  if(gx==gy) cout << "Yes" <<endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import re
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7
N = int(input())
CHAR = ["A", "C", "G", "T"]
pattern = r'ACG|GAC|A.?GC|AG.?C'
reg = re.compile(pattern)

dp = {a+b+c: 1 if not reg.search(a+b+c)
      else 0 for a in CHAR for b in CHAR for c in CHAR}


for i in range(N-3):
    next_dp = {key: 0 for key, _ in dp.items()}
    for key, val in dp.items():
        for c in CHAR:
            next_val = key+c
            if reg.search(next_val):
                continue
            else:
                next_dp[(key+c)[1:]] += dp[key]
    dp = next_dp
    for key in dp.keys():
        dp[key] %= MOD
print(sum(dp.values()) % MOD)


Measured memory_bytes: 3316
def roll(i):
    global u, s, e, w, n, d
    if i == 'N':
        u, s, n, d = s, d, u, n
    elif i == 'E':
        u, e, w, d = w, u, d, e
    elif i == 'S':
        u, s, n, d = n, u, d, s
    elif i == 'W':
        u, e, w, d = e, d, u, w

u, s, e, w, n, d = input().split()
q = int(input())
for i in range(q):
    u1, s1 = input().split()
    if u1 == u:
        pass
    elif u1 == s:
        roll('N')
    elif u1 == e:
        roll('W')
    elif u1 == w:
        roll('E')
    elif u1 == n:
        roll('S')
    elif u1 == d:
        roll('N')
        roll('N')
    if s1 == s:
        print(e)
    elif s1 == e:
        print(n)
    elif s1 == n:
        print(w)
    elif s1 == w:
        print(s)

Measured memory_bytes: 7724
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

bool isprime(ll i){
    if(i ==2) return true;
    if(i%2 == 0) return false;
    ll tmp = 3;
    double zz = 1+sqrt((double)i);
    while (tmp <= zz) {
        if (i%tmp == 0) {
            return false;
        }
        tmp+=2;
    }
    return true;
}
int main() {
    ll n;
    cin>>n;
    vector<ll> v;
    ll i = 55555;
    while (v.size()!=n) {
        
        if(isprime(i) && i%5==1) v.push_back(i);
        i--;
    }
    rep(i, v.size()-1) cout<<v[i]<<" ";
    cout<<v[v.size()-1]<<endl;
//    rep(i, v.size()-5) pr(isprime(v[i]+v[i+1]+v[i+2]+v[i+3]+v[i+4]));
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
 
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
 
using namespace std;
 
 
int inputValue(){
    int a;
    cin >> a;
    return a;
};
 
void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};
 
void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
 
template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
 
int main(int argc, const char * argv[]) {
    char s[5];
    int ans=0;
    scanf("%s",s);
    int i;
    rep(i,4){
        if(s[i] == '+'){
            ans+=1;
        }else{
            ans-=1;
        }
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N),B(N);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }

    //pair <int, int> は二つの整数
    vector<pair<int,int> > AB(N);
    for(int i=0; i<N; i++){
        AB[i] = make_pair(A[i],B[i]);
    }
    sort(AB.begin(),AB.end());

    long long ans=0;
    for(int i=0; i<N; i++){
        //お店で購入数を決める
        int buy = min(M,AB[i].second);
        //買った金額を加算する
        ans += (long long)buy * AB[i].first;

        M-=buy;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define int long long
#define all(arr) arr.begin(),arr.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define br '\n'
/*int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
int MOD = 100001;*/

void solve()
{
	int n;
	cin>>n;
	vi arr(n);
	scan(arr,n);
	int ans = 0;
	int k = 0;
	loop(j,0,n-1)
	{
		if(arr[j+1]>arr[j])
		{
			ans = max(ans,k);
			k = 0;
		}
		else
			k++;
	}
	ans = max(ans,k);
	cout<<ans<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

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

using namespace std;

int main() {
        int h, w, n;
        int sx, sy;
        sx = sy = 0;
        cin >> w >> h >> n;
        while (n-->0) {
                int x, y, a;
                cin >> x >> y >> a;
                switch (a) {
                case 1:
                        sx = max(sx, x);
                        break;
                case 2:
                        w = min(w, x);
                        break;
                case 3:
                        sy = max(sy, y);
                        break;
                case 4:
                        h = min(h, y);
                        break;
                }
        }
        int answ = max(0, w - sx);
        int ansh = max(0, h - sy);

        cout << answ * ansh << endl;
        return 0;
}


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

int main(){
	long long N;
	cin >> N;
	long long num = N%10;
	if(num == 3) {
		cout << "bon" << endl;
	} else if (num == 0 || num == 1 || num ==6 || num == 8) {
		cout << "pon" << endl;
	} else {
		cout << "hon" << endl;
	}
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;

string Main(int N, string s)
{
    const string AL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int S = s.size();
    string ans;
    REP(i, S) {
        int ind = (s[i]-'A'+N) % 26;
        ans.push_back(AL[ind]);
    }
    return ans;
}

int main(void){
    int N;
    cin >> N;
    string s;
    cin >> s;
    cout << Main(N, s) << endl;
    return 0;
}

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

int main() {
  int N, i;
  string s;
  int P, W, G, Y;
  cin >> N;
  for (i = 0; N > i; i++) {
    cin >> s;
  if (s == "P") 
    P++;
  if (s == "W")
    W++;
  if (s == "G")
    G++;
  if (s == "Y")
    Y++; 
  }
  
  if (Y == 0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}



Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

#print(N)
#print(A)
all = {}
for a in A:
  if a not in all:
    all[a] = 0
  all[a] +=1

#print(all)
total = 0
for key, v in all.items():
  total += int(v*(v-1)/2)

for k in range(len(A)):
  ans = total - (all[A[k]] -1)
  print(ans)

Measured memory_bytes: 26140
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;
int n,m;
ll ans;
vector<ll> a(200005);
vector<ll> d(200005);
int main(){
  cin>>n;
  REP(i,n)cin>>a[i];
  for(int i=0;i<n;i++)d[i+1]=d[i]+a[i];
  sort(d.begin(),d.begin()+(n+1));
  ll b=d[0];
  ll bkazu=1LL;
  for(int i=1;i<=n;i++){
    if(b!=d[i]){
      ans+=(bkazu*(bkazu-1))/2;
      b=d[i];bkazu=1LL;
    }else{
      bkazu++;
    }
  }
  ans+=(bkazu*(bkazu-1))/2;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3328
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
pre = a[0] - 1
ans = b[pre]
for i in range(1, n):
    x = a[i] - 1
    ans += b[x]
    if pre == x - 1:
        ans += c[pre]
    pre = x
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 3000 + 47;

vector<int> g[MAX];
int A[MAX];
int L[MAX];

bool isWin(int v)
{
	if (L[v]) return false;

	FOR(i, 0, SZ(g[v]))
	{
		int to = g[v][i];
		if (A[to] < A[v])
		{
			if (!isWin(to)) return true;
		}
	}

	return false;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n) cin >> A[i];
	FOR(i, 0, n - 1)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	FOR(v, 0, n)
	{
		bool lose = true;
		FOR(i, 0, SZ(g[v]))
		{
			int to = g[v][i];
			if (A[to] < A[v])
			{
				lose = false;
				break;
			}
		}

		L[v] = lose;
	}

	FOR(v, 0, n)
	{
		if (isWin(v))
		{
			cout << v + 1 << " ";
		}
	}

	cout << endl;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  double R; cin >> R;
  cout << setprecision(16) << 2 * R * PI << endl;

  return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m, x;
    cin >> n >> m >> x;
    x--;
    vector<ll> a(m);
    rep(i, m) cin >> a[i];
    vector<ll> dp(n, 0);
    rep(i, m) dp[a[i] - 1]++;
    reps(i, 1, n) dp[i] += dp[i - 1];
    if (x == 0) cout << 0 << endl;
    else cout << min(dp[x - 1], dp[n - 1] - dp[x]) << endl;
    // rep(i, n) printf("%lld%s", dp[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
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;
}
int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a * c, a * d), max(b * c, b * d));
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cstdio>
const int MAXB = 1e5+5;
int B, N;

int main() {
  scanf("%d", &N);
  int prev = MAXB;
  int ret = 0;
  for (int i = 1; i < N; ++i) {
    scanf("%d", &B);
    ret += std::min(B, prev);
    prev = B;
  }
  ret += B;
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 128
import java.awt.geom.Point2D;
import java.util.*;

public class Main {
	final double EPS = 1.0e-08;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0) break;
			double [] x = new double[n];
			double [] y = new double[n];
			for(int i=0; i < n; i++){
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}
			int ans = 1;
			for(int i=0; i < n; i++){
				for(int j=i+1; j < n; j++){
					double midx = (x[i] + x[j]) / 2.0;
					double midy = (y[i] + y[j]) / 2.0;
					double halfdis = Point2D.distance(x[i], y[i], x[j], y[j]) / 2;
					if(halfdis> 1.0 + EPS){
						continue;
					}
					double midxV = x[i] - midx;
					double midyV = y[i] - midy;
					double tocenterDis = Math.sqrt(1.0 - halfdis * halfdis);
					for(int k=0; k <= 1;k++){
						double midxV2, midyV2;
						if(k==0){
							midxV2 = midyV * -1;
							midyV2 = midxV;
						}
						else{
							midxV2 = midyV;
							midyV2 = midxV * -1;
						}
						double dis2 = Math.sqrt(midxV2 * midxV2 + midyV2 * midyV2);
						double cx = (midxV2) * tocenterDis / dis2 + midx;
						double cy = (midyV2) * tocenterDis / dis2 + midy;
						//System.out.println("cx= " + cx + "cy " + cy);
						int res = getCount(cx,cy,x,y);
						ans = Math.max(ans, res);
					}
				}
			}
			//System.out.print("ANS= ");
			System.out.println(ans);
		}
	}

	private int getCount(double cx, double cy, double[] x, double[] y) {
		int count = 0;
		for(int i=0; i < x.length;i++){
			double res = Point2D.distance(cx, cy, x[i], y[i]);
			if(res<= 1.0 + EPS){
				count++;
			}
		}
		return count;
	}

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

Measured memory_bytes: 13000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126
{
    class B
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int a = int.Parse(S.Substring(0, 2));
            int b = int.Parse(S.Substring(2, 2));
            int flag = 0;
            if (a <= 12 && 0 < a) { flag++; }
            if (b <= 12 && 0 < b) { flag+=2; }
            string ans = "";
            switch (flag)
            {
                case 0:ans = "NA";break;
                case 1: ans = "MMYY"; break;
                case 2: ans = "YYMM"; break;
                default:ans = "AMBIGUOUS";
                    break;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#import<cstdio>
#import<map>
#define I(M,A)for(i=0;i<M;i++)scanf("%d",&x),A[i+1]=A[i]+x;
main(){for(int n[1501],m[1501],o,a,b,i,j,x;scanf("%d%d",&a,&b),a;printf("%d\n",o)){std::map<int,int>z;*n=*m=o=0;I(a,n)I(b,m)for(i=0;i<=a;i++)for(j=0;j<=b;)z[n[i]+m[j++]]++;for(std::map<int,int>::iterator p=z.begin();p!=z.end();p++)o+=p->second*(p->second-1)/2;}}

Measured memory_bytes: 18000
#include<stdio.h>

int main(){
  int a=0,b=0,d=0,r=0;
  double f;

  scanf("%d %d",&a,&b);

    d=a/b;
  printf("%d ",d);
    
    r=a%b;
    printf("%d ",r);

    f=(double)a/(double)b;
  printf("%f\n",f);
  return 0;

}

Measured memory_bytes: 1068
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:1
*Problem:Bringing Order To Disorder
*Date:2019-7-5
*Algorithm:My Rubbish DP that will TLE 
*Stats:AC-Aaizu1360*/

bool debug=false;

map<ll,ll> dp[15][150][3];

const int LIMITED=1,FREE=0,EXCEED=2;
string s;

int allSum;
ll allPro;

ll dfs(int pos,int sum,ll pro,int limit){
	
//	cout<<pos<<" "<<sum<<" "<<pro<<" "<<limit<<endl;
	
//	cout<<"Compare with "<<allSum<<" "<<allPro<<endl;
	
	
	if(sum>allSum){
		return 0;
	}
	if(sum==allSum && pro>allPro){
		return 0;
	}
	if(sum==allSum && pro==allPro && limit==EXCEED){
		return 0;
	}
	if(dp[pos][sum][limit].count(pro)){
		return dp[pos][sum][limit][pro];
	}
//	cout<<"PTP"<<endl;
	
	if(pos==s.size()){
		
//		cout<<"Note:Good"<<endl;
		if(sum<allSum){
			return 1;
		}
		if(sum==allSum && pro<allPro){
			return 1;
		}
//		cout<<"Answer accept protect failed"<<endl;
		if(sum==allSum && pro==allPro){
			
			return !limit;
		}
		return 0;
	}
	
	ll poss=0;
	for(int i=0;i<=9;i++){
//		cout<<"Choosing "<<i<<endl;
//		cout<<"{"<<endl;
		poss+=dfs(pos+1,sum+i,pro*(i+1),(limit==EXCEED?EXCEED:(limit==LIMITED?(i==s[pos]-'0'?LIMITED:(i>s[pos]-'0'?EXCEED:FREE)):FREE)));
//		cout<<"}"<<endl;
	}
	
	return dp[pos][sum][limit][pro]=poss;
}

int main(int argc,char* argv[]){
	cin>>s;
	
	for(int i=0;i<s.size();i++){
		allSum+=s[i]-'0';
	}
	
	allPro=1;
	for(int i=0;i<s.size();i++){
		allPro*=(s[i]-'0'+1);
	}
	
	cout<<dfs(0,0,1,LIMITED)<<endl;
	return 0;
}




Measured memory_bytes: 41536
n = int(input())
s = input()
ans = 0
for i in range(1000):
  i1 = str(i)
  i2 = i1.zfill(3)
  index1 = s.find(i2[0])
  if (index1 == -1) or (index1 == n-1):
    continue
  else:
    index1 += 1
    index2 = s.find(i2[1],index1)
    if (index2 == -1) or (index2 == n-1):
      continue
    else:
      index2 += 1
      index3 = s.find(i2[2],index2)
      if index3 != -1:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int total = 0;
    for (int i = 0;i<m;i++){
        int x;
        cin>>x;
        total+=x;
    }
    cout<<max(-1,n-total)<<endl;
    return 0;
}

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

int main(){
	// 実装できれば良いんだよ
	int N; cin >> N;
	string S[N];
	for (int i=0; i<N; i++){
		cin >> S[i];
	}

	int M=0;
	int A=0;
	int R=0;
	int C=0;
	int H=0;

	for (int i=0; i<N; i++){
		if (S[i][0] == 'M'){
			M++;
		} else if (S[i][0] == 'A') {
			A++;
		} else if (S[i][0] == 'R') {
			R++;
		} else if (S[i][0] == 'C') {
			C++;
		} else if (S[i][0] == 'H') {
			H++;
		}
	}

	long long ans = 0;
	ans += (long long)M*A*R;
	ans += (long long)M*A*C;
	ans += (long long)M*A*H;
	ans += (long long)M*R*C;
	ans += (long long)M*R*H;
	ans += (long long)M*C*H;
	ans += (long long)A*R*C;
	ans += (long long)A*R*H;
	ans += (long long)A*C*H;
	ans += (long long)R*C*H;

	cout << ans << endl;
}

Measured memory_bytes: 6144
#!/usr/bin/perl
use POSIX qw(floor);

my ($a,$b,$c,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $t = 0;
if( $a > 0 and $k > 0 ){
  my $v = ( $a < $k ? $a : $k );
  $t += $v;
  $k -= $v;
}

if( $b > 0 and $k > 0 ){
  my $v = ( $b < $k ? $b : $k );
  $k -= $v;
}

if( $c > 0 and $c > 0 ){
  my $v = ( $c < $k ? $c : $k );
  $t -= $v;
}

print "$t\n";





Measured memory_bytes: 6628
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;
	char c;
	char str[1024];
	string s;
	ll l;
	int nextInt(){
		scanf("%d", &n);
		return n;
	}
	ll nextLong(){
		scanf("%lld", &l);
		return l;
	}
	char nextChar(){
		scanf("%c", &c);
		return c;
	}
	string next(){
		scanf("%s", str);
		return string(str);
	}
	string nextLine(){
		getline(cin, s);
		return s;
	}
};
Input in;

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

int dp[110][110][2][2];

int main(){
	dp[0][0][0][1] = dp[0][0][1][1] = 1;
	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			for(int k = 0; k < 2; k++){
				int nx = i + dx[k], ny = j + dy[k];
				(dp[nx][ny][k][0] += dp[i][j][k][0] + dp[i][j][k][1]) %= 100000;
				(dp[nx][ny][k][1] += dp[i][j][(k+1)%2][0]) %= 100000;
			}
		}
	}


	while(1){
		int h = in.nextInt(), w = in.nextInt();
		if(h == 0 && w == 0) break;
		ll ans = 0LL;
		rep(i, 2) rep(j, 2){
			ans += dp[w-1][h-1][i][j];
		}
		ans %= 100000;
		cout<<ans<<endl;
		
	}
}

Measured memory_bytes: 1384
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc151_a();
	}
	
	
	public static void solve_abc151_a(){
		
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		
		String[] s = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r",
						"s","t","u","v","w","x","y","z"};
		
		int ci = 0;
		
		for(int si=0;si<s.length;si++){
			
			if(c.equals(s[si])){
				ci = si;
				break;
			}
		}
		
		System.out.println(s[ci+1]);
		sc.close();
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
using ll = long long;

const int INF = 1001001001;

int main()
{
    string msg="YES";
	ll n(0), x(0), y(0);
	cin>>n;
	vector<ll> a(n);
	
	rep(i, n)cin>>a[i];
	sort(a.begin(),a.end());
	x= a[0];
	
	repi(i,1,n){
	    if(x==a[i]){
	        msg="NO";
	        break;
	    }
	    x=a[i];
	}
	cout<<msg<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  if( n%2 == 0 ){
    for(ll i=n-1;i>=0;--i){
      if( (i+1)%2 == 0 ){
        cout << a.at(i) << " ";
      }
    }
    for(ll i=0;i<n;++i){
      if( (i+1)%2 == 1 ){
        cout << a.at(i) << " ";
      }
    }
  }else{
    for(ll i=n-1;i>=0;--i){
      if( (i+1)%2 == 1 ){
        cout << a.at(i) << " ";
      }
    }
    for(ll i=0;i<n;++i){
      if( (i+1)%2 == 0 ){
        cout << a.at(i) << " ";
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3712
class dice:
    def __init__(self, first, second, third, fourth, fifth, sixth):
        self.up = first
        self.down = sixth
        self.S = second
        self.E = third
        self.N = fifth
        self.W = fourth
    def move(self, direction):
        if direction == "S":
            temp = self.up
            self.up = self.N
            self.N = self.down
            self.down = self.S
            self.S = temp 
            return self
        elif direction == "E":
            temp = self.up
            self.up = self.W
            self.W = self.down
            self.down = self.E
            self.E = temp
            return self
        elif direction == "N":
            temp = self.up
            self.up = self.S
            self.S = self.down
            self.down = self.N
            self.N = temp
            return self
        else:
            temp = self.up
            self.up = self.E
            self.E = self.down
            self.down = self.W
            self.W = temp
            return self

nums = list(map(int,input().split()))
dice1 = dice(nums[0], nums[1], nums[2], nums[3], nums[4], nums[5])
command = input()
commandlen = len(command)
for i in range(commandlen):
    dice1 = dice1.move(command[i])
print(str(dice1.up))


Measured memory_bytes: 5608
<?php
  $tmp = explode(" ",trim(fgets(STDIN)));

  $n = $tmp[0];
  $k = $tmp[1];
  
  $data = explode(" ",trim(fgets(STDIN)));
  rsort($data);

  $total = array_sum($data);
  $minus = 0;
  
  if($n<=$k){
    echo "0\n";
  }else{
    for($i=0; $i<$k; $i++){
      $minus += $data[$i];
    }

    echo ($total-$minus)."\n";
  }

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

const int MAX = 666667;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(){
    ll X, Y;
    cin >> X >> Y;

    if ((X+Y) % 3 != 0 || (X - 2*Y) % 3 != 0 || (2*X-Y) % 3 != 0) {
        cout << 0 << endl;
        return;
    }

    COMinit();
    int n = (-X + 2*Y) / 3, m = (2*X - Y) / 3;
    cout << COM(n+m, n) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    int count = 0;
    for(int i=1;i<=n;++i){
        int a;cin>>a;
        if(i%2 == 1 and a%2 == 1)count++;
    }
    cout << count << endl;
    return 0;
    
}

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

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

int n, T, H, Tm;
int t[128];
int h[128];

int solve() {
    int sum = 0;
    while(1){
        rep(i,n){
            if(t[i]>0) {
                T++;
                if(T>Tm) return i;
                sum += 10;
                t[i]--;
            }else if(h[i]>0){
                H++;
                sum+=100;
                h[i]--;
            }else {
                return i;
            }

            if(sum>=90) {
                int rest=sum-90;
                while(rest>0 && T>0) {
                    rest-=10;
                    T--;
                    t[i]++;
                }
                while(rest>=100 && H>0) {
                    rest-=100;
                    H--;
                    h[i]++;
                }
                if(rest>0) return i;
                else sum=0;
            }
        }
    }
}

int main() {
    while(cin>>n>>T>>H>>Tm && n){
        rep(i,n)cin>>t[i]>>h[i];
        cout<<solve()+1<<endl;
    }
}

Measured memory_bytes: 1164
while True:
    try:
        t=int(input())
        n=int(input())
        M=0
        for i in range(n):
            s,f=map(int,input().split())
            A=f-s
            M=M+A
        if t>M:
            print(t-M)
        else:
            print("OK")
    except:
        break


Measured memory_bytes: 5600
#include<iostream>
#include<string>
  
using namespace std;
  
int main(){
    int n;
    int a[100],b[100];
    int x,y,v;
    while(true){
    cin>>n;
    if(n==0)
        break;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int tmp;
  for (int i=0;i<n;i++) { 
    for (int j=i+1;j<n;j++) { 
      if (a[i]>a[j]) { 
        tmp=a[i]; 
        a[i] =a[j]; 
        a[j] = tmp; 
      } 
    } 
  }
  int s=1;
  for(int i=0;i<n;i++){
      while(true){
          int d=0;
      for(int j=0;j<n;j++){
          if(a[j]!=s)
              d++;
      }
      if(d==n){
          b[i]=s;
          s++;
          break;
      }
      s++;
      }
  }
  x=n-1;
  y=n;
  v=a[0];
  a[0]=0;
  while(true){
      int i=0;
      while(true){
          if(i==n){
              v=0;
              break;
          }
          if(b[i]>v){
              v=b[i];
              b[i]=0;
              y--;
              break;
          }
          i++;
      }
      if(y==0)
          break;
      int j=0;
      while(true){
          if(j==n){
              v=0;
              break;
          }
          if(a[j]>v){
              v=a[j];
              a[j]=0;
              x--;
              break;
          }
          j++;
      }
      if(x==0)
          break;
    }
      cout<<y<<endl;
      cout<<x<<endl;
    }
    return 0;
} 
 

Measured memory_bytes: 1164
"use strict";
function main(input) {
  let n = parseInt(input[0]);
  
  let index = {};

  let max = 0;

  for(let i=1;i<n+1;i++){
    if(index[input[i]]===undefined){
      index[input[i]] = 1;
    }else{
      index[input[i]]++;
    }
    max = (index[input[i]] > max)?index[input[i]]:max;
  }

  let result = [];
  let i=0;
  for(let key in index){
    if(index[key]===max){
      result[i] = key;
      i++;
    }
  }

  result.sort();

  for(let i=0;i<result.length;i++){
    console.log(result[i]);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 86824
import java.util.Scanner;
//import java.util.Map;
//import java.util.HashMap;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		int x = s.length()-2;
		char[] letters = s.toCharArray();
		System.out.print(letters[0]);
		System.out.print(x);
		System.out.print(letters[s.length()-1]);
	}
}


Measured memory_bytes: 21844
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    if((a + b) % 2 != 0) cout << "IMPOSSIBLE";
    else cout << (a + b) / 2;
    cout << endl;
    return 0;
}


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


using namespace std;
int digits(int n){
	int count = 0;
	while(n!=0){
		n/=10;
		count++;
		}
	return count;
	}

int main(){
	int n;
	cin>>n;
	int count = 0;
	for(int i =1; i<n+1; i++){
		if(digits(i)%2==1) count++;
		
		}
	cout<<count;	
	
	return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

int main()
{
    ll n,c;
    cin >> n >> c;
    vector<vector<pll>> bangumi(c);
    rep(i,n){
        ll si,ti,ci;
        cin >> si >> ti >> ci;
        ci--;
        bangumi[ci].emplace_back(mp(si, ti));
    }
    vll s(1e5 + 1, 0);
    rep(k,c){
        sort(all(bangumi[k]));
        if (bangumi[k].empty())
            continue;
        s[bangumi[k][0].F - 1]++;
        repf(i,1,bangumi[k].size()){
            if (bangumi[k][i-1].S<bangumi[k][i].F){
                s[bangumi[k][i - 1].S]--;
                s[bangumi[k][i].F - 1]++;
            }
        }
        s[bangumi[k][bangumi[k].size()-1].S]--;
    }
    ll ans = 0;
    ll now = 0;
    rep(i, 1e5 + 1){
        now += s[i];
        ans = max(ans, now);}
    cout << ans << endl;
}


Measured memory_bytes: 3584
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
// Practice is the only shortcut to improve
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define PI 2*acos(0.0)
#define pii pair<int,int>
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define coutv(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define cinv(v) for(auto &it:v)cin>>it;
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using ordered_set =tree<T, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;
*/
//sieve bool b[1000005];void primenire(){int i, j;b[0]=true;b[1]=true;for(i=4; i<=1000000; i+=2){b[i]=true;}for(i=3; i<=1001; i+=2){if(!b[i]){for(j=i*i; j<=1000001; j+=2*i){b[j]=true;}}}}
//power ll power(ll a,ll b){if(b==0) return 1LL;if(b&1) return a*power(a,b-1);else return power(a,b/2)*power(a,b/2);}
//bigmod long long int m(long long int a,long long int b,long long int c){if(b==0)return 1;if(b%2==0){long long int  tmp=m(a,b/2,c);return ((tmp%c)*(tmp%c))%c;}elsereturn ((a%c)*(m(a,b-1,c)%c))%c;}
//MaxSubarraySum ll mss(vector<ll>v){ll mx=v[0];ll sz=v.size();for(int i=1;i<=sz;i++){ll t=v[i]+v[i-1];if(t>=v[i]) v[i]=t;mx=max(mx,v[i]*1LL);}return mx;}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

void solve()
{
    ll a,b,c;
    cin>>a>>b;
    map<ll,bool>m;
    fr(i,1,b)
    {
        cin>>c;
        m[c]=1;
    }
    for(ll i=a;; i++)
    {
        bool ok=1;
        ll n=i;
        while(n)
        {
            ll d=n%10;
            if(m[d])
            {
                ok=0;
                break;
            }
            n/=10;
        }

        if(ok)
        {
            cout<<i<<endl;
            return;
        }
    }
}
int main()
{
    rj
    solve();



    return 0;
}



Measured memory_bytes: 3628
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

count=0
for i in range(n):
    for j in range(i+1,n):
        num=0
        for k in range(d):
            num+=(x[i][k]-x[j][k])**2
        if num==int(num**.5)**2:
            count+=1

print(count)

Measured memory_bytes: 3188
#import <Foundation/Foundation.h>
int main() {
    int n;
    scanf("%d",&n);
    int *d = (int*)malloc(sizeof(int)*n);
    for(int i=0;i<n;i++) scanf("%d", d+i);
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 6996
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<int> a(n),cnt(9);
	for (int i = 0; i < n; i++){
		cin>>a[i];
		a[i]/=400;
		if(a[i]>8) a[i] = 8;
		cnt[a[i]]++;
	}
	int num = 0;
	for (int i = 0; i < 8; i++){
		if(cnt[i]>0) num++;
	}
	cout<<(num>0?num:1)<< " "<<num+cnt[8]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <map>
using namespace std;

typedef long long ll;
const ll inf = 1e15;

int main() {
    ll n; cin >> n;
    ll  ans = inf;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ll tmp = i +  n / i - 2; 
            ans = min(ans,tmp);
        }
    }
    cout << ans <<"\n";
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, L, T;
int X[110000], W[110000];
int A[110000];

signed main() {
    cin >> N >> L >> T;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> W[i];
    }
    for (int i = 0; i < N; i++) {
        if (W[i] == 1) A[i] = (X[i] + T % L) % L;
        else A[i] = (X[i] + L - T % L) % L;
    }
    sort(A, A + N);
    int key = (X[0] + T % L) % L;
    if (W[0] == 2) key = (X[0] + L - T % L) % L;

    int idx1;
    if (W[0] == 1) {
        for (int i = 0; i < N; i++) {
            if (A[i] == key) {
                idx1 = i;
                break;
            }
        }
    } else {
        for (int i = N - 1; i >= 0; i--) {
            if (A[i] == key) {
                idx1 = i;
                break;
            }
        }
    }

    int R1 = 0, R2 = 0;
    for (int i = 1; i < N; i++) {
        if (W[0] == W[i]) continue;
        R1 += 2;
        int dist = X[i] - X[0];
        if (W[0] == 2) dist = L - dist;
        if (dist < T % L * 2) R2++;
        if (dist < T % L * 2 - L) R2++;
    }
    int sw = R1 * (T / L) + R2;
    sw %= N;
    int idx2 = sw;
    if (W[0] == 2)idx2 = (N - sw) % N;

    for (int i = 0; i < N; i++) {
        cout << A[(i + idx1 - idx2 + N) % N] << endl;
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main () {
	const ll INF = pow(10, 11);
	const int MAX_Nv = pow(10, 5);
	int N, W; cin >> N >> W;
	vector<ll> dp(MAX_Nv + 1, INF); dp[0] = 0; // dp[j] = 価値jを作るために必要な品物の重さの最小値
	int w, v;
	rep(i, N) {
		cin >> w >> v;
		for (int j = MAX_Nv; j >= v; j--) dp[j] = min(dp[j], dp[j - v] + w);		
	}
	for (int j = MAX_Nv; j >= 0; j--) if (dp[j] <= W) {
		cout << j << endl;
		break;
	}	
}

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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int a, b;
    cin >> a >> b;
    bool ans = a%3==0 || b%3==0 || (a+b)%3==0;
    cout << (ans ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256