akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[15];
int n;
inline long long dfs(int x,long long sum,int last)
{
	long long ml=0;
	for(int i=last;i<=x;i++)
		ml=ml*10+s[i]-'0';
	if(x>=n)
		return sum+ml;
	return dfs(x+1,sum+ml,x+1)+dfs(x+1,sum,last);
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	printf("%lld\n",dfs(1,0,1));
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int count = n;
        for(int i = 0; i < n - 1; i++){
        	if(s.charAt(i) == s.charAt(i + 1)){
            	count--;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 39544
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
#define inf 123456789
int read() {
    char cc = getchar(); int cn = 0, flus = 1;
    while(cc < '0' || cc > '9') {  if( cc == '-' ) flus = -flus;  cc = getchar();  }
    while(cc >= '0' && cc <= '9')  cn = cn * 10 + cc - '0', cc = getchar();
    return cn * flus;
}
const int N = 500000 + 5 ; 
int n, A, B, C, Ans, num, vis[N]; 
struct Node {
    int a, b, c ;
} s[N];
struct node {
    int val, id ;
    bool operator < ( const node& x ) const {
        return val < x.val ; 
    }
};
priority_queue<node> qA, qB, QA, QB ;
signed main()
{
	A = read(), B = read(), C = read() ; int x, y, z ; 
	n = A + B + C ; 
    rep( i, 1, n ) x = read(), y = read(), z = read(), num += z,
        s[i].a = x - z, s[i].b = y - z, 
        QA.push((node){ s[i].a, i }), QB.push((node){ s[i].b, i }) ;
    int con = 0 ;
    while( 1 ) {
        node u1 = QA.top(); node u2 = QB.top() ; 
        int cnt1 = 0, cnt2 = 0 ;
        while( vis[u1.id] ) QA.pop(), u1 = QA.top() ;
        while( vis[u2.id] ) QB.pop(), u2 = QB.top() ; 
        int toA = u1.val, frA = u1.id, toB = u2.val, frB = u2.id;
        int f1 = 0, f2 = 0 ; 
        if( qB.size() ) {
            cnt1 = qB.top().val ;
            if( ( toA < cnt1 + u2.val ) ) toA = cnt1 + u2.val, f1 = 1 ;
        }
        if( qA.size() ) {
            cnt2 = qA.top().val ;
            if( ( toB < cnt2 + u1.val ) ) toB = cnt2 + u1.val, f2 = 1 ;
        }
        if( qA.size() == A ) {
            Ans += toB ; 
            if( f2 )
                qA.pop(), qB.push((node){ -cnt2, 0 }), qA.push((node){s[u1.id].b - s[u1.id].a, 0}), vis[u1.id] = 1 ;
            else
                qB.push((node){s[u2.id].a - s[u2.id].b}), vis[u2.id] = 1 ;
        }
        else if( qB.size() == B ) {
            Ans += toA ; 
            if( f1 )
                qB.pop(), qA.push((node){ -cnt1, 0 }), qB.push((node){s[u2.id].a - s[u2.id].b, 0}), vis[u2.id] = 1 ;
            else qA.push((node){s[u1.id].b - s[u1.id].a, 0}), vis[u1.id] = 1 ;
        }
        else if( toA < toB ) {
            Ans += toA ; 
            if( f1 ) 
                qB.pop(), qA.push((node){ -cnt1, 0 }), qB.push((node){s[u2.id].a - s[u2.id].b, 0}), vis[u2.id] = 1 ;
            else qA.push((node){s[u1.id].b - s[u1.id].a, 0}), vis[u1.id] = 1 ; ;
        }
        else {
            Ans += toB ; 
            if( f2 )
                qA.pop(), qB.push((node){ -cnt2, 0 }), qA.push((node){s[u1.id].b - s[u1.id].a, 0}), vis[u1.id] = 1 ;
            else
                qB.push((node){s[u2.id].a - s[u2.id].b}), vis[u2.id] = 1 ;
        }
        if( ( qA.size() == A ) && ( qB.size() == B ) ) break ; 
    }
    printf("%lld\n", Ans + num ) ; 
    return 0;
}

Measured memory_bytes: 14948
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<long long, long long> P;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<P> ab(n);
    for(int i = 0; i < n; i++)
    {
        P p;
        cin >> p.first >> p.second;
        ab[i] = p;
    }
    sort(ab.begin(), ab.end());
    int co = 0;
    long long ans = 0LL;
    for(int i = 0; i < n; i++)
    {
        if ((co+ab[i].second) <= m) {
            ans += ab[i].first*ab[i].second;
            co += ab[i].second;
        }
        else
        {
            ans += ab[i].first*(m-co);
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

//const int INF = 1e9 + 1;
//const ll LLINF = 1e17 + 1;
//const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
//const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
//const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================
	

	ll N;
	cin >> N;

	if (N % 2 == 1) {
		cout << 0;
		return 0;
	}

	ll beki = 0;
	while (true) {
		if (N >= pow(5, beki + 1) * 2) {
			beki++;
		}
		else {
			break;
		}

	}


	ll ans = 0;
	for (ll i = 1; i <= beki; i++) {

		ans += N / ((ll(pow(5, i)) * 2)) ;

	}
	   

	cout << ans ;


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>
#include <iomanip>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;

using namespace std;

ll n, m, k;
ll h, w;


int main(){
    ll n;
    cin >> n;
    vector<ll> ret(n,0);
    for (int i=1; i < 101; ++i){
        for (int j=1; j < 101 ; ++j){
            for(int k=1; k < 101; ++k){
                ll val = i*i + j*j + k*k + i*j + j*k + k*i;
                val -= 1;
                if(val < n) ret[val]+= 1;
            }
        }
    }
    for(int i=0; i<n; ++i){
        cout << ret[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3224
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      ArrayList<Integer> list = new ArrayList<Integer>();
      list.add(Integer.valueOf(input.next()));
      list.add(Integer.valueOf(input.next()));
      list.add(Integer.valueOf(input.next()));
      list.sort(Comparator.naturalOrder());
      System.out.println(list.get(0) + " " + list.get(1) + " " + list.get(2));
  }

}


Measured memory_bytes: 26116
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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

	double ave = sum / (double)n;
	int min;
	if(ave - (int)ave < 0.5) min = (int)ave;
	else min = (int)ave + 1;

	int cost = 0;
	for(int i = 0; i < n; i++){
		cost += (a[i] - min) * (a[i] - min);
	}

	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N,re = 0;
    int d[50];
    scanf("%d",&N);
    for(int i = 0;i < N;i++)scanf("%d",&d[i]);
    for(int i = 0;i < N;i++)
    {
        for(int j = 0;j < N;j++)
        {
            if(j == 0)j += i;
            if(j != i)re += d[i] * d[j];
        }
    }
    printf("%d",re);
    return 0;
}

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

int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    rep(i,k+1){
        rep(j,k+1){
            if(i+j<=s&&s-(i+j)<=k)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;vector<int>L(N);long long J=0;
  for(int X=0;X<N;X++){
    cin>>L[X];
  }
  sort(L.begin(),L.end());
  for(int X=0;X<N-2;X++){
    for(int Y=X+1;Y<N-1;Y++){
      for(int Z=Y+1;Z<N;Z++){
        if(L[X]+L[Y]>L[Z])J++;
        else break;
      }
    }
  }
  cout<<J<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
int S[22];
int D[111];

int dp[1<<15][101];

signed main(){
    while(cin>>N>>M,N||M){
        rep(i,N)cin>>S[i];
        rep(i,M)cin>>D[i];
        sort(D,D+M);

        fill_n(*dp,(1<<15)*101,INT_MAX);
        dp[0][0]=0;
        for(int i=0;i<1<<N;i++){
            int sum=0;
            rep(j,N)if(i>>j&1)sum+=S[j];
            for(int j=0;j<=M;j++){
                if(j!=M){
                    chmin(dp[i][j+1],dp[i][j]+abs(sum-D[j]));
                }
                for(int k=0;k<N;k++){
                    if(i>>k&1)continue;
                    chmin(dp[i|(1<<k)][j],dp[i][j]);
                }
            }
        }
        cout<<dp[(1<<N)-1][M]<<endl;
    }
    return 0;
}

Measured memory_bytes: 28916
N = int(input())

# kth entry: [max up to ak, bk, ck]
max_happiness = [[None] * 3 for _ in range(N)]

for k in range(N):
    if k == 0:
        max_happiness[k] = [int(n) for n in input().split()]
    else:
        ak, bk, ck = [int(n) for n in input().split()]

        a_opt, b_opt, c_opt = max_happiness[k-1]
        max_happiness[k][0] = ak + max(b_opt, c_opt)
        max_happiness[k][1] = bk + max(a_opt, c_opt)
        max_happiness[k][2] = ck + max(a_opt, b_opt)

print(max(max_happiness[-1]))


Measured memory_bytes: 64820
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

  int N;
  int A[110];
  cin >> N;
  REP(i,N) cin >> A[i];
  int ans=0;
  REP(i,N-1) for(int j=i+1;j<N;j++) ans=max(ans,abs(A[i]-A[j]));
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> count = new HashMap<String, Integer>();
		for(int i = 0 ; i < N ; ++i){
			String s = sc.next();
			if(count.containsKey(s)){
				int v = count.get(s);
				count.put(s, v + 1);
			}else{
				count.put(s, 1);
			}
		}
		int max = 0;
		for(String k : count.keySet()){
			int v = count.get(k);
			max = Math.max(max, v);
		}
		List<String> lst = new ArrayList<String>();
		for(String k : count.keySet()){
			int v = count.get(k);
			if(v == max){
				lst.add(k);
			}
		}
		Collections.sort(lst);
		for(String s : lst){
			System.out.println(s);
		}

	}
}


Measured memory_bytes: 86848
#include <stdio.h>

void run(int a[][25],int b[][25],int x,int y,int w,int h){
	if(x-1>=0&&b[x-1][y]==0&&a[x-1][y]==1){
		b[x-1][y]=1;
		run(a,b,x-1,y,w,h);
	}
	if(y-1>=0&&b[x][y-1]==0&&a[x][y-1]==1){
		b[x][y-1]=1;
		run(a,b,x,y-1,w,h);
	}
	if(x+1<=w-1&&b[x+1][y]==0&&a[x+1][y]==1){
		b[x+1][y]=1;
		run(a,b,x+1,y,w,h);
	}
	if(y+1<=h-1&&b[x][y+1]==0&&a[x][y+1]==1){
		b[x][y+1]=1;
		run(a,b,x,y+1,w,h);
	}
}

int get_ans(int b[][25],int w,int h){
	int i,j;
	int ans=0;
	for(i=0;i<w;i++){
		for(j=0;j<h;j++){
			if(b[i][j]==1)ans+=1;
		}
	}
	return ans;
}

int main(){
	int a[25][25];		//?????????1,?????????-1,?????¨??°???0
	int b[25][25];	//??°?????????????????????true
	int w,h;
	char c;
	int x,y;	//?????£???????????§?¨?
	int i,j,k,l;
	int ans;

	while(1){
		scanf("%d %d",&w,&h);
		scanf("%c",&c);
		if(w==0&&h==0)break;
		for(j=0; j<h; j++){
			for(i=0; i<w; i++){
				b[i][j]=0;
				scanf("%c",&c);
				if(c=='.')a[i][j]=1;
				if(c=='#')a[i][j]=-1;
				if(c=='@'){
					a[i][j]=0;
					x=i;
					y=j;
					b[x][y]=1;
				}
			}
			scanf("%c",&c);
		}
		// for(i=0; i<h; i++){
		// 	for(j=0; j<w; j++){
		// 		printf("%d ",a[j][i]);
		// 	}
		// 	printf("\n");
		// }
		// printf("\n\n");
		// for(i=0; i<h; i++){
		// 	for(j=0; j<w; j++){
		// 		printf("%d ",b[j][i]);
		// 	}
		// 	printf("\n");
		// }
		run(a,b,x,y,w,h);
		printf("%d\n",get_ans(b,w,h));
	}
	return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1234567;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    ll X;
    cin >> X;
    ll cnt = 100;
    for(int i = 1;i < 4000;i++) {
        cnt = cnt + (cnt / 100);
        if(cnt >= X) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

int a[1000], b[1000];
int c[1000];

int dp[1001][1<<12];

typedef pair<int, int> P;
P p[1000];

const int INF = 1e+8;

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        p[i] = P(a[i], i);
        for(int j = 0; j < b[i]; j++){
            int d;
            cin >> d;
            d--;
            int m = (1<<d);
            c[i] = c[i]|m;
        }
    }
    for(int i = 0; i < (1<<N); i++){
        dp[0][i] = INF;
    }
    dp[0][0] = 0;

    sort(p, p+N);

    for(int i = 0; i < M; i++){
        for(int j = 0; j < (1<<N); j++){
            dp[i+1][j] = dp[i][j];
        }
        int idx = p[i].second;
        for(int j = 0; j < (1<<N); j++){
            dp[i+1][j|c[idx]] = min(dp[i][j|c[idx]], dp[i+1][j|c[idx]]);
            dp[i+1][j|c[idx]] = min(dp[i+1][j|c[idx]], dp[i][j]+a[idx]);
        }
        
    }
    if(dp[M][(1<<N)-1] == INF){
        cout << -1 << endl;
        return 0;
    }
    cout << dp[M][(1<<N)-1] << endl;
}

Measured memory_bytes: 16256
#include<iostream>

using namespace std;

int main(void){

    int n;

    cin >> n;

    for(int i = 1;i <= 9;i++){
        if(n / i < 10 && n % i == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
[n,k] = [int(i) for i in input().split()]

dic = {}
for i in range(n):
    dic[i] = 0

for i in range(k):
    d = int(input())
    a = [int(i)-1 for i in input().split()]
    for j in a:
        dic[j] = 1
print(n-sum(dic.values()))


Measured memory_bytes: 67508
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

template<typename _T> void OutIter(_T beg, _T end, string separator = " ", bool eol = true) {
	cout << *beg;
	for (auto it = beg + 1; it != end; ++it) {
		cout << separator << *it;
	}
	if(eol)cout << endl;
}

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	IN_V(ll, hls, n);

	ll culh = hls[0], cnt = 0, cntmax = -1;
	REP(i, 1, n) {
		if (hls[i] > culh) {
			cntmax = max(cnt, cntmax);
			cnt = 0;
		}
		else {
			++cnt;
		}
		culh = hls[i];
	}
	cntmax = max(cnt, cntmax);

	cout << cntmax << endl;
	return 0;
}

Measured memory_bytes: 1024
while True :
    H, W = map(int, input().split())
    if H == 0 and W == 0 :
        break
    
    for h in range(H) :
        if h == 0 or h == H-1 :
            print("#" * W)
        else :
            print("#", "." * (W-2), "#", sep="", end="")
            print()
    print()


Measured memory_bytes: 5628
n = int(input())
t, a = list(map(int, input().split()))
H = list(map(int, input().split()))

h = 9999999
index = -1
for i, Hi in enumerate(H):
    if abs(a - (t - 0.006*Hi)) <= abs(a - (t - 0.006*h)):
        h = Hi
        index = i + 1
print(index)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.gir","r",stdin);freopen ("kmp.cik","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;

int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	ll k=0;
	fo(i,1,n)
		if(ar[i]!=i)
			k++;
	if(k>2)
		cout<<"NO";
	else
		cout<<"YES";


}



/*     cd onedrive\desktop\kod
cls


*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 1000000007;
int n;
int a[200000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int sumA = 0;
	rep(i, n) { sumA += a[i]; }
	
	int ans = 0;
	rep(i, n) {
		sumA -= a[i];
		
		ans += a[i] * (sumA % mod);
		ans %= mod;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5192
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

//最大公約数
ll gcd(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
//最小公倍数
//gcd関数を使用
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int main(){

	ll N, K;
	vector<ll> A;
	cin >> N >> K;
	A = vector<ll>(N);
	ll MAX = 0;
	for(int i = 0; i < N; i ++){
		cin >> A[i];
		MAX = max(MAX, A[i]);
	}
	for(int i = 1; i < N; i ++){
		A[i] = gcd(A[i - 1], A[i]);
	}
	ll G = A[N - 1];
	if(K <= MAX && K % G == 0)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
D = [0] * 100005
for i in range(N):
    a, b = map(int, input().split())
    D[a] += b

t = 0
for i in range(100005):
    t += D[i]
    if t >= K:
        print(i)
        exit()


Measured memory_bytes: 5748
/*
  Contest 063
  B - Varied
  Rakesh Kumar --> 28/08/2020
 */

#include <bits/stdc++.h>

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

    std::string s, d(26, '0');
    std::getline(std::cin, s);
    std::string r = "yes";
    for (char c : s) {
        if (d[c - 'a'] == '0') {
            d[c - 'a'] = '1';
        } else {
            r = "no";
            break;
        }
    }
    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
typedef long long ll;
using namespace std;

int A[500010], xsum[500010], prv[1100000]={}, zsum[500010];
ll dp[500010][2], mod=1000000007;

int main(void){
    int N;
    cin >> N;
    for(int i=0; i<N; ++i) cin >> A[i];
    xsum[0]=0;
    for(int i=0; i<N; ++i) xsum[i+1]=(xsum[i])^(A[i]);
    dp[0][0]=1;
    dp[0][1]=0;
    if(xsum[N]){
        for(int i=1; i<N; ++i){
            dp[i][0]=dp[i-1][0];
            dp[i][1]=dp[i-1][1];
            if(xsum[i]==0) (dp[i][0] += dp[i][1]) %= mod;
            if(xsum[i]==xsum[N]) (dp[i][1] += dp[i][0]) %= mod;
        }
        cout << dp[N-1][0] << endl;
        return 0;
    }
    zsum[0]=0;
    for(int i=1; i<N; ++i){
        zsum[i]=zsum[i-1];
        if(xsum[i]){
            int k=prv[xsum[i]];
            dp[i][0]=dp[k][0];
            dp[i][1]=dp[k][1];
            (dp[i][0] += (dp[i][1]*(zsum[i]-zsum[k]))%mod) %= mod;
            (dp[i][1] += dp[i][0]) %= mod;
            prv[xsum[i]]=i;
        }else{
            ++zsum[i];
        }
    }
    ll ans=1;
    for(int i=0; i<zsum[N-1]; ++i) (ans *= 2) %= mod;
    for(int i=N-1; i>0; --i){
        if(prv[xsum[i]]==i){
            (ans += dp[i][1]) %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];
int n,k;

int sz[N],dp[N],ed[N];
int dfs(int x, int p)
{
    int ret = 0;

    sz[x] = 1;
    for(int nx:G[x])if(nx!=p)
    {
        ret = max(ret,dfs(nx,x));
        sz[x] += sz[nx];
    }
    if(sz[x]==1) dp[x] = -1;

    int ct = 0;
    for(int nx:G[x])if(nx!=p)
    {
        dp[x] = max(dp[x],dp[nx]);
        ed[x] = max(ed[x],ed[nx]);
        ct += (sz[nx]>=k);
    }
    ed[x] = max(ed[x],ct);

    int g0=-1, g1=-1;
    for(int nx:G[x])if(nx!=p)
    {
        int tmp = ct - (sz[nx]>=k);
        dp[x] = max(dp[x],ed[nx]+tmp);
        ed[x] = max(ed[x],ed[nx]+tmp);

        int tg = ed[nx]-(sz[nx]>=k);
        if(g1<tg) g1=tg;
        if(g0<g1) swap(g0,g1);
    }
    dp[x] = max(dp[x],ct+g0+g1);

    ret = max(ret,dp[x]+(n-sz[x]>=k));
    return ret;
}

int main()
{
    scanf(" %d %d", &n, &k);
    rep(i,n-1)
    {
        int u,v;
        scanf(" %d %d", &u, &v);
        --u; --v;
        G[u].pb(v);
        G[v].pb(u);
    }

    printf("%d\n", dfs(0,-1));
    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    while (cin >> n >> k) {
        VI A(n);
        FOR(i,0,n) {
            char c; cin >> c;
            A[i] = c == 'R';
        }
        int i = 0;
        while (i < n-1 && k) {
            if (A[i] != A[i+1]) {
                int j = i+1;
                while (j < n && A[j] == A[i+1])
                    j++;
                FOR(p,i+1,j)
                    A[p] ^= 1;
                k--; i = j;
            }
            else
                i++;
        }
        i = 0; int ans = 0;
        while (i < n) {
            int j = i;
            while (j < n && A[j] == A[i])
                j++;
            ans += j-i-1; i = j;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 640
S = list(input())
T = list(input())
SL = len(S)
TL = len(T)
ans = 1000
for i in range(SL - TL +1):
  count = 0
  for j in range(TL):
    if S[i+j] != T[j]:
      count += 1
  ans = min(ans,count)
print(ans)
    

Measured memory_bytes: 9112
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int cnt[1000000] = {};
int main(){
    int n,t;
    cin >> n >> t;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]--;
    }
    long long ans = 0;
    long long now = 0;
    for(int i = 0;i < t;++i){
        now += cnt[i];
        ans = max(ans,now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3468
n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a

l = [None]*n
r = [None]*n
tmp = 0
for i in range(n):
    tmp = gcd(tmp, a[i])
    l[i] = tmp
tmp = 0
for i in range(n-1, -1, -1):
    tmp = gcd(tmp, a[i])
    r[i] = tmp
ans = max(l[-2], r[1])
for i in range(n-2):
    ans = max(ans, gcd(l[i], r[i+2]))
print(ans)

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A < 6) {
    cout << 0 << endl;
  }
  if (A >= 6 && A <= 12) {
    cout << B / 2 << endl;
  }
  if (A > 12) {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 1e3 + 10;
struct NODE{
	int x, y, step;
	NODE(){}
	NODE(int a, int b, int c){x = a; y = b; step = c;} 
	bool operator < (const NODE & other)
	const{return step > other.step;}
}now; 
priority_queue<NODE>que;
char mp[N][N];
int vist[N][N], dist[N][N];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
int n, m, SX, SY, EX, EY;
int bfs()
{
	for(int i = 1;i <= n; i++)
		for(int j = 1;j <= m; j++)
			dist[i][j] = -1;
	que.push(NODE{SX, SY, 0});
	while(que.empty() == 0)
	{
		now = que.top();
		que.pop();
		int x = now.x;	int y = now.y;
		dist[x][y] = now.step;
		if(x == EX && y == EY)
			return dist[x][y];
		if(vist[x][y])	continue;
		vist[x][y] = 1;
		for(int i = 0; i < 4; i++)
		{
			int xx = x + dx[i]; int  yy = y + dy[i];
			if(xx > 0 && xx <= n && yy > 0 && yy <= m &&mp[xx][yy] == '.' && vist[xx][yy] == 0)
			{
				que.push(NODE(xx, yy, now.step));
			}
		}
		for(int i = -2; i <= 2; i++)
			for(int j = -2; j <= 2; j++)
			{
				int xx = x + i;	int yy = y + j;
				if(xx > 0 && xx <= n && yy > 0 && yy <= m &&mp[xx][yy] == '.' && vist[xx][yy] == 0)
				{
					que.push(NODE(xx, yy, now.step + 1));
				}
			}
	}
	return -1;
}
int main()
{
	scanf("%d%d", &n, &m);
	scanf("%d%d", &SX, &SY);
	scanf("%d%d", &EX, &EY);
	for(int i = 1; i <= n; i++)
		scanf("%s", mp[i] + 1);
	cout<<bfs()<<endl;
	return 0;
}

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

int main()
{
  unordered_set<string> used;
  int n;
  cin >> n;
  char pre = ' ';
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (pre != ' ' && pre != s.front()) {
      cout << "No\n";
      return 0;
    }
    pre = s.back();
    if (used.find(s) != used.end()) {
      cout << "No\n";
      return 0;
    }
    used.insert(s);
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	cin >> N;
	Vec< int > A(N);
	for_(i,0,N) cin >> A[i];
	Vec< int > B = A;
	sort(allof(B));
	for_(i,0,N) {
		if (A[i] == B[N-1]) cout << B[N-2] << endl;
		else cout << B[N-1] << endl;
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main(){
	
	ll X,K,Q;cin >> X >> K;
	vector<pair<ll,ll>> v;
	REP(i,K){
		ll r;cin >> r;
		v.EB(r,-1);
	}
	cin >> Q;
	REP(i,Q){
		ll a, b;cin >> a >> b;
		v.EB(a,b);
	}
	
	sort(ALL(v));
	
	ll minX = 0;
	ll minY = 0;
	ll maxX = X;
	ll maxY = X;
	ll type = -1;
	ll nowT = 0;
	
	REP(i,v.size()){
		minY += type * (v[i].FI - nowT);
		if(minY < 0){
			minX -= minY;
			minY = 0;
		}
		if(minY > X)minY = X;
		maxY += type * (v[i].FI - nowT);
		if(maxY > X){
			maxX -= (maxY - X);
			maxY = X;
		}
		if(maxY < 0)maxY = 0;
		maxX = max(maxX,minX);
		//cout << v[i].FI << " " << v[i].SE << " " << minX << " " << minY << " " << maxX << " " << maxY << endl;
		
		if(v[i].SE == -1)type = -type;
		else {
			if(v[i].SE <= minX){
				cout << minY << endl;
			}
			else if(v[i].SE < maxX){
				cout << minY + (v[i].SE - minX) << endl;
			}
			else {
				cout << maxY << endl;
			}
		}
		nowT = v[i].FI;
	}
	
	return 0;
}


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

public class Main {

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

      int count=0;
      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      String[] line = br.readLine().split(" ");
      for (int i=0; i < n; i++) {
        seq[i] = Integer.parseInt(line[i]);
      }

      for(int i=0,f=1,t; i<n || f==1; i++ ) {
        f=0;
        for(int j=n-1; j>0; j-- ) {
          if( seq[j] < seq[j-1]) {
            t = seq[j];
            seq[j] = seq[j-1];
            seq[j-1] = t;
            count++;
            f=1;
          }
        }
      }

      StringBuilder s = new StringBuilder();
      for (int i : seq) { s.append(i).append(" "); }
      s.setLength(s.length()-1);
      s.append("\n").append(count);
      System.out.println(s);
    }
  }
}


Measured memory_bytes: 24492
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()

int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}


signed main() {
	int A, B;
	cin >> A >> B;
	cout << lcm(A, B);
}

Measured memory_bytes: 888
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>

using namespace std;

int N, M;
int A[100005], B[100005];

set<pair<int, int> > S;
int num[100005];
vector<int> Adj[100005];
vector<int> V;

int P[100005];
int d[100005];

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= N - 1 + M; i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= N - 1 + M; i++) {
		num[B[i]]++;
		Adj[A[i]].push_back(B[i]);
	}

	for (int i = 1; i <= N - 1 + M; i++) {
		S.insert(pair<int, int>(num[i], i));
	}

	while (S.size() > 0) {
		pair<int, int> Q = *(S.begin());
		int U = Q.second;
		int H = Q.first;
		V.push_back(U);
		S.erase(Q);
		for (int i = 0; i < (int)Adj[U].size(); i++) {
			int G = Adj[U][i];
			S.erase(pair<int, int>(num[G], G));
			num[G]--;
			S.insert(pair<int, int>(num[G], G));
		}
	}

	/*for (int i = 0; i < (int)V.size(); i++){
		cout << i<<" " <<V[i] << endl;
}*/

	for (int i = 0; i < (int)V.size(); i++) {
		int U = V[i];
		for (int j = 0; j < (int)Adj[U].size(); j++) {
			int H = Adj[U][j];
			if (d[H] < d[U] + 1) { d[H] = d[U] + 1; P[H] = U; }
		}
	}

	for (int i = 1; i <= N; i++) {
		cout << P[i] << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 13436
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

int main()
{
    LL a,b,x,t1,t2;
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x==0)
        t1=a/x;
    else
        t1=a/x+1;
    t2=b/x;
    printf("%lld\n",t2-t1+1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> split(const string &s, char c){
	vector<string> vs;
	size_t prev = 0, cur;
	while((cur = s.find(c, prev)) != string::npos){
		vs.push_back(s.substr(prev, cur - prev));
		prev = cur + 1;
	}
	vs.push_back(s.substr(prev));
	return vs;
}

int count_indent(const string &s){
	int answer = 0;
	while(s[answer] == ' '){ ++answer; }
	return answer;
}

struct Node {
	bool has_child;
	string name;
	string value;
	vector<Node> children;
	// parse
	int row;
	Node() : has_child(false), name(), value(), children() { }
};

vector<Node> mapping(const vector<string> &s, int r, int indent){
	vector<Node> result;
	while(r < s.size()){
		string cur = s[r];
		if(count_indent(cur) != indent){ break; }
		cur = cur.substr(indent);
		vector<string> vs = split(cur, ':');
		Node n;
		n.name = vs[0];
		if(vs.size() == 2 && vs[1] == ""){
			// has child
			n.has_child = true;
			if(r + 1 < s.size()){
				int next_indent = count_indent(s[r + 1]);
				if(next_indent > indent){ n.children = mapping(s, r + 1, next_indent); }
			}
			n.row = r = n.children.back().row;
		}else if(vs.size() >= 2){
			// value
			n.value = cur.substr(vs[0].size() + 2);
			n.row = ++r;
		}
		result.push_back(n);
	}
	return result;
}

void recur(const vector<Node> &t, const vector<string> &q, int p);
void recur(const Node &n, const vector<string> &q, int p){
	if(p == q.size()){
		if(n.has_child){
			cout << "object" << endl;
		}else{
			cout << "string \"" << n.value << "\"" << endl;
		}
	}else{
		recur(n.children, q, p);
	}
}
void recur(const vector<Node> &t, const vector<string> &q, int p){
	bool found = false;
	for(int i = 0; i < t.size(); ++i){
		if(t[i].name == q[p]){
			recur(t[i], q, p + 1);
			found = true;
			break;
		}
	}
	if(!found){
		cout << "no such property" << endl;
	}
}

int main(){
	string q;
	getline(cin, q);
	vector<string> yaml;
	while(!cin.eof()){
		string s;
		getline(cin, s);
		if(s != ""){ yaml.push_back(s); }
	}
	vector<Node> tree = mapping(yaml, 0, 0);
	vector<string> query = split(q.substr(1), '.');
	recur(tree, query, 0);
	return 0;
}

Measured memory_bytes: 1456
s = input()
n = len(s)
flag = 1
for i in range(int(n/2)):
    if s[i] != s[n-i-1]:
        flag = 0
        break
n2 = int((n-1)/2)
if flag == 1:
    for i in range(int(n2/2)):
        if s[i] != s[n2-i-1]:
            flag = 0
            break
if flag == 1:
    print("Yes")
else:
    print("No")


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

int main(){
    int N,M,*K,**A,i,*count,cnt=0;
    cin >> N >> M;
    K = new int[N];
    A = new int*[N];
    count = new int[M];
    for(i=0;i<M;i++){
        count[i] = 0;
    }
    for(i=0;i<N;i++){
        cin >> K[i];
        A[i] = new int[K[i]];
        for(int j=0;j<K[i];j++){
            cin >> A[i][j];
            count[A[i][j]-1]++;
        }
    }
    for(i=0;i<M;i++){
        if(count[i]==N){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int x, a, b;
  cin >> x >> a >> b;

  if (a >= b) cout << "delicious" << endl;
  else if (a + x >= b) cout << "safe" << endl;
  else cout << "dangerous" << endl;


  
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<pair<int,int>> p(n);




	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		p.at(i-1)=pair<ll, ll>(a, i);
	}
	sort(p.begin(),p.end(),greater<pair<int,int>>());

	multiset<ll> mset;
	mset.insert(0); mset.insert(0);
	mset.insert(n + 1); mset.insert(n + 1);
	long long ans=0;
	
	for (auto q : p) {
		auto v = q.first;
		auto i = q.second;
		auto r = mset.lower_bound(i);
		auto rr = next(r);
		auto l = prev(r);
		auto ll = prev(l);
		mset.insert(i);

		ans += ((*l - *ll)*(*r - i) + (*rr - *r)*(i - *l))*v;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main() {
    int x, y;
    int flag = 0;
    scanf("%d %d", &x, &y);
    int group[12] = {1, 3, 5, 7, 8, 10, 12, 4, 6, 9, 11, 2};
    int group2[12] = {0};
    for (int i = 0; i < 12; i++){
        if (x == group[i]){
            group2[i]++;
        }
        if (y == group[i]){
            group2[i]++;
        }
    }

    for (int i = 0; i < 12; i++){
        if (i == 7 || i == 11){
            flag = 0;
        }
        flag += group2[i];
        if (flag == 2){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;

};

Measured memory_bytes: 256
import math
import itertools

N=int(input())
xy=[list(map(int,input().split())) for i in range(N)]

li=list(range(N))
co=[]
sum=0

for i in itertools.permutations(li,N):
    co.append(list(i))

for i in range(len(co)):
    for j in range(N-1):
        sum+=((xy[co[i][j]][0]-xy[co[i][j+1]][0])**2+(xy[co[i][j]][1]-xy[co[i][j+1]][1])**2)**(1/2)
print(sum/len(co))

Measured memory_bytes: 10356
s = input()
n = int(input())

for _ in range(n):
    line = input().split()
    order = line[0]
    a = int(line[1])
    b = int(line[2])
    p = line[3] if len(line) == 4 else ''

    if order == 'print':
        print(s[a:b+1])
    elif order == 'reverse':
        s = s[:a] + ''.join(reversed(s[a:b+1])) + s[b+1:]
    elif order == 'replace':
        s = s[:a] + p + s[b+1:]

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  
  bool b = true;
  for (int i = 0; i < n; i++) {
    if (v.at(i) % 2 == 0) {
      if (v.at(i) % 3 != 0 && v.at(i) % 5 != 0) {
        b = false;
      }
    }
  }
  
  if (b) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val n = readInputLine().toInt()
    val cnt = IntArray(n)

    val person = readInputLine().split(" ").map { it.toInt() - 1 }

    for (i in n - 2 downTo 0) {
        cnt[person[i]]++
    }

    cnt.forEach {
        pw.println(it)
    }

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s;cin>>s;
    ll k;cin>>k;
    char n=s[0];
    vl c;
    ll cnt=0,ans=0;
    for(int i=0;i<s.size();++i){
        if(s[i]==n)cnt++;
        else{
            n=s[i];
            c.PB(cnt);
            cnt=1;
        }
    }
    c.PB(cnt);
    if(c.size()==1){
        cout<<s.size()*k/2<<endl;
        return 0;
    }
    ll m=0;
    if(s[0]==s[s.size()-1]){
        m=c[0]+c[c.size()-1];
        for(int i=1;i<c.size()-1;++i){
            ans+=c[i]/2*k;
        }
        ans+=c[0]/2+c[c.size()-1]/2+m/2*(k-1);
    }
    else{
        rep(i,c.size()){
            ans+=c[i]/2*k;
        }
    }
    cout<<ans<<endl;
}


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

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#define fi first
#define se second
#define x first
#define y second
#define pb push_back
#define last(s) (s)[(s).size()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
#define time chas
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define files freopen("little.in", "r", stdin);freopen("little.out", "w", stdout);

using namespace std;

using llong = long long;
using ld = long double;
using itn = int;
using ii = pair<int,int>;\
using ull = unsigned long long;
using pll = pair<llong, llong>;
using psi = pair<string, int>;
using ll = pair<llong, llong>;

const llong over999 = 1e9;
const ld over999ld = 1e18+1;
const llong md = 1e9+7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
const llong nich = 0;
const int mnogo = 300;

/**/

int n, m, d, p[100010], a[400][400], q;
ii pt[100010];

int dist(ii x, ii y){
    return abs(x.fi - y.fi) + abs(x.se - y.se);
}

int32_t main() {
    kchay;
    
    cin >> n >> m >> d;
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
            pt[a[i][j]] = {i, j};
        }
    }
    
    for(int i = 1; i <= d; i++){
        for(int j = i+d; j <= n*m; j += d){
            p[j] = p[j-d] + dist(pt[j-d], pt[j]);
        }
    }
    
    cin >> q;
    while(q--){
        int x, y;
        cin >> x >> y;
        if(x > y)swap(x, y);
        cout << p[y] - p[x] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main()
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll d=n/k;
    ans=d*d*d;
    if(k%2==0)
    {
        if(n%k>=k/2)
        {
            d+=1;
        }
        ans+=(d*(d)*(d));
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(0<=A&&0<=C) {
    //cout << "ぬーん" << endl;
    C-=B;
    if(C<=0) {
      cout << "Yes" << endl;
      return 0;
    }
    A-=D;
    if(A<=0) {
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3648
a,b,c,d = map(int, input().split())
x = a//d
y = c//b


if a % d == 0 :
    x = a//d
else:
    x += 1


if c % b == 0 :    
    y = c//b
else:
    y += 1
    
if y <= x:
    print('Yes')
else:
    print('No')


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

int main(){
    
    int W, H;
    cin>>W>>H;
    
    int x, y, r;
    cin>>x>>y>>r;
    
    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
    cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
     return 0;
}


Measured memory_bytes: 3100