akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> s(n, 0);
    for (int i = 0; i < q; i++){
        cin >> a[i];
        s[a[i]-1]++;
    }
    ll sum = 0;
    for (auto &e : s) sum += e;
    for (int i = 0; i < n; i++){
        if (k-sum+s[i] <= 0) cout << "No\n";
        else cout << "Yes\n";
    }
    
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3956
import java.util.*;

public class Main {
	 
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		String jstr=cin.nextLine();
		List<String> str=new ArrayList<>();
		while(true) {
			String cstr=cin.next();
			if(cstr.indexOf("END_OF_TEXT")>-1)break;
			str.add(cstr);
		}
		
		int res=0;
		//System.out.println(jstr);
		//System.out.println(str);
		
		for(int i=0;i<str.size();i++) {
			//String s=str.substring(i, i+jstr.length());
			if(str.get(i).length()==jstr.length()) {
				if(str.get(i).equalsIgnoreCase(jstr))res++;
			}
		}
		System.out.println(res);
	}
	
	
}


Measured memory_bytes: 26372
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  vector <ll> group(N), A(N);
  for (int i = 0; i < N; i++){
    group[i] = i;
    cin >> A[i];
  }
  
  for (int i = 0; i < M; i++){
    int X, Y; cin >> X >> Y;

    int GX = group[X], GY = group[Y];
    while (GX != group[GX]){
      GX = group[GX];
    }
    while (GY != group[GY]){
      GY = group[GY];
    }
    group[max(GX, GY)] = min(GX, GY);
  }

  for (int i = 0; i < N; i++){
    int G = group[i];
    while (G != group[G]) G = group[G];
    group[i] = G;
  }

  vector <ll> cnt[N];
  vector <bool> checked(N);
  for (int i = 0; i < N; i++){
    int G = group[i];
    cnt[G].push_back(A[i]);
    checked[G] = true;
  }

  ll ans = 0, type = 0;
  priority_queue <ll, vector<ll>, greater<ll> > que;
  for (int i = 0; i < N; i++){
    if (checked[i] == true){
      type++;
      sort(cnt[i].begin(), cnt[i].end());
      ans += cnt[i][0];
      for (int j = 1; j < cnt[i].size(); j++){
        que.push(cnt[i][j]);
      }
    }
  }
  
  if (type == 1){
    cout << 0 << endl;
  }else if (que.size() >= type - 2){
    for (int i = 0; i < type - 2; i++){
      ans += que.top(); que.pop();
    }
    cout << ans << endl;
  }else{
    cout << "Impossible" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, L;
    scanf("%d%d", &n, &L);
    vector<ll> a(n);
    ll max = -LINF;
    int maxi = 0;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        if (i > 0 && max < a[i] + a[i - 1]) {
            max = a[i] + a[i - 1];
            maxi = i;
        }
    }
    if (max >= L) {
        printf("Possible\n");
        for (i = 1; i < maxi; i++) {
            printf("%d\n", i);
        }
        for (i = n - 1; i > maxi; i--) {
            printf("%d\n", i);
        }
        printf("%d\n", maxi);
    }
    else {
        printf("Impossible\n");
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#define Mod 998244353ll
#define Maxn 300
#define ll long long
ll dp[Maxn+5][Maxn*Maxn+5];
ll dp2[Maxn+5][Maxn*Maxn+5];
int v[Maxn+5];
int main(){
    int n,s;
    ll p3,ans;
    scanf("%d",&n);
    s=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&v[i]);
        s+=v[i];
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
    	for(int j=0;j<=s;j++){
    		if(j>=v[i]){
    			dp[i][j]=(dp[i-1][j]*2+dp[i-1][j-v[i]])%Mod;
			}
            else{
            	dp[i][j]=(dp[i-1][j]*2)%Mod;
			}
		}
	}
    p3=1;
    for(int i=1;i<=n;i++){
    	p3=(p3*3)%Mod;
	}
    ans=0;
    for(int i=(s+1)/2;i<=s;i++){
    	ans=(ans+dp[n][i])%Mod;
	}
	if(s%2==0){
		dp2[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=Maxn*Maxn;j++){
				if(j>=v[i]){
					dp2[i][j]=(dp2[i-1][j]+dp2[i-1][j-v[i]])%Mod;
				}
				else{
                	dp2[i][j]=(dp2[i-1][j])%Mod;
				}
			}
		}
        ans=(ans-dp2[n][s>>1])%Mod;
    }
    ans=p3-ans*3;
    while(ans<0){
    	ans+=Mod;
	}
    ans%=Mod;
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    cout<<((n)*(n-1))/2+((m)*(m-1))/2<<endl;
    return 0;
}

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

using namespace std;
int ipow(int a,int b){
    int ans=1;
    for(int i=0;i<b;i++)ans=ans*a;
    return ans;
}

int main() {
    int a;
    cin>>a;
    for(int i=a;i>0;i--){
        for(int j=31;j>1;j--){
            for(int k=2;;k++){
                if(ipow(j,k)>i)break;
                if(ipow(j,k)==i){cout<<i;return 0;}
            }
        }
    }
    cout<<1;
    return 0;
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
    int a, b, r;
    char op;
    while(1) {
        scanf("%d %c %d", &a, &op, &b);
        if(op == 63) break;
        if(op == 43) r = a + b;
        if(op == 45) r = a - b;
        if(op == 42) r = a * b;
        if(op == 47) r = a / b;
        printf("%d", r);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	string s[3];
	cin>>s[0]>>s[1]>>s[2];
	cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,k;
  cin >> n >> k;
  ll co=1;
  while(1){
    if(n/k==0)break;
    n=n/k;
    co++;
  }
  pri(co);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    char x;
    while(scanf("%c",&x)!=EOF){
        if(x=='A'){
            printf("T");
        }
        if(x=='T'){
            printf("A");
        }
        if(x=='G'){
            printf("C");
        }
        if(x=='C'){
            printf("G");
        }
    }
    printf("\n");
    return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++) std::cin >> a[i];
    int cnt = 0;
    while(1){
        bool flag = false;
        for(int i = 0; i < n; i++){
            if(a[i] % 2 == 0){
                a[i] = a[i] >> 1;
            }else{
                flag = true;
                break;
            }
        }

        if(flag) break;
        cnt++;
    }

    std::cout << cnt << std::endl;
    return 0;
}


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

min_abs = abs(sum(W))
for i in range(N):
    s1 = sum(W[:i+1])
    s2 = sum(W[i+1:])
    if abs(s1 - s2) < min_abs:
        min_abs = abs(s1 - s2)
print(min_abs)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

N = int(input())
S = input()

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)


Measured memory_bytes: 9172
s=int(input())
a=[s]
tmp=s
index=1
while True:
    if tmp%2==0:
        tmp=tmp/2
        a.append(int(tmp))
        index+=1
    else:
        tmp=tmp*3+1
        a.append(int(tmp))
        index+=1

    if len(a)!=len(list(set(a))):
        print(index)
        exit(0)


Measured memory_bytes: 38384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(){
		Carrot_Num =Carrot_Time_Rest = 0;
		Total_Time = 0.0;
	}

	void set(int arg_Carrot_Num,double arg_Carrot_Time_Rest,double arg_Total_Time){
		Carrot_Num = arg_Carrot_Num;
		Carrot_Time_Rest = arg_Carrot_Time_Rest;
		Total_Time = arg_Total_Time;
	}

	int Carrot_Num;
	double Total_Time,Carrot_Time_Rest;
};

int main(){

	Info first;
	int N,Have_Limit;
	double Normal_Speed,Carrot_Speed,Carrot_Time_Length,L;
	scanf("%d %d %lf %lf %lf %lf",&N,&Have_Limit,&Carrot_Time_Length,&Normal_Speed,&Carrot_Speed,&L);

	double Location[N+2];
	Location[0] = 0.0;
	for(int i = 1; i <= N; i++){
		scanf("%lf",&Location[i]);
	}
	Location[N+1] = L;

	first.set(0,0.0,0.0);

	double Dist;
	int use_num;

	for(int i = 1; i <= N+1;i++){

		Dist = Location[i] - Location[i-1];
		if(Dist <= Carrot_Speed*first.Carrot_Time_Rest){
			first.Carrot_Time_Rest -= Dist/Carrot_Speed;
			first.Total_Time += Dist/Carrot_Speed;

		}else{
			if(first.Carrot_Time_Rest > 0){
				Dist -= Carrot_Speed*first.Carrot_Time_Rest;
				first.Total_Time += first.Carrot_Time_Rest;
				first.Carrot_Time_Rest = 0;
			}

			use_num = 0;
			for(int k = 1; k <= first.Carrot_Num;){
				if(Dist <= Carrot_Speed*Carrot_Time_Length){
					first.Carrot_Time_Rest = Carrot_Time_Length-Dist/Carrot_Speed;
					first.Total_Time += Dist/Carrot_Speed;
					Dist = 0.0;
					use_num = k;
					break;
				}else{
					Dist -= Carrot_Speed*Carrot_Time_Length;
					first.Total_Time += Carrot_Time_Length;
					k++;
					if(k > first.Carrot_Num){
						use_num = first.Carrot_Num;
						break;
					}
				}
			}
			first.Carrot_Num -= use_num;

			if(Dist > 0){
				first.Total_Time += Dist/Normal_Speed;
			}
		}
		if(first.Carrot_Num <= Have_Limit){
			first.Carrot_Num++;
			if(first.Carrot_Num > Have_Limit){
				first.Carrot_Num--;
				first.Carrot_Time_Rest = Carrot_Time_Length;
			}
		}
	}

	printf("%.8lf\n",first.Total_Time);
}

Measured memory_bytes: 2752
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0]
R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[-i-1]))
MAX = 0
for i in range(N):
    MAX = max(MAX, gcd(L[i], R[-i-1]))
print(MAX)



Measured memory_bytes: 16112
#include <stdio.h>
int H,A[500001];
void maxHeapify(int i){
	int l,r,largest,t;
	l=2*i;
	r=2*i+1;
	if(l<=H && A[l]>A[i]){
		largest=l;
	}
	else{
		largest=i;
	}
	if(r<=H && A[r]>A[largest]){
		largest=r;
	}
	if(largest!=i){
		t=A[i];
		A[i]=A[largest];
		A[largest]=t;
		maxHeapify(largest);
	}
}

void buildMaxHeap(){
  int i;
	for(i=H/2;i>=1;i--){
		maxHeapify(i);
	}
}

int main(){
	int i;
	scanf("%d",&H);
	for(i=1;i<=H;i++){
		scanf("%d",&A[i]);
	}
		buildMaxHeap();

	for(i=1;i<=H;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 3812
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    for j in range(l):
        print(sum(a[i][k] * b[k][j] for k in range(m)), end='')
        if j != l - 1:
            print(' ', end='')
    print('')

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

int main() {
  int N, W; cin >> N >> W;
  vector<pair<int, int>> kazu(N+1);
  rep(i, N) {
    int a, b; cin >> a >> b;
    kazu[i+1] = make_pair(a, b);
  }
  
  int dp[110][10010];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i < N+1; i++) {
    for (int j = 1; j < W+1; j++) {
      auto p = kazu[i];
      if (p.second <= j)  dp[i][j] = max(dp[i-1][j], dp[i-1][j-p.second] + p.first);
      
      else dp[i][j] = dp[i-1][j];
    }
  }
  
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 7416
#include <iostream>
#include <cstdio>

using namespace std;


int mov_x[] = {-1, 0, 1, 0};
int mov_y[] = {0, 1, 0, -1};


int main()
{
    char grid[52][52] = { 0 };
    int H, W;
    cin >> H >> W;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            char ch;
            cin >> ch;
            grid[i][j] = ch;
        }
    }

    bool feasible = true;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (grid[i][j] == '.')
                continue;
            bool adj = false;
            for (int m = 0; m < 4; m++) {
                if (grid[i+mov_y[m]][j+mov_x[m]] == '#')
                    adj = true;
            }
            if (!adj) {
                feasible = false;
            }
        }
    }
    if (feasible)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  if (s == t.substr(0, s.size())) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }
struct pt{
    int x, y, c;
};
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int h, w; 
vector<string> fld;

void bfs(){
    int blk = 0;
    rep(i, h) rep(j, w) if(fld[i][j]=='#') blk++;
    arr<bool> seen(h, vector<bool>(w, false));
    seen[0][0] = true;
    queue<pt> que;
    que.push({0,0,0});

    while(!que.empty()){
        pt p = que.front(); que.pop();
        rep(i, 4){
            int x = p.x + dx[i], y = p.y + dy[i];
            // printf("%d, %d, %d\n", x, y, p.c);
            if(x < 0 || x >= h || y < 0 || y >= w) continue;
            if(fld[x][y]=='#') continue;
            if(x == h-1 && y == w-1){
                int need = p.c + 2;
                // printf("%d %d %d\n", blk, need, h*w);
                pr(h*w - need - blk);
                return;
            }
            if(seen[x][y]) continue;
            seen[x][y] = true;
            que.push({x, y, p.c+1});
        }
    }
    pr(-1);
    return;
}

int main()
{
    cin >> h >> w;
    rep(i, h) {
        string s; cin >> s;
        fld.push_back(s);
    }
    // rep(i, h) pr(fld[i]);
    bfs();
    return 0;}

Measured memory_bytes: 3616
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
mo=10**9+7
imp='IMPOSSIBLE'
alp=string.ascii_lowercase
num=enumerate(alp)
d=dict()
for i,j in num:
    d[j]=i

n=I()
w=[]
ans=0
di=defaultdict(int)
X=[]
for i in range(n):
    s=''.join(sorted(list(input())))
    di[s]+=1
for i,j in di.items():
    ans+=j*(j-1)//2
    
print(ans)

Measured memory_bytes: 62552
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n;
String a;
int b = 0;
int[][]kard = new int[4][13];
String []mark = {"S","H","C","D"};
n = sc.nextInt();
for(int i=0; i<n; i++){ 
a = sc.next();
b = sc.nextInt();
for(int d=0; d<4; d++){
if(mark[d].equals(a))
kard[d][b-1]++;
}
}
for(int c=0; c<4; c++){
	for(int d=0; d<13; d++){
		if( kard[c][d]==0) System.out.println(mark[c]+" "+(d+1)); 
	}
}
}
}

Measured memory_bytes: 18244
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
struct edge {
	int to;
	ll cost;
	edge(int to, ll cost = 1) :to(to), cost(cost) {}
};
bool bipartite_matching_dfs(int v, vector<vector<edge>> &G, vector<int> &match, vector<bool> &used) {
	used[v] = true;
	for (edge e : G[v]) {
		int w = match[e.to];
		if (w < 0 || !used[w] && bipartite_matching_dfs(w, G, match, used)) {
			match[v] = e.to;
			match[e.to] = v;
			return true;
		}
	}
	return false;
}
int bipartite_matching(vector<vector<edge>> &G, int V) {
	vector<int> match(V, -1);
	vector<bool> used(V);
	int res = 0;
	for (int i = 0; i < V; i++) {
		if (match[i] < 0) {
			fill(used.begin(), used.end(), false);
			if (bipartite_matching_dfs(i, G, match, used)) {
				res++;
			}
		}
	}
	return res;
}
ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}
int main() {
	int m, n;
	vector<int> b(500);
	vector<int> r(500);
	vector<vector<edge>> G(1000, vector<edge>());
	while (cin >> m >> n, m) {
		for (int i = 0; i < m + n; i++) G[i].clear();
		for (int i = 0; i < m; i++) cin >> b[i];
		for (int i = 0; i < n; i++) cin >> r[i];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				if (gcd(b[i], r[j]) > 1) {
					G[i].emplace_back(j + m);
					G[j + m].emplace_back(i);
				}
			}
		}
		cout << bipartite_matching(G, m + n) << endl;
	}
}


Measured memory_bytes: 11500
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        char s[] = inp.next().toCharArray();
        Arrays.sort(s);
        char ans[] = {'a', 'b', 'c'};
        if (Arrays.equals(s, ans)) System.out.println("Yes");
        else System.out.println("No");
        inp.close();
    }
}


Measured memory_bytes: 22740
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
using namespace std;
template <typename T> inline T __lcm(T a,T b)
{
    return (a*b)/__gcd(a,b);
}

ll h[1000000];
ll dp[1000000];
ll n,k;
ll fun(ll i)
{
    if(i>=n)
    {
        return MAX_NUM;
    }
    if(i==n-1)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    //return dp[i]=min(fabs(h[i]-h[i+1])+fun(i+1),fabs(h[i]-h[i+2])+fun(i+2));
    ll minimum=MAX_NUM;
    for(int j=1;j<=k;j++)
    {
        ll temp=fabs(h[i]-h[i+j])+fun(i+j);
        minimum=min(minimum,temp);
    }
    return dp[i]=minimum;
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    memset(dp,-1,sizeof(dp[0])*1000000);
    ll ans=fun(0);
    printf("%lld\n",ans);
}


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

int main() {
  string N;
  cin >> N;
  if (
      (N[0] == N[1] && N[1] == N[2])
      ||
      (N[1] == N[2] && N[2] == N[3])
     ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>

using namespace std;
int main()
{
	int a,b,c,d,x,y;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if( a > d || b < c) printf("0\n");
	else {
		if( a > c) x = a;
		else x = c;
		if(b > d) y = d;
		else y = b;
		printf("%d\n",y-x);
	}
	return 0;
}

Measured memory_bytes: 256
dict = {'AC':0,'WA':0,'TLE':0,'RE':0}
n = int(input())
for i in range(n):
    s = input()
    dict[s]+=1

print('AC x '+str(dict['AC']))
print('WA x '+str(dict['WA']))
print('TLE x '+str(dict['TLE']))
print('RE x '+str(dict['RE']))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i, n - 2) {
        char temp[4] = {s[i], s[i + 1], s[i + 2]};
        if (strcmp("ABC", temp) == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func isPrime(a int) bool {
	for j := 2; j*j <= a; j++ {
		if a%j == 0 {
			return false
		}
	}
	return true
}

func main() {
	x := nextInt()

	for i := x; i <= 1000000; i++ {
		if isPrime(i) {
			fmt.Println(i)
			return
		}
	}
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,command,x;
    set<int> mySet;
    cin >> n;
    
    for(int i = 0;i < n;++i){
        cin >> command >> x;
        switch(command){
                // insert
            case 0:{
                mySet.insert(x);
                cout << mySet.size() << endl;;
                break;
                // find
            }
            case 1:{
                bool find = mySet.find(x) != mySet.end() ? true : false;
                cout << find << endl;
                break;
                //delete
            }
            case 2:{
                mySet.erase(x);
                break;
            }
        }
    }
}



Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, out;
    double outd;
    cin >> a >> b;

    outd = (a + b) / 2.0;
    out = (a + b) / 2;
    if (outd != out)
    {
        out += 1;
    }
    cout << out << endl;
}

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

int main() {
	int N;
	cin >> N;
	int A = 0;
	int B = 0;	
	vector<int>data(N);
	for (int i = 0; i < N; ++i) {
		cin >> data[i];
	}
	sort(data.rbegin(),data.rend());
	for (int i = 0;i<N;++i) {
		if (0 == i%2) {
			A += data[i];
		}
		else {
			B += data[i];
		}
	}
	cout << A - B << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2005,INF=1<<30;

int S[MAX][MAX][2];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,D;cin>>N>>D;
    vector<vector<int>> cnt(D,vector<int>(D));
    
    //if(D>30) return 0;
    
    vector<int> A(200000);
    
    for(int i=1;i*i<=200000;i++){
        A[i*i]=i;
    }
    for(int i=190000;i>=0;i--){
        if(A[i]==0) A[i]=A[i+1];
    }
    
    for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        cnt[a%D][b%D]++;
    }
    
    int ans=0;
    
    for(int i=0;i<D;i++){
        for(int j=0;j<D;j++){
            ans=max(ans,A[cnt[i][j]]-1);
        }
    }
    
    for(int i=0;i<D;i++){
        for(int j=0;j<D;j++){
            if(cnt[i][j]>ans*ans){
                S[i+1][j+1][0]++;
                S[i+1+D][j+1][0]++;
                S[i+1][j+1+D][0]++;
                S[i+1+D][j+1+D][0]++;
            }
            if(cnt[i][j]>ans*(ans+1)){
                S[i+1][j+1][1]++;
                S[i+1+D][j+1][1]++;
                S[i+1][j+1+D][1]++;
                S[i+1+D][j+1+D][1]++;
            }
        }
    }
    
    for(int k=0;k<2;k++){
        for(int i=0;i<=2*D;i++){
            for(int j=1;j<=2*D;j++){
                S[i][j][k]+=S[i][j-1][k];
            }
        }
        for(int j=0;j<=2*D;j++){
            for(int i=1;i<=2*D;i++){
                S[i][j][k]+=S[i-1][j][k];
            }
        }
    }
    
    int left=-1,right=D-1;
    
    while(right-left>1){
        int mid=(left+right)/2;
        bool ok=false;
        for(int i=0;i<D;i++){
            for(int j=0;j<D;j++){
                bool check=true;
                /*for(int a=0;a<D;a++){
                    for(int b=0;b<D;b++){
                        if(a>mid&&b>mid&&cnt[(i+a)%D][(j+b)%D]>ans*ans) check=false;
                        
                        if(a>mid&&b<=mid&&cnt[(i+a)%D][(j+b)%D]>ans*(ans+1)) check=false;
                        
                        if(a<=mid&&b>mid&&cnt[(i+a)%D][(j+b)%D]>ans*(ans+1)) check=false;
                    }
                }*/
                mid++;
                
                if(S[i+D][j+mid][1]+S[i+mid][j][1]-S[i+D][j][1]-S[i+mid][j+mid][1]>=1) check=false;
                
                if(S[i+mid][j+D][1]+S[i][j+mid][1]-S[i+mid][j+mid][1]-S[i][j+D][1]>=1) check=false;
                
                if(S[i+D][j+D][0]+S[i+mid][j+mid][0]-S[i+D][j+mid][0]-S[i+mid][j+D][0]>=1) check=false;
                
                mid--;
                
                if(check) ok=true;
            }
        }
        
        if(ok) right=mid;
        else left=mid;
    }
    //assert(right!=D-1);
    //assert(right!=0);
    cout<<ans*D+right<<endl;
}






Measured memory_bytes: 36352
#組み合わせ4000C3=10,658,668,000なので全探索は無理

n = int(input())
s = str(input())

r = s.count("R")
g = s.count("G")
b = s.count("B")

paircount_without_regulation = r*g*b

#j−i ≠ k−jの条件に引っかかるペア数を数える。
i = 0
j = 1
k = 2
between_counter = 1
regulation_counter = 0

while k <= n-1:
    while k <= n-1:
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            regulation_counter += 1
        i += 1
        j += 1
        k += 1

    i = 0
    j = 1
    k = 2
    j += between_counter
    k += between_counter*2
    between_counter += 1
    #print(between_counter)

result = paircount_without_regulation - regulation_counter

print(result)


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

int main(){
    int n,k;
    int a[210000];
    cin >> n >> k;
    for(int i = 0;i < n; i++) cin >> a[i];

    int baket[210000] = {0};
    for(int i = 0; i < n; i++){
        baket[a[i]]++;
    }

    int counter = 0;
    for(int bi = 1; bi <= n; bi++){
        // cout << "baket[" << bi << "] is "<<baket[bi] << endl;
        // cout << baket[bi];
        if(baket[bi]){
            counter++;
        }
    }
    cout << endl;


    if(counter > k){
        int diff = counter - k;
        // cout << "diff is " << diff << endl;
        int ans = 0;
        static int count = 0;
        sort(baket,baket+n+1);
        // cout << "sorted array is  ";
        // for(int i = 0; i <= n; i++) cout << baket[i] << " ";
        // cout << endl;
        for(int j = 1;j < n;j++){
            // cout << baket[j] << endl;
            if(baket[j] != 0){
                // cout << "baket[" << j << "] is " << baket[j] << endl;
                ans += baket[j];
                count += 1;
                // cout << "count is " << count << endl;
                if(count == diff) break;
                // cout << "ans is " << ans << endl;
            }
        }
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>> C(H,vector<char>(W));
    vector<vector<char>> D(H*2,vector<char>(W));
    rep(i,H){
        rep(j,W){
            cin>>C.at(i).at(j);
        }
    }
    rep(i,2*H){
        rep(j,W){
            D.at(i).at(j)=C.at((i)/2).at(j);
        }
    }
    rep(i,2*H){
        rep(j,W){
            cout << D.at(i).at(j);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#define llint long long

using namespace std;

llint n, k;
llint a[200005], sum[200005];

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i], a[i] = a[i]+1;
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
	
	llint ans = 0;
	for(int i = 1; i+k-1 <= n; i++) ans = max(ans, sum[i+k-1]-sum[i-1]);
	
	printf("%.11f\n", ans*0.5);
	return 0;
}

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

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

	int maxH  = 0;
	int ans = 0;
	for(int i = 0; i < N; i++)
	{
		int h;
		cin >> h;
		if(maxH <= h){
			maxH = h;
			ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void)

{
    int ara[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i, n;
    cin>>n;
    n--;
    cout<<ara[n]<<endl;
    return 0;
}


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

using namespace std;

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

int main() {
  int k;
  cin >> k;
  int ans = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = a + 1; b <= k; b++) {
      for (int c = b + 1; c <= k; c++) {
        int x = gcd(a, b);
        int y = gcd(x, c);
        ans += y * 6;
      }
    }
  }
  for (int a = 1; a <= k; a++) {
    for (int b = a + 1; b <= k; b++) {
      int x = gcd(a, b);
      ans += x * 6;
    }
  }
  ans += k * (k + 1) / 2;
  cout << ans << endl;

  return 0;
}

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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int dp[22][20000001];
bool comp[22][22];
int n;

int calc(int m, int w){
	if(dp[m][w]!=-1) return dp[m][w];
	if(m==n) return 1;
	int ans=0;
	rep(i, 0, n-1){
		if(!(w&(1<<i))) continue;
		if(comp[m][i]){
			ans=(ans+calc(m+1, w&(~(1<<i)))%MOD)%MOD;
		}
	}
	return dp[m][w]=ans;
}

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i, 0, n-1){
  	rep(j, 0, n-1){
  		cin >> comp[i][j];
  	}
  }
  rep(i, 0, n){
  	rep(j, 0, (1<<(n+1))-1){
  		dp[i][j]=-1;
  	}
  }
  cout << calc(0, (1<<(n+1))-1);
}

Measured memory_bytes: 364156
#                         author:  kagemeka 
#                         created: 2019-11-07 12:33:44(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    n, x, *m = (int(i) for i in sys.stdin.read().split())
    x -= sum(m)
    c = n
    c += x // min(m)
    print(c)



if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

#define MAXN 100005

vi h;
vector<vi> g;
int bom = 0;

int main() {

    int n, m;
    cin >> n >> m;

    h = vi(n + 1);
    g = vector<vi>(n + 1);

    fo(i, n) cin >> h[i + 1];

    fo(i, m) {
        int a, b;
        cin >> a >> b;

        g[a].pb(b);
        g[b].pb(a);
    }


    fo(i, n) {
        bool good = true;
        for ( auto it : g[i + 1] ) {
            if ( h[it] >= h[i + 1] ) good = false;
        }
        if ( good ) bom++;
    }

    cout << bom << endl;

    return 0;
}

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

using namespace std;

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

    long long min_num = 1000001;
    long long max_num = -1000001;
    long long sum = 0;
    
    for(int i = 0; i < n; i++){
        long long tmp;
        cin >> tmp;
        
        sum += tmp;
        if(min_num > tmp){
            min_num = tmp;
        }
        
        if(max_num < tmp){
            max_num = tmp;
        }
    }
    
   cout << min_num << " " << max_num << " " << sum << endl;
}


Measured memory_bytes: 3088
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

int minpts(vector<pair<int, int>> &spells, vector<vector<int>> &mem, int idx,
           int curhealth) {
  if (curhealth <= 0) {
    return 0;
  }

  if (idx < 0) {
    return 1e9;
  }

  if (mem[idx][curhealth] != -1) {
    return mem[idx][curhealth];
  }

  mem[idx][curhealth] =
      min(minpts(spells, mem, idx, curhealth - spells[idx].first) +
              spells[idx].second,
          minpts(spells, mem, idx - 1, curhealth));
  return mem[idx][curhealth];
}

int main() {
  FASTIO();

  int h, n;
  cin >> h >> n;

  vector<pair<int, int>> spells(n);
  vector<vector<int>> mem(n + 1, vector<int>(h + 1, -1));
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    spells[i] = mp(a, b);
  }

  cout << minpts(spells, mem, n - 1, h);
}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N, P;
string S;
int t[202020];

void solve() {


    FOR(N)
    S[i] -= '0';
    if (P == 2 || P == 5) {
        int ans = 0;
        FOR(N) {
            if (S[i] % P == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return;
    }
    int tot = 0;
    int ten = 1;
    int ans = 0;
    t[0]++;
    for (int i = N - 1; i >= 0; i--) {
        tot += ten * S[i];
        tot %= P;
        ans += t[tot];
        t[tot]++;


        ten *= 10;
        ten %= P;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> P >> S;
    solve();
    return 0;
}


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

using namespace std;

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

    int n, tempNum = 0, maxNum = 0;
    vector<long long> h;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        long long x;
        cin >> x;

        h.emplace_back(x);
    }

    for (int i = 0; i < n-1; ++i) {
        if (h[i] < h[i+1]) {
            if (tempNum > maxNum) {
                maxNum = tempNum;
            }

            tempNum = 0;
        } else {
            ++tempNum;
        }

        if (tempNum > maxNum) {
            maxNum = tempNum;
        }
    }

    cout << maxNum;
}


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

typedef int Digit[5];

int n;
int ds[114514];

int Convert(int t, int *ds) {
  if (t == 0) {
    ds[0] = 0;
    return 1;
  }

  int cnt = 0;
  while (t > 0) {
    ds[cnt++] = t%10;
    t /= 10;
  }
  reverse(ds, ds+cnt);
  return cnt;
}

int main() {
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &ds[i]);
  }

  int ans = 0;
  while (1) {
    Digit gs;
    int k = Convert(ans, gs);
    bool fail = false;
    for (int i=0; i<=n-k; i++) {
      int cnt = 0;
      for (int j=0; j<k; j++) {
        cnt += (ds[i+j] == gs[j]);
      }

      if (cnt == k) {
        fail = true;
        break;
      }
    }

    if (!fail) break;
    ans++;
  }

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

Measured memory_bytes: 3228
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long i = long.Parse(str[1]);
		long ans = N - i + 1;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int f[N][10];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  int p[N][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }

  // ビットで全探索
  bool s[10]; // 姉の店が開いているか否か
  int maxi = -INF;
  for (int i = 1; i < 1024; i++) {
    fill(s, s + 10, false);
    for (int j = 0; j < 10; j++) {
      if (1 & (i >> j)) s[9-j] = true;
    }

    int gain = 0;
    for (int j = 0; j < N; j++) {
      int cnt = 0;
      for (int k = 0; k < 10; k++) {
        if (f[j][k] && s[k]) cnt++;
      }
      gain += p[j][cnt];
    }
    maxi = max(maxi, gain);
  }

  // 解答
  cout << maxi << endl;

  return 0;
}


Measured memory_bytes: 256
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }


int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int n;cin>>n;
    cout<<n+n*n+n*n*n;
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 3648
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

using namespace std;

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

const int maxn = 2e5 + 10;

int t,n,m;

int main(void) {
	int mod;
	cin >> mod;
	int n = mod % 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
		cout << "hon" << endl;
	} else if(n == 0 || n == 1 || n == 6 || n == 8) {
		cout <<"pon" << endl;
	} else if(n == 3){
		cout << "bon" << endl;
	}

	return 0;	
}
 

Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <vector>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

typedef long long int ll;
const ll MOD = 1000000007;

ll N,K;
ll dp[2010][2010];

int main() {
  cin >> N >> K;
  rep(i,N+2){
    rep(j,N+2){
      if (i == 0 && j != 0) dp[i][j] = 0;
      else if (j == 0) dp[i][j] = 1;
      else {
        dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
      }
      // cerr << dp[i][j] << " ";
    }
    // cerr << endl;
  }
  
  for(ll i=1; i<=K; i++){
    if (N-K-i+1 < 0) {
      cout << "0" << endl;
      continue;
    }
    ll ans = (dp[i][K-i] * dp[i+1][N-K-i+1]) % MOD;
    cout << ans << endl;
  }
}

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

int main(void)
{
        int a1, a2, a3, a4, a;
        int b1, b2, b3, b4, b;
        cin >> a1 >> a2 >> a3 >> a4;
        cin >> b1 >> b2 >> b3 >> b4;
        a = a1 + a2 + a3 + a4;
        b = b1 + b2 + b3 + b4;

        if(a <= b){
                cout << b << endl;
        }
        else if(a > b){
                cout << a << endl;
        }

        return (0);
}

Measured memory_bytes: 1160