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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
/*GRAPH_TEMPLATE=============================================*/
template<typename T>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T cost; //辺の重み
    Edge(int t, T w) : srch(-1), to(t), cost(w) {}
    Edge(int t, T w, int src) : srch(src), to(t), cost(w) {}
};
template<typename T>
using W_Graph = vector<vector<Edge<T>>>;   //重み付きグラフ
using Graph = vector<vector<int>>;         //通常グラフ
template<typename T>
using Matrix = vector<vector<T>>;          //隣接行列(使わなさそう...)

/*FUNCs=================================================*/
int n;
Graph g;
vector<PII> order;
map<PII,int> colors;

void dfs(int now, int prev, int pre_color) {
    int color = 1;
    for(auto next : g[now]) {
        if(next==prev) continue;
        if(color == pre_color) ++color;
        colors[make_pair(now, next)] = color;
        colors[make_pair(next, now)] = color;
        dfs(next, now, color);
        ++color;
    }
    return;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    cin >> n;
    g.resize(n); //グローバルにグラフを置いたらresize!
    rep1(i,n-1) {
        int a, b; cin >> a >> b;
        --a; --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        order.emplace_back(a,b);
        colors[make_pair(a,b)] = 0;
        colors[make_pair(b,a)] = 0;
    }
    int maxdiv = -1;
    int start_node = -1;
    rep(i,n) {
        int div = g[i].size();
        if(chmax(maxdiv, div)) start_node = i;
    }
    cout << maxdiv << '\n';

    dfs(start_node, -1, -1);

    for(auto p : order) {
        cout << colors[p] << '\n';
    }
}

Measured memory_bytes: 19448
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
const ll INF=0xffffffffffffff;
ll N,M,Q;
ll D[100000];
ll d[100000];
ll U[200000],V[200000];
ll R[200000];
bool ansin[100000];
ll anum[200000];
vector<ll> G[100000];
vector<ll> G2[100000];
priority_queue<ll,vector<ll> ,greater<ll > >  q;



bool mov[200000];
int main()
{
	cin>>N>>M>>Q;
	rep(i,M){
		cin>>U[i]>>V[i];
		U[i]--;
		V[i]--;
		G[V[i]].pb(U[i]);
		G[U[i]].pb(V[i]);
	}
	rep(i,Q){
		cin>>R[i];
		R[i]--;
		mov[R[i]]=1;
	}
	fill(D,D+N,INF);
	D[0]=0;
	
	q.push(0);
	while(!q.empty()){
		ll x=q.top();
		q.pop();
		rep(i,G[x].size()){
			if(D[G[x][i]]>D[x]+1){
				D[G[x][i]]=D[x]+1;
				q.push(G[x][i]);
			}
		}
	}
	ll cnt=1;
	fill(d,d+N,INF);
	d[0]=0;
	ansin[0]=1;
	rep(i,M){
		if(!mov[i]){
			G2[U[i]].pb(V[i]);
			G2[V[i]].pb(U[i]);
		}
	}
	q.push(0);
	while(!q.empty()){
		ll x=q.top();
		q.pop();
		rep(i,G2[x].size()){
			if(d[G2[x][i]]>d[x]+1){
				d[G2[x][i]]=d[x]+1;
				if(d[G2[x][i]]==D[G2[x][i]]&&!ansin[G2[x][i]]){
					ansin[G2[x][i]]=1;
					cnt++;
				}
				q.push(G2[x][i]);
			}
		}
	}
	anum[Q-1]=cnt;
	rrep1(i,Q-1){
		ll a=U[R[i]];
		ll b=V[R[i]];
		G2[a].pb(b);
		G2[b].pb(a);
		if(d[a]+1<d[b]){
			d[b]=d[a]+1;
			if(d[b]==D[b]&&!ansin[b]){
					ansin[b]=1;
					cnt++;
			}
			q.push(b);
		}
		else if(d[b]+1<d[a]){
			d[a]=d[b]+1;
			if(d[a]==D[a]&&!ansin[a]){
					ansin[a]=1;
					cnt++;
			}
			q.push(a);
		}
		while(!q.empty()){
			ll x=q.top();
			q.pop();
			rep(i,G2[x].size()){
			if(d[G2[x][i]]>d[x]+1){
					d[G2[x][i]]=d[x]+1;
					if(d[G2[x][i]]==D[G2[x][i]]&&!ansin[G2[x][i]]){
						ansin[G2[x][i]]=1;
						cnt++;
					}
					q.push(G2[x][i]);
				}
			}
		}
		anum[i-1]=cnt;
	}
	rep(i,Q) cout<<N-anum[i]<<endl;
}

Measured memory_bytes: 30248
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int N;
  cin >> N;
  int x[110],y[110], h[110];
  rep(i, N) cin >> x[i] >> y[i] >> h[i];
  
  int high;
  int ok;
  int start = 0;
  
  while(h[start]==0){
    start++;
  }
  
  swap(x[0], x[start]);
  swap(y[0], y[start]);
  swap(h[0], h[start]);
  
  rep(i, 101){
    rep(j, 101){
      ok = 1;
      high = abs(x[0]-i)+abs(y[0]-j)+h[0];
      FOR(k, 1, N) if(h[k]!=max(high-abs(x[k]-i)-abs(y[k]-j), 0)) ok = 0;
      if(ok==1){
        cout << i << " " << j << " " << high << endl;
        return 0;
      }
    }
  }
    
}

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

int main() {
 string a;
 cin >> a;
 char q,w,e,r;
 q = a.at(0);
 w = a.at(1);
 e = a.at(2);
 r = a.at(3);
 if(q == w || w == e || e == r){
   cout << "Bad" <<endl;
 }
 else{
   cout << "Good" <<endl;
 }
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        // 宣言
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> octBalls = new ArrayList<>();
        
        // 入力値取得
        int n = sc.nextInt();
        
        for(int i=0;i<n;i++){
            octBalls.add(sc.nextInt());
        }
        
        int total = 0;
        int pattern = (n * (n-1)) / 2; 
        // 
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(!(k <= j)){
                    total = total + (octBalls.get(j) * octBalls.get(k));                    
                }
                continue;
            }
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 22612
#include<cstdio>
#include<cstdlib>
#include<cstring>
struct Node{
  int key;
  Node *next,*prev;
};
Node *nil;
Node* listSearch(int key){
  Node *cur=nil->next;
  while(cur != nil && cur->key !=key){
    cur=cur->next;
  }
  return cur;
}
void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}
void printList(){
  Node *cur=nil->next;
  int isf = 0;
  while(1){
    if(cur==nil)break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}
void deleteNode(Node *t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
void deleteFirst(){
  deleteNode(nil->next);
}
void deleteLast(){
  deleteNode(nil->prev);
}
void deleteKey(int key){
  deleteNode(listSearch(key));
}
void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){ insert(key); np++; size++; }
    else if(com[0]=='d'){
      if(strlen(com)>6){
	if(com[6]=='F') deleteFirst();
	else if(com[6]=='L') deleteLast();
      }else{
	deleteKey(key);nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 33968
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*16
int xi[nn];int n,v;
vector<int> all;
int tol[nn][20],tor[nn][20];
int dpr[nn],dpl[nn],pre[nn];
void _min(int&x,int y){
	x=min(x,y);
}
void _max(int&x,int y){
	x=max(x,y);
}
void build(){
	int u=v/2;while(u) all.push_back(u),u=u/2;all.push_back(0);
	for(int i=0;i<all.size();i++){
		tol[0][i]=tol[1][i]=1;for(int j=2;j<=n;j++)
			if(all[i]>=xi[j]-xi[j-1]) tol[j][i]=tol[j-1][i];
			else tol[j][i]=j;
			
		tor[n+1][i]=tor[n][i]=n;for(int j=n-1;j>=1;j--)
			if(all[i]>=xi[j+1]-xi[j]) tor[j][i]=tor[j+1][i];
			else tor[j][i]=j;
	}

	memset(pre,0x3f,sizeof pre);memset(dpl,0x3f,sizeof dpl);
	dpl[0]=n+1,dpr[0]=0;
	for(int i=0;i<(1<<all.size());i++){
		for(int j=0;j<all.size();j++) if((1<<j)&i);else{
			_min(dpl[i|(1<<j)],tol[dpl[i]-1][j]);
			_max(dpr[i|(1<<j)],tor[dpr[i]+1][j]);
		}
	}
	
	for(int i=0;i<(1<<all.size());i++)
		_min(pre[dpr[i]],dpl[((1<<all.size())-1)^i]);
	for(int i=n-1;i>=0;i--) _min(pre[i],pre[i+1]);
}

int lb[nn],rb[nn];int pa[nn];
int find(int x){
	if(pa[x]==x) return x;
	return pa[x]=find(pa[x]);
}
void link(int x,int y){
	x=find(x),y=find(y);
	pa[x]=y;_min(lb[y],lb[x]);
	_max(rb[y],rb[x]);
}
signed main(){
	scanf("%d%d",&n,&v);for(int i=1;i<=n;i++) scanf("%d",&xi[i]);sort(xi+1,xi+n+1);
	build();
	
	for(int i=1;i<=n;i++) pa[i]=i,lb[i]=rb[i]=i;
	for(int i=1;i<n;i++) if(xi[i+1]-xi[i]<=v) link(i,i+1);
	
	for(int i=1;i<=n;i++){
		int l=lb[find(i)],r=rb[find(i)];
		if(pre[l-1]<=r+1) puts("Possible");
		else puts("Impossible");
	}
	
	return 0;
}

Measured memory_bytes: 55168
import java.io.*;
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner stdIn = null;
		stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int[] data = new int[100000];
		int i = 0;
		
		while( stdIn.hasNext() ){
			if( stdIn.hasNextInt() ){
				data[i] = stdIn.nextInt();
			} else {
				stdIn.next();
			}
			i++;
		}
		
	
//		for(int j = 0; j < i; j++){
		int count = 2;
/*			if( data[j] >= 2 )
				count++;
			if( data[j] >= 3 )
				count++;*/

		int[] p = new int[999999];
		p[0] = 2;
		p[1] = 3;
		for(int l = 5; l < 1000000; l += 2){
			for(int k =1; k < count; k++){
				if( l % p[k] == 0 ){
					break;
				}
				else if ( p[k] > Math.sqrt(l) ){
					p[count] = l;
					count++;
					break;
				}
			}
		}
	
		for(int j = 0; j < i; j++){
		       	for(int k = 0; k < count; k++){
				if( data[j] < p[k] ){
					System.out.println(k);
					break;
				}else if( k == count-1 ){
					System.out.println(count);
				}
			}
						
		}
	}
}

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

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

  ll i;
  for(i=sqrt(n); i>0; i--){
    if(n%i == 0){
      break;
    }
  }

  cout << i + n/i - 2 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int n,m;
    cin>>n>>m;
    vector<P> schedule;

    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        b--;
        P v=P(b,a);
        schedule.push_back(v);
    }
    //schedule (ato,mae)
    sort(schedule.begin(),schedule.end());

    int count=0;
    int t=-1;

    rep(i,m){
        if(schedule[i].second>t){
            count++;
            t=schedule[i].first;
        }
    }

    cout<<count<<endl;

}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    
    for (int i = 0; i < S.length(); i++){
        int cheker = i + 1;
        if (cheker % 2 != 0){
            cout << S[i];
        }
    }
    
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
long long inf=1e+9+7;
int main(){
    int n;cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<long long> a0(62,0);
    vector<long long> a1(62,0);
    for(int i=0;i<n;i++){
        for(long long bit=0;bit<62;++bit){
            if(a[i]&(1ull<<bit)){
                a1[bit]++;
            }
            else a0[bit]++;
//            if(i==0)cout<<bit<<endl;
        }
    }
    long long sum=0;
    for(int i=0;i<62;i++){
        long long bit=0;
        bit|=(1ull<<i);
        bit%=inf;
        long long buf=a1[i]*a0[i];
        buf%=inf;
        sum+=buf*bit;
        sum%=inf;

//        cout<<i<<" "<<a0[i]<<" "<<a1[i]<<" "<<sum<<" "<<bit<<endl;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2560
MOD = 10**9 + 7
N = 10**6  # 10**6が限界
factorial_mod = [1, 1]  # factrial_mod[i] := i! mod p
modular_multiplicative_inverse = [0, 1]  # モジュラ逆数 := i^(-1) ≡ x (mod p) となるx
factorial_inverse_mod = [1, 1]  # factrial_inverse_mod[i] := (i!)^(-1) mod p
 
for i in range(2, N + 1):  # O(N)
    factorial_mod.append((factorial_mod[i - 1] * i) % MOD)
    modular_multiplicative_inverse.append((-modular_multiplicative_inverse[MOD % i] * (MOD // i)) % MOD)
    factorial_inverse_mod.append((factorial_inverse_mod[i-1] * modular_multiplicative_inverse[i]) % MOD)
 
def nCr_mod(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return factorial_mod[n] * factorial_inverse_mod[r] * factorial_inverse_mod[n - r] % MOD

# ---------------------- #
 
n, k = (int(x) for x in input().split())
ans = 0
for i in range(min(n - 1, k) + 1):
    # nCi * n-iHi = nCi * n-1Ci
    ans += nCr_mod(n, i) * nCr_mod(n - 1, i)
    ans %= MOD
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& x : A) cin >> x;
  sort(A.begin(), A.end());
  A.push_back(-1);  // sentinel value.
  int prev = A[0], n_contiguous = 1, n_nums = 0;
  for (int i = 1; i < A.size(); ++i) {
    int now = A[i];
    if (now != prev) {
      if (n_contiguous % 2 == 1) {
        ++n_nums;
      }
      n_contiguous = 1;
    } else {
      ++n_contiguous;
    }
    prev = now;
  }
  cout << n_nums << endl;
}


Measured memory_bytes: 1024
from operator import add
n,m,x = map(int, input().split())
#n: 参考書の数, m: 学びたいアルゴリズムの数, x: 達成したい理解度
C = []
A = []
for _ in range(n):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

ans = 10**10
flg = False
for bit in range(2**n):
    tmp = 0
    tmp_list=[0]*m
    for j in range(n):
        if (bit >> j) & 1:
            tmp += C[j]
            tmp_list = map(add, tmp_list, A[j])
    if min(tmp_list) >= x: #目標を達成
        ans = min(ans, tmp)
        flg = True

if flg:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 9304
# dp[n][w]とすると，O(nw)でwが大きすぎて大変
# dp[n][v]として，価値vを達成するための最小のwを記録するO(N^2 V_{max})
# さらにdp[v]としてw, vを使うかどうかで更新する
import sys
input = sys.stdin.readline
import numpy as np

n, W = map(int, input().split())
dp = np.full(10**5 + 1, 10**12, dtype='int64')
dp[0] = 0 
for _ in range(n):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

#print(np.max(np.where(dp <= W)))
print(np.where(dp <= W)[0][-1])

Measured memory_bytes: 15136
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
char s[100010];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),c0=0,c1=0;
	for(int i=1;i<=n;i++)
	if(s[i]=='0')c0++;else c1++;
	printf("%d",min(c0,c1)<<1);
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int n,m,a,b;
    long long c=1,d=1,p=1000000007;
    cin>>n>>m;
    a=n;
    b=m;
    if(n==m){
        c=2;
    }else if(n<m){
        a=m;
        b=n;
    }
    if(a-b>1){
        d=0;
    }else{
        for(int i=2;i<=b;i++){
            d=(d*i)%p;
            d=(d*i)%p;
        }
        if(c==1){
            d=(d*a)%p;
        }else{
            d=(d*2)%p;
        }
    }
    cout<<d<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
  long long n;
  cin >> n;
  long long a[n+10],i,prod=1,zero=0;
  for(i=1;i<=n;i++){
    cin >> a[i];
    if(a[i]==0)zero++;
  }
  if(zero>0){
    cout << "0" << endl;
    return 0;
  }
  for(i=1;i<=n;i++){
    if(a[i] <= 1000000000000000000/prod){
      prod *= a[i];
    }else{
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << prod << endl;
}


Measured memory_bytes: 4396
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}



int main() {
    char str[222];
        scanf("%s", str);
        int n = strlen(str);
        for (int i = n - 2; i; i -= 2) {
            if (strncmp(str, str + i / 2, i / 2) == 0) {
                printf("%d\n", i);
                return 0;
            }
        }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  int smallest = 1100000000;
  bool can = true;
  for (int i = N-1; i >= 0; i--) {
    if (H[i] < smallest) smallest = H[i];
    else {
      if (H[i] > smallest+1) {
        can = false;
        break;
      }
    }
  }
  if (can) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 640
N = int(input())
t=[0]
x = [0]
y = [0]
for i in range(N):
    a,b,c = [int(j) for j in input().split()]
    t.append(a)
    x.append(b)
    y.append(c)

sum = 0
for i in range(N):
    time = t[i+1]  - t[i]
    dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if time < dist:
        print("No")
        break
    else:
        if dist%2 == time%2:
            sum += 1
            continue
        else:
            print("No")
            break

if sum == N:
    print("Yes")

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

using ll = long long;

constexpr ll mod = 1e9 + 7;

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

    ll ans = 1, remain = 0;
    for(int i = 0; i < 2 * n; ++i) {
        if(i & 1) {
            if(s[i] == 'W') { // must right
                remain += 1;
            } else {
                if(remain == 0) ans = 0;
                (ans *= remain) %= mod;
                remain--;
            }
        } else {
            if(s[i] == 'W') { // must left
                if(remain == 0) ans = 0;
                (ans *= remain) %= mod;
                remain--;
            } else {
                remain += 1;
            }
        }
    }

    if(remain != 0) ans = 0;
    for(int i = 1; i <= n; ++i) {
        (ans *= i) %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> s(h); for (auto&& e : s) cin >> e;
  reverse(begin(s), end(s));
  struct Event {
    int id, x, y; bool in;
    bool operator<(const Event& r) const {
      return y * r.x != r.y * x ? y * r.x < r.y * x : in < r.in;
    }
  };
  V<Event> es;
  for (int x = 0; x < w; ++x) for (int y = 0; y < h; ++y) {
    es.emplace_back(Event{y * w + x, x + 1, y, true});
    es.emplace_back(Event{y * w + x, x, y + 1, false});
  }
  sort(begin(es), end(es));
  int res = 0, curr = 0;
  set< pair<int, char> > se;
  for (const auto& e : es) {
    if (e.in) {
      auto itr = se.emplace(e.id, s[e.id / w][e.id % w]).first;
      if (s[e.id / w][e.id % w] == '#') {
        if ((itr == begin(se) or prev(itr)->second == '.') and (next(itr) == end(se) or next(itr)->second == '.')) ++curr;
      } else {
        if (itr != begin(se) and prev(itr)->second == '#' and next(itr) != end(se) and next(itr)->second == '#') ++curr;
      }
    } else {
      auto itr = se.find({e.id, s[e.id / w][e.id % w]});
      if (s[e.id / w][e.id % w] == '#') {
        if ((itr == begin(se) or prev(itr)->second == '.') and (next(itr) == end(se) or next(itr)->second == '.')) --curr;
      } else {
        if (itr != begin(se) and prev(itr)->second == '#' and next(itr) != end(se) and next(itr)->second == '#') --curr;
      }
      se.erase({e.id, s[e.id / w][e.id % w]});
    }
    // for (auto itr = begin(se); itr != end(se); ++itr) {
    //   curr += itr->second == '#' and (next(itr) == end(se) or next(itr)->second == '.');
    // }
    res = max(res, curr + 1);
  }
  cout << res << '\n';
}


Measured memory_bytes: 19820
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int F[101][10];
long long P[101][10];
int main() {
    int N;
    long long ans=-(1<<30);
    cin >> N;

    for(int i=0; i<N; i++){
        for(int j=0; j<10; j++){
            cin >> F[i][j];
        }
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<11; j++){
            cin >> P[i][j];
        }
    }
    // 10個の各時間帯について営業を1, 休みを0で表すと
    // 0000000001(2進数) から 1111111111(2) で1023通りあるのでbは1から
    // 1を10bitシフトして10000000000(2)未満で表現する
    for(int b=1; b<(1<<10); b++){
        long long profits=0;
        for(int j=0; j<N; j++){
            // 店jといくつ同じ時間帯に営業しているか計上
            int sameopen=0;
            for(int k=0; k<10; k++){
                if(F[j][k] && (b>>k & 1))
                    sameopen++;
            }
            // 店jと同じ時間帯に営業している数にあたる利益を追加
            profits+=P[j][sameopen];
        }
        ans = max(profits,ans);
    }

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



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int ans = 0;

		Scanner scan = new Scanner(System.in);

		int n = Integer.parseInt(scan.next());

		for(int i = 0; i < n; i++){
			int count = 0;
			String s2 = scan.next();
			int youso = Integer.parseInt(s2);

			while (0 == (youso % 2)) {
				youso = youso / 2;
				count++;
			}

			if(i == 0){
				ans = count;
			}else{
				if(ans > count){
					ans = count;
				}
			}
		}

		System.out.println(ans);
	}

}


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

void solve(std::string S) {
    if (S.back() == 's') {
        cout << S + "es" << endl;
    } else {
        cout << S + "s" << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint fact[2005], fact_i[2005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 2005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 2005; i++){
		fact_i[i] = pow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_i[k], ret %= mod;
	ret *= fact_i[n-k], ret %= mod;
	return ret;
}

llint N;
llint A, B, C, D;
llint dp[1005][1005];

int main(void)
{
	cin >> N;
	cin >> A >> B >> C >> D;
	make_fact();
	
	dp[0][0] = 1;
	llint val;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= N; j++){
			if(dp[i][j] == 0) continue;
			for(int k = 0; j + (i+1)*k <= N; k++){
				if(k != 0 && (i+1 < A || i+1 > B)) break;
				if(k != 0 && (k < C || k > D)) continue;
				val = 1;
				for(int l = 0; l < k; l++){
					val *= comb(N-j-(i+1)*l, i+1);
					val %= mod;
				}
				val *= fact_i[k];
				val %= mod;
				dp[i+1][j+(i+1)*k] += (dp[i][j] * val) % mod;
				dp[i+1][j+(i+1)*k] %= mod;
			}
		}
	}
	
	cout << dp[N][N] << endl;
	return 0;
}

Measured memory_bytes: 8192
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Contest
{
    struct Edge
    {
        public int U, V;
        public int Dist;

        public Edge(int u, int v, int w)
        {
            U = u;
            V = v;
            Dist = w;
        }
    }
    class Program
    {

        public void Solve()
        {
            var sc = new Scanner();
            int N = sc.NextInt();
            int K = sc.NextInt();

            int b = 0;
            int c = 0;
            double ans = 0;
            for (int i = 1; i <= N; i++)
            {
                int cnt = 0;
                while (true)
                {
                    if ((i << cnt) < K) cnt++;
                    else break;
                }

                double p = Math.Pow(0.5, cnt) / N;
                //Console.WriteLine($"{i} {p}");
                ans += p;
            }
            Console.WriteLine(ans);
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
void judge(ll m,ll x)
{
	if(!m)return;
	if(n/m==x&&n%m==x)ans+=m;
}
int main()
{
	cin>>n;
	for(ll i=1;i*i<=n;i++)
	if(n%i==0)
	{
		judge(i-1,n/i);
		if(i*i<n)judge(n/i-1,i);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <iterator>
#include <string>
#include <assert.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = std::pair<int, int>;
using vpii = vector<pii>;
using trio = std::pair<int, pii>;
#define all(x) begin(x), end(x)

int main()
{
	cin.tie(0);
	cout.tie(0);
	std::ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vi h(n + 1);
	vi cost(n + 1, 1e9);
	for (int i = 1; i <= n; ++i) cin >> h[i];
	cost[n] = 0;
	cost[n - 1] = std::abs(h[n] - h[n - 1]);
	for (int i = n - 2; i > 0; --i)
	{
		for (int j = i + 1; j <= std::min(n, i + k); ++j)
		{
			cost[i] = std::min(cost[i], std::abs(h[j] - h[i]) + cost[j]);
		}
	}
	cout << cost[1] << endl;
	return 0;
}

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define int ll

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a = b; return true;} return false; }

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

ll extgcd(ll a, ll b, ll& x, ll& y)
{
    ll d = a;
    if(b != 0)
    {
        d = extgcd(b, a%b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d; 
}

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll M; cin >> M;
    ll sum = 0, dsum = 0;
    REP(i, M)
    {
        ll d, c; cin >> d >> c;
        sum += c;
        dsum += d*c;
    }
    cout << sum-1+(dsum-1)/9 << endl;
}
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] H = new int[N];
            for (int i = 0; i < N; i++) {
                H[i] = in.nextInt();
            }

            int[] cumsum = new int[N];
            for (int j = N - 1 - 1; j >= 0; j--) {
                if (H[j] >= H[j + 1]) {
                    cumsum[j] = 1 + cumsum[j + 1];
                } else {
                    cumsum[j] = 0;
                }
            }

            int max = 0;
            for (int j = 0; j < N; j++) {
                max = Math.max(max, cumsum[j]);
            }

            System.out.println(max);
        }
    }
}


Measured memory_bytes: 49396
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    float ma,mi,ins;
    scanf("%f",&ins);
    ma=mi=ins;
    while(~scanf("%f",&ins)){
        ma=max(ma,ins);
        mi=min(mi,ins);
    }
    printf("%f\n",ma-mi);
}

Measured memory_bytes: 0
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n,m;
  cin>>n>>m;
  
  set<tuple<int,int,int>> s;
  int a,b;
  rep(i,m){
    cin>>a>>b;
    s.insert({a,b,i});
  }
  
  vector<int> A(m),B(m);
  int tmp=-1,cnt=0;
  for(auto x:s){
    if(tmp!=get<0>(x)){
      tmp=get<0>(x);
      cnt=1;
    }
    else cnt++;
    A[get<2>(x)]=get<0>(x);
    B[get<2>(x)]=cnt;
  }
  
  rep(i,m){
    cout<<setfill('0')<<right<<setw(6)<<A[i];
    cout<<setfill('0')<<right<<setw(6)<<B[i]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end()
#define int long long
#define double long double
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
int n;
int a[20];
int x[20][20];
int y[20][20];

int counter(int x){
	if(x==0) return 0;
	return counter(x>>1)+(x&1);
}
void solve(){
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    for(int j=1;j<=a[i];j++){
      cin>>x[i][j]>>y[i][j];
    }
  }
  int ans=0;
  for(int bit=1;bit<(1<<n);bit++){
    bool ok=true;
    for(int i=1;i<=n;i++){
      if(!(bit>>(i-1)&1)) continue;
      for(int j=1;j<=a[i];j++){
        if((bit>>(x[i][j]-1)&1)^y[i][j]) ok=false;
      }
    }
    if(ok) ans=max(ans,counter(bit));
  }
  cout<<ans<<endl;
}
main(){
	solve();
	return 0;
}


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

int main() {
	vector<vector<int>> bingo(3, vector<int>(3));
	bool check[3][3];

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			int a;
			cin >> a;
			bingo.at(i).at(j) = a;
		}
	}
	int n;
	cin >> n;
	vector<int> num(n);
	for(int i = 0; i < n; i++){
		int b;
		cin >> b;
		num[i] = b;
	}

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			check[i][j] = false;
			for(int k = 0; k < n; k++){
				if(bingo[i][j]==num[k]){
					check[i][j]=true;
				}
			}
		}
	}

	string ans = "No";
	for(int i = 0; i < 3; i++){
		if(check[i][0]&&check[i][1]&&check[i][2]){
			ans = "Yes";
		} else if(check[0][i]&&check[1][i]&&check[2][i]){
			ans = "Yes";
		}
	}

	if(check[0][0] && check[1][1] && check[2][2]){
		ans = "Yes";
	}
	if(check[0][2]&&check[1][1] &&check[2][0]){
		ans = "Yes";
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i).sort
B = gets.split.map(&:to_i).sort
C = gets.split.map(&:to_i).sort
def bsearch(a, ac, wa, &test)
  while (ac - wa).abs > 1
    wj = (ac + wa) / 2
    if test[a[wj]]
      ac = wj
    else
      wa = wj
    end
  end
  ac
end
sum = 0
B.each do |b|
  if A[0] < b and b < C[-1]
    i = bsearch(A, 0, N) { |a| a < b }
    k = bsearch(C, N-1, -1) { |c| b < c }
    sum += (i+1) * (N-k)
  end
end
p sum

Measured memory_bytes: 32252
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // Initialize
          	var strDate = cin.ReadLine;
          	var ansDate = "2018";
            // Process
			ansDate += strDate.Substring(4);
          	// Output
        	WriteLine(ansDate);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 26124
#include<iostream>
#include<algorithm>
using namespace std ;
int a[100001];
int check[100001] ;
int main() {
	string n ;
	cin >> n ;
	string k  ;
	for(int i = 0 ; i <	n.length() ;i++){
		if(n[i] >='0' && n[i] <='9'){
			k+=n[i];
		}
		else{
			if(k.size()> 0) 	k.erase(k.length()-1,1);
		}
	}
	cout << k ;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=1e9+9;
const ll inf2=1e16+9;
const ll mol=1e9+7;
const int maxn=5e3+9;
const ll maxx=1e12+9;

int n,k,ar[maxn],p[maxn];
int vis[maxn];
ll tmp[maxn+maxn],ans=-inf2;
ll ss[maxn+maxn];

ll calc_tmp(int len,int cnt)
{
    for(int i=1;i<=len;i++) tmp[i+len]=tmp[i];
    len*=2;
    for(int i=1;i<=len;i++) ss[i]=ss[i-1]+tmp[i];
    ll res=-inf2;
    for(int i=1;i<=len;i++)
        for(int j=i;j<=len&&j-i+1<=cnt;j++)
            res=max(res,ss[j]-ss[i-1]);
    return res;
}
void calc_cir(int s)
{
    int len=0;
    ll sum=0;
    while(!vis[s]) vis[s]=1,tmp[++len]=ar[s],sum+=ar[s],s=p[s];
    if(sum>=0)
    {
        ans=max(sum*(k/len)+calc_tmp(len,k%len),ans);
        if(k/len>=1) ans=max(sum*(k/len-1)+calc_tmp(len,len),ans);
    }
    ans=max(ans,calc_tmp(len,k));
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&p[i]);
    for(int i=1;i<=n;i++) scanf("%d",&ar[i]);
    for(int i=1;i<=n;i++)
        if(!vis[i]) calc_cir(i);
    printf("%lld\n",ans);
}


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

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

const int max_n = half_inf;
ll n, k, a[max_n];

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

void solve() {
    sort(a, a + n, greater<>());
    if (k > a[0]) {
        cout << "IMPOSSIBLE" << endl;
        return;
    }
    ll n_gcd = a[0];
    repone(i, n - 1) n_gcd = gcd(n_gcd, a[i]);
    if (k % n_gcd == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

int main() {
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 1024
#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 erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

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() {
  map<int, int> d;
  map<int, int> t;

  int n;
  cin >> n;
  rep(i, 0, n) {
    int D;
    cin >> D;
    if(!d.count(D)) d[D] = 0;
    d[D]++;
  }
  int m;
  cin >> m;
  rep(i, 0, m) {
    int T;
    cin >> T;
    if(!t.count(T)) t[T] = 0;
    t[T]++;
  }

  for(auto ite:t){
    if(!d.count(ite.first) || ite.second > d[ite.first]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}


Measured memory_bytes: 18944
#include <stdio.h>
#define DATANUM 60000

int maxarray(int va[], int std1);
int minarray(int vb[], int std2);

int main(void) {
    int num[DATANUM] = {0};
    int i, j, std;
    
    num[0] = 1;
    num[1] = 1;
    
    for(i = 2; i < DATANUM; i++) {
        if(i != 2 && i % 2 == 0) num[i] = 1;
        if(i != 3 && i % 3 == 0) num[i] = 1;
        if(i != 5 && i % 5 == 0) num[i] = 1;
        if(i != 7 && i % 7 == 0) num[i] = 1;
        for(j = 2; j < i; j++) {
            if(!(i % j)) {
                num[i] = 1;
                break;
            }
        }
    }
    
    while(~scanf("%d", &std)) {
        printf("%d %d\n", maxarray(num, std), minarray(num, std));
    }

    return(0);
    
}

int maxarray(int va[], int std1) {
    int max, i;
    
    max = 2;
    
    for(i = 2; i < std1; i++) {
        if(i > max && va[i] != 1) {
            max = i;
        }
    }
    
    return(max);
}

int minarray(int vb[], int std2) {
    int min, i, count = 0;
    
    for(i = std2 + 1; i < DATANUM; i++) {
        if(vb[i] != 1 && count == 0) {
            min = i;
            count++;
        }
    }
    
    return(min);
}

Measured memory_bytes: 836
A,B,C,D,E,F=map(int, input().split())
A*=100
B*=100

ans_t=0
ans_s=0
for a in range(0,F+1,A):
    for b in range(0,F-a+1,B):
        w=a+b
        if w==0: continue
        for c in range(0,F-w+1,C):
            for d in range(0,F-w-c+1,D):
                s=c+d
                t=w+s
                if w*E<s*100: break
                if ans_s*t<=s*ans_t:
                    ans_t=t
                    ans_s=s

print(ans_t,ans_s)


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

int main()
{
	string s;
	cin>>s;
	for (int i=0;i<=s.size()-1;i++)
	{
		if (s[i]=='1')  s[i]='9';
		else if (s[i]=='9')  s[i]='1';
	}
	cout<<s<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

struct union_find{
    vector<int> par;
    vector<int> chs;
    union_find(int N){
        par.resize(N);
        chs.resize(N);
        for(int i=0;i<N;i++) par[i] = i;
        for(int i=0;i<N;i++) chs[i] = 1;
    }
    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        chs[ry] += chs[rx];
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    int size(int x){
        return chs[root(x)];
    }
};

int N,M;
vector<pair<int,int>> v;
deque<ll> dq;

int main(){
    int a,b;
    cin >> N >> M;
    union_find t(N);
    for(int i=0;i<M;i++){
        cin >> a >> b;
        v.push_back(make_pair(a-1,b-1));
    }
    reverse(v.begin(),v.end());
    ll h = (ll)N * (ll)(N-1) / 2;
    dq.push_front(h);
    for(int i=0;i<M-1;i++){
        if(t.same(v[i].first,v[i].second)){
            dq.push_front(h);
            continue;
        }
        h -= (ll)(t.size(v[i].first)) * (ll)(t.size(v[i].second));
        dq.push_front(h);
        t.unite(v[i].first,v[i].second);
    }
    for(int i=0;i<M;i++){
        cout << dq[i] << endl;
    }
    return 0;
}

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

h, w = map(int, input().split())

area = []
for i in range(h):
    area.append(input())
#print(area)

for i in range(h):
    for j in range(w):
        if area[i][j] == "#":
            print("#", end="")
        else:
            count = 0
            for k in range(max(0, i-1), min(i+1, h-1)+1):
                for l in range(max(0, j-1), min(j+1, w-1)+1):
                    if area[k][l] == "#":
                        count += 1
            print(count, end = "")
    print()



Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)

int main(){
    string s;cin >> s;
    set<char> w;
    FOREACH(c,s){
        w.insert(c);
    }
    string str = "qwertyuiopasdfghjklzxcvbnm";
    sort(str.begin(),str.end());
    FOREACH(c,str){
        if(find(w.begin(),w.end(),c)==w.end()){
            cout<<c<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512