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

int main(){
    int n,m;
    cin >> n >> m;
    int taro,hanako;
    bool flag;
    int x,y;
    while (n || m){
        taro = 0;
        hanako = 0;
        vector<int> taro_card(n);
        for (int i = 0; i<n; i++){
            cin >> taro_card[i];
            taro += taro_card[i];
        }
        vector<int> hanako_card(m);
        for (int i = 0; i<m; i++){
            cin >> hanako_card[i];
            hanako += hanako_card[i];
        }
        sort(taro_card.begin(), taro_card.end());
        sort(hanako_card.begin(), hanako_card.end());
        flag = false;
        x = -1;
        for (int i = 0; i<n; i++){
            for (int j = 0; j<m; j++){
                if (taro - taro_card[i]*2 + hanako_card[j]*2 == hanako){
                    x = taro_card[i];
                    y = hanako_card[j];
                    flag = true;
                    break;
                }
            }
            if (flag) break;
        }
        if (x==-1) cout << -1 << endl;
        else cout << x << " " << y << endl;
        cin >> n >> m;
    }
}



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

const int D = 80*160+10;
bitset<D*2> dp[81][81];

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

    int h, w;
    cin >> h >> w;
    vector<vector<int>> ab(h, vector<int>(w));
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> ab[i][j];
        }
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            int x;
            cin >> x;
            ab[i][j] = abs(ab[i][j] - x);
        }
    }

    dp[0][0][D-ab[0][0]] = 1;
    dp[0][0][D+ab[0][0]] = 1;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(i){
                dp[i][j] |= dp[i-1][j] << ab[i][j];
                dp[i][j] |= dp[i-1][j] >> ab[i][j];
            }
            if(j){
                dp[i][j] |= dp[i][j-1] << ab[i][j];
                dp[i][j] |= dp[i][j-1] >> ab[i][j];
            }
        }
    }
    int res = D*2;
    for(int i = 0; i < D*2; ++i){
        if(dp[h-1][w-1][i]) res = min(res, abs(i-D));
    }
    cout << res << endl;
}

Measured memory_bytes: 20864
#include<bits/stdc++.h>
#define int long long

using namespace std ;

const int N = 1e5 +5 ;
int dp[N][3] ;
signed main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    int n  ;
    cin >> n ;
    vector<vector<int>> ar(n) ;

    for(int i = 0 ; i  <n ; ++i)
    {
        vector<int> v(3)  ;
        for(int j = 0 ; j < 3 ;++j )
        {
            cin >>v[j] ;
        }

        ar[i] = v ;


    }


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

            dp[i][j] = max(dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3]) + ar[i-1][j] ;

        }
    }
    cout << *max_element(dp[n] , dp[n]+3) << endl ;






}


Measured memory_bytes: 11064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;


int main(void) {
	int n, m, i, g[100003], t, r, b;
	string s;
	vector<int> ans;

	cin >> n >> m >> s;

	for (i = n; i >= 0; i--) {
		if (s[i] == '0') t = i;
		g[i] = t;
	}

	r = n;
	while (r > 0) {
		b = g[max(0, r - m)];
		if (b >= r) {
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(r - b);
		r = b;
	}

	for (i = ans.size() - 1; i >= 0; i--) {
		cout << ans[i] << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>C;
    matP pro(C,vp(0));
    rep(i,N){
        cin>>A>>B>>M;
        --M;
        pro[M].emplace_back(A, B);
    }
    rep(i,C) sort(pro[i].begin(), pro[i].end());
    ll ans = 0;
    vec now(C,0);
    reps(i,1,(1e+5)+1){
        ll temp = 0;
        rep(j,C) {
            if(now[j] >= pro[j].size()) continue;
            if(pro[j][now[j]].se < i) ++now[j];
            if(now[j] >= pro[j].size()) continue;
            if((pro[j][now[j]].fi <= i) && (pro[j][now[j]].se >= i)) ++temp;
        }
        ans = max(ans, temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const LL N=505,mo=1e9+7;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,q,f[N][N];
int main()
{
	n=read();m=read();q=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		f[x][y]++;
	}
	for(int len=2;len<=n;len++){
		for(int i=1;i+len-1<=n;i++){
			int j=i+len-1;
			f[i][j]=f[i][j]+f[i+1][j]+f[i][j-1]-f[i+1][j-1];
		}
	}
	while(q--){
		int x=read(),y=read();
		printf("%d\n",f[x][y]);
	}
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX_V 100005
#define MAX_E 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef priority_queue<P> PQ;

int main(void) {
    ll n, m;
    cin >> n >> m;
    ll i, j;
    ll x[100001], y[100001];
    
    for(i=1; i<=n; i++)
        cin >> x[i];
    
    for(i=1; i<=m; i++)
        cin >> y[i];
    
    ll X=0, Y=0;
    
    for(i=1; i<=n; i++) {
        X+=(i*2-n-1)*x[i]%MOD;
        X%=MOD;
    }
    for(i=1; i<=m; i++) {
        Y+=(i*2-m-1)*y[i]%MOD;
        Y%=MOD;
    }
    
    prin((X*Y)%MOD);
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
const int mod = 1e9 + 7;

int32_t main()
{	
	fastio;
    
    int n; cin >> n;
    vector<int> a(n+1);
    unordered_map<int,int> mp;
   	for(int i=1; i<=n; i++){
   		cin >> a[i];
   		mp[i+a[i]]++;
   	}
   	int ans = 0;
   	for(int i=1; i<=n; i++){
   		ans += mp[i-a[i]];
   		//ans += mp[i+a[i]];
   	}
   	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19988
from collections import defaultdict
n, m = list(map(int, input().split()))
edge = defaultdict(list)
for i in range(m):
  a, b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
visited = [0 for i in range(n)]
ans = 0

def dfs(x, t):
  if t==n:
    return 1

  visited[x] = 1
  cur = 0
  for nx in edge[x]:
    if not visited[nx]:
      cur += dfs(nx, t+1)
  visited[x] = 0
  return cur

print(dfs(0, 1))

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;

int main(){
    ll x;cin>>x;
    ll a=100;
    ll count=0;
    while(true){
        a+=a/100;
        count++;
        if(a>=x) break;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#define maxn 55
std::vector<int> g[maxn] , r[maxn];

int dfn[maxn] , low[maxn] , ecc[maxn] , tot , n , m , idx;

std::stack<int> st;
void Tarjan(int x , int fx)
{
	dfn[x] = low[x] = ++idx;
	st.push(x);
	for(int i = 0 ; i < (int)g[x].size() ; ++i)
	{
		if(!dfn[g[x][i]])
		{
			Tarjan(g[x][i] , x);
			low[x] = std::min(low[x] , low[g[x][i]]);
		}
		else if(g[x][i] != fx) low[x] = std::min(low[x] , dfn[g[x][i]]);
	}
	if(dfn[x] == low[x])
	{
		++tot;
		while(st.top() != x)
		{
			ecc[st.top()] = tot;
			st.pop();
		}
		ecc[x] = tot;
		st.pop();
	}
}


inline void init()
{
	for(int i = 1 ; i <= 50 ; ++i) g[i].clear() , r[i].clear();
	std::memset(dfn,0,sizeof(dfn)) , std::memset(low , 0 , sizeof(low));
	tot = 0;
}

int main()
{
//	while(scanf("%d%d",&n,&m) != EOF)
//	{
		scanf("%d%d",&n,&m);
		for(int i = 1 ; i <= m ; ++i)
		{
			int x , y;
			scanf("%d%d",&x,&y);
			g[x].push_back(y) , g[y].push_back(x);
		}
		Tarjan(1 , 1);
		printf("%d\n",tot - 1);
//	}
}






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


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  ll n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  rep(i, q){
    int v;
    cin >> v;
    v--;
    a[i] = v;
  }

  vector<ll> score(n);

  for(int i = 0; i < q; ++i){
    score[a[i]]++;
  }

  rep(i, n){
    if(k - (q - score[i]) > 0){
      cout << "Yes" << endl;
    } else {
      cout << "No" <<endl;
    }
  }

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

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

int main() {
	int a,b; cin >> a >> b;
	int count = 0;
	for (int i = a; i <= b; i++){
		string s = to_string(i);
		int size = s.size();
		if (size%2 == 0){
			string a = s.substr(0,size/2);
			string b = s.substr(size/2, size/2);
			reverse(all(b));
			if (a == b){
				count++;
			}
		}else{
			string a = s.substr(0,size/2);
			string b = s.substr(size/2+1, size/2);
			reverse(all(b));
			if (a == b){
				count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int buwei(int x)
{
    return (x-(x%10)+10);
}

int main()
{
    int a[5];
    int min=9;
    int t,n,time=0;
    int i;
    scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
    for(i=0;i<5;i++)
    {
            t=a[i]%10;
            if(t<min&&t!=0)
            {
                n=i;
                min=t;
            }
    }
    for(i=0;i<5;i++)
        if(i!=n&&a[i]%10!=0)
            time+=buwei(a[i]);
        else
            time+=a[i];
    printf("%d\n",time);
    return 0;
}


Measured memory_bytes: 128
k = int(input())
g = [[0] * 200 for i in range(200)]
ans = 0

def gcd(a, b):
    if a > b:
        if b == 0:
            return a
        return gcd(b, a % b)
    else:
        if a == 0:
            return b
        return gcd(a, b % a)

for i in range(1, k + 1):
    for j in range(i, k + 1):
        for k in range(j, k + 1):
            if i == j and j == k:
                ans += gcd(i, gcd(j, k))
            elif i == j or j == k or k == i:
                ans += 3 * gcd(i, gcd(j, k))
            else:
                ans += 6 * gcd(i, gcd(j, k))
print(ans)

Measured memory_bytes: 9492
from collections import defaultdict as dd
f1,f2=True,True
s,t=input(),input()
ds,dt=dd(list),dd(list)

for i,c in enumerate(s):
  ds[c].append(i)
for i,c in enumerate(t):
  dt[c].append(i)

for i in ds.keys():
  if len({t[j] for j in ds[i]})!=1:f1=False
for i in dt.keys():
  if len({s[j] for j in dt[i]})!=1:f2=False

print("Yes" if f1 and f2 else "No")

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int dp[5][4001];

int main()
{

    dp[0][0] = 1;

    for (int i = 1; i <= 4; i++)
    {
        rep(j, 4001)
        {
            rep(k, 1001)
            {
                if (j - k >= 0)
                    dp[i][j] += dp[i - 1][j - k];
            }
        }
    }

    int n;
    while (cin >> n)
    {
        OP(dp[4][n]);
    }
    return 0;
}


Measured memory_bytes: 3164
S = input()
a = int(S[:2])
b = int(S[2:])

if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= a <= 12:
    print('MMYY')
elif 1 <= b <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	char a, b;

	cin >> a >> b;

	if (a == 'H' && b == 'H') {
		cout << "H" << endl;
	}else if (a == 'H' && b == 'D') {
		cout << "D" << endl;
	}
	else if(a == 'D' && b == 'H') {
		cout << "D" << endl;
	}
	else if(a == 'D' && b == 'D') {
		cout << "H" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d ", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,ans,kari;
  cin >> n >> a >> b >> c;
  int d[n];
  for(int i = 0;i < n;i++) cin >> d[i];
  sort(d,d+n);
  reverse(d,d+n);
  c += d[0];
  ans = c/(a+b);
  for(int i = 1;i < n;i++){
    c += d[i];
    if(ans < c/(a+b*(i+1)) ){
      ans = c/(a+b*(i+1));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3124
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstdlib>
using namespace std;
int a,b;
int main(){
    scanf("%d %d",&a,&b);
    if(a>0)printf("Positive\n");
    else if(a==0||(a<0&&b>0))printf("Zero\n");
    else if((abs(b)-abs(a))%2)printf("Positive\n");
    else printf("Negative\n");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_lst = [int(elem) for elem in input().split()]

res = 1
for a in a_lst:
  if a % 2 == 0:
    if a % 3 == 0 or a % 5 == 0:
      pass
    else:
      res = 0
      break
if res == 0:
  print("DENIED")
else:
  print("APPROVED")

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
long long n,i,j,f[100005][5],a[100005][5];
int main()
{
    cin>>n;
    for (i=1;i<=n;i++)
        for (j=1;j<=3;j++)
            cin>>a[i][j];
    f[1][1]=a[1][1];
    f[1][2]=a[1][2];
    f[1][3]=a[1][3];
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=3;j++)
        {
            if (j==1)
            {
                f[i][j]=max(f[i-1][2]+a[i][j],f[i-1][3]+a[i][j]);
            }
            if (j==2)
            {
                f[i][j]=max(f[i-1][1]+a[i][j],f[i-1][3]+a[i][j]);
            }
            if (j==3)
            {
                f[i][j]=max(f[i-1][1]+a[i][j],f[i-1][2]+a[i][j]);
            }
           // cout<<f[i][j]<<" ";
        }
       // cout<<endl;
    }
    cout<<max(f[n][1],max(f[n][2],f[n][3]));
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main(){
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c-=b;
        if(c<=0)break;
        a-=d;
        
    }
    if(c<=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3628
// =================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// =================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=2000+10;

struct Edge { int v,nxt; } e[N];
int head[N];

inline void addEdge(int u,int v) {
    static int cnt=0;
    e[++cnt]=(Edge){v,head[u]},head[u]=cnt;
}

int n;
int a[N],vis[N],deg[N];
int G[N][N];

inline void dfs(int u) {
    vis[u]=1;
    for (re int i=1;i<=n;++i) {
        if (vis[i]||!G[u][i]) continue;
        ++deg[i],addEdge(u,i);
        dfs(i);
    }
}

inline void topsort() {
    priority_queue<int> Q;
    for (re int i=1;i<=n;++i)
        if (!deg[i]) Q.push(i);
    while (!Q.empty()) {
        int u=Q.top(); Q.pop();
        printf("%d ",a[u]);
        for (re int i=head[u];i;i=e[i].nxt) Q.push(e[i].v);
    }
}

int main() {
    n=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1);
    for (re int i=1;i<=n;++i)
        for (re int j=i+1;j<=n;++j) {
            if (__gcd(a[i],a[j])==1) continue;
            G[i][j]=G[j][i]=1;
        }
    for (re int i=1;i<=n;++i)
        if (!vis[i]) dfs(i);
    topsort();
    return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    cout << (N - 1 + K - 2) / (K - 1) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    int dp[s.size() + 1][t.size() + 1];
    memset(dp, 0, sizeof(dp));

    for (auto i=0; i<s.size(); ++i)
    {
        for (int k = 0; k<t.size(); ++k)
        {
            // Sのi番目とTのj番目が同じ文字なら共通部分列
            if (s[i] == t[k])
                dp[i + 1][k + 1] = std::max(dp[i+1][k+1], dp[i][k] + 1);
            // 一致してなかったときはSのi文字目とTのj文字目までのLCSで大きい方
            else
            {
                dp[i + 1][k + 1] = std::max(dp[i+1][k+1], dp[i+1][k]);
                dp[i + 1][k + 1] = std::max(dp[i+1][k+1], dp[i][k+1]);
            }
        }
    }

    std::string result;
    int i = s.size();
    int j = t.size();
    while (0 < i && 0 < j)
    {
        // 一致してないので dp[i][j+1] のLCSで更新していた場合
        if (dp[i][j] == dp[i-1][j])
            i--;
        // 一致してないので dp[i+1][j] のLCSで更新していた場合
        else if (dp[i][j] == dp[i][j-1])
            j--;
        // s[i+1], t[j+1] が一致してた場合
        else
        {
            result = s[i-1] + result;
            i--;
            j--;
        }
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 38788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, C;
vector<pii> v[30];
int cum[200010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> C;
  for (int i = 0; i < N; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    v[c - 1].emplace_back(s, t);
  }
  for (int i = 0; i < C; i++) {
    sort(v[i].begin(), v[i].end());
    int l = 0, r = 0, vz = v[i].size();
    while (l < vz) {
      while (r + 1 < vz && v[i][r].second == v[i][r + 1].first) r++;
      cum[v[i][l].first * 2 - 1]++;
      cum[v[i][r].second * 2]--;
      l = ++r;
    }
  }
  int ans = cum[0];
  for (int i = 1; i < 200010; i++) {
    cum[i] += cum[i - 1];
    ans = max(ans, cum[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2304
import copy
N, K = map(int, input().split())

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

for k in range(K):
    next_array = [1] * N
    minus_array = [0] * N
    plus = 0
    for i in range(N):
        next_array[i] += plus
        plus += 1
        if i + A_array[i] < N:
            minus_array[(i + A_array[i])] += 1
        plus -= minus_array[i]

    minus_array = [0] * N
    plus = 0
    for i in range(N - 1, -1, -1):
        next_array[i] += plus
        plus += 1
        if i - A_array[i] >= 0:
            minus_array[(i - A_array[i])] += 1
        plus -= minus_array[i]
    A_array = copy.deepcopy(next_array)
    if A_array == [N] * N:
        break

print(" ".join(map(str, A_array)))


Measured memory_bytes: 181640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import defaultdict
mod = 10**9+7

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
xy.sort()
Ans = N
for i in range(N):
    for j in range(i+1, N):
        a, b = xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]
        ans = N
        for k in range(N):
            for l in range(k+1, N):
                if xy[k][0]+a == xy[l][0] and xy[k][1]+b == xy[l][1]:
                    ans -= 1
        Ans = min(Ans, ans)
print(Ans)


Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    vector<int> check(N);
    rep(i, N) check[i] = i + 1;
    int a = 0, b = 0;
    int cnt = 0;
    do {
        cnt++;
        if(P == check)
            a = cnt;
        if(Q == check)
            b = cnt;
    } while(next_permutation(All(check)));
    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
#E問題
N,M=map(int,input().split())
S=str(input())
Slist=list(S)
T=str(input())
Tlist=list(T)
#gcd(二つの数)
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
MINA=int(N*M/gcd(N,M))
n=int(MINA/N)
m=int(MINA/M)
flag=0
nn=int(M/n)
mm=int(N/m)
SS=[]
TT=[]
for i in range(mm):
    SS.append(Slist[i*m])
for i in range(nn):
    TT.append(Tlist[i*n])
if SS != TT:
    flag=1
if flag==0:
    print(MINA)
else:
    print(-1)

Measured memory_bytes: 4980
#include <stdio.h>

int main(void){
 
  int n , i;
  int ans=0;
  
	scanf("%d", &n);
	
	for(i=1; i<=n; i++){
		if(i >= 1 && i <= 9) ans++;
		if(i >= 100 && i <= 999) ans++;
		if(i >= 10000 && i <= 99999) ans++;
	}
  	printf("%d\n", ans);
 
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int N,M,sum=0;
  scanf("%d",&N);
  scanf("%d",&M);
  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    sum += A[i];
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(A[i] >= (double)sum/(4*M)){
      count++;
    }
  }
  if(count >= M){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

 
int main() {
    int n;
    cin>>n;
    vector<int> X(n),Y(n);
    rep(i,n)cin>>X[i];
    rep(i,n)Y[i]=X[i];
    sort(Y.begin(),Y.end());
    int t2=Y[n/2],t1=Y[n/2-1];
    rep(i,n){
       if(X[i]<=t1)cout<<t2<<endl;
       else cout<<t1<<endl;
    }
}

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

map<int, int> mp;
int a[100010];

int main()
{
	int n, m;
	cin >> n >> m;
	
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	sort(a, a + n);
	
	int x, y;
	
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		mp[y] += x;
	}
	
	long long ans = 0;
	
	for(int i = 0; i < n; i++)
	{
		if(mp.size() && mp.rbegin() -> first > a[i])
		{
			a[i] = mp.rbegin() -> first;
			mp.rbegin() -> second--;
			
			if(mp.rbegin() -> second == 0)
				mp.erase(mp.rbegin() -> first);
		}
		
		ans += a[i];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  sort(d.begin(),d.end());
  int ans=d[n/2]-d[(n/2)-1];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

int n,m,q;
int X[400],Y[400];
int h[7][7],t[7][7][7];

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

void putBall(int x,int y,int color){
  t[y][x][h[y][x]] = color;
  h[y][x]++;
}

bool judge(int color){
  rep(x,n){
    rep(y,n){
      rep(z,n){
        rep(d,13){


          int xx = x;
          int yy = y;
          int zz = z;
          int i = 0;

          while(0 <= xx && xx < n && 0 <= yy && yy < n && 0 <= zz && zz < n && t[yy][xx][zz] == color){
            xx += dx[d];
            yy += dy[d];
            zz += dz[d];
            i++;
          }
          if(i >= m) return true;
        }
      }
    }
  }
  return false;
}

int main(void){
  while(cin>>n>>m>>q,n||m||q){
    memset(h,0,sizeof(h));
    memset(t,-1,sizeof(t));

    rep(i,q){
      cin>>X[i]>>Y[i];
      X[i]--;
      Y[i]--;
    }

    int color = 0;
    bool printFlg = false;
    rep(i,q){
      putBall(X[i],Y[i],color);

      /*
      rep(z,n){
        rep(x,n){
          rep(y,n){
            printf("%2d",t[y][x][z]);
          }
          cout<<endl;
        }
        cout<<endl;
      }
      cout<<"--"<<endl;
      */

      if(judge(color)){
        printFlg = true;
        cout<<(color ? "White " : "Black ")<<i+1<<endl;
        break;
      }
      color = !color;
    }
    if(!printFlg) cout<<"Draw\n";
  }
}

Measured memory_bytes: 876
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

w = input()
import collections
c = collections.Counter(w)
for k, v in c.items():
    if v % 2 != 0:
        print('No')
        quit()
print('Yes')


Measured memory_bytes: 9308
program main
  implicit none

  character ( len = 10 ) :: ss, tt, uu
  integer :: aa, bb

  read *, ss, tt
  read *, aa, bb
  read *, uu

  if ( ss == uu ) then
     aa = aa - 1
  else if ( tt == uu ) then
     bb = bb - 1
  end if

  print *, aa, bb

end program main


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, P=1000000007, ans = 1;std::cin >> n;
  vll t(n), a(n);
  re(i, n) std::cin >> t[i];re(i, n) std::cin >> a[i];
  if(t[n-1]!=a[0]){
    std::cout << 0 << '\n';
    return 0;
  }
  bool flag = true;
  re(i, n){
    if((i==0||(t[i]!=t[i-1]))&&t[i]>a[i]) flag = false;
    if((i==0||(a[n-i-1]!=a[n-i]))&&a[n-i-1]>t[n-i-1]) flag = false;
  }
  if(!flag){
    std::cout << 0 << '\n';
    return 0;
  }
  re(i, n){
    if(!(i==0||(t[i]!=t[i-1]))&&!(i==n-1||(a[i]!=a[i+1]))){
      ans = (ans * min(a[i], t[i]))%P;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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


int main(){
    ll n;cin>>n;
    n=n%10;
    if(n==3)cout<<"bon"<<endl;
    else if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

    









Measured memory_bytes: 3640
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
 
void main() {
	auto X = readln.split[0].to!int;
	writeln(X == 7 || X == 5 || X == 3 ? "YES" : "NO");
}


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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7;
int n, a[N];

struct node
{
	pair<int, int> best;
	pair<int, int> best_pos;
	int fi, se;
	int fi_pos;
	int se_pos;
} t[2][4 * N], big;

inline node combine(node a, node b)
{
	if(b.best < a.best)
	{
		a.best = b.best;
		a.best_pos = b.best_pos;
	}
	if(mp(a.fi, b.se) < a.best)
	{
		a.best = mp(a.fi, b.se);
		a.best_pos = mp(a.fi_pos, b.se_pos);
	}
	if(b.fi < a.fi)
		a.fi = b.fi, a.fi_pos = b.fi_pos;
	if(b.se < a.se)
		a.se = b.se, a.se_pos = b.se_pos;
	return a;
}

inline void build(int v, int tl, int tr)
{
	if(tl == tr)
	{
		if(tl & 1)
		{
			t[0][v].best = mp(1e9, 1e9);
			t[0][v].best_pos = mp(1e9, 1e9);
			t[0][v].fi = a[tl];
			t[0][v].fi_pos = tl;
			t[0][v].se = 1e9;
			t[0][v].se_pos = 1e9;
			t[1][v].best = mp(1e9, 1e9);
			t[1][v].best_pos = mp(1e9, 1e9);
			t[1][v].fi = 1e9;
			t[1][v].se = a[tl];
			t[1][v].fi_pos = 1e9;
			t[1][v].se_pos = tl;
		}
		else
		{                     
			t[1][v].best = mp(1e9, 1e9);
			t[1][v].best_pos = mp(1e9, 1e9);
			t[1][v].fi = a[tl];
			t[1][v].fi_pos = tl;
			t[1][v].se = 1e9;
			t[1][v].se_pos = 1e9;
			t[0][v].best_pos = mp(1e9, 1e9);
			t[0][v].best = mp(1e9, 1e9);
			t[0][v].fi = 1e9;
			t[0][v].se = a[tl];
			t[0][v].fi_pos = 1e9;
			t[0][v].se_pos = tl;
		}
		return;
	}
	int tm = tl + tr >> 1;
	build(v + v, tl, tm);
	build(v + v + 1,tm + 1, tr);
	t[0][v] = combine(t[0][v + v], t[0][v + v + 1]);
	t[1][v] = combine(t[1][v + v], t[1][v + v + 1]);
}

inline node get(int id, int v, int tl, int tr, int l, int r)
{
	if(l > r) return big;
	if(tl == l && tr == r)
		return t[id][v];
	int tm = tl + tr >> 1;
	return combine(get(id, v + v, tl, tm, l, min(r, tm)), get(id, v + v + 1, tm + 1, tr, max(tm + 1, l), r)); 
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	vector<int> ans;
	fo(i, n)
		cin >> a[i];
	big.best = big.best_pos = mp(1e9, 1e9);
	big.fi = big.fi_pos = big.se = big.se_pos = 1e9;
	build(1, 1, n);
	set<pair<pii, pii > > q;
	q.insert(mp(t[0][1].best, mp(1, n)));
	while(!q.empty())
	{
		pair<pii, pii> cur = *q.begin();
		q.erase(q.begin());
		int l = cur.S.F, r = cur.S.S;
		int typo = ((l & 1) ^ 1);
		node res = get(typo, 1, 1, n, l, r);
		ans.pb(res.best.F);
		ans.pb(res.best.S);
		int nl = l;
		int nr = res.best_pos.F - 1;
		int nltypo = ((nl & 1) ^ 1);
		if(nl < nr)
			q.insert(mp(get(nltypo, 1, 1, n, nl, nr).best, mp(nl, nr)));
		nl = nr + 2;
		nr = res.best_pos.S - 1;
		nltypo = ((nl & 1) ^ 1);
		if(nl < nr)
			q.insert(mp(get(nltypo, 1, 1, n, nl, nr).best, mp(nl, nr)));
		nl = nr + 2;
		nr = r;
		nltypo = ((nl & 1) ^ 1);
		if(nl < nr)
			q.insert(mp(get(nltypo, 1, 1, n, nl, nr).best, mp(nl, nr)));
	}
	for(int x : ans)
		cout << x << ' ';
	return 0;
}

Measured memory_bytes: 55668
package main

import (
	"fmt"
)

func main(){
	var N int
	fmt.Scan(&N)
	L := make([]int, N)
	for i:=0; i<N; i++ {
		fmt.Scan(&L[i])
	}

	tri := 0
	for i:=0; i<N; i++ {
		for j:=i+1; j<N; j++ {
			for k:=j+1; k<N; k++ {
				if (L[i] == L[j]) || (L[j] == L[k]) || (L[k] == L[i]) {
					continue
				}

				if  (L[i] + L[j] <= L[k]) ||
					(L[j] + L[k] <= L[i]) ||
					(L[k] + L[i] <= L[j]){
					continue
				}
				tri++
			}
		}
	}
	fmt.Println(tri)
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vector<P> data(n);
    rep(i,n) {
        int x, y; cin >> x >> y;
        data[n-i-1] = P(x,y);
    }
    ll ans = 0;
    rep(i,n) {
        ll x = (ll)data[i].first+ans, y = (ll)data[i].second;
        ans += (x+y-1)/y*y-x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
	int n;
	cin >> n;
	int a[n + 1], b[n + 1];
	vector < int > g1, g2;
	for(int i = 1; i <= n; ++i)cin >> a[i] >> b[i];
	for(int i = 1; i <= n; ++i){
		g1.push_back(a[i]);
		g2.push_back(b[i]);
	}
	g1.push_back(-1);
	g2.push_back(-1);
	sort(g1.begin(), g1.end());
	sort(g2.begin(), g2.end());
	if(n % 2 == 1){
		cout << g2[(n + 1) / 2] - g1[(n + 1) / 2] + 1 << endl;
	}else{
		cout << g2[n / 2] + g2[n / 2 + 1] - g1[n / 2] - g1[n / 2 + 1] + 1 << endl;
	}
}

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

N = int(input())
A = list(map(int, input().split()))

ans = [0] * N

ans[0] = sum(A[::2]) - sum(A[1::2])
for i in range(1, N):
    ans[i] = A[i-1] * 2 - ans[i-1]

print(" ".join(map(str, ans)))


Measured memory_bytes: 19224
import java.util.*;

class Main{
    public static void main(String arg[]){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        String ans = a + b + c;
        int X = Integer.parseInt(ans);
        if(X % 4 == 0){
            System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int prime[10000],vis[100000]={1,1},cnt=0,b[100]={},l=0,v[10000],flag;
int main()
{
    for(int i=2;i<=300;i++)
        for(int j=i*i;j<=55555;j=j+i)
        if(!vis[j])
        vis[j]=1;
    for(int i=2;i<=55555;i++)
        if(!vis[i]&&i%5==1)
            prime[cnt++]=i;
    int n;
    while(cin>>n)
    {
        for(int i=0;i<n-1;i++)
            cout<<prime[i]<<" ";
        cout<<prime[n-1]<<endl;
    }
    return 0;
}


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

int main(){
    int n;
    int k;
    cin >> n;
    cin >> k;
    vector<int> v; 
    int a; 
    for (int i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
    }

    int count  = 0;
    for (auto i : v){
        // cout << i << " ";
        if (i >= k) count++;
    }

    cout << count << "\n";
    
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>k;

    for(int i=1;i<=n;i++)
        cin>>A[i];

    for(int i=1;i<n;i++)
        if(mx<A[i]+A[i+1]){
            mx = A[i]+A[i+1];
            idx = i;
        }

    if(A[idx]+A[idx+1]<k){
        cout<<"Impossible\n";
        return 0;
    }

    cout<<"Possible\n";

    for(int i=1;i<idx;i++)
        cout<<i<<"\n";

    for(int i=n-1;i>=idx+1;i--)
        cout<<i<<"\n";

    cout<<idx<<"\n";

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
    int W, H, x, y, r;

		cin >> W >> H >> x >> y >> r;

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

Measured memory_bytes: 3108
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;



int main(){
	
int n,m;
while(1){
	cout<<setprecision(20);
	cin>>n>>m;
	if(!n&&!m)break;
	double a=n,b=0,h=99999999999999;
	for(int i=0;i<=n/2;i++){
		double x=i,y=n-i;
		h=min(h,abs(sqrt(x*x+y*y)-m));


	}
	cout<<h<<endl;

}

	return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }

int main()
{
	//printf("使用可能な最大スレッド数：%d\n", omp_get_max_threads());

	int N;
	cin >> N;
	vvi D(N, vi(2));
	rep(i, N){
		cin >> D.at(i).at(0) >> D.at(i).at(1);
	}
	int cnt = 0;
	rep(i, N){
		if(D.at(i).at(0) == D.at(i).at(1)){
			cnt++;
			if(cnt == 3){
				Yes;
				return 0;
			}
		}else{
			cnt = 0;
		}
	}
	No;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
int  gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
namespace NTT {
	const int MOD = 998244353;  // to be set appropriately
	const long long PR = 3;     // to be set appropriately

	void trans(vector<long long> &v, bool inv = false) {
		int n = (int)v.size();
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k >(i ^= k); k >>= 1);
			if (i > j) swap(v[i], v[j]);
		}
		for (int t = 2; t <= n; t <<= 1) {
			long long bw = modpow(PR, (MOD - 1) / t, MOD);
			if (inv) bw = modinv(bw, MOD);
			for (int i = 0; i < n; i += t) {
				long long w = 1;
				for (int j = 0; j < t / 2; ++j) {
					int j1 = i + j, j2 = i + j + t / 2;
					long long c1 = v[j1], c2 = v[j2] * w % MOD;
					v[j1] = c1 + c2;
					v[j2] = c1 - c2 + MOD;
					while (v[j1] >= MOD) v[j1] -= MOD;
					while (v[j2] >= MOD) v[j2] -= MOD;
					w = w * bw % MOD;
				}
			}
		}
		if (inv) {
			long long inv_n = modinv(n, MOD);
			for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD;
		}
	}

	// C is A*B
	vector<long long> mult(vector<long long> A, vector<long long> B) {
		int size_a = 1; while (size_a < A.size()) size_a <<= 1;
		int size_b = 1; while (size_b < B.size()) size_b <<= 1;
		int size_fft = max(size_a, size_b) << 1;

		vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
		for (int i = 0; i < A.size(); ++i) cA[i] = A[i];
		for (int i = 0; i < B.size(); ++i) cB[i] = B[i];

		trans(cA); trans(cB);
		for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD;
		trans(cC, true);

		vector<long long> res((int)A.size() + (int)B.size() - 1);
		for (int i = 0; i < res.size(); ++i) res[i] = cC[i];
		return res;
	}
};
typedef pair<int, int>p;
p point[200003];
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i <n; i++) {
		cin >> point[i].first;
		point[i].second = 1;
	}
	for (int i = n; i <2*n; i++) {
		cin >> point[i].first;
		point[i].second = 0;
	}
	sort(point, point + 2 * n);
	int cnt = 0;
	int mode = 0;
	long long ans = 1;
	for (int i = 0; i < 2 * n; i++) {
		if (cnt == 0) {
			cnt += 1;
			mode = point[i].second;
		}
		else {
			if (point[i].second == mode) {
				cnt += 1;
			}
			else {
				ans *= cnt;
				ans %= 1000000007;
				cnt -= 1;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;  
int main() 
{
	FAST
	ll n;
	cin>>n;
  	ll a[n],m=0,c=0;
  	for(ll i=0;i<n;i++)
      	cin>>a[i];
 	for(ll i=1;i<n;i++)
    {
      	if(a[i-1]>=a[i])
        	c++;	
        else
        {
        	m=max(m,c);
        	c=0;
		}
    }
    m=max(m,c);
    cout<<m;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int a;
            int b;
            int c;
            int d;
            int x = 0;
            for (a = 0; a < 10; a++) {
                for (b = 0; b < 10; b++) {
                    for (c = 0; c < 10; c++) {
                        for (d = 0; d < 10; d++) {
                            if (a + b + c + d == n) {
                                x++;
                            }
                        }
                    }
                }
            }
            System.out.println(x);

        }
    }
}



Measured memory_bytes: 26732
#include <iostream>
#include <string>

using namespace std;

string solve(long long a, long long  b)
{
	if (a < 0 && b < 0) {
		if ((b - a + 1) % 2 == 0) {
			return "Positive";
		}
		else {
			return "Negative";
		}
	}
	else if (a > 0 && b > 0) {
		return "Positive";
	}
	else {
		return "Zero";
	}
}

int main()
{
	long long  a, b;
	cin >> a >> b;
	cout << solve(a, b) << endl;
}


Measured memory_bytes: 256
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
MOD = 10**9+7
for i in range(2, 10**5+10):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)

def comb(n, r, mod=MOD):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = int(input())
A = map(int, input().split())
d = {}
n1 = n2 = -1
for i, a in enumerate(A):
  if a in d:
    n1 = N - i
    n2 = d[a]
    break
  d[a] = i

ans = [0] * (N+1)
for k in range(1, N+2):
  ans[k-1] = (comb(N+1, k) - comb(n1+n2, k-1)) % MOD

print(*ans, sep='\n')

Measured memory_bytes: 40772
import std.stdio;

int gcd(int a, int b) {
	int gcd_(int x, int y) {
		if (y == 0) return x;
		return gcd_(y, x % y);
	}
	if (a > b) return gcd_(a, b);
	return gcd_(b, a);
}

void main() {
	int count;
	readf(" %s", &count);

	long sum;
	foreach (i;0..count) {
		foreach (j;0..count) {
			auto ij = gcd(i + 1, j + 1);
			foreach (k;0..count) {
				sum += gcd(ij, k + 1);
			}
		}
	}

	writeln(sum);
}


Measured memory_bytes: 2792
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

X, Y = map(int, input().split())
if (X+Y) % 3 != 0:
  print(0)
  exit()

n = (2*Y-X) // 3
m = (2*X-Y) // 3
if n < 0 or m < 0:
  print(0)
  exit()

ans = ncr(n+m,n,mod)
print(ans)

Measured memory_bytes: 3188