akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<ll,ll>a;
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		a[now]++;
		ans+=now;
	}
	ll q;
	cin>>q;
	for(ll i=0;i<q;i++){
		ll b,c;
		cin>>b>>c;
		ll now=a[b];
		ans-=now*b;
		a[b]=0;
		a[c]+=now;
		ans+=now*c;
		cout <<ans<<endl;
	}
	// your code goes here
	return 0;
}

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

int main(){
  int H,W;
  cin>>H>>W;

  vector<string> s(H);
  int i;
  for(i=0;i<H;i++)
  cin>>s.at(i);

  vector<int> dx={-1,0,1,0};
  vector<int> dy={0,1,0,-1};

  bool ans=true;
  int count=0;
  for(i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s.at(i).at(j)=='.'){
        count++;
        continue;
      }
      else{
        ans=false;
        for(int k=0;k<4;k++){
          int nx=i+dx.at(k);
          int ny=j+dy.at(k);

          if(nx<0||nx>H-1||ny<0||ny>W-1)
          continue;
          if(s.at(nx).at(ny)=='#')
          ans=true;
        }
      }
      if(ans==false)
      break;
    }
    if(ans==false)
    break;
  }


  if(ans==true||count==H*W)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int cnt[200005];
int main() {
    int n;
    cin>>n;
    for(int i=2;i<=n;i++)
    {
        int t;
        scanf("%d",&t);
        cnt[t]++;
    }
    for(int i=1;i<=n;i++) printf("%d\n",cnt[i]);
    return 0;
}


Measured memory_bytes: 4444
#include <bits/stdc++.h>
typedef long long ll;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define All(x) (x).begin(),(x).end()
using namespace std;

int main() {
  ll N,M;
  cin >> N >> M;
  vector<ll> x(M),sa;
  rep(i,M){
    cin >> x[i];
  }
  sort(All(x));
  if(M==1){
    cout << 0 << endl;
    return 0;
  }
  //すべての差を求めて,差の合計からN-1個
  for(ll i=0;i<=M-2;i++) {
    sa.push_back(x[i+1]-x[i]);
  }
  sort(All(sa));
  ll saMax=x[M-1]-x[0];
  for(ll i=0;i<N-1&&i<sa.size();i++) {
    saMax -= sa[sa.size()-1-i];
  }
  cout << saMax << endl;
}

Measured memory_bytes: 2168
#include<stdio.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int main(){
  int n;
  int i,j;
  int w[120];
  int ans;
  int tmp=10000000;
  int x,y;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
}

    for(i=1;i<n;i++){
      x=0;
      y=0;
      for(j=0;j<i;j++){
        x+=w[j];
      }
      for(j=i;j<n;j++){
        y+=w[j];
      }

      if(x>y){
        tmp=MIN(tmp,(x-y));
      }else if(x<y){
        tmp=MIN(tmp,(y-x));
      }else if(x==y){
        tmp=0;
      }
    }

    printf("%d",tmp);
  
  return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    // Your code here!
    int h,a,cnt=0;
    scanf("%d%d",&h,&a);
    while(3){
        if(h<=0)break;
        h-=a;
        cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    int n,t,a;
    cin >> n;
    cin >> t >> a;
    vector<int> h(n);
    int ans = -1;
    double diff = 10000;
    for(int i = 0;i < n;i++){
          cin >> h[i];
          double temp = abs(a - (t - h[i] * 0.006));
          if(temp < diff){
                diff = temp;
                ans = i + 1;
          }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
bool check(int x,int y)
{//这是一个搜索,最终就可以了
    if(x==1&&y==0||(x==0&&y==1))
        return false;//lose态
    bool flag=false;
    for(int i=2;i<=x;i+=2)
        if(!check(x-i,y+i/2))
            flag=true;
    for(int i=2;i<=y;i+=2)
        if(!check(x+i/2,y-i))
            flag=true;
    return flag;
}
void pattern()
{
    for(int i=1;i<=5;i++)
    {
        for(int j=1;j<=10;j++)
        {
            cout<<i<<' '<<j<<' ';
            if(check(i,j))
                cout<<"win"<<endl;
            else
                cout<<"lose"<<endl;
        }
    }
}
int main()
{
    ll x,y;
   // pattern();
    while(cin>>x>>y)
    {
        if(abs(x-y)>1)
            puts("Alice");
        else
            puts("Brown");
    }
    return 0;
}


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

int main() {
    int N, K, d;
    set<int> D;
    scanf("%d %d", &N, &K);
    for (int i = 0; i < K; i++) {
        scanf("%d", &d);
        D.insert(d);
    }
    int ans = N;
    while (1) {
        bool flg = true;
        int ans_ = ans;
        for (int i = 0; i < 5; i++) {
            int a = ans_ % 10;
            if (D.count(a)) flg = false;
            ans_ /= 10;
            if (ans_ == 0) break;
        }
        if (flg) break;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
from math import floor
C, S, F = [], [], []
for _ in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for start in range(N):
    ans = 0
    if start == N-1:
        print(ans)
        break
    for i in range(start, N-1):
        if ans <= S[i]:
            ans = S[i]
            ans += C[i]
        else:
            if ans % F[i] == 0:
                ans += C[i]
            else:
                ans += (F[i] - ans % F[i])
                ans += C[i]
            
    print(ans)

Measured memory_bytes: 74372
H, W = list(map(int, input().split()))
c, A = [], []

for i in range(10):
    c.append(list(map(int, input().split())))

for i in range(H):
    A.append(list(map(int, input().split())))

for k in range(10):
    for j in range(10):
        for i in range(10):
            c[j][i] = min(c[j][i], c[j][k] + c[k][i])

ans = 0
for aa in A:
    for a in aa:
        if a == -1:
            continue
        else:
            ans += c[a][1]

print(ans)

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main()
{
  int price = 700;
  for (int ii=0; ii<3; ++ii) {
    char c;
    cin >> c;
    if (c=='o')
      price +=100;
  }

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


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

public class Main {	

	private static void solve(){
		//Implement solution here.
		long N = nl();
		long K = nl();
		System.out.println(Math.min(N % K, Math.abs(N % K - K)));
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#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)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  map<int, int> mp;
  vector<int> roop;
  rep(i, n) cin >> a[i];
  mp[0]++;
  roop.push_back(0);
  int f = 0;
  while (1) {
    int size = mp.size();
    int next = a[f] - 1;
    // cout << "next" << next << endl;
    mp[next]++;
    if (size == mp.size()) {
      roop.push_back(next);
      break;
    }
    roop.push_back(next);
    f = next;
  }
  int back = roop.back();
  int shuki;
  rep(i, roop.size()) {
    if (roop[i] == back) {
      shuki = roop.size() - i - 1;
      break;
    }
  }
  // rep(i, roop.size()) cout << roop[i] << endl;
  // cout << "shuki" << shuki << endl;
  if (k > roop.size() - shuki) {
    k -= roop.size() - shuki;
    k %= shuki;
    cout << roop[roop.size() - shuki + k] + 1 << endl;
  } else {
    cout << roop[k] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 14688
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
/*
caba
abc
  
 */

public class Main {

	
	
    public static void main(String args[] ) throws Exception {
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
//        char[] s = sc.next().toCharArray();
//        char[] t = sc.next().toCharArray();
//        int n = s.length;
//        int m = t.length;
//        int max = 0;
//        for(int i=0;i<n-m+1;i++) {
//        	int c=0;
//        	int in=0;
//        	for(int j=i;j<m;j++) {
//        		if(s[j]==t[in]) {
//        			c++;
//        		}
//        		in++;
//        	}
//        	max = Math.max(max, c);
//        }
        double d = sc.nextDouble();
        double t = sc.nextDouble();
        double s = sc.nextDouble();
        
        if(d/s<=t) {
        	pw.print("Yes");
        } else {
        	pw.print("No");
        }
        
        
        //pw.print(t.length-max);
        pw.close();
    }
    
    
    
    
    
    
   
   static <T> void deb(T x){
       System.out.println(x);
   }
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

Measured memory_bytes: 33152
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))

#A_11,A_12,A_13=(int(x) for x in input().split())
#B_11,B_12,B_13=(int(x) for x in input().split())
#C_11,C_12,C_13=(int(x) for x in input().split())
N=int(input())
#A=list(map(int, input().split()))

l=[]
for i in range(N):
    a=int(input())
    l.append(a)

if A[0]in l and A[1] in l and A[2] in l:
    print('Yes')
elif B[0] in l and B[1] in l and B[2] in l:
    print('Yes')
elif C[0] in l and C[1] in l and C[2] in l:
    print('Yes')
elif A[0] in l and B[0] in l and C[0] in l:
    print('Yes')
elif A[1] in l and B[1] in l and C[1] in l:
    print('Yes')
elif A[2] in l and B[2] in l and C[2] in l:
    print('Yes')
elif A[0] in l and B[1] in l and C[2] in l:
    print('Yes')
elif A[2] in l and B[1] in l and C[0] in l:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
typedef long long int ll;
using namespace std;
const int MOD = 1000000007;


int main() {
	int N; cin >> N;
	vector<ll>data(N);
	ll ans = 0;
	for (int i = 0; i < N; i++)cin >> data[i];
	for (int i = 0; i < N-1; i++) {
		if (data[i + 1] - data[i] < 0) {
			ans += -data[i + 1] + data[i];
			data[i + 1] = data[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int R;
  cin >> R;
  cout << (2 * R * acos(-1)) << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll c[20];
ll a[20][20];

ll d[20];
void base2(ll x){
    ll i=0;
    while(x!=0){
        d[i]=x%2;
        x = x/2;
        i++;
    }
}


void solve(){

    ll n,m,x;
    cin >> n >> m >> x;
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }

    /*
    base2(30);
    rep(i,20){
        cout << d[i];
    }
    cout << endl;
    */

    ll ans = INF;
    ll rikai[20];
    rep(i,20){
        rikai[i]=0;
    }
    rep(i,(1 << n)){
        rep(i,20){
            rikai[i]=0;
        }
        ll tmp=0; //値段
        base2(i);
        /*
        rep(t,n){
            cout << d[t];
        }
        cout << endl;
        */
        //d[j]:j番目の本を買う
        rep(j,n){
            if(d[j]==1){
                tmp += c[j];
                rep(k,m){
                    rikai[k] += a[j][k];
                }
            }
        }
        bool b=true;
        rep(j,m){
            if(rikai[j]<x){
                b = false;
            }
        }
        if(b) ans = min(ans,tmp);
    }

    if(ans!=INF) cout << ans << endl;
    else cout << -1 << endl;




}

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


Measured memory_bytes: 3660
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
    int n;
    cin >> n;
    if(n==10 || n==100 || n==1000 || n==10000 || n==100000)cout << 10 << endl;
    else{
        int ans=0;
        ans+=n/100000;
        n%=100000;
        ans+=n/10000;
        n%=10000;
        ans+=n/1000;
        n%=1000;
        ans+=n/100;
        n%=100;
        ans+=n/10;
        n%=10;
        ans+=n;
        cout << ans << endl;
    }
}



    
   


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;

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

char m[405][405];
bool use[405][405];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

void init(int h, int w) {
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      use[i][j] = false;
    }
  }
}

int main() {
  int h,w;
  cin >> h >> w;
  
  for(int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < s.size(); j++) {
      m[i][j] = s[j];
    }
  }

  
  ll ans = 0;
  init(h,w);
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(m[i][j] == '.' || use[i][j]) continue;
      ll tmp = 0;
      ll c = 0;
      queue<P> p;
      p.push(P(i,j));
      use[i][j] = true;
      while(!p.empty()) {
	int x = p.front().first;
	int y = p.front().second;
	if(m[x][y] == '#') tmp++;
	p.pop();
	for(int k = 0; k < 4; k++) {
	  int nx = x + dx[k];
	  int ny = y + dy[k];
	  if(nx < 0 || ny < 0 || nx >= h || ny >= w || use[nx][ny]) continue;
	  if(m[x][y] == '#' && m[nx][ny] == '.') {
	    use[nx][ny] = true;
	    p.push(P(nx,ny));
	    c++;
	    continue;
	  }
	   if(m[x][y] == '.' && m[nx][ny] == '#') {
	     use[nx][ny] = true;
	    p.push(P(nx,ny));
	    continue;
	   }
	}
      }

      ans += tmp * c;
    }
  }
  
  
  cout << ans << endl;
}
	
	


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi acos(-1)
#define lli long long int
using namespace std;

int main()
{
    FIO
    int a[3];
    int i,sum = 0;
    for ( i = 0; i < 3; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    if (sum >= 22) cout << "bust" << endl;
    else cout << "win\n";
    
    return 0;
}
    

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()

	gg := 0 // 偶数+偶数
	kk := 0 // 奇数+奇数

	if n >= 2 {
		gg = n * (n - 1) / 2
	}
	if m >= 2 {
		kk = m * (m - 1) / 2
	}

	fmt.Println(gg + kk)

}

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


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

int main()
{

        int A, B;
        cin >> A >> B;

        int ans = A * B;

        for (int i = 0; i < 3; ++i) {

                int tmp = ans * (i+1);
                if (ans % 2) {
                        cout << "Yes" << endl;
                        exit(0);
                }

        }
        cout << "No" << endl;

}


Measured memory_bytes: 256
import numpy as np

n = int(input())
arr = np.array(list(map(int, input().split())))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)


Measured memory_bytes: 48820
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,k; cin>>n>>k;
    string s,sr,t; cin>>s;
    sr=s; reverse(al(sr));
    if(k==1){
        t=s+sr;
        string temp="{";
        rep(i,n+1){
            string cur=s;
            rep(j,n) cur[j]=t[i+j];
            if(temp>cur) temp=cur;
        }
        cout<<temp<<endl;
        return 0;
    }
    t=s+sr;
    string temp="{";
    rep(i,n+1){
        string cur=s;
        rep(j,n) cur[n-j-1]=t[i+j];
        if(temp>cur) temp=cur;
    }
    int d=0,c;
    rep(i,n){
        if(temp[i]==temp[0]) d++;
        else break;
    }
    c=d;
    rep(i,k-1){
        d*=2;
        if(d>n){
            rep(i,n) cout<<temp[0];
            cout<<endl;
            return 0;
        }
    }
    rep(i,d) cout<<temp[0];
    rep(i,n-d) cout<<temp[i+c];
    cout<<endl;
}


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

int main(){
	int n,num[100];
	long long int cnt[21] = {},tmp[21]= {};
	cin >> n;
	for(int i = 0;i < n;i++) cin >> num[i];
	cnt[num[0]] = 1;
	for(int i = 1;i < n - 1;i++){
		for(int j = 0;j < 21;j++){
			if(j - num[i] >= 0) tmp[j - num[i]] += cnt[j];
			if(j + num[i] <= 20) tmp[j + num[i]] += cnt[j];
		}
		for(int j = 0;j < 21;j++) {
			cnt[j] = tmp[j];
			tmp[j] = 0;
		}
	}
	cout << cnt[num[n - 1]] << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) {
	return s == string(s.rbegin(), s.rend());
}

int main() {
	string S,T; cin>>S>>T;
	int RS[26],RT[26];
	for(int i=0; i<26; i++) {
		RS[i]=RT[i]=-1;
	}

	for(int i=0; i<S.length(); i++) {
		int Sch=S.at(i)-'a', Tch=T.at(i)-'a';
		if(RS[Sch]<0)
			RS[Sch]=Tch;
		else if(RS[Sch]!=Tch) {
			cout<<"No"<<endl;
			return 0;
		}

		if(RT[Tch]<0)
			RT[Tch]=Sch;
		else if(RT[Tch]!=Sch) {
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;
}


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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  unordered_map<int, int> m;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    m[a]++;
  }
  vector<int> counts;
  counts.reserve(m.size());
  for (auto& it : m) {
    counts.emplace_back(it.second);
  }
  sort(counts.rbegin(), counts.rend());
  int ans = 0;
  for (size_t i = k; i < counts.size(); ++i) {
    ans += counts[i];
  }
  cout << ans << "\n";
}


Measured memory_bytes: 9288
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  char s[4];
  ll i;
  rep(i,4) cin>>s[i];
  ll a[4];
  rep(i,4){
    a[i]=s[i]-'A';
  }
  sort(a,a+4);
  if(a[0]==a[1] and a[0]!=a[2] and a[2]==a[3]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
        char c;

        while (1)
        {
                scanf("%c", &c);
                if (c >= 'A' && c <= 'Z')
                        printf("%c", c + 32);
                else if (c >= 'a' && c <= 'z')
                        printf("%c", c - 32);
                else if (c == '\n')
                        break;
                else
                        printf("%c", c);
        }
printf("\n");
        return 0;
}



Measured memory_bytes: 2056
#include<iostream>
using namespace std;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
    int b,c;
    cin>>b>>c;
    if(a[b-1]==a[c-1]) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pub push_back
#define ll long long
					  
using namespace std;



int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("seating.in", "r", stdin);
	//freopen("seating.out", "w", stdout);
	int n;
	cin >> n;
	if (n % 10 == (n / 100)) cout << "Yes"; else cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	static int paper[10][10];
	int x, y, size;
	int count_blank, max_ink;
	int i, j;
	char c;
	
	while (scanf("%d %c %d %c %d", &x, &c, &y, &c, &size) != EOF){
		if (size >= 1){
			paper[x][y]++;
			if (x + 1 < 10){
				paper[x + 1][y]++;
			}
			if (x - 1 >= 0){
				paper[x - 1][y]++;
			}
			if (y + 1 < 10){
				paper[x][y + 1]++;
			}
			if (y - 1 >= 0){
				paper[x][y - 1]++;
			}
		}
		if (size >= 2){
			if (x + 1 < 10 && y + 1 < 10){
				paper[x + 1][y + 1]++;
			}
			if (x + 1 < 10 && y - 1 >= 0){
				paper[x + 1][y - 1]++;
			}
			if (x - 1 >= 0 && y + 1 < 10){
				paper[x - 1][y + 1]++;
			}
			if (x - 1 >= 0 && y - 1 >= 0){
				paper[x - 1][y - 1]++;
			}
		}
		if (size == 3){
			if (x + 2 < 10){
				paper[x + 2][y]++;
			}
			if (x - 2 >= 0){
				paper[x - 2][y]++;
			}
			if (y + 2 < 10){
				paper[x][y + 2]++;
			}
			if (y - 2 >= 0){
				paper[x][y - 2]++;
			}
		}
	}
	max_ink = 1;
	count_blank = 0;
	for (i = 0; i < 10; i++){
		for (j = 0; j < 10; j++){
			if (max_ink < paper[i][j]){
				max_ink = paper[i][j];
			}
			if (paper[i][j] == 0){
				count_blank++;
			}
		}
	}
	
	printf("%d\n%d\n", count_blank, max_ink);
	return 0;
}

Measured memory_bytes: 600
N=int(input())
S=input()

w=[0]*(N+1)
e=[0]*(N+1)
for i,s in enumerate(S):
    w[i+1]+=w[i]
    if s=="W": w[i+1]+=1
    e[i+1]+=e[i]
    if s=="E": e[i+1]+=1
ans=N
for i in range(N):
    now = w[i]+(e[N]-e[i+1])
    if now<ans: ans=now
print(ans)

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

int main(){
  char s;
  cin >> s;
  if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;
void Anon_mouS(){
    string s,t;
    cin>>s>>t;
    int n,m;
    cin>>n>>m;
    string u;
    cin>>u;
    // cin>>u;
    if(u==s)n--;
    else m--;
    cout<<n<<" "<<m<<endl;

}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main(void){
    std::string s;
    int k;
    std::cin >> k;
    std::cin >> s;
    std::cout << s.substr(0, k) << ((s.size() > k)? "..." : "") << std::endl;

    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> L(N),R(N);
    rep(i,N) cin >> L[i] >> R[i];

    auto dist=[&](int &cur, int id) {
        if (L[id] <= cur and cur <= R[id]) return 0LL;
        ll ret = 0;
        if (cur < L[id]) {
            ret = L[id] - cur;
            cur = L[id];
        } else {
            ret = cur - R[id];
            cur = R[id];
        }
        return ret;
    };
    auto calc=[&](int b) {
        set<pii> dicl,dicr;
        ll ret = 0;
        rep(i,N) {
            dicl.emplace(L[i],i);
            dicr.emplace(R[i],i);
        }
        int cur = 0;
        rep(i,N) {
            int id;
            if (b) {
                auto it = dicl.rbegin();
                id = it->second;
            } else {
                auto it = dicr.begin();
                id = it->second;
            }
            dicl.erase(pii(L[id],id));
            dicr.erase(pii(R[id],id));
            ret += dist(cur,id);
            b = 1-b;
        }
        ret += abs(cur);
        return ret;
    };

    cout << max(calc(0),calc(1)) << ln;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
struct range{
	int L,R;
};

int main() {
	// your code goes here
	int n,m;
	scanf("%d %d",&n,&m);
	vector<range>ranges(m);
	range ans;
	bool posible = true;
	for(int i=0;i<m and posible; i++){
		scanf("%d %d",&ranges[i].L, &ranges[i].R);
		//printf("%d %d\n",ranges[i].L, ranges[i].R);
		if(i==0) {
			ans.L = ranges[i].L ;
			ans.R = ranges[i].R ;
		} 
		else{
			ans.L = max(ans.L, ranges[i].L) ;
			ans.R = min(ans.R, ranges[i].R) ;
		}
		if(ans.L > ans.R) posible = false;
	}
	printf("%d\n", posible ? (ans.R-ans.L+1) : 0);
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int i, j, n;
	map <int, int> tab;
	cin >> n;
	bool ans = true;
	for (i = 0; i < n && ans; ++i)
	{
		cin >> j;
		tab[j]++;
		if (tab[j] >= 2) ans = false;
	}
	if (ans) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}



Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
const int mod = 998244353;
const int max_size = 2e5+11;
int n,k,a,b;
long long dp[max_size] = {};
vector<pair<int,int>> arr;

int main(){
    scanf("%d%d", &n, &k);
    while(k--){
        scanf("%d%d", &a, &b);
        arr.emplace_back(a,b);
    }
    dp[1] = 1, dp[2] = -1;
    for(int i = 1; i <= n ; ++i){
        if (i > 1) {
            dp[i] += dp[i-1]; dp[i] %= mod;
        }
        for(auto& it : arr){
            if(i+it.first <= n) {
                dp[i+it.first] += dp[i];
                dp[i+it.first] %= mod;
            }
            if(i+it.second+1 <= n) {
                dp[i+it.second+1] -= (dp[i]-mod);
                dp[i+it.second+1] %= mod;
            }
        }
    }
    printf("%lld", dp[n]%mod);
    return 0;
}

Measured memory_bytes: 5336
using System;
using System.Collections.Generic;
public class ABC132B {
    public static void Main() {
        int n, ans = 0;
        List<int> p = new List<int>();
        List<int> comp = new List<int>(3){0, 0, 0};
        n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++) {
            p.Add(int.Parse(str[i]));
        }
        for (int i = 1; i < n - 1; i++) {
            comp[0] = p[i - 1];
            comp[1] = p[i];
            comp[2] = p[i + 1];
            comp.Sort();
            if (comp[1] == p[i]) ans++;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
N=int(input())
count=0
nums_count=[]
for i in range(N):
    nums=[int(e) for e in input().split()]
    nums_count.append(nums)

count=0
for i in range(N-2):
    if (nums_count[i][0]==nums_count[i][1]) and (nums_count[i+1][0]==nums_count[i+1][1]) and (nums_count[i+2][0]==nums_count[i+2][1]):
        count=1

if count==1:
    print("Yes")
else:
    print("No")


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

#define INF 10000000000
long long i,j,k,n,res,tmp;

int main(){
    int N; cin>>N;
    vector<vector<long long> > A(N,vector<long long>(N,0));
    for (i = 0; i < N; i++)
		for (j = 0; j < N; j++)cin>>A[i][j];
    for(i = 0; i < N-1; i++){
        for(j = i+1; j < N; j++){
            tmp = INF;
            for(k = 0; k < N; k++){
                if(i==k||j==k)continue;
                tmp = min(tmp,A[i][k]+A[k][j]);
                if(A[i][j]>A[i][k]+A[k][j]){
                    cout<<-1<<endl;
                    return 0;
                }
            }
            if(A[i][j]<tmp){
                res += A[i][j];
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4320
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val l = Array.fill(n)(sc.nextLong())
  var ans = 0
  for {
    i <- 0 until n-2
    j <- i+1 until n-1
    k <- j+1 until n
  } {
    val max = l(i).max(l(j)).max(l(k))
    if (l(i) != l(j) && l(i) != l(k) && l(j) != l(k) &&
      max < l(i) + l(j) + l(k) - max
    ) {
      ans += 1
    }
  }
  println(ans)
}


Measured memory_bytes: 55680
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
using namespace std;

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define __Mammamia__                ios_base :: sync_with_stdio(false);
#define ll                          long long
#define MAXN                        200007

int main()
{
    ll n, k, res = (ll)0; cin >> n >> k;

    if(!k){cout << n * n << endl; return 0;}

    for(ll i = 1; i <= n; ++i)
    {
        if(i > k)
        {
            res += (n / i) * (i - k) + max((ll)0, (n % i - k + 1));
        }
    }
    cout << res << endl;

    return 0;
}






Measured memory_bytes: 256
N,Q=gets.split.map &:to_i
S=gets.chomp
m=[]
(0..(N-2)).each{|i|
    if S[i]=='A' && S[i+1]=='C'
        m << i
    end
}
#p m
(0...Q).each{|i|
    l,r=gets.split.map &:to_i
    li=m.bsearch_index{|x| x>=l-1}
    ri=m.bsearch_index{|x| x>=r-1}
    if li==nil
        li=m.size
    end
    if ri ==nil
        ri=m.size
    end
    #p [li, ri]
    puts (m[ri-1]==r ? ri-li-1 : ri-li) 
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin >> n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];

	sort(a,a+n);
	ll cnt = 0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			ll sum = a[i] + a[j];

			ll beg = j+1 , last = n-1 , mid , ans = -1;
			while(beg <= last)
			{
				mid = (beg + last)/2;
				if(a[mid] < sum)
				{
					ans = mid;
					beg = mid + 1;
				}
				else
				{
					last = mid - 1;
				}
				
			}
			if(ans != -1)
			{
				cnt += (ans - j);
			}
		}
	}
	cout << cnt;
	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    vector<int> a(26);
    for(int i = 0;i < s.size();i++){
        a[s[i] - 'a']++;
    }
    for(int i = 0;i < 26;i++){
        if(a[i] == 0){
            char ans = 'a' + i;
            cout << ans << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;  
  int a;
  for (int i = 0; i < N; ++i) {
    int b; cin >> b;
    a |= b;
  }
  for (int i = 0; i < 32; ++i) {
    if ((a>>i)&1) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;  
}


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

using namespace std;

int main() {
	int A, B;
	string S, T, U;
	cin >> S >> T >> A >> B >> U;
	if (U == S)
		A--;
	else if (U == T)
		B--;
	cout << A << " " << B;
	return 0;
}

Measured memory_bytes: 256
def main():
    x1, y1, x2, y2 = map(int, input().split())

    x3 = x2 - (y2-y1)
    y3 = y2 + (x2-x1)
    x4 = x3 - (x2-x1)
    y4 = y3 - (y2-y1)

    print(x3, y3, x4, y4)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61304
import queue

n, m = map(int, input().split())
ab = [[] for i in range(n)]
A = []
B = []

for i in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    ab[a].append(b)
    ab[b].append(a)
    A.append(a)
    B.append(b)

def bfs(ab, n, na, nb):
    ok = [False for i in range(n)]
    q = queue.Queue()
    q.put(0)
    while not q.empty():
        f = q.get()
        ok[f] = True
        for c in ab[f]:
            if (f==na and c==nb) or (f==nb and c==na):
                continue
            if ok[c] == False:
                q.put(c)
    
    flag = True
    for i in ok:
        flag &= i
    return flag

ans = 0
for a, b in zip(A, B):
    if bfs(ab, n, a, b) == False:
        ans += 1

print(ans)

Measured memory_bytes: 3952
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;
using ll = long long int;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,K;
vector<ll> A;
ll d;

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

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> K;
    d = 0;
    for (int i = 0; i < N; i++)
    {
      ll a; cin >> a;
      d = __gcd(d,a);
      A.push_back(a);
    }   
}

int solve(){
  ll maxA = *max_element(A.begin(),A.end());
  if(K>maxA){cout << "IMPOSSIBLE" << endl; return 0;}
  if(K%d!=0){cout << "IMPOSSIBLE" << endl; return 0;}
  else {cout << "POSSIBLE" << endl; return 0;}  

  return 0;
}   

int main()
{
  input();
  solve();
  return 0;
}


Measured memory_bytes: 1400
import numpy as np
words = lambda t : list(map(t, input().split()))
n,m = words(int)

l = 0
r = n+1

for i in range(m):
    li,ri = words(int)
    l = max(l,li)
    r = min(r,ri)

print(max(0, r - l + 1))


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

#define int long long 

using namespace std;

void solve()
{
	int n;
	cin>>n;
	if(n<=29)
	{
		cout << "No";
	}
	else
		cout << "Yes"<< endl;
}

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	//int t;cin >> t;while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(10**6)

s = [False, False] + [True for i in range(1000000)]

for i in range(1000000):
	if s[i]:
		for j in range(i * 2, 1000000, i):
			s[j] = False

def main():
	a, d, n = map(int, input().split())
	if a == 0 and d == 0 and n == 0:
		return
	su = 0
	for i in range(100000):
		if s[a+d*i]:
			su += 1
		if su == n:
			print(a+d*i)
			break
	main()
	return

main()


Measured memory_bytes: 21228
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    t, a = list(map(int, input().rstrip('\n').split()))
    h = list(map(int, input().rstrip('\n').split()))
    tn = 0
    ma = 10 ** 10
    for i in range(n):
        tt = abs(t - (h[i] * 0.006) - a)
        if ma > tt:
            ma = tt
            tn = i + 1
    print(tn)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
n, m = map(int, input().split())
k = []
s = []
for i in range(m):
    tmp = [int(j) for j in input().split()]
    k.append(tmp[0])
    s.append(tmp[1:])
p = [int(i) for i in input().split()]

count = 0

for i in range(2**n):
    switches =str(format(i, 'b').zfill(n))
    lights = ""
    for light in range(m):
        s_on = 0
        for connect in s[light]:
            if switches[connect-1] == "1":
                s_on += 1
        if s_on % 2 == p[light]:
            lights += "1"
    if lights == "1" * m:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAXN = 1e5+1;

vector<int> con[MAXN];
int dp[MAXN];
int visited[MAXN];
int ans;

int dfs(int u) {
  if (visited[u]) return dp[u];

  visited[u] = 1;
  for (auto ch: con[u]) {
    dp[u] = max(dp[u], 1 + dfs(ch));
  }

  ans = max(ans, dp[u]);
  return dp[u];
}

int main() {
  // https://atcoder.jp/contests/dp/tasks/dp_g
  ll N, M;
  cin >> N >> M;
  for(auto i = 0; i<M; i++) {
    int u, v;
    cin >> u >> v;
    con[u].push_back(v);
  }


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

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



Measured memory_bytes: 7936
#include <bits/stdc++.h>
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 All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

// UnionFind
struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    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;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

int main() {
    int N;
    cin >> N;
    vector<pii> city(N);
    vector<int> place(N);
    rep(i, N) {
        cin >> city[i].first >> city[i].second;
        city[i].first--, city[i].second--;
        place[city[i].first] = i;
    }
    vector<int> X(N);
    rep(i, N) { X[city[i].second] = city[i].first; }
    sort(All(city));
    UnionFind uf(N);
    set<int> se;
    for(int i = 0; i < N; i++) {
        auto it = se.lower_bound(city[i].second);
        int cnt = 0;
        while(it != se.begin()) {
            it--;
            uf.unite(i, X[*it]);
            cnt++;
        }
        if(cnt == 0)
            se.insert(city[i].second);
    }
    vector<int> res(N);
    rep(i, N) { res[place[i]] = uf.size(i); }
    rep(i, N) { cout << res[i] << endl; }
}

Measured memory_bytes: 13624