akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int n;
  int a[10000];
  int k = 0;
  cin >> n;
  FOR(i,n)
    cin >> a[i];
  bool hoge=true;
  while(hoge){
    FOR(i,n){
      if(a[i]%2==1) {
        hoge=false;
        break;
      }
      a[i]/=2;
    }
    k++;
  }
  cout << k-1 fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
uses
        math;
var
        x,y:integer;
        z:longint;
begin
       // clrscr;
        read(x,y);
        writeln;
        z:=0;
        z:=max(x*y,x+y);
        z:=max(z,x-y);
        write(z);
        readln
end.


Measured memory_bytes: 128
#include<stdio.h>
int main (void){
int a,b,c;
int i;
int count=0;
scanf("%d %d %d",&a,&b,&c);
for(i=a;i<=b;i++){
if(c%i==0){
count++;
}
}
printf("%d\n",count);
return 0;
}

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

const int N = 100010;
typedef long long ll;
typedef std::pair <ll, int> pii;

ll a[N], b[N];
ll ans[N];

int main(){
	int n, q;
	scanf("%d%d", &n, &q);
	a[1] = n;
	for (int i = 2; i <= q + 1; ++ i){
		scanf("%lld", &a[i]);
	}
	std::set <pii> set;
	for (int i = 0; i <= q + 1; ++ i){
		set.insert({a[i], i});
	}
	int cnt = 0;
	for (int now = 0; ; ){
		b[cnt ++] = a[now];
		auto u = set.upper_bound({a[now], INT_MAX});
		if (u == set.end()) break;
		for (int i = now; i < u -> second; ++ i){
			set.erase({a[i], i});
		}
		now = u -> second;
	}
	std::map <ll, ll, std::greater <ll>> Hash;
	Hash[b[cnt - 1]] = 1;
	while (true){
		auto u = Hash.begin();
		if (u -> first <= b[1]){
			break;
		}
		int sit = std::lower_bound(b + 1, b + cnt, u -> first) - b - 1;
		Hash[b[sit]] += u -> first / b[sit] * u -> second;
		ll y = u -> first % b[sit];
		if (y){
			Hash[y] += u -> second;
		}
		Hash.erase(u);
	}
	for (auto u : Hash){
		ans[u.first] = u.second;
	}
	for (int i = n - 1; i >= 1; -- i){
		ans[i] += ans[i + 1];
	}
	for (int i = 1; i <= n; ++ i){
		printf("%lld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
double get(pair<int,int>a,pair<int,int>b){
	int x=a.ff-b.ff;
	int y=a.ss-b.ss;
	x=x*x;y=y*y;
	return (double)sqrt(x+y);
}
void solve(){
	ll n;cin>>n;
	str a;cin>>a;
	stack<char>s;
	for(auto i:a){
		if(s.empty()){
			s.push(i);
		}
		else{
			if(s.top()==i){continue;}
			else{s.push(i);}
		}
	}
	cout<<(int)s.size();
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 3796
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int a = Character.getNumericValue('a');

		int[][] map = new int[n][26];
			for(int i = 0; i < n; i++){
				String input = br.readLine();
				for(int j =0; j<input.length(); j++){
					int idx = Character.getNumericValue(input.charAt(j)) - a;
					map[i][idx] += 1;
			}
		}
		int[] alp = new int[26];
		for(int i =0; i<26; i++){
			alp[i] =(int)1e9;
		}

		for(int i=0; i<n; i++){
			for(int j=0; j<26; j++){
				if(map[i][j] == 0){
					alp[j] = 0;
				}else{
					alp[j] = Math.min(map[i][j],alp[j]);
				}
			}
		}

		for(int i=0; i<26;i++){
			char c = (char)('a' + i);
			int count = alp[i];
			for(int j=0; j<count; j++){
				System.out.print(c);
			}
		}
		
	}
}

Measured memory_bytes: 22740
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

int i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
void solve()
{
	lli r,g,b,n; cin>>r>>g>>b>>n;
	lli ct=0;
	rep(i,0,3000)
	 rep(j,0,3000)
	    if( n-i*r-j*g >=0 && (n-i*r-j*g)%b==0)
	    	 ++ct;
  cout<<ct<<"\n";
}

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

using P = pair<ll,ll>;
#define v first
#define w second

// v高い順（vが同じならw軽い方優先）
bool comp(P a, P b){
    return a.v == b.v ? a.w < b.w : a.v > b.v;
}

int main(void){
    ll N,W;
    cin>>N>>W;
    vector<P> a(N);
    rep(i,N){
        ll v,w;
        cin>>v>>w;
        a[i] = {v,w};
    }
    vector<P> dp = {{0,0}};

    rep(i,N){
        vector<P> tmp;
        for(P s : dp){
            tmp.push_back(s);
            tmp.push_back({s.v + a[i].v, s.w + a[i].w});
        }

        sort(all(tmp),comp);
        dp.clear();
        ll w_border = W+1;
        for(P s : tmp){
            if( w_border > s.w){
                w_border = s.w;
                dp.push_back(s);
            }
        }
        assert((ll)dp.size() <= N*N+1);
    }
    cout<<dp[0].v<<endl;
    return 0;
}



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

int main() {
    int n;
    cin >> n;
    map<string, int> m;
    long long sum = 0;
    for (int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        sum+=m[s];
        m[s]++;
        // sum+=m[s]++;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main()
{
	int i;
	int c1[5], c2[5], c3[5];
	int a1, a2, a3, b1, b2, b3;

	for (i = 0; i < 3; i++)
		scanf("%d", &c1[i]);
	for (i = 0; i < 3; i++)
		scanf("%d", &c2[i]);
	for (i = 0; i < 3; i++)
		scanf("%d", &c3[i]);

	a1 = 0;
	b1 = c1[0];
	b2 = c1[1];
	b3 = c1[2];
	a2 = (c2[0] + c2[1] - b1 - b2) / 2;
	a3 = (c3[0] + c3[1] - b1 - b2) / 2;

	if (((a1 + b1) == c1[0]) && ((a1 + b2) == c1[1]) && ((a1 + b3) == c1[2]) && 
		((a2 + b1) == c2[0]) && ((a2 + b2) == c2[1]) && ((a2 + b3) == c2[2]) &&
		((a3 + b1) == c3[0]) && ((a3 + b2) == c3[1]) && ((a3 + b3) == c3[2])) 
		printf("Yes");
	else 
		printf("No");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    repr(i, k, n+1){
        ans += (n-i+1)*i+1;
        ans %= MOD;
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3636
import sys
input=sys.stdin.readline
import heapq

def dijkstra(graph,N,s):
    distance = {(i + 1, j): 1e7 for i in range(N) for j in range(3)}
    distance[s]=0
    q=[]
    heapq.heappush(q,(distance[s],s))
    while len(q)>0:
        cost,v=heapq.heappop(q)
        if cost>distance[v]:
            continue
        else:
            for w in graph[v]:
                if distance[w]>distance[v]+1:
                    distance[w]=distance[v]+1
                    heapq.heappush(q,(distance[w],w))
    return distance


if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    E=[list(map(int,input().split())) for _ in range(M)]
    S,T=list(map(int,input().split()))
    graph={(i+1,j):[] for i in range(N) for j in range(3)}
    for e in E:
        graph[(e[0],0)].append((e[1],1))
        graph[(e[0],1)].append((e[1],2))
        graph[(e[0],2)].append((e[1],0))
    distance=dijkstra(graph,N,(S,0))
    d=distance[(T,0)]
    if d%3==0:
        print(d//3)
    else:
        print(-1)


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

using pii = pair<int, int>;

vector<pii> findNearPos(pii p, int h, int w) {
  vector<pii> v;
  int x = p.first;
  int y = p.second;
  for (int i = -1; i <= 1; ++i) {
    for (int j = -1; j <= 1; ++j) {
      if (i == 0 && j == 0) {
        continue;
      }
      if ((0 <= x + i && x + i < h) &&
          (0 <= y + j && y + j < w)) {
        v.emplace_back(x + i, y + j);
      }
    }
  }

  return v;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> grid(h, vector<int>(w));
  vector<pii> bombPos;
  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < w; ++j) {
      if (s[j] == '.') {
        grid[i][j] = 0;
      } else {
        grid[i][j] = -1;
        bombPos.emplace_back(i, j);
      }
    }
  }

  for (const auto& p : bombPos) {
    vector<pii> nearPos = findNearPos(p, h, w);
    for (const auto& np : nearPos) {
      if (grid[np.first][np.second] != -1) {
        grid[np.first][np.second]++;
      }
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (grid[i][j] == -1) {
        cout << "#";
      } else {
        cout << grid[i][j];
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
long long a[10010];
long long b[10010];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	long long cnt=0;
	long long ans=0;
	for(int i=0;i<n;i++){
		if(b[i]-a[i]<0)ans+=a[i]-b[i];
		else if(b[i]-a[i]>0)cnt+=(b[i]-a[i])/2;
	}
	if(ans<=cnt)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	int x,y,z;
	cin >> x >> y >> z;
	cout << z <<' '<< x <<' '<< y << endl;
	return(0);
}

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

class Main
{
    public static void main(String[] args)
    {
	Scanner sc = new Scanner(System.in);
	
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	if(a<b)
{
if(b<c)
{
System.out.println("Yes");
}else{
System.out.println("No");
}

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






    }
}


Measured memory_bytes: 26236
import sys
from math import log10, floor
K = input()
d = int(input())
digit_num = len(K)
MOD = 10**9+7
# memo_ls[i][j][k] : 上からi桁目まででMODがjでflgがkの個数
memo_ls = [[[0 for _k in range(2)] for j in range(d)] for i in range(digit_num + 1)]
memo_ls[0][0][0] = 1
dic = {j : j % d for j in range(10)}
for i, n in enumerate(K, 1):
    n = int(n)
    for j in range(10):
        for k in range(d):
            _from = (k - j) % d
            memo_ls[i][k][1] = (memo_ls[i][k][1] + memo_ls[i-1][_from][1]) % MOD
            if j == n:
                memo_ls[i][k][0] = (memo_ls[i-1][_from][0] + memo_ls[i][k][0]) % MOD
            elif j < n:
                memo_ls[i][k][1] = (memo_ls[i-1][_from][0] + memo_ls[i][k][1]) % MOD
print((sum(memo_ls[digit_num][0]) - 1) % MOD)

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

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String[] str;
		while(sc.hasNext()) {
			str = sc.next().split(",");
			int[] hand = new int[13];
			int max = 0;
			boolean flag = false;
			int number = Integer.MIN_VALUE;
			int count = 0;

			Arrays.fill(hand, 0);

			//???????????\?????????
			for(int $ = 0; $ < str.length; $++) {
				int num = Integer.parseInt(str[$]) - 1;
				hand[num] += 1;
				max = Math.max(max, hand[num]);
			}

			if(hand[0] == 1 && hand[12] == 1 && hand[11] == 1 && hand[10] == 1 &&hand[9] == 1) {
				flag = true;
			} else {
				for(int $ = 0; $ < hand.length; $++) {
					if(hand[$] == 1 && ($ == number || number == Integer.MIN_VALUE)) {
						number = $ + 1;
						if(++count == 5) {
							flag = true;
							break;
						}
					}
				}
			}

			Arrays.sort(hand);

			//?????????????????????????????°???4????????¨???
			if(max == 4) {
				System.out.println("four card");
			} else if(max == 3) {
				if(hand[hand.length - 2] == 2) {
					System.out.println("full house");
				} else {
					System.out.println("three card");
				}
			} else if(max == 2) {
				if(hand[hand.length - 2] == 2) {
					System.out.println("two pair");
				} else {
					System.out.println("one pair");
				}
			} else {
				if(flag) {
					System.out.println("straight");
				} else {
					System.out.println("null");
				}
			}
		}
	}

}

Measured memory_bytes: 26100
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define inv(i, a, b)        for (int i = (int)(a); i >= (int)(b); i--)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, unsigned int y) {                                                    //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BTripleDots {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) {
      cout << S << endl;
    } else {
      cout << S.substr(0, K) + string(3, '.') << endl;
    }
  }
};


signed main() {
  BTripleDots solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int num[3]={0};
  int five=0,sev=0;
  scanf("%d %d %d",&num[0],&num[1],&num[2] );

  for(int i=0;i<3;i++){
      if(num[i] == 5)five++;
      if(num[i] == 7)sev++;
  }

  if(five == 2 && sev == 1){
    puts("YES");
  }else{
    puts("NO");
  }

  return 0;
}


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

const int N=300100;

int n,a[N],e[N],w[N],ans=0x3f3f3f3f;

inline int nextInt()
{ 
    char c=getchar();
	for(;c!='W'&&c!='E';c=getchar());
	for(;c=='E'||c=='W';c=getchar())return c=='E';
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		e[i]=e[i-1];w[i]=w[i-1];
		a[i]=nextInt();
		if(a[i])e[i]++;
		else w[i]++;
	}
	for(int i=1;i<=n;i++)
		ans=min(ans,w[i-1]+e[n]-e[i]);
	cout<<ans<<endl;
	return 0;
}
 

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <set>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;

    int t, x, y;
    int last_t = 0;
    int now_x = 0;
    int now_y = 0;

    for (int i = 0; i < n; ++i)
    {
        cin >> t >> x >> y;
        int dist = abs(x-now_x) + abs(y-now_y);
        int dist_t = t - last_t;

        if (dist > dist_t || dist%2 != dist_t%2)
        {
            cout << "No" << "\n";
            return 0;
        }
        else
        {
            last_t = t;
            now_x = x;
            now_y = y;
        }
    }

    cout << "Yes" << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vector<i64> a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(all(a));
	reverse(all(a));
	i64 ans = 0;
	i64 p = 0;
	rep(i, 0, n - 1) {
		if (a[i] == a[i + 1]) {
			if (p) {
				ans = p * a[i];
				break;
			}
			p = a[i];
			i++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))

def isCenter(l3):
  center = l3[1]
  l3.sort()
  return center == l3[1] and l3[0] != l3[1]

cnt = 0

for i in range(n - 2):
  if isCenter(p[i:i+3]):
    cnt += 1

print(cnt)


Measured memory_bytes: 38384
// Oh boi here we go again
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define pii pair < int, pi >
#define next next123
#define left left123

const int N = 2e5 + 7;
const int INF = 1e9 + 7;

int n;
string s;

main(){
    cin >> n >> s;
    int ans = 0;
    for (int i = 2; i < s.length(); i++){
        if (s[i] == 'C' && s[i - 1] == 'B' && s[i - 2] == 'A')
            ans++;
    }
    cout << ans;
}


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

using namespace std;
typedef unsigned long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll MOD = 998244353LL;
int N;

int main() {
    cin >> N;

    vi D(N);
    for (int i = 0; i < N; i++) {
        cin >> D[i];
    }

    if (N == 1 && D[0] == 0) {
        cout << 1 << endl;
        return 0;
    }
    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    sort(D.begin(), D.end());  // 昇順

    if (D[0] != 0 || D[1] != 1) {
        cout << 0 << endl;
        return 0;
    }

    vi count(N);
    count[0] = 1;

    ll ans = 1;
    for (int i = 1; i < N; i++) {
        if (D[i] == 1) {
            count[D[i]]++;
        } else if (D[i] - D[i - 1] > 1) {
            cout << 0 << endl;
            return 0;
        } else {
            count[D[i]]++;
            ans *= count[D[i] - 1];
            ans %= MOD;
        }
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 1e5 + 5;

vector<pair<ll, int>> node[N];
map<pii, int> idx;
set<pair<ll, int>> st;
vector<pii> vec;

int n, curr = 1;
bool visited[N];

void explore(int v)
{
	visited[v] = true;
	for (auto i : node[v])
		if (!visited[i.second])
			st.insert(
			{ i.first, i.second });
}

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

	cin >> n;
	vec.resize(n);
	rep(i, 0, n)
	{
		int a, b;
		cin >> a >> b;

		if (!idx[
		{ a, b }])
			idx[
			{ a, b }] = curr++;
		vec[i] =
		{	a, b};
	}

	sort(all(vec));

	rep(i, 0, n-1)
	{
		int a = idx[vec[i]], b = idx[vec[i + 1]];
		int val = min(abs(vec[i].first - vec[i + 1].first),
				abs(vec[i].second - vec[i + 1].second));

		node[a].push_back(
		{ val, b });
		node[b].push_back(
		{ val, a });
	}

	rep(i, 0, n)
		swap(vec[i].first, vec[i].second);

	sort(all(vec));
	rep(i, 0, n-1)
	{
		int a = idx[
		{ vec[i].second, vec[i].first }], b = idx[
		{ vec[i + 1].second, vec[i + 1].first }];

		int val = min(abs(vec[i].first - vec[i + 1].first),
				abs(vec[i].second - vec[i + 1].second));

		node[a].push_back(
		{ val, b });
		node[b].push_back(
		{ val, a });
	}

	explore(1);

	ll mst = 0;
	// cost, idx, par if needed
	while (!st.empty())
	{
		auto i = st.begin();
		st.erase(st.begin());

		ll cost = i->first, idx = i->second;

		if (!visited[idx])
		{
			mst += cost;
			explore(idx);
		}
	}

	cout << mst << endl;

	return 0;
}


Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    long long a,b,ans=0,mod=1e9+7,i=1;

    cin>>a>>b;

    if(a==b || abs(a-b)==1){

        if(a<b)
            swap(a,b);
        ans=1;
        if(a==b){
            i=2;
        }
        for(int i=1; i<=a; i++){

            ans*=i;
            ans%=mod;

            if(i==b){
                b=ans;
            }
        }
        ans = (ans*b*i)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int n;
	cin >> n;
	while(1) {
		if (n % 111 == 0) break;
		n++;
	}
	cout << n << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);
  int n; cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  map<int, int> q;
  REP(i, n) q[a[i]] = i;
  int ma = 1;
  int tmp = 1;
  FOR(i, 1, n) {
    if(q[i+1] > q[i]) {
      tmp++;
    } else {
      ma = max(ma, tmp);
      tmp = 1;
    }
  }
  ma = max(ma, tmp);

  cout << n - ma << endl;
}


Measured memory_bytes: 14336
#include<stdio.h>
int main(){
    int n,a=0;
    scanf("%d",&n);
    int p[n];
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(int j=1;j<n-1;j++){
        if(((p[j-1]<p[j])&&(p[j]<p[j+1]))||((p[j-1]>p[j])&&(p[j]>p[j+1]))){
            a++;
        }
    }
    printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>

typedef long long ll;

using namespace std;
map<ll,bool> m;
int main()
{
	int n;
	cin >> n;
	int num = 0;
	for(int i = 1; i <= n; i++){
		ll k;
		cin >> k;
		if(m[k] == true){
			m[k] = false;
			num--;
		}else{
			m[k] = true;
			num++;
		}
	}
	cout << num <<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n,m,r=0;
    cin>>n>>m;
    vector<vector<int>> v(n+1);
    vector<int> deg(n+1,0),dis(n+1,0);
    for(int i=0;i<m;i++)
    {
        int s,t;
        cin>>s>>t;
        v[s].emplace_back(t);
        deg[t]++;
    }
    queue<int> q;
    for(int i=1;i<v.size();i++)
        if(!deg[i]) q.push(i);
    while(q.size())
    {
        for(auto e:v[q.front()])
        {
            dis[e]=max(dis[e],dis[q.front()]+1);
            r=max(r,dis[e]);
            deg[e]--;
            if(!deg[e]) q.push(e);
        }
        q.pop();
    }
    cout<<r<<'\n';
}


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

int main() {
  long long K,A,B,ans;
  cin >>A>>B>>K;
  if(A>=K){
  cout <<A-K<<" "<<B<< endl;
  }
  else if(A+B>=K){
    cout<<0<< " "<<B-K+A<<endl;
  }
  else{
    cout<<0<<" "<<0<<endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();

        int d = b - a;

        int small = (1 + (d - 1)) * (d - 1) / 2;
        int answer = small - a;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
import sys
input = lambda: sys.stdin.readline().rstrip()

S = input()

N = len(S)

def check_pai(s):
    reversed_s = s[::-1]
    return s == reversed_s

lS = S[:(N-1)//2]
rS = S[(N+1)//2:]

if check_pai(S) and check_pai(lS) and check_pai(rS):
    print("Yes")
else:
    print("No")

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

using namespace std;

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

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

ll N;
ll ans = 1;
ll mod = (ll)1e9+7;

void solve() {
    cin >> N;
    vector<pii> obj;
    rep(i,N) {
        int a;
        cin >> a;
        obj.push_back(pii(a, 0));
    }
    rep(i,N) {
        int a;
        cin >> a;
        obj.push_back(pii(a, 1));
    }
    sort(obj.begin(), obj.end());
    multiset<int> st1, st2;
    rep(i,2*N) {
        if (obj[i].second == 0) {
            if (st2.empty()) {
                st1.insert(obj[i].first);
            } else {
                ans *= st2.size();
                ans %= mod;
                st2.erase(st2.begin());
            }        
        } else {
            if (st1.empty()) {
                st2.insert(obj[i].first);
            } else {
                ans *= st1.size();
                ans %= mod;
                st1.erase(st1.begin());
            }     
        }
    }
    cout << ans << endl;
}

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


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

int g(int a,int b){
    if(a<b)
        swap(a,b);
        
    if(a%b==0)
        return b;
        
    return !b?a:g(b,a%b);
}

int gcd(int a,int b,int c){
    return g(g(a,b),g(b,c));
}

int main(){
    int k;
    scanf("%d",&k);
    long long s=0LL;
    for(int i=1;i<=k;++i){
        for(int j=1;j<=k;++j){
            for(int c=1;c<=k;++c){
                s+=gcd(i,j,c);
            }
        }
    }
    
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 3664
/* にぶたん二回 */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<P> array_;
    int tmp_j = 0, tmp_s = 0;
    int zenkai = 0;

    REP(i, n) {
        if(s[i] == '0') {
            /* 順立ち */
            if(zenkai == 0) {
                tmp_j++;
            } else {
                array_.push_back({tmp_j, tmp_s});
                tmp_j = 1;
                tmp_s = 0;
                zenkai = 0;
            }
        } else {
            /* 逆立ち */
            if(zenkai == 1) {
                tmp_s++;
            } else {
                zenkai = 1;
                tmp_s++;
            }
        }
    }
    array_.push_back({tmp_j, tmp_s});

    REP(i, array_.size()) {
        //cout << array_[i].first << " " << array_[i].second << endl;
    }

    if(array_[0].first == 0) {
        if(k >= array_.size() - 1) {
            cout << n << endl;
            return 0;
        }
    } else {
        if(k >= array_.size()) {
            cout << n << endl;
            return 0;
        }
    }

    /* 累積和 */
    vector<ll> ruiseki(array_.size()+1);
    ruiseki[0] = 0;
    REPN(i, 1, array_.size()+1) {
        ruiseki[i] = ruiseki[i-1] + array_[i-1].first + array_[i-1].second;
    }

    ll ans = 0;

    REP(i, array_.size() - k + 1) {    
        ll tmp = ruiseki[i+k] - ruiseki[i];
        if(i != 0) {
            tmp += array_[i-1].second;
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;
int N, A, B, C, D;

const int MAX_ARG=1100;
// 組み合わせを求める公式
ll dp_comb[MAX_ARG][MAX_ARG];
ll comb(int a,int b){
  if(a<0||b<0)return 0;
  if(a<b)return 0;
  else if(b==0)return 1;
  else if(dp_comb[a][b]>=0)return dp_comb[a][b];
  return dp_comb[a][b]=(comb(a-1,b)+comb(a-1,b-1))%mod;
}

// O(logn)で繰り返し二乗法によりnum^p%modを計算
ll mod_pow(ll num,ll p,ll mod){
  ll mul=num;
  ll res=1;
  while(p){
    if(p%2)res=(res*mul)%mod;
    p/=2;
    mul=(mul*mul)%mod;
  }
  return res;
}
// fermerの小定理を用いてmodの割算を計算
ll div_mod(ll num,ll mod){
  return mod_pow(num,mod-2,mod);
}


ll dp[1010][1010];
ll rec(int n, int size){
    if(dp[n][size] >= 0) return dp[n][size];
    ll res = 0;
    if(size > B){
        res = (n == 0);
    }
    else{
        (res += rec(n, size + 1)) %= mod;
        ll c = 1;
        ll p = 1;
        for(int i = 1; i <= D && n - i * size >= 0; i++){
            (p *= i) %= mod;
            (c *= comb(n - (i - 1) * size, size)) %= mod;
            if(i >= C){
                ll pinv = div_mod(p, mod);
                ll tmp = (pinv * c) % mod;
                (res += tmp * rec(n - i * size, size + 1)) %= mod;
            }
        }
    }
    return dp[n][size] = res;
}

int main(){

    fastStream();
    cin >> N >> A >> B >> C >> D;
    memset(dp_comb, -1, sizeof(dp_comb));
    memset(dp, -1, sizeof(dp));
    cout << rec(N, A) << endl;

    return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    ll k = 0, dif1 = 0, dif2 = 0;
    for (int i = 0; i < n; i++) {
        k += b[i] - a[i];
        if (a[i] < b[i]) {
            dif1 += (b[i] - a[i] + 1) / 2;
        } else {
            dif2 += a[i] - b[i];
        }
    }
    if (max(dif1, dif2) <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int x;
int gcd(int a,int b) {
	if (a%b==0) return b;
	return gcd(b,a%b);
}
int main(){
	scanf("%d",&x);
	printf("%d",360/gcd(360,x));
	return 0;
}

Measured memory_bytes: 3824
N=int(input())
A=list(map(int,input().split()))

d=[0]*(N+1)

f=1
H=2**N

for i in range(N+1):
    if i==0:
        d[i]=1
    else:
        d[i]=(d[i-1]-A[i-1])*2
        
    if A[i]>d[i]:
        f=0

J=[0]*(N+1)
J[N]=A[N]

if f==0:
    print(-1)
else:
    for i in range(N-1,-1,-1):
        if d[i]>=J[i+1]+A[i]:
            J[i]=J[i+1]+A[i]
        else:
            J[i]=d[i]

    print(sum(J))


Measured memory_bytes: 701736
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


int main(void){
    string S;
    cin>>S;
    
    for(int i=0;i<S.size();i++){
        if((i%2==1 && S.at(i)=='R') || (i%2==0 && S.at(i)=='L')){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()
    val xs = readLine()!!.split(' ').map { it.toInt() }

    var cnt = 0
    var min = xs.first()
    var max = xs.first()
    var profit = 0

    for (a in xs.slice(1..xs.lastIndex).plus(-1)) {
        if (a < min) {
            val p = max - min

            if (p == profit) {
                cnt++
            } else if (p > profit) {
                cnt = 1
                profit = p
            }

            min = a
            max = a
        }
        max = Math.max(max, a)
    }

    println(cnt)
}


Measured memory_bytes: 53932
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include<bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class CHalfAndHalf {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll a, b, c, x, y;
	    in >> a >> b >> c >> x >> y;

	    ll res = 0;
        ll res2 = 0;

        res += min(x, y)*c*2;
        if(x > y){
            res += min((x-y)*a, (x-y)*c*2);
        }else{
            res += min((y-x)*b, (y-x)*c*2);
        }
        res2 += x*a + y*b;

//        cout << res sp res2 << endl;
        out << min(res, res2) << endl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	CHalfAndHalf solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N, M = [int(v) for v in input().split()]
A = [0] + [int(v) for v in input().split()]
for i in range(1, N + 1):
    A[i] = (A[i] + A[i - 1]) % M

from collections import Counter
import math


def combinations_count(n, r):
    if n <= 1:
        return 1
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


counter = Counter()
for a in A:
    counter[a] += 1

ans = 0
for c in counter.values():
    if c <= 1: continue
    ans += combinations_count(c, 2)
print(ans)

Measured memory_bytes: 14252
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

struct edge{lint from,to,cost;};
edge es[200000]; // MAX_E
lint d[200000]; // MAX_V
int V,E;
int roop=0;
lint save;
bool check=true;

void bellmanford(int S){
  fill(d,d+V,LINF);
  d[S]=0;
  while(true){
    bool update=false;
    rep(i,E){
      edge e=es[i];
      if(d[e.from]!=LINF && d[e.to]>d[e.from]+e.cost){
        d[e.to]=d[e.from]+e.cost;
        if(roop==V) d[e.to]=-LINF;
        update=true;
      }
    }
    if(!update) break;
    roop++;
    if(roop==2*V){
      if(d[V-1]>=-LINF/2) break;
      else{
        check=false;
        break;
      }
    }
  }
}

int main(void){
  int P;
  cin >> V >> E >> P;
  rep(i,E){
    edge in;
    cin >> in.from >> in.to >> in.cost;
    in.cost-=P;
    in.cost*=-1;
    in.from--,in.to--;
    es[i]=in;
  }
  bellmanford(0);
  if(check) cout << max(0LL,d[V-1]*-1) << endl;
  else cout << -1 << endl;
}

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

int main() {
  long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long ans=0;
  
  ans=max(a*c,max(a*d,max(b*d,b*c)));
  cout<<ans<<endl;
  
  return 0;
  

}


Measured memory_bytes: 3616
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################


n,k = list(map(int, input().split()))

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

for ii in range(n*10):
    i = ii+1
    ar = ValueToArray10(i, int(1+(math.log(i)+0.00001)/math.log(10)))
    ok=1
    for j in ar:
        for k in a:
            if(j==k):
                ok=0
    if(ok==1 and i>=n):
        print(i)
        exit()


















































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

using namespace std;

typedef long long ll;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int ans=0;
	REP(i, 3){
		if(s[i]=='o') ++ans;
	}
	cout<<700+ans*100<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,k,sum,i;
	scanf("%d %d",&n,&k);
	sum=k;
	for(i=1;i<n;i++)	{
		sum=sum*(k-1);
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int H, W, K;
	cin >> H >> W >> K;
	K--;
	int dp[101][8] = { 0 };
	dp[0][0] = 1;
	REP(i, H) {
		REP(j, (1 << (W - 1))) {
			bool F = true;
			REP(k, W - 2) {
				if ((j >> k) % 4 == 3) F = false;
			}
			if (!F)continue;
			
			VI P(W);
			REP(a, W)P[a] = a;

			REP(a, W - 1) {
				if ((j >> a) & 1)swap(P[a], P[a + 1]);
			}
			REP(a, W) {
				dp[i + 1][P[a]] += dp[i][a];
				dp[i + 1][P[a]] %= mod;
			}
		}
	}

	cout << dp[H][K] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <numeric>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e16;

/*
<url:>
問題文============================================================

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

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

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    string s,p;cin >> s >> p;
    int len = s.length();
    s += s;
    for(int i = 0; i < len;i++){
        if(s.substr(i,p.length()) == p){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3236
#include<iostream>
using namespace std;
#define ll long long
int main()
{
	ll n,y;
	cin>>n>>y;
	ll i,j,k;
	y/=1000;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n-i;j++)
		{
			for(k=0;k<=n-i-j;k++)
			{
				if(i*10+j*5+k==y&&i+j+k==n)
				{
					cout<<i<<" "<<j<<" "<<k<<endl;
					return 0;
				}
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	return 0;
} 

Measured memory_bytes: 384