akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(void){

  while(1){ 
    int a = 1;//テ、ツクツ?
    int b = 2;//テ・ツ債?
    int c = 3;//テヲツ敖ア
    string s;
    int n;
    cin >> n;
    if( n == 0 )break;
    int sum = 1;
    for( int i = 0 ; i < n ; i++ ){
     
      cin >> s;

      if( s == "North" ) {
        int temp1 = b;
        b = 7 - a;
        a = temp1;
        sum += a;
      }
      else if( s == "East" ){
        int temp2 = c;
        c = a;
        a = 7 - temp2;
        sum += a;
      }
      else if( s == "West" ){
        int temp3 = c;
        c = 7 - a;
        a = temp3;
        sum += a;
      }
      else if( s == "South" ){
        int temp4 = a;
        a = 7 - b;
        b = temp4;
        sum += a;
      }
      else if( s == "Right" ){
        int temp5 = b;
        b = c;
        c = 7 - temp5;
        sum += a;
      }
      else if( s == "Left" ){
        int temp6 = c;
        c = b;
        b = 7 - temp6;
        sum += a;
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
# import numpy as np
import itertools

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# print(P)
	# 一度計算したサイクル情報をキャッシュしておくための配列
	# cycleIDs = np.full( N, -1, np.int64 )
	cycleIDs = [ -1 for _ in range(N)]
	cycleInfs = []
	cycleID = 0
	procCnt = 0

	for n in range(N):
		v = n

		if cycleIDs[v] != -1:
			continue
		else:
			currentCycleCosts = []
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleCosts.append( C[v] )
				cycleIDs[v] = cycleID

				v = P[v]
				if cycleIDs[v] != -1:
					# サイクル終了
					# ループを含めない最大の処理回数
					procCnt = K % len( currentCycleCosts )
					# それで足りてるのかわからないが、Last2周分は、ループ合計がプラスでも必ずしもループするとは限らない
					# その部分は、ちゃんと計算する
					# -------------------------------------------------
					# 4 101
					# 2 3 4 1
					# 50 -49 -50 50
					# 上記のようなパターンの場合、
					# 最大25回ループ + 1回処理可能だが、その場合、25 + 50 = 75
					# 24回ループ + 2回処理でやめると、124になる
					# 無条件でループする回数は、ループ可能な最大の回数-1らしい
					# -------------------------------------------------
					# 割り切れて、尚且つサイクル合計がマイナスのパターンで、最低１個は処理するのにもここで対応
					if len( currentCycleCosts ) + procCnt <= K:
						procCnt += len( currentCycleCosts )

					cycleInfs.append( ( procCnt, len(currentCycleCosts), currentCycleCosts * 3 ) )
					cycleID += 1
					break



	# scores = []
	# procCnt = 0
	ans = -10 ** 9
	for procCnt, currentCycleSize, currentCycleCosts in cycleInfs:

		# サイクル内でループしてスコアを稼ぐ場合の考慮
		loopScore = 0
		if sum(currentCycleCosts) > 0:
			cycleLoopCnt =  ( K - procCnt ) // currentCycleSize
			loopScore = cycleLoopCnt * sum(currentCycleCosts[:currentCycleSize])
			# print("loopScore",loopScore,procCnt)

		# このサイクルに属する全頂点分をまとめて計算する
		for i in range(currentCycleSize):
			# print(np.roll( currentCycleCosts, i ).cumsum()[:procCnt])
			score = max( itertools.accumulate( currentCycleCosts[i:i+procCnt] ) )
			if ans < score + loopScore:
				ans = score + loopScore
			# ans = max( ans, score + loopScore )


	print(ans)
	# print(max(scores))


Measured memory_bytes: 9960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool f[110];
int main(){
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		ll d;
		cin>>d;
		for(int j=0;j<d;j++){
			ll a;
			cin>>a;
			f[a]=1;
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++)if(!f[i])ans++;
	cout<<ans;
	return 0;
}


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

int a[100006];
int cnt[100006];

int main(){
  int n;
  int i;
  ll ans = 1;

  scanf("%d", &n);

  for(i = 0;i <= n;i++) cnt[i] = 0;

  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }

  if(n % 2 == 0){
    for(i = 1;i < n;i += 2){
      if(cnt[i] != 2){
        printf("0\n");
        return 0;
      }
    }

    n = n/2;
    for(i = 0;i < n;i++) ans = ans*2 % MODSIZE;
    printf("%lld\n", ans);
  }

  else {
    if(cnt[0] != 1){
      printf("0\n");
      return 0;
    }

    for(i = 2;i < n;i += 2){
      if(cnt[i] != 2){
        printf("0\n");
        return 0;
      }
    }

    n = n/2;
    for(i = 0;i < n;i++) ans = ans*2 % MODSIZE;
    printf("%lld\n", ans);
  }

  return 0;
}


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

using namespace std;

#define ll long long

int main() {
    double n;   cin >> n;
    cout << fixed << setprecision(4) << acos(-1) * 2 * n ;
}



// 5 3 1 1 4

// 1 2 3 4 5

// 4 100 1000

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,m,i,sum=0;
  cin>>n>>m;
    vector<long> a(m+1);
  for(i=0;i<m;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  if(n-sum>=0){
    cout<<(n-sum)<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder stdout = new StringBuilder();
		String s1 = sc.next();
		String s2 = new StringBuilder(sc.next()).reverse().toString();
		if(s1.equals(s2)){
			stdout.append("YES");
		}else{
			stdout.append("NO");
		}
		System.out.println(stdout);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k; k--;
    char x = s[k];
    rep(i, s.size()) {
        if(s[i]!=x) s[i] ='*';
    }
    print(s);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
  int N,i=0,sum=0;
  scanf("%d",&N);
  int A[N],B[N-1];
  while(i!=N-1){
    scanf("%d",&B[i++]);
  }
  for(i=0;i<N;i++) A[i]=0;
  i=1;
  
  A[0]=B[0]; A[N-1]=B[N-2];
  if(i<=N-2){
    while(i!=N-1){
      A[i]=B[i-1];
      if(A[i]>B[i]) A[i]=B[i];
      i++;
    }
  }
  for(i=0;i<N;i++) sum+=A[i];
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=610;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,d1,d2,id[N][N],col[N*N][2],tot=0;
pii p[N*N];
vector<pii> E[2];
void work(int d,int t) {
    for(int i=0;i<=n&&d-i*i>=0;i++) {
        int j=sqrt(d-i*i);
        if(i*i+j*j!=d) continue;
        E[t].pb(mp(i,j));
        E[t].pb(mp(-i,j));
        E[t].pb(mp(i,-j));
        E[t].pb(mp(-i,-j));
    }
}
bool in(int x) {
    return 0<=x&&x<=n;
}
void dfs(int u,int t) {
    for(pii d:E[t]) {
        int x=p[u].fi+d.fi,y=p[u].se+d.se,v;
        if(!in(x)||!in(y)||~col[v=id[x][y]][t]) continue;
        col[v][t]=col[u][t]^1,dfs(v,t);
    }
}
int main() {
    n=gi(),d1=gi(),d2=gi(),n=2*n-1;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++) id[i][j]=++tot,p[tot]=mp(i,j);
    work(d1,0),work(d2,1);
    memset(col,-1,sizeof(col));
    for(int i=1;i<=tot;i++)
        for(int j=0;j<2;j++) if(col[i][j]==-1) col[i][j]=1,dfs(i,j);
    n=(n+1)>>1;
    for(int i=1,cnt=0;i<=tot;i++) {
        if(col[i][0]&&col[i][1]) {
            ++cnt;
            printf("%d %d\n",p[i].fi,p[i].se);
            if(cnt==n*n) break;
        }
    }
    return 0;
}


Measured memory_bytes: 30592
n, m = map(int, input().split())
L = []
P = []
for i in range(m):
    a, b = map(int, input().split())
    L.append(a)
    P.append(b)
ans = min(P) - max(L) + 1
if(ans > 0):
    print(ans)
else:
    print('0')


Measured memory_bytes: 11016
import java.util.Scanner;

/**
 * Structured Program II
 */
public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);
        // 中間試験の点数 m、期末試験の点数 f、再試験の点数 r
        int m,f,r, sum;
        String seiseki = "";
        while (true) {
            m = scan.nextInt();
            f = scan.nextInt();
            r = scan.nextInt();
            sum = m + f;
            if (m == -1 && f == -1) {
                return;
            } else if (m < 0 || f < 0) {
                seiseki = "F";
            } else if (sum >= 80) {
                seiseki = "A";
            } else if (sum >= 65 && sum < 80) {
                seiseki = "B";
            } else if (sum >= 50 && sum < 65) {
                seiseki = "C";
            } else if (sum >= 30 && sum < 50) {
                seiseki = "D";
                if (r >= 50) {
                    seiseki = "C";
                }
            } else if (sum < 30) {
                seiseki = "F";
            }
            System.out.println(seiseki);
        }
    }
}

Measured memory_bytes: 19372
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    a[i] %= 2;
  }
  if (count(a,a+N,1)) {
    cout << "first";
  } else {
    cout << "second";
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  ll r = 0, ans = 0;
  ll sum = 0;
  for (ll l = 0; l < N; l++) {
    while (r < N && (sum + A[r]) == (sum ^ A[r])) {
      sum += A[r];
      r++;
    }
    ans += r - l;
    if (r == l) r++;
    else sum -= A[l];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n;
        while (cin >> n) {
                int a[100005], t1 = 0, t2 = 0;
                for (int i = 0; i < n; i++) {
                        cin >> a[i];
                        if (a[i] % 4 == 0) {
                                t1++;
                        }
                        if (a[i] % 2 == 0 && a[i] % 4 != 0) {
                                t2++;
                        }
                }
                int t = t1 * 2 + 1 + t2;
                if (t1 == 0) {
                        t--;
                }
                if (t2 % 2 == 1) {
                        t--;
                }
                if (t >= n) {
                        cout << "Yes" << endl;
                } else {
                        cout << "No" << endl;
                }
        }
        return 0;
}


Measured memory_bytes: 640
import  numpy

A = int(input())
B = int(input())
C = int(input())
X = int(input())

lisA=list(range(A+1))
lisB=list(range(B+1))
lisC=list(range(C+1))

vA=numpy.repeat(lisA, len(lisB)*len(lisC))
vB=numpy.repeat(len(lisA)*lisB, len(lisC))
vC=numpy.repeat(len(lisA)*len(lisB)*lisC,1)


O = numpy.matrix([500,100,50])
P = numpy.array([vA,vB,vC]).reshape(3,len(vA))
Q = O*P
ans=numpy.sum(Q==X)

print(ans)


Measured memory_bytes: 19844
a = []
for i in range(3):
    a.append([int(i) for i in input().split()])

x = 0
for i in range(3):
    if i == 0:
        a00 = a[i][0]
        a01 = a[i][1]
        a02 = a[i][2]
    else:
        if a[i][0] - a00 != a[i][1] - a01 or a[i][0] - a00 != a[i][2] - a02:
            x = 1
        if a[i][1] - a01 != a[i][0] - a00 or a[i][1] - a01 != a[i][2] - a02:
            x = 1
        if a[i][2] - a02 != a[i][0] - a00 or a[i][2] - a02 != a[i][1] - a01:
            x = 1

for i in range(3):
    if i == 0:
        a00 = a[0][i]
        a01 = a[1][i]
        a02 = a[2][i]
    else:
        if a[0][i] - a00 != a[1][i] - a01 or a[0][i] - a00 != a[2][i] - a02:
            x = 1
        if a[1][i] - a01 != a[0][i] - a00 or a[1][i] - a01 != a[2][i] - a02:
            x = 1
        if a[2][i] - a02 != a[0][i] - a00 or a[2][i] - a02 != a[1][i] - a01:
            x = 1

if x == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int H = sc.NextInt();
        int N = sc.NextInt();
        int[] A = sc.IntArray();
        long sum = 0;
        foreach (int i in A)
        {
            sum += i;
        }

        Console.WriteLine(sum >= H ? "Yes" : "No");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

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

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

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

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

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

        return result;
    }

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

        return result;
    }

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

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 16864
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
  
int main()
{
    int h,w,n;
    cin>>h>>w>>n;
    cout<<(n+max(h,w)-1)/max(h,w);
}

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


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

	int arr[n];


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

	double ans = 0;

	for(int i=0;i<n;i++)
	{
		ans+=(1.0/arr[i]);
	}

	ans = 1/ans;

	cout<<ans;
    
    
    return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

ll x,y;
int main() {
    scanf("%lld%lld",&x,&y);
    if(x%y == 0) pout(-1);
    else printf("%lld\n",x);
    return 0;    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt(),flag=0;
		for(int i=a;i<=b;i++) {
			if(i%k==0) {
				flag=1;
				System.out.println("OK");
				break;
			}
		}
		if(flag==0) System.out.println("NG");
	}
}

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

    auto clk=clock();
    typedef long long ll;
    typedef long double ld;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    #define F first
    #define S second
    #define PB push_back
    #define MP make_pair
    #define Mod 1000000007
    #define REP(i,a,b) for (int i = a; i <= b; i++)
    #define all(x) x.begin(),x.end()

    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n; cin>>n;
        vector<int>v(n);
        for(int i=0;i<n;i++) cin>>v[i];
        sort(all(v));
        int ans=0;
        for(int i=2;i<n;i++){
            for(int j=0;j<i-1;j++){
                int k=(v.begin()+i-upper_bound(v.begin()+j+1,v.begin()+i,v[i]-v[j]));
                ans+=k;
            }
        }
        cout<<ans;
        cerr<<"\n"<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<"\n";
        return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define N 15000001
int main()
{
   ll a,b,c;
  cin>>a>>b>>c;
  cout<<max(0LL,c-(a-b));
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,k[1000],p[1000],i,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k[i],&p[i]);
		if(k[i]>=p[i]){
			a=k[i]%p[i];
			if(a==0){
				printf("%d\n",p[i]);
			}
			if(a!=0){
				printf("%d\n",a);
			}
		}
			else	if(k[i]<=p[i]){
				printf("%d\n",k[i]);
			}
	}
	return 0;
}


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

using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

template<typename T>
struct fenwick_tree {
   int tree_n = 0;
   vector<T> tree;
   
   fenwick_tree(int n = -1) {
      if (n >= 0)
         init(n);
   }
   
   void init(int n) {
      tree_n = n;
      tree.assign(tree_n + 1, 0);
   }
   
   // index is in [0, tree_n).
   void update(int index, const T &change) {
      assert(0 <= index && index < tree_n);
      for (int i = index + 1; i <= tree_n; i += i & -i)
         tree[i] += change;
   }
   
   // Returns the sum of the range [0, count).
   T query(int count) const {
      assert(count <= tree_n);
      T sum = 0;
      for (int i = count; i > 0; i -= i & -i)
         sum += tree[i];
      return sum;
   }
   
   // Returns the sum of the range [a, b).
   T query(int a, int b) const {
      return query(b) - query(a);
   }
   
   bool set(int index, T value) {
      assert(0 <= index && index < tree_n);
      T current = query(index , index + 1);
      if (current == value)
         return false;
      update(index, value - current);
      return true;
   }
};

struct query {
   int l , r , id;
   query(int _l , int _r , int _id) {
      l = _l;
      r = _r;
      id = _id;
   }
   
   bool operator < (const query& other) const {
      if(r == other.r) {
         return l < other.l;
      }
      return r < other.r;
   }
};

const int N = 5 * 1e5 + 5;

signed main() {
   fio;
   int n , q; cin >> n >> q;
   vector<int> a(n) , answer(q);
   for(int &it : a) {
      cin >> it;
   }
   vector<query> b;
   for(int i = 0; i < q; i++) {
      int l , r; cin >> l >> r;
      --l;
      --r;
      b.push_back({l , r , i});
   }
   
   sort(b.begin() , b.end());

   fenwick_tree<int> tree(N);
   vector<int> last(N , -1);
   int cur = 0;
   for(int i = 0; i < n; i++) {
      int it = a[i];
      if(last[it] == -1) {
         last[it] = i;
         tree.update(i , 1);
      } else {
         tree.update(last[it] , -1);
         last[it] = i;
         tree.update(i , 1);
      }
      while(cur < q and b[cur].r == i) {
         answer[b[cur].id] = tree.query(b[cur].l , b[cur].r + 1);
         cur++;
      }
   }
   
   for(int i = 0; i < q; i++) {
      cout << answer[i] << endl;
   }

   return 0;
}




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

int main()
{
    string s;
    cin>>s;
    string t="";
    int c=0;
    int n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            t+=s[i];
            c=0;
        }
        else if(s[i]=='1'){
            t+=s[i];
            c=0;
        }
        else{
            c++;
            t+="*";
            if(i-(c*2-1)<0){
                continue;
            }
            else{
                t[i-(c*2-1)]='*';
            }

        }
    }

    int nx=t.size();
    string ans="";
    for(int i=0;i<nx;i++){
        if(t[i]=='*'){
            continue;
        }
        else{
            ans+=t[i];
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	ans := 0
	for i := range make([]struct{}, n-1) {
		j := i + 1

		dic1 := map[rune]struct{}{}
		for _, v := range s[j:] {
			dic1[v] = struct{}{}
		}

		dic2 := map[rune]struct{}{}
		for _, v := range s[:j] {
			dic2[v] = struct{}{}
		}

		cnt := 0
		for k := range dic1 {
			if _, in := dic2[k]; in {
				cnt++
			}
		}
		if cnt > ans {
			ans = cnt
		}
	}
	fmt.Print(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int x){
  if(x < 2) return false;
  else if (x == 2) return true;
  if(x % 2 == 0) return false; //偶数を消去
  for(int i=3; i*i<=x; i+=2){ //偶数を消去することで＋２ずつできる。
    if(x % i == 0) return false;
  }
  return true;
}

int main(){
  int n,x;
  int cnt = 0;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> x;
    if(isPrime(x)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3092
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int[] b = new int[3];

		int count = 0;

		for (int i = 1; i < n - 1; i++) {
			b[0] = a[i - 1];
			b[1] = a[i];
			b[2] = a[i + 1];
			Arrays.sort(b);
			if (b[1] == a[i])
				count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
def func(acc, tmp, N):
    for i in range(tmp,N):
        if acc[i]==0:
            return i
    return -1

N,M=[int(x) for x in input().split()]
con=[[] for i in range(N+1)]
acc=[0 for i in range(N+1)]
for m in range(M):
    X,Y,Z=[int(x) for x in input().split()]
    con[X].append(Y)
    con[Y].append(X)
ans=1
acc[0]=1
acc[1]=1
focus=[1]
L=1
tmp=1
while(L<N):
    newfocus=[]
    if len(focus)==0:
        c=func(acc, tmp, N)
        tmp=c+1
        focus=[c]
        acc[c]=1
        ans+=1
        L+=1
    for f in focus:
        for c in con[f]:
            if acc[c]==0:
                newfocus.append(c)
                acc[c]=1
                L+=1
    focus=newfocus[:]
print(ans)

Measured memory_bytes: 71072
import java.util.Scanner;


public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int line = Integer.parseInt(sc.nextLine());
		int n = Integer.parseInt(sc.nextLine());

		int[] values = new int[line];
		for(int i=0;i<line;i++){
			values[i] = i+1;
		}

		for(int i=0;i<n;i++){
			String[] s = sc.nextLine().split(",");
			int a = Integer.parseInt(s[0]);
			int b= Integer.parseInt(s[1]);

			int value = values[a-1];
			values[a-1] = values[b-1];
			values[b-1] = value;
		}

		for(int i=0;i<line;i++){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 17180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200025,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,g[N][2],b[N],fa[N],ans[N];
vector<int> e[N];
struct segment_tree{
	int siz,root[N],f[N*50],ch[N*50][2];
	void add(int x,int l,int r,int pos){
		f[x]++;
		if (l==r) return;
		int mid=(l+r)>>1;
		if (pos<=mid){
			if (!ch[x][0]) ch[x][0]=++siz;
			add(ch[x][0],l,mid,pos);
		}
		else{
			if (!ch[x][1]) ch[x][1]=++siz;
			add(ch[x][1],mid+1,r,pos);
		}
	}
	void add(int x,int pos){
		if (!root[x]) root[x]=++siz;
		add(root[x],1,n,pos);
	}
	int merge(int x,int y,int l,int r){
		if (!x) return y;if (!y) return x;
		int cur=++siz,mid=(l+r)>>1;f[cur]=f[x]+f[y];
		ch[cur][0]=merge(ch[x][0],ch[y][0],l,mid);
		ch[cur][1]=merge(ch[x][1],ch[y][1],mid+1,r);
		return cur;
	}
	void merge(int x,int y){root[x]=merge(root[x],root[y],1,n);}
	int count(int x,int val){
		if (!val) return 0;
		int l=1,r=n,mid;x=root[x];
		while (x&&(l!=r)){
			mid=(l+r)>>1;
			if (val<=mid) r=mid,x=ch[x][0];
			else l=mid+1,x=ch[x][1];
		}
		return f[x];
	}
}f[2];
void work(int x,int fa){
	if (x>g[fa][0]) g[x][0]=x,g[x][1]=g[fa][0];
	else if (x>g[fa][1]) g[x][0]=g[fa][0],g[x][1]=x;
	else g[x][0]=g[fa][0],g[x][1]=g[fa][1];
	b[x]=(g[x][0]==fa) ? x : b[fa];
	f[0].add(x,g[x][0]);
	f[1].add(x,g[x][1]);
	for (auto y : e[x])
	if (y!=fa){
		work(y,x);
		f[0].merge(x,y);
		f[1].merge(x,y);
	}
}
void calc(int x,int fath){
	fa[x]=fath;
	if (x==g[x][0]) ans[x]=ans[fa[x]]+f[1].count(x,g[x][1]);
	else{
		int y=g[x][0];
		ans[x]=ans[fa[y]]+f[0].count(b[x],y)+f[1].count(y,g[y][1])-f[1].count(b[x],g[y][1]);
	}for (auto y : e[x])
	if (y!=fath) calc(y,x);
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		e[u].push_back(v);
		e[v].push_back(u);
	}
	work(1,0);
	calc(1,0);
	for (int i=2;i<=n;i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 261632
#include<stdio.h>

int main()
{
    int n;
    int a, b;

    scanf("%d", &n);
    a = n / 100;
    b = n % 100;

    if ((1 <= a) && (12 >= a)) {
        if ((1 <= b) && (12 >= b)) {
            printf("AMBIGUOUS\n");
        }
        else printf("MMYY\n");
    }
    else if ((1 <= b) && (12 >= b)) {
        printf("YYMM\n");
    }
    else {
        printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (n / (a + b)) * a + min(a, n % (a + b));
}


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

int main(){
    int k,n;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int b=n-1;
    int c=k-1;
    cout << (b+c-1)/c  << endl;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.lang.*;
public class Main {
	
		
		public static void main(String[] args) throws IOException {
			java.util.Scanner scan = new java.util.Scanner(System.in);
		int x = scan.nextInt();
			
//			BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
//			String str = br.readLine();
//			int x = Integer.parseInt(str);
//			
		if(1<=x || x<=100){;
		System.out.println(x*x*x);// TODO ?????????????????????????????????????????????
		}
		}	
			
		
	
	}
	

Measured memory_bytes: 26224
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
             long long int tmp;
             long long int r = 1;
             if (b > a) {
                           tmp = a;
                           a = b;
                           b = tmp;
             }
             r = a % b;
             while (r != 0) {
 
 
                           a = b;
                           b = r;
                           r = a % b;
 
             }
             return b;
}

const long long int mod=1000000007;
int main(){
	long long int n,m;
	string str[30][30];
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
		cin>>str[i][j];

		if(str[i][j]=="snuke"){cout<<(char)(j+'A')<<i+1<<endl;}
		}
	}
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,a[100001],i,left = 0,ans = 0;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    a[i] = 1000000001;

    qsort(a,n + 1,sizeof(int),asc);

    if(n != 1)
    {
        for (i = 1; i < n + 1; i++)
        {
            if(a[i] != a[i - 1])
            {
                ans += (i - left) % 2;
                left = i;
            }
        }
        printf("%d\n",ans);
    }
    else
    {
        printf("1\n");
    }
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(nullptr)
#define INF (1LL<<62)-1
#define F first
#define S second
#define pb push_back

ll dp[102][100002];

ll dosomething(ll w, ll n, vector<ll> &wt, vector<ll> &val, ll i)
{
    if(i>=n || w<=0) return 0;
    if(dp[i][w]!=-1) return dp[i][w];

    if(wt[i]>w) dp[i][w] = dosomething(w,n,wt,val,i+1);
    else dp[i][w] = max(dosomething(w,n,wt,val,i+1), val[i]+dosomething(w-wt[i],n,wt,val,i+1));

    return dp[i][w];
}

int main()
{
    FASTIO;
    for(ll i=0;i<102;i++) for(ll j=0;j<100002;j++) dp[i][j]=-1;
    ll n,w;
    cin>>n>>w;
    vector<ll> wt(n),val(n);
    for(ll i=0;i<n;i++) cin>>wt[i]>>val[i];

    cout<<dosomething(w,n,wt,val,0)<<"\n";
}

Measured memory_bytes: 83332
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

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

	return ans;
}


const int MOD = 1000000007;

int main() {
	int x, y, X, Y;
	cin >> x >> y >> X >> Y;
	int w = X - x;
	int h = Y - y;
	REP(i, h) {
		cout << "U";
	}
	REP(i, w)cout << "R";
	REP(i, h)cout << "D";
	REP(i, w)cout << "L";

	cout << "L";
	REP(i, h + 1)cout << "U";
	REP(i, w + 1)cout << "R";
	cout << "D";

	cout << "R";
	REP(i, h + 1)cout << "D";
	REP(i, w + 1)cout << "L";
	cout << "U";
	return 0;
}




Measured memory_bytes: 256
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
constexpr auto mod = 1000000007;

using namespace std;
 


int main() {
int n,k;
  vector<int> h(n);
  cin>>n>>k;
  rep(i,n){
    cin>>h.at(i);
  }
  sort(all(h));
  reverse(all(h));
  
  for(int i=0;i<k&&i<n;i++){
    h.at(i)=0;
  }
  
  long int sum=0;
  rep(i,n){
    sum+=h.at(i);
  }
  cout<<sum;
}


Measured memory_bytes: 16640
N, W = map(int, input().split())
vw = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    value = vw[i][0]
    weight = vw[i][1]
    for w in range(W + 1):
        if w >= weight:
            dp[i + 1][w] = max(dp[i][w - weight] + value, dp[i][w])
        else:
            dp[i + 1][w] = dp[i][w]
print(dp[-1][-1])



Measured memory_bytes: 41880
#include <bits/stdc++.h>
using namespace std;
using Grid = vector<vector<int>>;

int	calc_dist(int w, int h, const vector<vector<int>>& w_wall,
		const vector<vector<int>> &h_wall)
{
	Grid	dist(h, vector<int>(w, -1));
	queue<pair<int, int>>	que;
	int	dx[4] = {1, 0, -1, 0};
	int	dy[4] = {0, 1, 0, -1};
	int sx = 0, sy = 0, gx = w - 1, gy = h - 1;
	int cx, cy, nx, ny;
	que.push(make_pair(sy, sx));
	dist.at(sy).at(sx) = 1;
	while (!que.empty() && dist.at(gy).at(gx) == -1) {
		cy = que.front().first;
		cx = que.front().second;
		que.pop();
		for (int i = 0; i < 4; ++i) {
			ny = cy + dy[i];
			nx = cx + dx[i];
			if (ny < 0 || h <= ny || nx < 0 || w <= nx)
				continue;
			if (i % 2 == 0 && w_wall.at(cy).at(min(nx, cx)))
				continue;
			if (i % 2 == 1 && h_wall.at(min(cy, ny)).at(cx))
				continue;
			if (dist.at(ny).at(nx) != -1)
				continue;
			dist.at(ny).at(nx) = dist.at(cy).at(cx) + 1;
			que.push(make_pair(ny, nx));
		}
	}
	return max(0, dist.at(gy).at(gx));
}

int	main()
{
	int	w, h;
	while (cin >> w >> h) {
		if (w == 0 && h == 0)
			break;
		vector<vector<int>>	w_wall(h, vector<int>(w - 1));
		vector<vector<int>>	h_wall(h - 1, vector<int>(w));
		for (int i = 0; i < 2 * h - 1; ++i) {
			if (i % 2 == 0) {
				for (int j = 0; j < w - 1; ++j)
					cin >> w_wall.at(i / 2).at(j);
			} else {
				for (int j = 0; j < w; ++j)
					cin >> h_wall.at(i / 2).at(j);
			}
		}
		cout << calc_dist(w, h, w_wall, h_wall) << endl;
	}
}


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

int main() {
  string S;
  cin >> S;

  if (S=="Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S=="Cloudy"){
    cout << "Rainy" << endl;
  }
  else if (S=="Rainy"){
    cout << "Sunny" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500;
ll n;
ll A[N][N], B[N][N], F[N][N];

int main() {
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			scanf("%lld",&A[i][j]);
			B[i][j] = A[i][j];
		}
	}	
//	for(int i=0;i<n;i++) {
//		for(int j=0;j<n;j++) {
//			cout<<A[i][j]<<" ";
//		}
//		cout<<endl;
//	}	
	
	for(int k=0;k<n;k++) {
		for(int i=0;i<n;i++) {
			if(i == k)continue;
			for(int j=0;j<n;j++) {
				if(j == i || j == k)continue;
				if(A[i][j] == A[i][k] + A[k][j])
					F[i][j] = 1;
				if(A[i][j] > A[i][k] + A[k][j])
					A[i][j] = A[i][k] + A[k][j];	
			}
		}
	}
//	for(int i=0;i<n;i++) {
//		for(int j=0;j<n;j++) {
//			cout<<F[i][j]<<" ";
//		}
//		cout<<endl;
//	}	
	bool flag = false;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(A[i][j] < B[i][j]) {
				flag = true;
			}
		}
	}	
	
	if(flag)puts("-1");
	else {
		ll tot = 0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				if(!F[i][j])tot += A[i][j];
			}
		}
		cout<<tot<<endl;
	}
	return 0;
}

Measured memory_bytes: 4608
N, M = [int(x) for x in input().split()]
K = [[0]*N]*M
for i in range(M):
  K[i] = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
total = 0
for i in range(2 ** N):
    lamp = [0] * N
    for j in range(N):
        if ((i >> j) & 1):
            lamp[j] = 1
    flag = True
    for x in range(M):
      result = 0
      for y in K[x][1:]:
        if lamp[y-1] == 1:
          result += 1
      result %= 2
      if result != P[x]:
        flag = False
    if flag:
      total += 1
print(total)

Measured memory_bytes: 3188
/*
This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks.

We can simulate the movement (comings and goings) of the cars as follow:

An entry of a car is represented by its number.
An exit of a car is represented by 0
For example, a sequence

1 6 0 8 10
demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter.

Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.
 */
 
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	vector<int> cars(100000), ans;
	int temp, i=0, m;
	while (cin >> temp) {
		if (temp != 0) {
			cars[i] = temp;
			i++;
		} else {
			int p = i-1;
			if (p >= 0) {
				ans.push_back(cars[p]);
				i--;
			}
		}
	}
	for (int j=0; j<ans.size(); j++)
		cout << ans[j] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
  int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int find = 1;
  for (int i = 0; i < N; i++) {
    if (a[i] == find) {
      ans++;
      find++;
    }
  }
  if (ans == 0) {
    cout << -1 << endl;
  }
  else {
    cout << N - ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n;cin>>n;
  map<ll,ll> count;
  ll min = LINF, max = -LINF;
  rep(i,n){
    ll a;cin>>a;
    if(count.count(a) == 0){
      count[a] = 0;
    }
    count[a]++;
    chmin(min, a);
    chmax(max, a);
  }
  
  if(n==2){
    if(min == 1 && max == 1){
      cout<<"Possible"<<endl;
    }else{
      cout<<"Impossible"<<endl;
    }
    return 0;
  }

  if(count[min] >= 3){
    cout<<"Impossible"<<endl;
    return 0;
  }
  if(count[min] == 2){
    if(min * 2 - 1 < max){
      cout<<"Impossible"<<endl;
      return 0;
    }
  }else{
    if(min * 2 < max){
      cout<<"Impossible"<<endl;
      return 0;
    }
  }
  for(int i = min+1; i <= max; i++){
    if(count[i] <= 1){
      cout<<"Impossible"<<endl;
      return 0;
    }
  }
  cout<<"Possible"<<endl;
  return 0;
}

Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a>b:
    a_l = a-(t*v)
    b_l = b-(t*w)
    if b_l >= a_l:
        print('YES')
    else:
        print("NO")

elif b>a:
    a_l = a+(t*v)
    b_l = b+(t*w)
    
    if a_l >= b_l:
        print('YES')
    else:
        print("NO")



Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    ll i,x=0,p;
    p=stoi(s);
   // cout<<p<<endl;
    for(i=0;i<s.size();i++)
    {
        x+=s[i]-'0';
    }
    if(p%x==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	int cost = 700;
	string s;
	cin >> s;

	if (s[0]=='o') {
		cost = cost + 100;
	}

	if (s[1] == 'o') {
		cost = cost + 100;
	}

	if (s[2] == 'o') {
		cost = cost + 100;
	}

	cout << cost << endl;

	return 0;
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define NIL NULL
 
struct node {
  struct node *p;
  struct node *l;
  struct node *r;
  int key;
};
 
typedef struct node * Node;
Node root;
 
void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node,int);
 
int main(){
  int m,k,i;
  char str[10];
 
  scanf("%d",&m);
 
  for(i = 0; i < m; i++){
    scanf("%s",str);
 
    if(str[0] == 'i') {
      scanf("%d",&k);
      insert(k);
    }
    else if(str[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(str[0] == 'f'){
    	scanf("%d",&k);
    	if(treeSearch(root,k) != NIL) printf("yes\n");
    	else printf("no\n");
  	}
  }
  return 0;
}
 
void insert(int z){
   Node x,y,a;
 
  y = NIL;
  x = root;
  a = (Node)malloc(sizeof(struct node));
 
  a->key = z;
  a->l = NIL;
  a->r = NIL;
 
  while(x != NIL){
    y = x;
    if(a->key < x->key) x = x->l;
    else x = x->r;
  }
  a->p = y;
 
  if( y == NIL) root = a;
  else if(a->key < y->key) y->l = a;
  else y->r = a;
   
}
 
void inorder(Node root){
  if(root == NIL) return;
  inorder(root->l);
  printf(" %d",root->key);
  inorder(root->r);
}
 
void preorder(Node root){
  if(root == NIL){
    return;}
  printf(" %d",root->key);
  preorder(root->l);
  preorder(root->r);
}
Node treeSearch(Node root,int z){
	if(root == NIL || z == root->key) return root;
	else if(z < root->key) return treeSearch(root->l,z);
	else return treeSearch(root->r,z);
}

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

int main() {
  int n;

  cin >> n;

  vector<int> a(n), cnt(10e5 + 2);

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

  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
    if (a[i] - 1 > 0) cnt[a[i] - 1]++;
    cnt[a[i] + 1]++;
  }

  sort(cnt.begin(), cnt.end(), greater<int>());

  cout << cnt[0];

  return 0;
}

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

int main(){
  cout << fixed << setprecision(12);
  //小数点12ケタのおまじない
  double  x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double L = 0;
  double X = pow(x2-x1,2);
  double Y = pow(y2-y1,2);
  L = sqrt(X + Y);
  cout << L << endl;
  return 0;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll h,w;
ll MX=50;
vector<vector<char>> maze(MX,vector<char>(MX,'#'));
vvl d(MX,vl(MX,-1));
ll dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll dfs(){
  queue<P> q;
  q.push(P(0,0));
  while(q.size()){
    P p=q.front();
    q.pop();
    if(p.first==h-1&&p.second==w-1){
      break;
    }
    rep(i,4){
      ll nx=p.first+dx[i],ny=p.second+dy[i];
      if(nx>=0&&ny>=0&&nx<h&&ny<w&&maze[nx][ny]!='#'&&d[nx][ny]==-1){
        d[nx][ny]=d[p.first][p.second]+1;
        q.push(P(nx,ny));
      }
    }
  }
  return d[h-1][w-1];
}
int main() {
  cin >> h >> w;
  d[0][0]=0;
  ll cnt=0;
  rep(i,h){
    rep(j,w){
      cin >> maze[i][j];
      if(maze[i][j]=='.'){
        cnt++;
      }
    }
  }
  ll x=dfs();
  if(x==-1){
    cout << x << endl;
  }
  else
    cout << cnt-x-1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  ll m, k;
  cin >> m >> k;
  if (k >= (1 << m)) {
    cout << -1 << endl;
    return 0;
  }
  if (m == 0) {
    cout << "0 0" << endl;
    return 0;
  }
  if (m == 1) {
    if (k == 0) {
      cout << "0 0 1 1" << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }
  cout << k << " ";
  for (ll i=0; i < 1 << m; i++) {
    if (i != k) {
      cout << i << " ";
    }
  }
  cout << k << " ";
  for (ll i=(1 << m) - 1; i >= 0; i--) {
    if (i != k) {
      cout << i << " ";
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

int main(int argc, char *argv[])
{
  int n,m;
  cin >> n >> m;
  double a[n],b[n],c[n];
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  double asum=0;
  rep(i,(1<<n)){
    if(__builtin_popcount(i)!=m) continue;
    double tsum=0;
    rep(j,n)if((i>>j)&1)
      rep(k,n)if((i>>k)&1){
        double x,y,z;
        x=a[j]-a[k];
        y=b[j]-b[k];
        z=c[j]-c[k];
        tsum += x*x+y*y+z*z;
      }
    asum=max(asum,tsum);
  }
  printf("%.8f\n",asum/2);
  return 0;
}

Measured memory_bytes: 1252