akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define d double
#define lli	long long int
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int main()
{
	lli n,i,ans=0,x;
	cin >> n;
	vector<lli>v(n);
	for(i=0;i<n;i++)	cin >> v[i];
	x=1;
	for(i=0;i<n;i++)
	{
		if(v[i]==x)
		{
			ans++;
			x++;
		}
	}
	if(ans==0)	ans=(-1);
	else	ans=n-ans;
	cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 1792
r,c,k = map(int,input().split())
lst = [[0]*c for _ in range(r)]
for i in range(k):
    a,b,v = map(int,input().split())
    lst[a-1][b-1] = v
dp0 = [[0]*c for _ in range(r)]
dp1 = [[0]*c for _ in range(r)]
dp2 = [[0]*c for _ in range(r)]
dp3 = [[0]*c for _ in range(r)]
dp1[0][0] = lst[0][0]

for i in range(r):
    for j in range(c):
        s = max(dp0[i][j], dp1[i][j], dp2[i][j], dp3[i][j])
        x,y = i+1,j
        if x < r:
            dp0[x][y] = max(dp0[x][y], s)
            if lst[x][y]:
                dp1[x][y] = max(dp1[x][y], s+lst[x][y])
        x,y = i,j+1
        if y < c:
            dp3[x][y] = max(dp3[i][j], dp3[x][y])
            if lst[x][y]:
                dp3[x][y] = max(dp2[i][j]+lst[x][y], dp3[x][y])
            
            dp2[x][y] = max(dp2[x][y], dp2[i][j])
            if lst[x][y]:
                dp2[x][y] = max(dp2[x][y], dp1[i][j]+lst[x][y])
            
            dp1[x][y] = max(dp1[x][y], dp1[i][j])
            if lst[x][y]:
                dp1[x][y] = max(dp1[x][y], dp0[i][j]+lst[x][y])
            
            dp0[x][y] = max(dp0[x][y], dp0[i][j])
print(max(dp0[-1][-1], dp1[-1][-1], dp2[-1][-1], dp3[-1][-1]))


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

int main()
{
    int N;
    scanf("%d",&N);
    int S[N],C[N],F[N],t=0;
    int i,j;
    for(i=1; i<N; i++)
    {
        scanf("%d%d%d",&C[i],&S[i],&F[i]);
    }
    int result[N];
    memset(result,0,sizeof(result));
    for(i=1; i<=N-1; i++)
    {
        for(j=i;j<=N-1;j++)
        {
            if(t<S[j])
                t=S[j];
            if(t%F[j]==0)
                t+=C[j];
            else
            {
                while(t%F[j]!=0)
                    t++;
                t+=C[j];
            }
        }
        result[i]=t;
        t=0;

    }

    for(i=1; i<=N-1; i++)
        printf("%d\n",result[i]);
    printf("%d\n",0);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100100;

int n, m, arr[MAXN], ans[MAXN];
char str[MAXN];

int main(){
	scanf("%d %d", &n, &m);
	scanf("%s", str);
	for(int i = 0; i <= n; i++) arr[i] = str[i] - '0';
	if(n <= m){
		printf("%d\n", n);
		return 0;
	}
	int nxtpos = -1;
	for(int i = 1; i <= m; i++){
		if(arr[n - i] == 0) nxtpos = n - i;
	}
	if(nxtpos == -1){
		printf("-1\n");
		return 0;
	}
	ans[0] = 0;
	for(int curpos = n; ; ){
		ans[++ans[0]] = curpos - nxtpos;
		curpos = nxtpos;
		if(nxtpos <= m){
			ans[++ans[0]] = nxtpos;
			break;
		}else{
			nxtpos = -1;
			for(int i = 1; i <= m; i++){
				if(arr[curpos - i] == 0) nxtpos = curpos - i;
			}
		}
		if(nxtpos == -1){
			printf("-1\n");
			return 0; 
		}
	}
	for(int i = ans[0]; i >= 1; i--) printf("%d ", ans[i]); printf("\n");
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>

using namespace std;


int main(){
   long int A,B;
   long int n,r;
   cin >> A >> B;
   if(A < B){
       int tmp = A;
       A = B;
       B = tmp;
   }
  n = A*B;
  r = A % B;
  while(r != 0){
      A = B;
      B = r;
      r = A % B;
  }

  cout << n / B;
return 0;
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec fac, finv;

ll PowMod(ll a, ll n){
	if(n == 1) return a;
	if(n%2 == 0) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
	return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

void init(ll n){
	fac.resize(n+1);
	fac[0] = 1;
	repn(i, n) fac[i] = (fac[i-1]*i)%MOD;
	finv.resize(n+1);
	finv[n] = PowMod(fac[n], MOD-2);
	repr(i, n) finv[i] = (finv[i+1]*(i+1))%MOD;
	finv[0] = 1;
}

int main(void){
	ll n;
	cin >> n;
	Vec a(n+1);
	rep(i, n+1) cin >> a[i];

	unordered_map<ll, ll> ump;
	for(ll i : a) ump[i]++;

	ll same = 0;
	for(P i : ump){
		if(i.sc == 2) same = i.fs;
	}

	init(n+1);

	ll t = 0;
	rep(i, n+1){
		if(a[i] == same){
			t += i;
			break;
		}
	}
	repr(i, n+1){
		if(a[i] == same){
			t += n-i;
			break;
		}
	}

	ll ans = 0;
	repn(i, n+1){
		if(i == 1){
			co(n);
			continue;
		}
		ans = combi(n+1, i);
		if(t >= i-1) ans -= combi(t, i-1);
		if(ans < 0) ans += MOD;
		co(ans);
	}

	return 0;
}


Measured memory_bytes: 7716
#include <cstdio>

int main()
{
	int a,b;
	char op;

	while(true) {
		scanf("%d %c %d",&a,&op,&b);

		if (op == '?')
			break;
		if (op == '+')
			printf("%d\n",a+b);
		if (op == '-')
			printf("%d\n",a-b);
		if (op == '*')
			printf("%d\n",a*b);
		if (op == '/')
			printf("%d\n",a/b);
	}

	return 0;
}


Measured memory_bytes: 2668
#include<stdio.h>
#include<stdlib.h>

typedef struct PLIST{
	struct PLIST *pre;
	struct PLIST *next;
	int key;
}plist;

plist *head;
plist *tail;

int compStr(char *str0, char *str1){
	int i = 0;
	for( i = 0; str0[i] != '\0' || str1[i] != '\0'; i++ ){
		if( str0[i] != str1[i] ){ return 0; }
	}
	if( str0[i] != str1[i] ){ return 0; }
	return 1;
}

void insert(plist *p, plist *next){
	if( p == NULL ){ return; }
	if( next != NULL ){
		p->pre = NULL;
		p->next = next;
		next->pre = p;
	}else{
		p->pre = NULL;
		p->next = NULL;
		tail = p;
	}
	head = p;
	return;
}

void delete(plist *p){
	if( p == NULL ){ return; }
	if( p->pre != NULL ){
		p->pre->next = p->next;
	}else{
		head = p->next;
	}
	if( p->next != NULL ){
		p->next->pre = p->pre;
	}else{
		tail = p->pre;
	}
	free(p);
	return;
}

int main(){
	int i = 0;
	int n = 0;
	char com[1024];
	int x = 0;
	scanf("%d", &n);
	plist *temp;
	for( i = 0; i < n; i++ ){
		scanf("%s", com);
		if( compStr(com, "insert\0") ){
			scanf("%d", &x);
			temp = (plist*)malloc(sizeof(plist));
			temp->key = x;
			insert(temp, head);
		}
		if( compStr(com, "delete\0") ){
			scanf("%d", &x);
			temp = head;
			while( temp != NULL ){
				if( temp->key == x ){ break; }
				temp = temp->next;
			}
			delete(temp);
		}
		if( compStr(com, "deleteFirst\0") ){
			delete(head);
		}
		if( compStr(com, "deleteLast\0") ){
			delete(tail);
		}
		/*
		temp = head;
		if( temp != NULL ){ printf("%d", temp->key); }
		while( (temp = temp->next) != NULL ){ printf(" %d", temp->key); }
		printf("\n");
		*/
	}
	temp = head;
	if( temp != NULL ){ printf("%d", temp->key); }
	while( (temp = temp->next) != NULL ){ printf(" %d", temp->key); }
	printf("\n");
	return 0;
}

Measured memory_bytes: 31788
#include<bits/stdc++.h>
using namespace std;
long long sum(long long arr[], long long n)
{
    long long sum = 0;
    for(long long i = 0; i < n; i++)
    sum += arr[i];

    return sum;
}

int main()
{
     long long arr[10001], n, i, max, min;


    cin >> n;


    for (i = 0; i < n; i++)
        cin >> arr[i];

    max = arr[0];

    for (i = 0; i < n; i++)

    {

        if (max < arr[i])

            max = arr[i];

    }

    min = arr[0];

    for (i = 0; i < n; i++)

    {

        if (min > arr[i])

            min = arr[i];

    }

    cout <<  min <<" " << max << " " << sum(arr, n) << endl;

return 0;
 }



Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long


#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
int MOD = 1000000007;
const int inf = 1001001001;
const ll INF = 1LL << 60;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x; cin >> x;
	if (x >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    const ll MOD = 1000000007;
    ll N, K; cin >> N >> K;
    vl A(N); rep(i, N) cin >> A[i];

    ll res = 0;
    rep(i, N) {
        ll cnt1 = 0;
        for (int j = i + 1; j < N; j++) {
            if (A[i] > A[j]) cnt1++;
        }

        ll cnt2 = 0;
        rep(j, N) {
            if (A[i] > A[j]) cnt2++;
        }

        res += (cnt1 * K) % MOD;
        res %= MOD;

        res += K * (K - 1) / 2 % MOD * cnt2 % MOD;
        res %= MOD;
    }

    cout << res << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> S(M);
    for (int i = 0; i < M; i++)
    {
        int K;
        cin >> K;
        vector<int> s(K);
        for (int j = 0; j < K; j++)
        {
            cin >> s[j];
        }
        S[i] = s;
    }
    vector<int> P(M);
    for (int i = 0; i < M; i++)
    {
        cin >> P[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << N); i++)
    {
        bool flag = true;
        string str = "";
        for (int j = N - 1; j >= 0; j--)
        {
            str += to_string((i >> j) & 1);
        }
        for (int j = 0; j < M; j++)
        {
            int total = 0;
            for (int s : S[j])
            {
                if (str[s - 1] == '1')
                {
                    total++;
                }
            }
            if (total % 2 != P[j])
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
set<int>  st[125];
int main()
{
  //freopen("input.txt","r",stdin);
   string s,t;
   cin>>s>>t;
   for(int i = 0;i<s.size();++i)
   {
       st[s[i]].insert(i);
   }
   int a = 0,b = 0;
   for(int i = 0;i<t.size();++i)
   {
       if(st[t[i]].empty()) return cout<<-1,0;
       if(st[t[i]].lower_bound(b)==st[t[i]].end()) a++,b = 0;
       b = *st[t[i]].lower_bound(b);
       b++;
   }
   cout<<a*s.size()+b<<endl;
}


Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

long long max(long long A,long long B){
    return A>B?A:B;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

long long roundup(long long A,long long B){
    return (A+B-1)/B;
}

int main(void){
    long long n,sum=0;
    scanf("%lld",&n);
    long long a[n],ans[n],sum2=0;
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    for (int i=0; i<n; i++){
        if (i%2!=0){
            sum2+=a[i]*2;
        }
    }
    long long count=1;
    for (int i=0; i<n; i++){
        if (i%2==0){
            ans[i]=sum-sum2;
            sum2-=a[i+1]*2;
            count+=2;
            if (count>n-1){
                count-=n;
            }
            sum2+=a[i]*2;
        }
    }
    sum2=0;
    for (int i=1; i<n; i++){
        if (i%2!=1){
            sum2+=a[i]*2;
        }
    }
    count=0;
    for (int i=0; i<n; i++){
        if (i%2==1){
            ans[i]=sum-sum2;
            sum2-=a[i+1]*2;
            count+=2;
            if (count>=n-1){
                count-=n-1;
            }
            sum2+=a[i]*2;
        }
    }
    for (int i=0; i<n; i++){
        if (i<n-1){
            printf("%lld ",ans[i]);
        } else {
            printf("%lld\n",ans[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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


pii dir[4] = {{0,1},{0,-1},{-1,0},{1,0}};
int h,w,k;
int sx,sy,gx,gy;

int bfs(vector<vi> &g){
	vector<vi> d(g.size(), vi(g[0].size()));
	queue<pii> q;	
	int dist = 1;
	q.push({sx,sy});
	d[sx][sy] = 1;
	while(q.size()){
		++dist;
		int cnt = q.size();
		while(cnt--){
			int x = q.front().first;
			int y = q.front().second;
			q.pop();
			rep(i,0,4){
				int cx = x, cy = y;
				rep(j,0,k){
					cx+=dir[i].first;
					cy+=dir[i].second;
					if((d[cx][cy] != 0 && d[cx][cy] < dist) || g[cx][cy] == 0){
						break;	
					}
					if(d[cx][cy] == 0){
						d[cx][cy] = dist;
						q.push({cx,cy});
					}
				}
			}
		}
	}
	int ans = d[gx][gy];
	--ans;
	return ans;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	scanf("%d %d %d",&h,&w,&k);
	vector<vi> g(h+2, vi(w+2));
	scanf("%d %d %d %d",&sx,&sy,&gx,&gy);
	rep(i,1,h+1){
		rep(j,1,w+1){
			char c;
			scanf(" %c",&c);
			g[i][j] = c == '.' ? 1 : 0;
		}
	}
	int ans = bfs(g);
	printf("%d\n", ans);
}


Measured memory_bytes: 30744
a={}
for i=1,9 do 
  a[i]=io.read("n")
end
local res="No"
if a[1]-a[2]==a[4]-a[5] and a[4]-a[5]==a[7]-a[8] then
  if a[2]-a[3]==a[5]-a[6] and a[5]-a[6]==a[8]-a[9] then
    if a[1]-a[4]==a[2]-a[5] and a[2]-a[5]==a[3]-a[6] then
      if a[4]-a[7]==a[5]-a[8] and a[5]-a[8]==a[6]-a[9] then
        res="Yes"
      end
    end
  end
end
print(res)

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int h,n;
    cin >> h >> n;
    int a[n];
    int b[n];
    rep(i,n)cin >> a[i] >> b[i];
    int mx=0;
    rep(i,n)chmax(mx,a[i]);
    int dp[h+mx+1];
    rep(i,h+mx+1){
        dp[i]=mod;
    }
    dp[0]=0;
    rep(i,h){
        rep(j,n){
            chmin(dp[i+a[j]],dp[i]+b[j]);
        }
    }
    int mn=mod;
    for(int i=h;i<=h+mx;i++){
        chmin(mn,dp[i]);
    }
    cout << mn;


}

/*



 */



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc020.contest.atcoder.jp/tasks/agc020_b>
問題文============================================================
 スケートリンクで、一人の大人の司会と N 人の子供がゲームを行います。
 ゲームは K ラウンドからなり、ラウンド i では司会が次のように言います。
 
 Ai 人組を作って！
 
 すると、まだ脱落していない子供たちは Ai 人からなるグループをできるだけ多く組みます。
 一人につき一つのグループにしか入れません。
 グループに入れなかった子供たちは脱落し、その他は次のラウンドに進みます。 ラウンドで誰も脱落しないこともありえます。
 
 最後まで、つまりラウンド K のあとまで残ったのは 2 人で、彼らが勝者となりました。
 
 あなたは A1, A2, ..., AK の値を聞き、N の値は知りませんが、推定してみたくなりました。
 
 ゲームの開始前にいた子供たちの人数として考えられる最小の値と、最大の値を求めてください。
 もしくは、考えられる N の値は存在しないと判定してください。
 

=================================================================

解説=============================================================

 後ろから考える
 
 後ろから考えた時、その時点での最小値と最大値を l,r とすると
 ここで A[i] を見た時 , l と　r の間に A[i]の倍数がなければ -1
 あれば
  l = (l + A[i] - 1)/A[i] * A[i]
  r = (r/A[i] + 1)*A[i] - 1
 となる
 
================================================================
*/
void solve(){
    ll K; cin >> K;
    vector<ll> A(K);
    for(auto &in:A) cin >> in;
    if(A[K-1] != 2){ cout << -1 << endl; return; }
    ll l = 2, r = 2;
    for(ll i = K - 1; i >= 0; i--){
        ll t = (l + A[i] - 1)/A[i] * A[i];
        if(t < l || t > r){
            cout << -1 << endl; return;
        }
        l = t;
        r = (r/A[i] + 1)*A[i] - 1;
    }
    cout << l << " " << r << endl;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int number = 0;

    if (N > 9) {
        number += 9;
    } else {
        cout << N;
        return 0;
    }

    if (N > 999) {
        number += 900;
    } else {
        cout << number + max(0, N - 100 + 1);
        return 0;
    }

    if (N > 99999) {
        number += 90000;
    } else {
        cout << number + max(0, N - 10000 + 1);
        return 0;
    }

    cout << number;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<P> W(N);
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    W.at(i) = P(B, A);
  }
  sort(W.begin(), W.end());
  
  ll time = 0;
  for (int i = 0; i < N; i++) {
    P p = W.at(i);
    time += p.second;
    if (time > p.first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

static const int N = 100;

int main() {

    int graph[N][N] = {0};
    int distance[N] = {-200000};
    bool alreadySearched[N] = {false};

    int n;scanf("%d",&n);
    for(int i=0;i<n;i++){
        int u;scanf("%d",&u);
        u--;
        int k;scanf("%d",&k);
        for(int j=0;j<k;j++){
            int v;scanf("%d",&v);
            v--;
            graph[u][v] = 1;
        }
    }


    queue<int> Q;
    Q.push(0);
    distance[0] = 0;
    alreadySearched[0] = true;

    while(!Q.empty()){
        int u = Q.front();
        for(int i=0;i<n;i++){
            if(!alreadySearched[i] && graph[u][i] == 1){
                Q.push(i);
                alreadySearched[i] = true;
                distance[i] = distance[u] + 1;
            }
        }
        Q.pop();
    }

    for(int i=0;i<n;i++){
        if(!alreadySearched[i]){
            distance[i] = -1;
        }
    }
    for(int i=0;i<n;i++){
        printf("%d %d\n", i+1, distance[i]);
    }

    return 0;
}


Measured memory_bytes: 3256
import math
def sieve(n):
    p = [1] * (n + 1)
    p[0] = p[1] = 0
    
    for i in range(math.ceil((n + 1) ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

def prime_factor(n):
    p = sieve(int(n ** 0.5))
    factor = []
    for pi in compress(count(0), p):
        while n % pi == 0:
            n //= pi
            factor.append(pi)

    if n != 1:
        factor.append(n)
    return factor

from sys import stdin
from itertools import compress, count

readline = stdin.readline


n = int(readline())
print('{}: '.format(n) + ' '.join(map(str, prime_factor(n))))

Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,a,n) for(int i=a;i<n;i++)
#define int long long
 main(){
  int n;
  while(cin>>n,n){
  int a[n],c=0,pp;;
  vector<int>p;
  vector<int>q;
  r(i,n){
    string t;
    cin>>t;
    if(t=="x")p.push_back(i);
    else{
      stringstream ss(t);
      int re;ss>>re;
      a[i]=re;
      q.push_back(re+1);
      q.push_back(re-1);
      q.push_back(re+2);
      q.push_back(re-2);
    }
  }
  r(i,q.size()){
    int cc=0;
    r(j,p.size())a[p[j]]=q[i];
    if(a[0]<a[1]){
      r(k,n-1){
        if(k%2==0){if(a[k]>=a[k+1])cc++;}
        else{if(a[k]<=a[k+1])cc++;}
      }
    }
    else continue;
      //cout<<cc<<endl;
    //cout<<q[i]<<endl;
    if(c&&cc==0&&pp!=q[i])goto A;
    if(cc==0)c++,pp=q[i];
  }
  if(c)cout<<pp<<endl;
  else cout<<"none"<<endl;
  if(0)A:cout<<"ambiguous"<<endl;
}
}

Measured memory_bytes: 3220
N = int(input())
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = []
for i,val in C.items():
  if val >= 4:
    use.append(i)
  if val >= 2:
    use.append(i)

use = sorted(use,reverse= True)
if len(use)<2:
  print(0)
else:
  print(use[0]*use[1])

Measured memory_bytes: 18600
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    string n;
    cin >> n;
    int res = 0;
    rep(i, n.length()) {
        res += int(n[i] - '0');
    }
    if (stoi(n) % res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N,A,B,C=map(int,input().split())
mod=10**9+7
ans=0
rev100=pow(100,mod-2,mod)
revAB=pow(A+B,mod-2,mod)
revA=A*revAB%mod
revB=B*revAB%mod
revC=pow(100-C,mod-2,mod)
revC=100*revC%mod
kaijo=[1]*(2*N)
for i in range(1,2*N):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku=[0]*(2*N)
gyaku[2*N-1]=pow(kaijo[2*N-1],mod-2,mod)
for i in range(2*N-1,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
AN=pow(revA,N,mod)
BN=pow(revB,N,mod)
for M in range(N,2*N):
    a=AN*pow(revB,M-N,mod)%mod
    b=BN*pow(revA,M-N,mod)%mod
    c=kaijo[M-1]*gyaku[N-1]*gyaku[M-N]%mod
    d=M*revC
    e=c*d*(a+b)%mod
    ans=(ans+e)%mod
print(ans)

Measured memory_bytes: 18804
# ABC073D - joisino's travel
from itertools import permutations
from scipy.sparse.csgraph import dijkstra


def main():
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = RABC[:R], RABC[R:]
    G = [[float("inf")] * (N + 1) for _ in range(N + 1)]
    for v, u, c in zip(*[iter(ABC)] * 3):
        G[v][u] = G[u][v] = c
    dist = {v: dijkstra(G, N + 1, v) for v in visit}
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(int(ans))


if __name__ == "__main__":
    main()

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

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	printf((A == B && A == C) || (A != B && A != C && B != C) ? "No" : "Yes");

	return 0;
}


Measured memory_bytes: 3752
NN=raw_input()
N=raw_input()
A = [int(i) for i in N.split()]
swap=0

for i in range(int(NN)):
  for j in reversed(range(i+1,int(NN))):
    if A[j] < A[j-1] :
      t = A[j]
      A[j] = A[j-1]
      A[j-1] = t
      swap+=1
      
print ' '.join([str(k) for k in A])
print swap

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	ll ans=0;
	cin>>n;
	map<pll,ll> from;
	range(i,1,n+1){
		ll a=i%10;
		ll tmp=i,b;
		while(tmp>=10){
			tmp/=10;
		}
		b=tmp;
		from[pll(b,a)]++;
	}
	range(i,1,n+1){
		ll a=i%10;
		ll tmp=i,b;
		while(tmp>=10){
			tmp/=10;
		}
		b=tmp;
		ans+=from[pll(a,b)];
	}
	puta(ans);
}


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

#define MAX_E 200000
#define MAX_V 100001
#define MAX_N 100000
#define INF 1e9

struct edge {
  int u, v, cost;
};

struct Point{
    int p, n;
    bool operator< (const Point &obj) const{
        if(this->p > obj.p) return true;
        else return false;
    }
};

int par[MAX_N];  // 親
int depth[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    depth[i] = 0;
  }
}

// 木の根を求める
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

// xとyの属する集合を併合
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (depth[x] < depth[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (depth[x] == depth[y])
      depth[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) { return find(x) == find(y); }

bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }

edge es[MAX_E];
int V, E; // 頂点数と辺数

int kruskal() {
  sort(es, es + E, comp); // edge.costが小さい順にソートする
  init(V);                     // Union-Findの初期化
  int res = 0;
  for (int i = 0; i < E; i++) {
    edge e = es[i];
    if (!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

priority_queue<Point> x, y;

int main(){
    cin >> V;
    E = 0;
    for(int i=0;i<V;++i){
        int a, b;
        cin >> a >> b;
        x.push((Point){a,i});
        y.push((Point){b,i});
    }
    while(!x.empty()){
        Point p = x.top(); x.pop();
        es[E] = (edge){p.n, x.top().n, x.top().p - p.p};
        E++;
    }
    while(!y.empty()){
        Point p = y.top(); y.pop();
        es[E] = (edge){p.n, y.top().n, y.top().p - p.p};
        E++;
    }
    cout << kruskal() << endl;

    return 0;
}


Measured memory_bytes: 5100
#include<stdio.h>
#define N 100

int main(){
  int i, j, s, t, flag, temp;
  int A[N];

  scanf("%d",&s);
  for(j = 0; j < s; j++){
    scanf("%d",&A[j]);
  }
  
  flag = 1;
  i = 0;
  t = 0;
  while(flag){
    flag = 0;
    for(j = s - 1; j >= i + 1; j--){
      if(A[j] < A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	flag = 1;
	t++;
      }
    }
    i++;
  }

  for(j = 0; j < s; j++){
    printf("%d",A[j]);
    if(j != s - 1) printf(" ");
  }
  printf("\n%d\n",t);
  
  return 0;
}

Measured memory_bytes: 604
n, m = list(map(int, input().split()))
switches_list = []
p = []
for index in range(m):
    tmp = list(map(int, input().split()))
    switches_list.append(tmp[1:])

p.extend(list(map(int, input().split())))

# 答え
count = 0

op_cnt = n  # スイッチの個数
for i in range(2 ** op_cnt):
    op = [0] * op_cnt  # あらかじめ [0, 0, 0] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = 1  # フラグが立っていた箇所を 1 で上書き
    # print(op)
    # ここで処理する
    flag = True
    for index in range(m):
        tmp = 0
        for switch in switches_list[index]:
            tmp += op[switch - 1]
        if tmp % 2 != p[index]:
            flag = False
            break
    
    if flag == True:
        count += 1

print(count)

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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  //a2-a1の確認
  if ((c[1][0]-c[0][0]) != (c[1][1]-c[0][1]) || (c[1][1]-c[0][1]) != (c[1][2]-c[0][2])) {
    cout << "No" << endl;
    return 0;
  }
  //a3-a2の確認
  if ((c[2][0]-c[1][0]) != (c[2][1]-c[1][1]) || (c[2][1]-c[1][1]) != (c[2][2]-c[1][2])) {
    cout << "No"<< endl;
    return 0;
  }
  if ((c[0][1]-c[0][0]) != (c[1][1]-c[1][0]) || (c[1][1]-c[1][0]) != (c[2][1]-c[2][0])) {
    cout << "No" << endl;
    return 0;
  }
  if ((c[0][2]-c[0][1]) != (c[1][2]-c[1][1]) || (c[1][2]-c[1][1]) != (c[2][2]-c[2][1])) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

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

using namespace std;

int main() {
    int w, h;
    cin >> w >> h;
    vector<int> yoko(w);
    for (int i = 0; i < w; i++)cin >> yoko[i];
    sort(yoko.begin(), yoko.end(),greater<int>());
    vector<int> tate(h);
    for (int i = 0; i < h; i++)cin >> tate[i];

    for (int i = 0; i < w; i++) {
        sort(tate.begin(), tate.end(),greater<int>());
        for (int j = 0; j < h; j++) {
            if (yoko[i] > 0 && tate[j] > 0) {
                yoko[i]--;
                tate[j]--;
            }
        }
    }

    bool ret = true;
    for (int i = 0; i < w; i++) {
        if (yoko[i] > 0)ret = false;
    }
    for (int i = 0; i < h; i++) {
        if (tate[i] > 0)ret = false;
    }

    cout << (ret ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    string ans;
    int k = s.size() - 1;
    if (s[k] == '2' || s[k] == '4' || s[k] == '5' || s[k] == '7' || s[k] == '9') ans = "hon";
    else if (s[k] == '0' || s[k] == '1' || s[k] == '6' || s[k] == '8') ans = "pon";
    else ans = "bon";
    cout << ans << "\n";
}

Measured memory_bytes: 3628
n=int(input())
sp=[0]*n
for i in range(n):
	s,p=input().split()
	p=str(100-int(p))
	if len(p)==1:
		p="0"+p
	elif len(p)==3:
		p="999"+p
	sp[i]=[s+p,i+1]
sp.sort()
for i in range(n):
	print(sp[i][1])

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

///#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,avx,sse4.1,sse4.2,mmx")
///#pragma GCC optimize ("unroll-loops")
///#pragma GCC optimize ("Ofast")
///#pragma GCC optimize ("O3")

using namespace std;

#define int long long
#define ff first
#define ss second
#define db double
#define ld long double
#define pb push_back

const int N = 1e6 + 5, M = 1e3 + 5;
const int inf = 1e9 + 100, mod = 1e9 + 7;
const ld eps = 1e-9, pi = atan2(0, -1);

mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r){
    return mt_rnd_64() % (r - l + 1) + l;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;

    cout << a + a * a + a * a * a;
    return 0;
}
/// hto ya? zvychayna domohospodarka chy president Ykrainy?


Measured memory_bytes: 3624
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    long long N,K;cin >> N >> K;
    if(N < K/2){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    if(K % 2 == 0){
        long long half_Kremainder = 0;
        long long zero_Kremainder = 0;
        zero_Kremainder = N/K;
        half_Kremainder = (N-K/2)/K+1;
        ans = pow(half_Kremainder,3)+pow(zero_Kremainder,3);
    }
    else{
        long long zero_Kremainder = 0;
        zero_Kremainder = N/K;
        ans = pow(zero_Kremainder,3);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4024
import java.util.Scanner;
 class Main {
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			boolean[] prime=new boolean[n+1];
			int count=0;
			for(int i=2;i<=n;i++){
				prime[i] = true;
			}
			for(int i=2;i<=n;i++){
				if (prime[i]==true) {
					count++;
					for (int j=i+i; j<=n; j+=i) {
						prime[j] = false;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 35544
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define int long long
using namespace std;
int bit[65];
int mod=1e9+7;
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif


// -------------------------------------Code starts here--------------------------------------------------------------------- 

	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=63;j++)
		{
			bit[j]+=a[i]%2;
			a[i]/=2;
		}
	}

	int ans=0;
	int p=1;
	for(int i=1;i<=63;i++)
	{
		// cout<<bit[i]<<" ";
		int z=(bit[i]*(n-bit[i]))%mod;
		z=(z*p)%mod;
		p=(p*2)%mod;
		ans=(ans+z)%mod;
	}
	cout<<ans;
	
// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int cm = in.nextInt();
            int[] s = new int[n];
            int[] e = new int[n];
            int[] c = new int[n];

            for (int i = 0; i < n; i++) {
                s[i] = in.nextInt();
                e[i] = in.nextInt();
                c[i] = in.nextInt();
            }

            int[] recordingMachines = new int[100001];
            for (int i = 0; i < 100001; i++) recordingMachines[i] = 0;

            for (int i = 1; i <= cm; i++) {
                int[] onAir = new int[100002];
                for (int j = 0; j < n; j++) {
                    if (c[j] == i) {
                        onAir[s[j]]++;
                        onAir[e[j] + 1]--;
                    }
                }
                for (int j = 1; j < onAir.length; j++) {
                    onAir[j] += onAir[j - 1];
                }
                for (int j = 0; j < recordingMachines.length; j++) {
                    if (onAir[j] >= 1) recordingMachines[j]++;
                }
            }


            int ans = 0;
            for (int i = 0; i < recordingMachines.length; i++) {
                if (recordingMachines[i] > ans) ans = recordingMachines[i];
            }

            out.println(ans);
        }

    }
}



Measured memory_bytes: 95376
#include <iostream>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while(a>0&&c>0){
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
    }
    if(a<=0){
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

const ll MOD = 1000000007;

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

  int N, K;
  cin >> N >> K;
  vector<Pii> xy;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    xy.push_back(Pii(x, y));
  }

  vector<Pii> xyX = xy;
  sort(xyX.begin(), xyX.end());

  ll smallest = (ll) 9e18;
  for (int i = 0; i < N; i++) {
    vector<Pii> xyXT;
    for (int j = i; j < min(i + K - 1, N); j++) xyXT.push_back(xyX[j]);
    ll down = xyXT[0].first, up = xyXT[xyXT.size()-1].first;
    for (int j = i + K - 1; j < N; j++) {
      xyXT.push_back(xyX[j]);
      up = xyXT[xyXT.size()-1].first;
      sort(xyXT.begin(), xyXT.end(), [](Pii a, Pii b){return a.second < b.second;});
      for (int k = 0; k < xyXT.size(); k++) {
        for (int l = k + K - 1; l < xyXT.size(); l++) {
          ll left = xyXT[k].second, right = xyXT[l].second;
          ll field = (up - down) * (right - left);
          if (field < smallest) smallest = field;
        }
      }
    }
  }

  cout << smallest << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define MAX_V 10000
using namespace std;
typedef pair<int,int> P;
map<P,P> idx;

/*?????§?????¢?????´?????????(Ford_Fulerson????????¨)???O(F|E|)*/

//????????¨????§???????(???????????????????????????)
struct edge{int to, cap, rev;};

vector<edge> G[MAX_V]; //??°???????????£??\?????????
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

//from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  idx[P(from,to)].second=G[to].size();
  G[to].push_back((edge){from,cap,G[from].size()-1});
  idx[P(from,to)].first=G[from].size()-1;
}

//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

//s??????t???????????§???????±???????
int max_flow(int s,int t,int X){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, X);
    if(f == 0)return flow;
    flow += f;
    if(X==1)return flow;
  }
}

int main(){
  int n,e,q,a,b,m;
  cin>>n>>e>>q;
  for(int i=0;i<e;i++){
    cin>>a>>b; a--; b--;
    if(a>b)swap(a,b);
    add_edge(a,b,1);
  }
  int ans=max_flow(0,n-1,INF);
  for(int i=0;i<q;i++){
    cin>>m>>a>>b; a--; b--;
    if(a>b)swap(a,b);
    if(m==1){
      add_edge(a,b,1);
      ans+=max_flow(0,n-1,1);
    }else{
      P x=idx[P(a,b)];
      int s=-1,t=-1;
      if(!G[a][x.first].cap)s=a,t=b;
      if(!G[b][x.second].cap)s=b,t=a;
      G[a][x.first].cap=0;
      G[b][x.second].cap=0;
      if(s>=0&&t>=0){
	int r=max_flow(s,t,1);
	if(!r){
	  ans--;
	  if(s!=0)max_flow(s,0,1);
	  if(t!=n-1)max_flow(n-1,t,1);
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 5312
for a in iter(input,'0 0'):
 m=[input()for _ in[0]*int(a.split()[0])]
 y=x=0;s={(0,0)}
 while'.'!=m[y][x]:
  u,v=x,y
  c=m[y][x]
  if c=='>':x+=1;
  if c=='v':y+=1;
  if c=='<':x-=1;
  if c=='^':y-=1;
  if(x,y)in s:print('LOOP');break
  else:s|={(x,y)}
 else:print(x,y)


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

using namespace std;

const long long INF = (long long) 1e15;

void solve(long long A, long long B, long long Q, vector<long long> s, vector<long long> t, vector<long long> x)
{
    s.insert(s.begin(), -INF), s.push_back(INF);
    t.insert(t.begin(), -INF), t.push_back(INF);
    for (auto q: x) {
        int ps = lower_bound(s.begin(), s.end(), q) - s.begin();
        int pt = lower_bound(t.begin(), t.end(), q) - t.begin();
        long long ans = INF;
        for (int i = -1; i <= 1; ++i) for (int j = -1; j <= 1; ++j) {
            ans = min(ans, abs(q-s[ps+i])+abs(s[ps+i]-t[pt+j]));
            ans = min(ans, abs(q-t[pt+i])+abs(t[pt+i]-s[ps+j]));
        }
        cout << ans << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long A;
    cin >> A;
    long long B;
    cin >> B;
    long long Q;
    cin >> Q;
    long long v;
    vector<long long> s;
    for(int i = 0 ; i < A ; i++){
        cin >> v;
        s.push_back(v);
    }
    vector<long long> t;
    for(int i = 0 ; i < B ; i++){
        cin >> v;
        t.push_back(v);
    }
    vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        cin >> x[i];
    }
    solve(A, B, Q, move(s), move(t), move(x));
    return 0;
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll a,v, b, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if(v > w){

        ll d = abs(a - b);
        ll vdiff = v - w;

        ll t2 = (d + vdiff - 1) / vdiff;

        if(t2 <= t){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }

    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
package main

import (
	"fmt"
	"math"
	"strings"
)

func SInt() int {
	var n int
	fmt.Scan(&n)
	return n
}

func DInt() (int, int) {
	var n int
	fmt.Scan(&n)

	var m int
	fmt.Scan(&m)
	return n, m
}

func SStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func StrSlice() []string {
	var s string
	fmt.Scan(&s)
	return strings.Split(s, "")
}

func main() {
	n, k := DInt()
	ans := n - 1
	s := SStr()
	ss := strings.Split(s, "")
	if len(ss) == 1 {
		ans = 0
	}
	var re int
	for index := 0; index < len(ss)-1; index++ {
		if ss[index] == ss[index+1] {
			re++
		}
	}
	ansre := re + 2*k

	fmt.Println(Min(ans, ansre))
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <tuple>
#include <iomanip>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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


int main(void){
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}

	int ans = 0;
	for (int i = 0; i < n; i++){
		int highest = 0;
		for (int j = 0; j < i; j++){
			highest = max(highest, h[j]);
		}
		if (h[i] >= highest){
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
/*bool isPrime(long long n) 
{ long long i;
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false;
  
    return true; 
}
 
long long factorial(long long n) 
{    if(n==0||n==1)
     return 1;
     else
     return n*factorial(n - 1);  
} 
 
long long binarySearch(long long arr[], long long l, long long r, long long x) 
{ 
    while (l <= r) { 
        long long  m = l + (r - l) / 2; 
  
        
        if (arr[m] == x) 
            return m; 
  
      
        if (arr[m] < x) 
            l = m + 1; 
  
       
        else
            r = m - 1; 
    } 
    return -1; 
} 
*/

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll x;
     cin>>x;
     if(x>=400&&x<=599)
     cout<<8<<endl;
     else if(x>=600&&x<=799)
     cout<<7<<endl;
     else if(x>=800&&x<=999)
     cout<<6<<endl;
     else if(x>=1000&&x<=1199)
     cout<<5<<endl;
     else if(x>=1200&&x<=1399)
     cout<<4<<endl;
	 else if(x>=1400&&x<=1599)
     cout<<3<<endl;
     else if(x>=1600&&x<=1799)
     cout<<2<<endl;
     else if(x>=1800&&x<=1999)
     cout<<1<<endl;
	return 0;
}


Measured memory_bytes: 3664