akhauriyash/Code-Regression huggingface dataset:
n = input()
n = n[::-1]
n += '0'
cnt = 0
dp = [[float('inf')] * 2 for _ in range(len(n) + 1)]
dp[0][0] = 0
dp[0][1] = 1
for i in range(len(n)):
    a = int(n[i])
    dp[i + 1][0] = min(dp[i][0] + a, dp[i][1] + 10 - a)
    dp[i + 1][1] = min(dp[i][0] + a + 1, dp[i][1] + 10 - (a + 1))
print(min(dp[len(n)][0], dp[len(n)][1]))

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)

#define BR "\n"
#define SP " "
#define fcout cout << fixed << setprecision(18)

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

  double pi = 3.14159265358979;
  vector<double> T(N);

  rep0(i, N) {
    double t; cin >> t;
    T[i] = 2 * pi * t / L;
  }

  double ansx = 0, ansy = 0;
  rep0(i, N) {
    rep(j, i + 1, N) {
      double t1, t2, c1, c2;
      c1 = j - i - 1;
      c2 = N - 2 - c1;
      t1 = (T[i] + T[j]) / 2 + pi;
      t2 = (T[i] + T[j]) / 2;
      ansx += c1 * cos(t1) + c2 * cos(t2);
      ansy += c1 * sin(t1) + c2 * sin(t2);
    }
  }
  ansx = ansx * 6 / N / (N - 1) / (N - 2);
  ansy = ansy * 6 / N / (N - 1) / (N - 2);
  fcout << ansx << SP << ansy << BR;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main(){
   std::string A, B, C;
   std::cin >> A >> B >> C;

   if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0]) std::cout << "YES" << std::endl;
   else std::cout << "NO" << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int x1, y1, x2, y2;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  int dif1, dif2;
  dif1 = x2 - x1;
  dif2 = y2 - y1;
  printf("%d %d %d %d\n", x2 - dif2, y2 + dif1, x2 - dif2 - dif1, y2 + dif1 - dif2);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
    using namespace std;
     
    int main()
    {
      int n, y ,i, j, k, a, b, c;
      cin >> n >> y;
      a = 0;
      b = 0;
      c = 0;
      for(i = 0; i <= n; i++)
      {
        for(j = 0; j <= (n-i); j++)
        {
          k = n - i - j;
          if(10000 * i + 5000 * j + 1000 * k == y)
          {
            a = i;
            b = j;
            c = k;
          }
        }
      }
      if(a != 0 || b != 0 || c != 0)
      {
        cout << a << " " << b << " " << c << endl;
      }
      else
      {
        cout << "-1 -1 -1" << endl;
      }
      return 0;
    }

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

using namespace std;
using ll = long long;
using ld = long double;

const int INF = 1e9;

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

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n + 1), b(m + 1), pa(n + 1, 0), pb(m + 1, 0);
  for(int i = 0; i < n; i++) {
    cin >> a[i + 1];
    pa[i + 1] = pa[i] + a[i + 1];
  }
  for(int j = 0; j < m; j++) {
    cin >> b[j + 1];
    pb[j + 1] = pb[j] + b[j + 1];
  }
  int ans = -INF;
  for(int i = 0; i <= n; i++) {
    ll temp = pa[i];
    ll sisa = k - temp;
    if(sisa < 0)
      break;
    int lul = upper_bound(pb.begin(), pb.end(), sisa) - pb.begin();
    // cerr << i << ' ' << lul - 1 << '\n';
    ans = max(ans, lul - 1 + i);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 9544
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
	

fast;

ll n,k;
cin>>n>>k;

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

	sort(p,p+n);

ll ans=0;
for(ll i=0;i<k;i++)
ans+=p[i];

cout<<ans;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int f(const vector<pair<int, int>>& vp, int a) {
    int b = 0, e = vp.size() - 1;
    while (b < e) {
        int m = (b + e) / 2 + 1;
        if (vp[m].first >= a) {
            b = m;
        } else {
            e = m - 1;
        }
    }
    return b;
}

int main() {        
    long long int n, h;
    cin >> n >> h;
    vector<pair<int, int>> vp;
    vector<long long int> pre(n, 0);
    long long int s = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        vp.emplace_back(b, a);
    }
    sort(vp.begin(), vp.end());
    reverse(vp.begin(), vp.end());
    for (int i = 0; i < n; i++) {
        s += vp[i].first;
        pre[i] = s;
    }
    int res = 0x3f3f3f3f;
    s = 0;
    for (int i = 0; i < n; i++) {
        s += vp[i].first;
        if (s >= h) {
            res = min(res, i + 1);
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        int index = f(vp, vp[i].second);
        long long int hh = h - pre[index];
        if (hh <= 0) {
            res = min(res, index + 1);
            continue;
        }
        int a = vp[i].second;
        res = min((long long int)res, (hh / a + (hh % a > 0 ? 1 : 0) + index + 1));

    }
    cout << res << endl;
}


Measured memory_bytes: 5100
#include<stdio.h>

int main(void){
    int n, n2, sn=0;

    scanf("%d", &n);

    n2 = n;
    while(n2){
        sn += n2 % 10;
        n2 /= 10;
    }
    if(n % sn == 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,a[200020],ans=0;
bool check(int mid)
{
	for(int i=2*mid+1,j=2*n;i<j;++i,--j)if(a[i]+a[j]<m)return 0;
	return 1;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=2*n;++i)scanf("%d",&a[i]);
	sort(a+1,a+1+2*n);
	int l=0,r=n,mid;
	while(l<r)
	{
		mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	for(int i=1,j=2*l;i<=l;++i,--j)ans=max(ans,a[i]+a[j]);
	for(int i=2*l+1,j=2*n;i<j;++i,--j)ans=max(ans,a[i]+a[j]-m);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 896
n,m=map(int,input().split())
switch=[ '0' * (10) for i in range(m)]
for i in range(m):
    li = list(map(int,input().split()))
    for j in range(len(li)):
        if j==0:
            continue
        lis = list(switch[i])
        lis[li[j]-1] = '1'
        switch[i] = ''.join(lis)
p=list(map(int,input().split()))
ans=0
# print(switch)
for i in range(2**n):
    on_switch=list(format(i,'010b')[::-1])
    flag=1
    for ii in range(m):
        s=switch[ii]
        icchi=0
        for z in range(10):
            if on_switch[z]=='1':
                if list(s)[z] == '1':
                    icchi+=1
        # print(''.join(on_switch),switch[ii])
        # print(i,ii,icchi)
        if icchi%2 != p[ii]:
            flag=0
            break
    if flag==1:
        ans+=1
        # print('yeah',i)
print(ans)

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

def main():
     n, m = map(int, input().split())
     ac_list = [False for i in range(n)]
     wa_list = [0 for i in range(n)]
     ac_ans = wa_ans = 0

     for i in range(m):
          p, s = input().split()
          p = int(p) - 1
          if not ac_list[p]:
               if s == 'AC':
                    ac_list[p] = True
                    ac_ans += 1
                    wa_ans += wa_list[p]
               else:
                    wa_list[p] += 1
     
     print('{} {}'.format(ac_ans, wa_ans))

if __name__ == "__main__":
    main()


Measured memory_bytes: 4656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, m, cnt = 0;
  char in[8];
  bool f = true;
  scanf("%d", &n);
  while(n--){
    scanf("%s %d", in, &m);
    if(in[0] == '(') cnt += m;
    else cnt -= m;
    if(cnt < 0) f = false;
  }

  if(f && !cnt) puts("YES"); else puts("NO");
  return 0;
}

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

#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ep emplace
#define MOD 1000000007LL
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define for1(i, n) for(int i = 1; i <= int(n); i++)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define fore(i, a, b) for(int i = int(a); i <= int(b); i++)
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;

const ll oo = 1000000000000000000;
const int N = 100005;

int v[N];
int dp[N][2];
int n;

int f(int i, int p){
    if(i == n) return p == 0;

    int &ans = dp[i][p];
    if(~ans) return ans;
    ans = f(i+1, (p*v[i])&1);
    ans += f(i+1, (p*(v[i]-1))&1);
    ans += f(i+1, (p*(v[i]+1))&1);
    return ans;
}

int main(){
    memset(dp, -1, sizeof dp);

    scanf("%d", &n);

    forn(i, n) scanf("%d", v+i);

    printf("%d\n", f(0, 1));


    return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

const (
	NONE = iota
	FAIL
	OK
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	res := make([][]int, h)
	var prev, curr string
	for i := 0; i < h; i++ {
		res[i] = make([]int, w)
		fmt.Scan(&curr)
		for j := 1; j < w; j++ {
			if curr[j] == '#' {
				if curr[j-1] == '#' {
					res[i][j-1] = OK
					res[i][j] = OK
				} else {
					res[i][j] = FAIL
				}
				if i > 0 {
					if prev[j] == '#' {
						res[i-1][j] = OK
						res[i][j] = OK
					}
				}
			}
		}
		prev = curr
	}

	for _, l := range res {
		for _, r := range l {
			if r == FAIL {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}

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

constexpr int64_t mod = 1'000'000'007; //'

int main(){
    int64_t N, K;
    int A[2000];
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    int64_t t;
    int cnt[2001], csum[2001];
    for(int i=0;i<=2000;i++) cnt[i] = csum[i] = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(A[i] > A[j]) t++;
        }
        cnt[A[i]]++;
    }
    for(int i=0;i<=2000;i++) csum[i] = cnt[i];
    for(int i=1999;i>=1;i--) csum[i] = (csum[i] + csum[i+1]) % mod;

    int64_t ans = t*K % mod;
    int64_t kk = K*(K-1)/2 % mod;
    for(int i=1;i<2000;i++){
        ans = (ans + cnt[i]*csum[i+1]%mod*kk%mod) % mod;
    }    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
# 高橋 HP:a ATK:b
# 青木 HP:c ATK:d
a, b, c, d = map(int, input().split())

# 高橋が主人公
while a >= 0 or c >= 0:
    a = a - d
    c = c - b
    if c <= 0:
        print('Yes')
        break
    elif a <= 0:
        print('No')
        break



Measured memory_bytes: 9092
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
int H,W,N;
int fie[1001][1001];
int A[1001][1001];
int solve(){
  A[0][0]=N-1;
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      if(fie[x][y]){
	A[x+1][y]+=(A[x][y]+1)/2;
	A[x][y+1]+=A[x][y]/2;
      } else {
	A[x+1][y]+=A[x][y]/2;
	A[x][y+1]+=(A[x][y]+1)/2;
      }
    }
  }
}
P traced(int x,int y){
  if(x==W || y==H) return P(x,y);
  P ret;
  if(A[x][y]%2){
    if(fie[x][y]) ret = traced(x,y+1);
    else ret = traced(x+1,y);
  } else {
    if(fie[x][y]) ret = traced(x+1,y);
    else ret = traced(x,y+1);
  }
  return ret;
}
int main(){
  while(1){
    memset(A,0,sizeof(A));
    scanf("%d %d %d",&H,&W,&N);
    if(!H && !W && !N) break;
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
	scanf("%d",&fie[j][i]);
    solve();
    P res = traced(0,0);
    
    printf("%d %d\n",res.S+1,res.F+1);
  }
}

Measured memory_bytes: 9052
<?php

const DIV = 1000000007;
fscanf(STDIN, "%d", $n);

$list = explode(" ", trim(fgets(STDIN)));

$num[0] = 3;
$ans = 1;

foreach($list as $value){
    $ans = $ans * $num[$value] %  DIV;
    if(isset($num[$value+1])){
        $num[$value+1]++;
    }else{
        $num[$value+1] = 1;
    }
    $num[$value]--;
}

echo $ans;

Measured memory_bytes: 19188
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	int N=inputValue();
	vector<int> L;
	inputVector(&L,N);
	sort(L.begin(),L.end());
	int accume=accumulate(L.begin(),L.end(),0LL);
	if(accume-L[N-1]>L[N-1]){
		cout << "Yes" << endl;
		return 0;
	}else{
		cout << "No" << endl;
		return 0;
	}
	return 0;
}


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

int main() {

  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> tt(n);
  for(int i = 0; i < n; i++) { 
    cin >> x.at(i);
    tt.at(i) = x.at(i); 
  } 
  
  sort(tt.begin(), tt.end());
  reverse(tt.begin(), tt.end());

  int tmp = 0;
  int ans = 10e10;
  for(int i = 0; i < tt.at(0)+ 100; i++) {
    int c = 0;
    for(int j = 0; j < n; j++) {
      tmp = (x.at(j) - i);
      c = c + tmp * tmp;
    }
    ans = min(ans,c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
	Scanner in = new Scanner(System.in);

	int X = in.nextInt();
	int t = in.nextInt();

	if(X - t <= 0){
		System.out.println(0);
	}
	else{
		System.out.println(X - t);
	}
}
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll unsigned long long
#define endl "\n"

void solve()
{
	ll ans=0;
	string s1,s2;
	cin>>s1>>s2;
	for(ll i=0;i<s1.length();i++)
	{
		if(s1[i]!=s2[i]) ans++;
	}
	cout<<ans;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

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

int main() {
  int N, D;
  cin >> N >> D;
  int i = 1;
  while(true){
    if(i + 2 * i * D < N){
      i++;
    }
    else break;
  }
  
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	ll N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	vector<ll> num;

	rep(i, N) {
		if (i == 0) {
			num.pb(1);
		} else {
			if (S[i] == S[i-1]) {
				num[num.size()-1]++;
			} else {
				num.pb(1);
			}
		}
	}

	int ans = 0;
	if (num.size() <= 2*K+1) {
		ans = N-1;
	} else {
		rep(i, num.size()) {
			if (i < 2*K) {
				ans += num[i];
			} else {
				ans += num[i];
				ans--;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  int n; cin >> n;
  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }

  vector<int> x(n), y(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
  }

  int ans = n;
  rep(i, n) {
    rep(j, n) {
      if(i == j) continue;
      int dx = x[j] - x[i], dy = y[j] - y[i];

      int tmp = 0;
      rep(k, n) {
        rep(l, n) {
          if(k == l) continue;
          if(dx == x[l] - x[k] && dy == y[l] - y[k]) {
            ++tmp;
            break;
          }
        }
      }

      chmin(ans, n - tmp);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <functional>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

char s[(int)1e5 + 9];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	int res = 0;
	for (int i = 1; i < n; ++i) {
		if (s[i] != s[i - 1]) {
			++res;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0) cout<<1;
	else if(b==0) cout<<2;
	else if(c==0) cout<<3;
	else if(d==0) cout<<4;
	else cout<<5;
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
typedef long long ll;
const int MOD = 1000000007; 
int n, k;
int a[110];
ll cum[100010];
ll dp[110][100010];

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

    for (int j = 0; j <= a[0]; j++) dp[1][j] = 1;
    for (int i = 1; i < n; i++) {
        cum[0] = 0;
        for (int j = 0; j <= k; j++) cum[j+1] = (cum[j] + dp[i][j]) % MOD;
        for (int j = 0; j <= k; j++) dp[i+1][j] = (cum[j+1] - cum[max(0, j - a[i])] + MOD) % MOD; 
    }
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 82048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cctype>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<ctime>

using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::queue;
using std::stack;
using std::set;
using std::vector;
using std::string;
using std::priority_queue;
using std::deque;
using std::pair;


int main(int argc, char** argv)
{
	if (argc == 2 && strcmp(argv[1], "-debug") == 0)
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}


	char s[100001];
	cin >> s;
	int len = strlen(s);
	int ans = len;
	for (int i = 1; i < len; i++)
		if (s[i] != s[i - 1])
			ans = std::min(ans, std::max(i, len - i));

	cout << ans;

	return 0;
}


Measured memory_bytes: 384
from collections import Counter
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    naga = len(set([A[i],B[i],C[i]]))
    if naga == 3:
        ans+=2
    if naga == 2:
        ans+=1
print(ans)

Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
int main()
{
	LL S=read();
	int l=1,r=1e9,as;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(1LL*mid*mid<=S)as=mid,l=mid+1;
		else r=mid-1;
	}
	pr1(0);pr1(0);
	if(1LL*as*as==S)
	{
		pr1(0);pr1(as);pr1(as);pr2(0);
		return 0;
	}
	if(1LL*as*(as+1)>S)
	{
		int ls=1LL*as*(as+1)-S;
		pr1(as);pr1(1);pr1(ls);pr2(as+1);
	}
	else
	{
		int ls=1LL*(as+1)*(as+1)-S;
		pr1(as+1);pr1(1);pr1(ls);pr2(as+1);
	}
	return 0;
}




Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

 static const long double pi = 3.141592653589793238462643;
 
int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    long double res;
    long double rec_long = pi * m /30;
    long double rec_short = (h*pi/6) + (m*pi/360);

    long double rec = rec_long - rec_short;

    if(rec < 0) rec = (-1)*rec;
    if(rec > pi) rec = 2*pi - rec;

    res = a*a + b*b - 2*a*b*cos(rec);
    cout << std::fixed << std::setprecision(12) << sqrtl(res) << endl;
}

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

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

        long d = sc.NextLong();
        long[] c = sc.LongArray();
        long[,] s = new long[d, 26];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < 26; j++)
            {
                s[i, j] = sc.NextLong();
            }
        }

        long[] last = new long[26];

        for (int i = 0; i < d; i++)
        {
            long maxCost = 0;
            long index = 0;

            for (int j = 0; j < 26; j++)
            {
                var cost = c[j] * (i + 1 - last[j]);
                if (cost > maxCost)
                {
                    maxCost = cost;
                    index = j;
                }
            }
            last[index] = i;
            Console.WriteLine(index + 1);
        }

        //long[] sums = new long[26];
        //for (int i = 0; i < 26; i++)
        //{
        //    long sum = 0;
        //    for (int j = 0; j < d; j++)
        //    {
        //        sum += s[j, i];
        //    }
        //    sums[i] = sum;
        //}

        //long maxDay = 0;
        //long max = 0;
        //for (int i = 0; i < 26; i++)
        //{
        //    if (sums[i] > max)
        //    {
        //        max = sums[i];
        //        maxDay = i;
        //    }
        //}
    }

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

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

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

            return _line[_index++];
        }

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

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

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


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

int main() {
  int N, l, r, S;
  S = 0;
  
  cin >> N ;
  
  
  for ( int i = 0 ; i < N; i++) { 
    cin >> l >> r;
    S += r - l + 1 ;
  }
  cout << S << endl;
}


Measured memory_bytes: 256
lis = map(int,list(raw_input()))
outop = []
out = ""
for i in xrange(8):
	n2 = format(i,"03b")
	oplis = map(int,list(str(n2)))
	sum = lis[0]
	for num in xrange(3):
		if oplis[num] == 1:
			sum += lis[num+1]
		else:
			sum -= lis[num+1]
	if sum == 7:
		for op in oplis:
			if op == 1:
				outop.append("+")
			else:
				outop.append("-")
		print  "{0[0]}{1[0]}{0[1]}{1[1]}{0[2]}{1[2]}{0[3]}=7".format(lis,outop)
		break

Measured memory_bytes: 2692
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int a,b,sum=0,maxa;
    int s[10];
    cin >> a;
    for(int i=0;i<a;i++)
        cin>>s[i];
    maxa=0;
     for(int i=0;i<a;i++)
        if(s[i]>s[maxa])
            maxa=i;
     for(int i=0;i<a;i++)
        if(i!=maxa)
            sum+=s[i];
    if(s[maxa]>=sum)
        cout<<"No"<<endl;

    else
        cout<<"Yes"<<endl;
    
    
	
	
	return 0;
}
	

Measured memory_bytes: 256
X,Y,i;x[12],y[12];q[9999],t,h,p,o,c;char *d="22210/.../01";main(n){for(;scanf("%d%d",&X,&Y),X;puts(o?"OK":"NA")){for(o=t=h=i=!scanf("%d",&n);i++<n;)scanf("%d%d",x+i,y+i);for(p=q[t++]=X*10+Y;t!=h&!o;p=q[h++])if(!(c=p/100)||abs(x[c]-p/10%10)<2&abs(y[c]-p%10)<2)for(o=c++==n,i=0;i<12;X>=0&X<10&Y>=0&Y<10?q[t++]=c*100+X*10+Y:0)X=p/10%10+d[i]-48,Y=p%10+d[11-i++]-48;}}

Measured memory_bytes: 0
#include <stdio.h>

int main() {
    int W, a, b;
    scanf("%d %d %d", &W, &a, &b);
    if (b < a) {
        int tmp = b;
        b = a;
        a = tmp;
    }
    b -= a;
    if (b<=W) {printf("%d\n", 0);}
    else { printf("%d\n", b-W);}
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define drep(x,a,b) for(int x=a;x>=b;x--)
#define rush() int T;scanf("%d",&T);while(T--)
#define wash(x,y) memset(x,y,sizeof(x));

int main(){
	int a[4][4];
	rep(i,1,3){
		rep(j,1,3)
			scanf("%d",&a[i][j]);
	}
	
	bool flag=(a[1][2]-a[1][1]==a[2][2]-a[2][1])&&
			(a[3][2]-a[3][1]==a[2][2]-a[2][1])&&
			(a[1][3]-a[1][2]==a[2][3]-a[2][2])&&
			(a[3][3]-a[3][2]==a[2][3]-a[2][2]);
	
	printf(flag?"Yes":"No");
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class C {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<P> vec[n];
      rep(i, n) {
        int a; cin >> a;
        while(a--) {
          int x, y; cin >> x >> y;
          x--;
          vec[i].emplace_back(x, y);
        }
      }

      int t = (1<<n);
      int ans = 0;
      rep(i, t) {
        bool flag = true;
        int cnt = 0;
        rep(j, n) {
          if (i&(1<<j)) {
            cnt++;
            for(auto e: vec[j]) {
              if ((((1<<e.first)&i) > 0 )^(e.second>0)) {
                flag = false;
                break;
              }
            }
          }
        }
        if (flag) {
          chmax(ans, cnt);
        }
      }

      cout << ans << endl;
    }
};

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    map<string, ll> m;
    rep(i, N) {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3636
a,b,m=map(int,input().split())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))

lst=[]
for i in range(m):
  x,y,z=list(map(int,input().split()))
  lst.append([x,y,z])
  
ans=min(aa)+min(bb)

for i in lst:
  ans=min(ans,aa[i[0]-1]+bb[i[1]-1]-i[2])
  
  
print(ans)

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

int main() {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (i == 0) {
			if (s[i] != 'A') {
				break;
			}
		}
		else {
			if (s[i] - 'Z' < 0) {
				if (2 <= i && i < s.size() - 1 && s[i] == 'C') {
					++count;
				}
				else {
					count = 0;
					break;
				}
			}
		}
	}
	if (count == 1) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define db double
#define ll long long
#define inf 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=10005;

int main(){
	FAST_IO;
	int a,b,c;
	cin >> a >> b >> c ;
	cout << max(0,c-a+b) << endl; 
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N, A[21], B[51], C[51];
int i, s = 0, p = -1;

int main() {
        scanf("%d", &N);

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

        for (i = 1; i <= N; i++) {
                scanf("%d", &B[i]);
        }

        for (i = 1; i < N; i++) {
                scanf("%d", &C[i]);
        }

        for (i = 1; i <= N; i++) {
                s += B[A[i]];
                if (A[i] == p + 1) {
                        s += C[p];
                }
                p = A[i];
        }

        printf("%d\n", s);

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin>>N;
    int a[N+1];
    rep(i, 1, N+1) {
        cin>>a[i];
    }
    int b[N+1]={};
    // memset(b, -1, sizeof(int));
    for (int i=N;i>0;--i) {
        int c=0;
        for (int j=2*i;j<=N;j+=i) {
            c^=b[j];
        }
        b[i]=a[i]^c;
    }
    int ans=0;
    rep(i, 1, N+1) {
        if (b[i])++ans;
    }
    cout<<ans<<endl;
    if (ans) {
        rep(i, 1, N+1) {
            if (b[i])cout<<i<<' ';
        }
        cout<<endl;
    }

}
int main()
{
    func();
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();

  long long ans = 0;
  for (int bit = 0; bit < (1 << (N - 1)); bit++) {
    long long tmp = 0;
    for (int i = 0; i < (N - 1); i++) {
      tmp *= 10;
      tmp += S.at(i) - '0';
      if (bit & (1 << i)) {
        ans += tmp;
        tmp = 0;
      }
    }
    tmp *= 10;
    tmp += S.back() - '0';
    ans += tmp;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3576
module ABC123

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: ABC123_B

  ! constants for this <module>
  integer(kind=INT16), parameter, private :: num_dishes =  5_INT16
  integer(kind=INT16), parameter, private :: time_unit  = 10_INT16

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine ABC123_B

    ! variables for this <subroutine>
    integer(kind=INT16) :: required_time    (1:num_dishes)
    integer(kind=INT16) :: required_time_mod(1:num_dishes)
    integer(kind=INT16) :: required_time_total
    integer(kind=INT16) :: retval_mod
    integer(kind=INT16) :: num_dishes_added

    ! support variables for this <subroutine>
    integer(kind=INT16) :: itr, elem_maxloc

    ! STEP.01
    ! initialize the total required time
    required_time_total = 0_INT16
    num_dishes_added        = 0_INT16

    ! STEP.02
    ! read out the each required time
    do itr = 1_INT16, num_dishes, 1_INT16
      read(unit=INPUT_UNIT, fmt='(I3)') required_time(itr)
    end do

    ! STEP.03
    required_time_mod(:) = mod(required_time(:), time_unit)

    ! STEP.04
    ! calculate the minimum total time
    do itr = 1_INT16, num_dishes, 1_INT16
      if(required_time_mod(itr) .eq. 0_INT16) then
        required_time_total    = required_time_total + required_time(itr)
        required_time_mod(itr) = 0_INT16
        num_dishes_added       = num_dishes_added + 1_INT16
      end if
    end do

    do itr = 1_INT16, num_dishes-num_dishes_added, 1_INT16

      elem_maxloc = maxloc(required_time_mod(:), dim=1)

      retval_mod = mod(required_time_total, time_unit)
      
      if(retval_mod .ne. 0_INT16) required_time_total = required_time_total - retval_mod + time_unit

      required_time_total = required_time_total + required_time(elem_maxloc)

      required_time_mod(elem_maxloc) = 0_INT16

    end do

    ! STEP.04
    ! output the tota; time
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') required_time_total

    ! STEP.END
    return

  end subroutine ABC123_B

end module ABC123


program main

  ! <module>s to import
  use, non_intrinsic :: ABC123

  ! require all variables to be explicitly declared
  implicit none

  call ABC123_B

end program main

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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(c+b-a>=0? c+b-a: 0)<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    double r;
    cin>>r;
    r = 2*PI*r;
    printf("%.9lf\n",r);
    return 0;
}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  
ll MOD = 1e9 + 7;

ll power(ll a , ll n)
{
    unsigned long long int result=1,x=a;
    while(n>0)
    {
        if(n % 2 ==1)
            result = (result * x);
        x = (x * x);
        n=n/2;
    }
    return result;
}

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

int main() 
{ 
    FIO
    int t;
    t=1;
    while(t--)
    {       
        int n;
        cin >> n;
        
        int cnt = 0;
        for(int i=1;i<=n;i++)
        {
            int x;
            cin >> x;

            if(x%2==1 && i%2==1)
            {
                cnt++;
            }
        }
        cout << cnt << endl;
    }   
    return 0; 
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

int n, k, MAX, MIN, flag;
int a[100005];
int main()
{
	flag = 0;
	MAX = -1;
	MIN = 1 << 30;
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		MAX = max(MAX, a[i]);
		MIN = min(MIN, a[i]);
	}
	if(MAX < k) printf("IMPOSSIBLE\n");
	else {
		for(int j = MIN; j >= 1; j--)
		{
			for(int i = 1; i <= n; i++)
			{
				if(a[i] % j != 0) break;
				if(i == n) flag = j;
			}
			if(flag != 0) break;
		}
		if(flag != 0 && k % flag != 0) printf("IMPOSSIBLE\n");
		else printf("POSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long;

ll scoring(vector<int>& schedule);
int D;
vector<int> decline(26);
vector<vector<int>> satis(365, vector<int>(26));

void solve_greedy(vector<int>& schedule){
    for(int d = 0;d < D;d++){
        int sel = 0;
        for(int i = 0;i < 26;i++){
            if(satis[d][i] > satis[d][sel]){
                sel = i;
            }
        }
        schedule[d] = sel;
    }
}



ll scoring(vector<int>& schedule){
    vector<int> lastHeld(26, 0);
    ll sat = 0;
    for(int d = 1;d <= D;d++){
        int contest = schedule[d-1];
        lastHeld[contest] = d;
        for(int i = 0;i < 26;i++){
            if(i == contest){
                sat += satis[d-1][i];
            }
            sat -= decline[i] * (d-lastHeld[i]);
        }
        // cout<<sat<<endl;
    }
    return sat;
}

ll calcDiff(vector<int>& schedule, vector<int>& d, vector<int>& q, int M){
    vector<set<int>> sched(26,set<int>());
    for(int i = 0;i < D;i++){
        sched[schedule[i]].insert(i);
    }
    // cout<<"A"<<endl;
    for(int i = 0;i < 26;i++){
        sched[i].insert(-1);
        sched[i].insert(D);
    }
    ll result = scoring(schedule);
    // cout<<"a"<<endl;
    for(int i = 0;i < M;i++){
        result -= satis[d[i]][schedule[d[i]]];
        result += satis[d[i]][q[i]];
        auto lastHeldNewP = sched[q[i]].lower_bound(d[i]);
        lastHeldNewP--;
        int lastHeldNew = *lastHeldNewP;
        int nextHeldNew = *sched[q[i]].lower_bound(d[i]+1);
        auto lastHeldOldP = (sched[schedule[d[i]]].lower_bound(d[i]));
        lastHeldOldP--;
        int lastHeldOld = *(lastHeldOldP);
        int nextHeldOld = *sched[schedule[d[i]]].lower_bound(d[i]+1);
        result += decline[q[i]] * (nextHeldNew - d[i]) * (d[i] - lastHeldNew);
        result -= decline[schedule[d[i]]] * (nextHeldOld - d[i]) * (d[i] - lastHeldOld);
        
        // cout<<q[i]<<" " <<lastHeldNew<<" "<<nextHeldNew<<" "<<d[i]<<endl;
        // cout<<schedule[d[i]]<<" "<<lastHeldOld<<" "<<nextHeldOld<<" "<<d[i]<<endl;
        
        sched[q[i]].insert(d[i]);
        sched[schedule[d[i]]].erase(d[i]);
        schedule[d[i]] = q[i];
        cout<<result<<endl;
        // cout<<scoring(schedule)<<endl;
        
    }
    return result;
}

int main(){
    cin>>D;
    for(int i = 0;i < 26;i++){
        int c;cin>>c;
        decline[i] = c;
    }
    for(int d = 0;d < D;d++){
        for(int i  = 0;i < 26;i++){
            int s;cin>>s;
            satis[d][i] = s;
        }
    }
    vector<int> schedule(D,0);
    // solve_greedy(schedule);
    // for(int i = 0;i < schedule.size();i++){
    //     cout<<schedule[i]+1<<endl;
    // }
    // scoring(schedule);
    for(int i = 0;i < D;i++){
        cin>>schedule[i];schedule[i]--;
    }
    int M;cin>>M;
    vector<int> d(M),q(M);
    for(int i = 0;i < M;i++){
        cin>>d[i]>>q[i];
        d[i]--;q[i]--;
    }
    // cout<<"A"<<endl;
    calcDiff(schedule, d,q,M);

}

Measured memory_bytes: 3900
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<int,int> m;
//int fr[maxn][205];
//map<int,int> m;

int main(){
	ios::sync_with_stdio(false);
	int n,m,x;long long sum=0;
	cin>>m>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		sum+=x;
	}
	if(sum>m){
		cout<<-1<<endl;
	}else{
		cout<<m-sum<<endl;
	}
	
}


Measured memory_bytes: 3644
# Problem C - Together

import collections

# input
N = int(input())
a_list = list(map(int, input().split()))

# initialization
num_counter = collections.Counter(a_list)
max_count = 0

# count
for k in num_counter.keys():
    nc = num_counter[k]
    tmp_mae = num_counter[k-1]
    tmp_ushiro = num_counter[k+1]
    max_count = max(max_count, nc + tmp_mae + tmp_ushiro)

# output
print(max_count)


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

using namespace std;

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

const int MAXN = 1e6 + 10;
const int MM = 1e9 + 7;

int n, m;
char s[MAXN], t[MAXN];
int a[MAXN];

int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    int ans = abs(m - a[1]);
    for (int i = 2; i <= n; i++){
        ans = __gcd(ans, abs(m - a[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    int j = 0;
    int i =0;
    string s;
    getline(cin,s);
    while (j<3) {
    if (s[j]==s[j+1]){i++;}
    j++;
    }
    if (i>0){cout << "Bad";}
    else{cout << "Good";}
}

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

int main(){
    int n;
        cin >> n;
    double sum=0, a;
        for(int i=0; i<n; i++){
            cin >> a;
            sum += 1/a;
        }
        cout << fixed << setprecision(15) << 1/sum << endl;
}


Measured memory_bytes: 256
(defun calc (r d xi)
  (- (* r xi) d))

(defun rec (r d xi c)
  (if (> c 9)
    xi
    (progn (format t "~a~%" (calc r d xi)) (rec r d (calc r d xi) (1+ c)))))

(rec (read) (read) (read) 0)


Measured memory_bytes: 12256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 桁DP

int dp[105][4][2];
/*
    dp[i][j][k] := iけためまで決めて、j個の非0を使って、
    k==0: そこまでの桁はnと一緒
    k==1: そこまでの桁はすでにn以下であることが確定
*/

int main(){
    string s;
     cin >> s;
     int n = s.size();
     int K;
     cin >> K;
     dp[0][0][0] = 1;
     rep(i, n)rep(j, 4)rep(k, 2){
         int nd = s[i] - '0';
         rep(d, 10){
             int ni = i+1, nj = j, nk = k;
             if (d!=0) nj++;
             if (nj>K) continue;
             if (k==0) {
                 if (d > nd) continue;
                 if (d < nd) nk = 1;
             }
             dp[ni][nj][nk] += dp[i][j][k];
         }
     }
     int ans = dp[n][K][0] + dp[n][K][1];
     cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256