akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int a,b;
	while(~scanf("%d%d",&a,&b))
	{
		int sum =a+b;
		if( a%3 == 0 || b%3 ==0 || sum%3 == 0)
			printf("Possible\n");
		else
			printf("Impossible\n");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
//#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
int main(){
	
	/*string s;
	int f=1,f1=1,co=0;
	cin>>s;
	/*char a='Z';
	cout<<(int)a<<endl;*/
	/*
	if(s[0]!='A')f=0;
	if(s[s.size()-1]=='C')f=0;
	for(int i=1;i<s.size();i++){
		if(65<=(int)s[i] && (int)s[i]<=90 && s[i]!='A' && s[i]!='C')f=0;
		if(s[i]=='C')co++;
		if(co!=1)f=0;
		cout<<f;
	}
	cout<<endl;
	if(f)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;*/
	string s,s1,s2;
	cin>>s>>s1>>s2;
	if(s[s.size()-1]==s1[0] && s1[s1.size()-1]==s2[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	
	
	
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int A[500000];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	string S, S2;
	S = ">";
	cin >> S2;
	S += S2;
	int N = S.size();
	S += "<";

	rep(i, N) {
		if (S[i] == '<') A[i] = A[i - 1] + 1;
	}

	for (int i = N - 1; i >= 0; i--) {
		if (S[i + 1] == '>') A[i] = max(A[i], A[i + 1] + 1);
	}

	ll kotae = 0;
	rep(i, N) {
		kotae += A[i];
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int counter[26]={};
    string str;
    while(getline(cin,str)){
        REP(i,str.size()){
            if(str[i]>='a'&&str[i]<='z')counter[str[i]-'a']++;
            else if(str[i]>='A'&&str[i]<='Z')counter[str[i]-'A']++;
        }
    }
    for (int i = 0; i < 26; i++)
    {
        printf("%c : %d\n",i+'a',counter[i]);
    }
    
}


Measured memory_bytes: 3352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define PB(b) push_back((b))
#define F_ first
#define S_ second

typedef long long int lli;
//typedef pair<int,int> P;

const int INF=1<<30;
const long long int INF_=1<<60;

//4,9

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	int N;
	while(cin >> N&&N){
		vector<int> I,P,Q,R;
		REP(i,0,N){
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			I.PB(a);
			P.PB(b);
			Q.PB(c);
			R.PB(d);
		}
		int p,q,r,c;
		cin >> p >> q >> r >> c;
		vector<int> ans;
		REP(i,0,N){
			if(P[i]<=p&&Q[i]<=q&&R[i]<=r&&P[i]*4+Q[i]*9+R[i]*4<=c) ans.PB(I[i]);
		}
		if(ans.empty()) cout << "NA" << endl;
		else REP(i,0,ans.size()) cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1252
#include <cstdio>
#include <cstring>
using namespace std;

#define L 3194304
bool HA[L];
char T[256];

int main() {
    unsigned int n, sum, t;
    char c;
    T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( register unsigned int i = 0; i++ < n; ) {
        sum = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            sum += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[sum] = true;
        } else {
            puts( HA[sum] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
int main()
{
    //sync;
    lld a[3],m=0,k;
    rep(i,0,3) {
        cin>>a[i];
        m = max(m,a[i]);
    }
    sort(a,a+3);
    cin>>k;
    while(k--) {
        a[2] *= 2;
    }
    cout<<(a[0]+a[1]+a[2]);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

# 初期化　（最小化問題なので、INFに初期化する)
dp = [float("inf")] * n

# 初期条件
dp[0] = 0

for i in range(1, n):
    # 1歩目を埋める処理
    if i == 1:
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), 
                    dp[i-2] + abs(h[i] - h[i-2]))
    # print(dp)

print(dp[n-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0;i<N;i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int A = 0;
  int b = 0;
  for (int i = 0; i < N; i++){
    if((i+1)%2==1)
      A += a[i];
      else
        b += a[i];
  }
  cout << A - b << endl;
}


Measured memory_bytes: 256
import heapq
import copy
N,K = map(int, input().split())
V_list= list(map(int, input().split()))

selected = []
left = []

max_sum = 0
left_sum = 0
for l in range(N):
    selected = copy.deepcopy(left)
    lr_sum = left_sum
    for r in range(N-l+1):
        # skip
        stock = K-l-r
        if stock < 0:
            break
        ri = N-r-1
        select_cnt = len(selected)
        tmp_sum = lr_sum
        max_sum = max(max_sum, tmp_sum)
        popper = copy.deepcopy(selected)

        for i in range(stock):
            if i >= select_cnt:
                break
            
            pop_v = heapq.heappop(popper)
            if pop_v > 0:
                break
            tmp_sum -= pop_v
            max_sum = max(max_sum, tmp_sum)

        r_val = V_list[ri]
        lr_sum += r_val
        heapq.heappush(selected, r_val)

    l_val = V_list[l]
    left_sum += l_val
    heapq.heappush(left, l_val)

print(max_sum)

Measured memory_bytes: 9352
//#pragma GCC optimize("O2")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pi>;
const int maxn = 2e2 + 55;
const int mod = 1e9 + 7;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll h, a;
	cin >> h >> a;
	cout << (h+a-1)/a;
}


Measured memory_bytes: 256
import itertools
n = int(input())
a_li = []
x_li = []
y_li = []
for i in range(n):
  a = int(input())
  a_li.append(a)
  tmp_x = []
  tmp_y = []
  for j in range(a):
    x, y = list(map(int, input().split()))
    x -= 1
    tmp_x.append(x)
    tmp_y.append(y)
  x_li.append(tmp_x)
  y_li.append(tmp_y)
total_li = list(itertools.product([0, 1], repeat=n))
ans = 0
for each in total_li:
  flag = True
  for i, person in enumerate(each):
    if person == 1:
      per_li = x_li[i]
      hone_li = y_li[i]
      for pe, ho in zip(per_li, hone_li):
        if each[pe] != ho:
          flag = False

  if flag:
    ans = max(ans, sum(each))
print(ans)

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    std::vector< int > cnt(31, 0);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        int a = 1;
        for(int j=0; j<31; j++){
            int b = 0;
            if(A[i] & a){
                b = 1;
            }
            cnt[j] += b;
            a *= 2;
        }
    }
    
    for(int i=0; i<N; i++){
        int a = 1;
        int ans = 0;
        for(int j=0; j<31; j++){
            int b = 0;
            if(A[i] & a){
                b = 1;
            }
            if((cnt[j] - b) % 2 == 1 ){
                ans += a;
            }
            a *= 2;
        }
        std::cout << ans << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
const int N = 100005, inf = 1e9;

int n, m, dep[N], v[N], s[N], e[N], r;
bool off;

vector<int> adj[N];

bool check (int C, int P) {
	dep[C] = dep[P] + 1;
	if(v[C] && (v[C]-v[r]+dep[C]-1)%2) return false;
	for(auto &T : adj[C]) {
		if(T == P) continue;
		if(!check(T, C)) return false;
	}
	return true;
}

void calc (int C, int P) {
	s[C] = -inf; e[C] = inf;
	if(v[C]) s[C] = e[C] = v[C];
	for(auto &T : adj[C]) {
		if(T == P) continue;
		calc(T, C);
		s[C] = max(s[C], s[T]-1);
		e[C] = min(e[C], e[T]+1);
	}
	if(s[C] > e[C]) off = true;
}

void solve (int C, int P) {
	v[C] = s[C];
	for(auto &T : adj[C]) {
		if(T == P) continue;
		s[T] = max(s[T], s[C]-1);
		e[T] = min(e[T], e[C]+1);
		solve(T, C);
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		v[A] = B+1; r = A;
	}
	calc(r, 0);
	if(off || !check(r, 0)) {puts("No"); return 0;}
	puts("Yes"); solve(r, 0);
	for(int i=1;i<=n;i++) printf("%d\n", v[i]-1);
}


Measured memory_bytes: 12672
using System;
    class Program
    {
      static void Main(string[] args)
      {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);
        var c = int.Parse(input[2]);
        var d = int.Parse(input[3]);
        var lib = (a + b) - (c + d);
        var ans = lib == 0? "Balanced" : lib > 0? "Left": "Right";
        //出力
        Console.WriteLine(ans);
      }
    }

Measured memory_bytes: 13140
n=int(input())
a=list(map(int,input().split()))
a.sort()
dp=[True]*a[-1]
def hantei(i):
    ans = True
    if i!=n-1:
        if a[i]==a[i+1]: ans = False
    if i!=0:
        if a[i]==a[i-1]: ans=False
    return ans
for val in set(a):
    for i in range(2*val,a[-1]+1,val): dp[i-1]=False
ans=0
for i in range(n):
    if dp[a[i]-1] and hantei(i)==1: ans+=1
print(ans)

Measured memory_bytes: 38520
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        
        if (a < b && b < c) System.out.println("Yes");
        else System.out.println("No");
        
    }
    
}


Measured memory_bytes: 26196
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    ll int a,b,c,d;
    cin >> a >> b >> c >> d;

    ll int ans1 = a*c;
    ll int ans2 = a*d;
    ll int ans3 = b*c;
    ll int ans4 = b*d;

    ll int ans = ans1;
    ans = max(ans,ans2);
    ans = max(ans,ans3);
    ans = max(ans,ans4);

    cout << ans;


}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

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

    int x = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            x = i * j;
            if(n == x){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


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

int A[100010];


int main ()
{
	int n, q, temp, cnt = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for(int i = 0; i < q; i++)
	{
		scanf("%d", &temp);
		if(*lower_bound(A, A+n, temp) == temp) cnt++;
	}
	cout << cnt << endl;
	return 0;
}
 


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
int64_t MAXN = 110, MAXV = 100010, MAXW = 1000000000;
// n番目の品物まで使用した時の、価値vにおける重量wの最小値
vector<vector<int64_t>> DP(110, vector<int64_t>(100010, 10000000000));

int main()
{
  int64_t N, W, w, v;
  cin >> N >> W;
  vector<pair<int64_t, int64_t>> wv(N + 1);
  for (int i = 1; i <= N; i++)
  {
    cin >> w >> v;
    wv.at(i) = make_pair(w, v);
  }
  for (int i = 0; i < MAXN; i++)
    DP.at(i).at(0) = 0; // 価値0を達成するためのwの最小値は0
  for (int n = 1; n <= N; n++)
  {
    for (int j = 1; j <= 100000; j++)
    {
      if (j - wv.at(n).second < 0)
      {
        DP.at(n).at(j) = DP.at(n - 1).at(j);
        continue;
      }
      if (DP.at(n - 1).at(j - wv.at(n).second) + wv.at(n).first < DP.at(n - 1).at(j))
        DP.at(n).at(j) = DP.at(n - 1).at(j - wv.at(n).second) + wv.at(n).first;
      else
        DP.at(n).at(j) = DP.at(n - 1).at(j);
    }
  }
  int64_t ans = 0;
  for (int i = 0; i <= 100000; i++)
  {
    if (DP.at(N).at(i) <= W)
      ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 87296
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	int s;
	cin>>s;
	for(int i=s;i<=999;i++)
		if(i%10==((i/10)%10)&&i%10==i/100)
		{
			cout<<i;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 256
#include    <iostream>

using namespace std;

int main() {
    while(1) {
        int i, j;

        cin >> i >> j;
        if(i == 0 && j == 0) break;
        if(i < j)   cout << i << ' ' << j << endl;
        else        cout << j << ' ' << i << endl;
    }

    return 0;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<ll> hp(n);
  rep(i,n) cin >> hp[i];
  sort(hp.rbegin(), hp.rend());
  ll ans = 0;
  rep(i,n) {
    if ( k > 0) k--;
    else {
      ans += hp[i];
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 4824
#define _USE_MATH_DEFINES

#define INF 0x3f3f3f3f

#include <cstdio>

#include <iostream>

#include <sstream>

#include <cmath>

#include <cstdlib>

#include <algorithm>

#include <queue>

#include <stack>

#include <limits>

#include <map>

#include <string>

#include <cstring>

#include <set>

#include <deque>

#include <bitset>

#include <list>

#include <cctype>

#include <utility>

 

using namespace std;

 

typedef long long ll;

typedef pair <int,int> P;

typedef pair <int,P > PP;

 

const static int tx[] = {0,1,1,1,0,-1,-1,-1};

const static int ty[] = {-1,-1,0,1,1,1,0,-1};



int main(){

  int H,W;

  while(~scanf("%d %d",&H,&W)){

    if(H==0 && W==0) break;



    char line[32];

    char stage[10][20];



    for(int y=0;y<H;y++){

      scanf("%s",line);

      for(int x=0;x<W;x++){

	stage[y][x] = line[x];

      }

    }



    string res = "";

    vector<string> spells;

    map<string,int> freq;

    

    for(int y=0;y<H;y++){

      for(int x=0;x<W;x++){

	int sx = x;

	int sy = y;



	for(int dir=0;dir<8;dir++){

	  string spell = "";

	  spell.push_back(stage[sy][sx]);

	  int dx = sx;

	  int dy = sy;

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

	    dx = tx[dir] + dx;

	    dy = ty[dir] + dy;

	    if(dx < 0) dx = W-1;

	    if(dx >= W) dx = 0;

	    if(dy < 0) dy = H-1;

	    if(dy >= H) dy = 0;



	    if(dy == sy && dx == sx) break;

	    spell.push_back(stage[dy][dx]);

	    freq[spell]++;

	    if(freq[spell] >= 2){

	      if(res.size() < spell.size()

		 || (res.size() == spell.size() && res > spell)){

		res = spell;

	      }

	    }

	  }

	  spells.push_back(spell);

	  // cout << spell << endl;

	}

      }

    }

    printf("%s\n",res != "" ? res.c_str() : "0");

  }

}

Measured memory_bytes: 35708
#include <iostream>

using namespace std;

int cnt[31][100001];
int total[100001];

int main(){
    int N, C;
    int ans = 0;
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        int s, t, c;
        cin >> s >> t >> c;
        cnt[c][s]++;
        cnt[c][t]--;
    }
    
    for(int i = 1; i <= 100000; i++){
        for(int j = 1; j <=C; j++){
            cnt[j][i] = cnt[j][i-1]+cnt[j][i];
        }
    }
    for(int i = 0; i <= 100000; i++){
        for(int j = 1; j <= C; j++){
            if(cnt[j][i] == 1 || cnt[j][i+1] == 1){
                total[i]++;
                //cout << i << ' ' << j << endl;
            }
        }
        ans = max(ans, total[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12416
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int t[25][25];
ll dp[18][(1<<16)+ 10];


int main(){
	int n;
	while(cin >> n && n){
		rep(i, n) rep(j, n + 1) cin>>t[i][j];
		rep(i, 18) rep(j, (1<<16) + 10) dp[i][j] = LINF;
		ll ans = LINF;
		
		rep(i, n){
			dp[0][1<<i] = (ll)t[i][0];
		}
		for(int i = 1; i < n; i++){
			for(int stg = 0; stg < n; stg++){					//stage
				for(int state = 0; state < (1<<n); state++){	//clear stage
					if(dp[i-1][state] == LINF) continue;	
					if((state & (1<<stg)) != 0) continue;		//clear
					int nstate = state | (1<<stg);				//next_state
					dp[i][nstate] = min(dp[i][nstate], dp[i-1][state] + t[stg][0]);	//clear without arm
					for(int arm = 0; arm < n; arm++){			//use arm number
						if((state & 1<<arm) == 0) continue;		//no arm
						dp[i][nstate] = min(dp[i][nstate], dp[i-1][state] + t[stg][arm+1]);
					}
				}
			}
		}
		int clear = (1<<n)-1;	//all clear
		ans = dp[n-1][clear];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 12308
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define IS_ODD(d) ((d) & 0x01)

int main(int argc, char *argv)
{
    int n, i;
    int a;
    int all_even;

    scanf("%d", &n);

    all_even = 1;
    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        if (IS_ODD(a)) {all_even = 0;}
    }

    if (all_even == 1) {
        printf("second\n");
    } else {
        printf("first\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;
    cin>>N>>K;
    if(N%K){
        cout1(1)
    }else{
        cout1(0)
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int k;
  cin>>k;
  int ans = -1;
  int x = 0;
  for(int i=0;i<k;i++) {
    x = ((10%k * x%k)%k + 7%k)%k;
    if(x==0) {
      cout << i+1 << '\n';
      return 0;
    }
  }
    cout << "-1\n";
  return 0;
}

Measured memory_bytes: 3604
local n = io.read("*n", "*l")
local r = 0
local r2 = 0
for i = 1, n do
  local s = io.read()
  if s:find("JPY") then
    local v = s:match("%d+")
    v = tonumber(v)
    r = r + v
  else
    local a = s:match("(%d+%.%d+)")
    a = tonumber(a)
    r = r + 380000 * a
  end
end
print(r)


Measured memory_bytes: 2800
n = int(input())
a_s_with_index = [(i, int(input())) for i in range(n)]
a_s = [a_i[1] for a_i in a_s_with_index]
a_s.sort()

for i, a_i in a_s_with_index:
    if  a_i == a_s[n-1]:
        a_max_i = n-2
    else:
        a_max_i = n-1

    print(a_s[a_max_i])


Measured memory_bytes: 33128
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	
	int ans=0;
	int rem=k;
	
	ans+=min(a,rem);
	rem-=min(a,rem);
	if(rem==0)
	{
		cout<<ans;return 0;
	}
	ans+=(min(b,rem)*0);
	rem-=min(b,rem);
	if(rem==0)
	{
		cout<<ans;return 0;
	}
	ans-=min(rem, c);
	cout<<ans;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
 
const string YES = "Yes";
const string NO = "No";
 
void func(long long N){
 
    string s = to_string(N);
 
    if(s[0]=='7' || s[1]=='7' || s[2]=='7')cout<<YES<<endl;
    else cout<<NO<<endl;
 
}
 
int main(){
    // cout << fixed << setprecision(5);
 
    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,d,i,j,count;
	while(cin>>n)
	{
	    count=0; 
		for(i=1;i<=n;i+=2)
		{	
		    d=0;
			for(j=1;j<=sqrt(i);j++)
			{
				if(i%j==0)
				    d+=2;
			}
			if(d==8)
			    count++;
		}
		cout<<count<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            input_iter = LazyLoadAllLines();
            //------------------------------------------------//
            var n = Read<long>();
            //var k = Read<long>();
            //var b = Read<long>();
            //var c = Read<long>();
            //var x = Read<long>();
            var als = Read<long>(n);

            //als.Sort((l, r) => (int)(r - l));

            var x = als.Select((val, idx) => new { val, idx }).ToList();
            x.Sort((l, r) => (int)(l.val - r.val));


            Console.WriteLine(string.Join(" ", x.Select(val => val.idx + 1)));

        }



        static IEnumerator<string> input_iter;

        static _T Read<_T>() where _T : struct
        {
            input_iter.MoveNext();
            return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
        }
        static string Read()
        {
            input_iter.MoveNext();
            return input_iter.Current;
        }
        static List<_T> Read<_T>(long num) where _T : struct { return new List<_T>(Enumerate<_T>(num)); }


        static IEnumerable<_T> Enumerate<_T>(long num)
        {
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                yield return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
            }
        }
        static IEnumerator<string> LazyLoadAllLines()
        {
            string line;
            do
            {
                line = Console.ReadLine();
                foreach (var s in line.Split(' '))
                    yield return s;
            } while (line != null);
        }
    }
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n - 1);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n - 1; ++i) cin >> c[i];

  int ans = 0;
  int pre = -1;
  for (int i = 0; i < n; ++i) {
    int type = a[i];
    int sat = b[type - 1];
    ans += sat;
    if (pre != -1 && type - pre == 1) {
      ans += c[type - 2];
    }
    pre = type;
  }

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



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
  for j in range(b+1):
    num = x - (500*i+100*j)
    if int(num / 50) <= c and num >=0:
      count += 1
print(count)

Measured memory_bytes: 3060
import numpy as np

n,m,d = map(int,input().split())

"""
#kuso code
start = time.time()
a = [random.randrange(n) for i in range(m)]
a = np.array(a)
b = np.abs(a[1:]-a[:-1])
cnt = np.sum(b == d)
ave = cnt

i = 0
while(time.time() - start < 10):
    a = [random.randrange(n) for i in range(m)]
    a = np.array(a)
    b = np.abs(a[1:]-a[:-1])
    cnt = np.sum(b == d)
    ave = ((i+1)*ave + cnt)/(i+2)
    i += 1
print(ave)
"""

oks_times_n = 2*np.max(n-2*d,0) + 2*d
ave = oks_times_n/n/n*(m-1)
if (d == 0):
    ave /= 2
print(ave)


Measured memory_bytes: 21088
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n,a,b;
	cin >> n >> a >> b;
	
	if((b-a)%2 == 0){
		cout << (b-a)/2 << endl;
		return 0;
	}

	int sa = a-1;
	int x = sa;
	int bb = b-sa;
	x++;
	bb--;
	x += (bb-1)/2;

	sa = n-b;
	int y = sa;
	int aa = a+sa;
	y++;
	aa++;
	y += (n-aa)/2;
	
	cout << min(x,y) << endl;
	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://agc041.contest.atcoder.jp/tasks/agc041_a

Measured memory_bytes: 3644
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    val n = readInt
    val b = new ArrayBuffer[Int]
    val g = for(i<-0 until n) yield {
      readLine.trim.split(" ").map(_.toInt)
    }

    var v = 0
    var total = 0
    b += v

    while(b.length < g.length) {
      var min = Int.MaxValue
      v = 0
      for(e <- b) {
        val list = (for(i<-0 until g(e).length if !b.contains(i)) yield (g(e)(i),i)).filter(_._1 != -1)
        if(list.length > 0) {
          val listMin = list.min
          if(listMin._1<min) {
            min = listMin._1
            v = listMin._2
          }
        }
      }
      total += min
      b += v
    }
    println(total)
  }
}

Measured memory_bytes: 62568
N = gets.to_i
S1 = gets.chomp.split("")
S2 = gets.chomp.split("")

sum = 1
S1.zip(S2).each.with_index do |(s1, s2), i|
  if s1 == s2
    if i == 0
      sum *= 3
    elsif S1[i-1] == S2[i-1]
      sum *= 2
    end
  else
    if i == 0
      sum *= 6
    elsif S1[i-1] == S2[i-1]
      sum *= 2
    elsif S1[i-1] != S2[i-1] and S1[i-1] != s1
      sum *= 3
    end
  end
end
puts sum % 1000000007


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

class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
	    InputStreamReader input = new InputStreamReader (System. in);
	    BufferedReader buffer = new BufferedReader(input);
	    String read = buffer.readLine();
	    int amount = Integer.parseInt(read);
	    int[][] graph = new int[amount][amount];

	    for(int i=0; i<amount; i++){
	    	read = buffer.readLine();
	    	String[] scan = read.split(" ");
	    	int[] scanInt = new int[scan.length];
	    	for(int j=0; j<scan.length; j++){
	    		scanInt[j] = Integer.parseInt(scan[j]);
	    	}
	    	for(int j=2; j<scanInt[1]+2; j++){
	    		graph[i][scanInt[j]-1] = 1;
	    	}
	    }
    	for(int j=0; j<amount; j++){
    		for(int k=0; k<amount; k++){
    			System.out.print(graph[j][k]);
        		if(k == amount-1){
        			System.out.println("");
        		}
        		else{
        			System.out.print(" ");
        		}
    		}
    	}
	}
}

Measured memory_bytes: 30632
#include <stdio.h>
#include <string.h>

int main()
{
  char str1[100] = {};
  char str2[100] = {};
  char seq[200] = {};

  scanf("%s %s", str1, str2);
  strcat(seq, str1);
  strcat(seq, str1);
  if(strstr(seq, str2) != NULL)
    printf("Yes\n");
  else
    printf("No\n");
}



Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<random>
#include<iomanip>

//#include"gap.h"

using namespace std;

const int int_max = 2147483647;

/*
const int MOD = 1000000007;
 

int N;
double p[3000];
double dp[3000][3000] = {};
 
int main(){
    cin >> N;
    int t = 1;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        
        p[i] = tmp * 100;
        
        //cin >> p[i];
        
        t *= 100;
    }
    
    dp[0][0] = 1;
    for(int i=1; i<=N; i++){
        for(int j=0; j<=N; j++){    //表ｊ枚
            dp[i][j+1] += dp[i-1][j]*p[i-1];
            //dp[i][j] += dp[i-1][j]*(1-p[i-1]);
            
            dp[i][j] += dp[i-1][j]*(100-p[i-1]);
            
            dp[i][j] /= 100;
        }
    }
    
    double ans = 0;
    for(int i=N/2+1; i<=N; i++){
        ans += dp[N][i];
    }
    
    
    cout << ans << endl;
    
    
    return 0;
}
*/


int N;
double p[3000];
double dp[3000][3000] = {};
 
int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> p[i];
    }
    
    dp[0][0] = 1;
    for(int i=1; i<=N; i++){
        for(int j=0; j<=N; j++){    
            dp[i][j+1] += dp[i-1][j]*p[i-1];
            dp[i][j] += dp[i-1][j]*(1-p[i-1]);
        }
    }
    
    double ans = 0;
    for(int i=N/2+1; i<=N; i++){
        ans += dp[N][i];
    }
    
    
    cout << fixed << setprecision(9) << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 70528
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#V, E, r = map(int, input().split())
#INF = V * 10001
#A = [int(i) for i in input().split()]


N = int(input())
A = [int(i) for i in input().split()]
dp = [0]*(N+1)
ans = 0
cnt = 0
tle = 0

As = list(set(A))
c = Counter(A)

for i in As:
  cnt = c[i]
  if(cnt<2):
    dp[i] = 0
  else:
    dp[i] = combinations_count(cnt, 2)

tle = sum(dp)

#print(dp)
for i in range(N):
  ans = tle - (c[A[i]]-1)
  if(ans < 0):
    ans = 0
  print(int(ans))

#print(ans)


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

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

  vector<int> members(n + 1, 0);

  rep(i, n - 1) {
    int a;
    cin >> a;
    members[a]++;
  }

  rep(i, n) { cout << members[i + 1] << endl; }

  return 0;
}


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

using namespace std;

int main() {
	
	int *A,N,frag=0;
	cin >> N;
	A = new int[N];

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

	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 0) {
			if ((A[i] % 3 != 0) && (A[i] % 5 != 0)) {
				frag = 1;
				break;
			}
		}
	}

	if (frag == 0) {
		cout << "APPROVED";
	}
	else {
		cout << "DENIED";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n,k,i,j,t,a[100001],min;
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	min=a[k-1]-a[0];
	for(i=k;i<n;i++)
		if(min>a[i]-a[i-k+1])
			min=a[i]-a[i-k+1];
	cout<<min;
	return 0;
}

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

#define rep(i, a, b)	for(int i = a; i <= b; ++i)

using namespace std;

const int N = 55;

int n, D[N];
int F[N];
int cnt[N];
int mask;
int shit;

int calc(){
	int ans = 24;
	vector <int> showkat;
	for(int i = 0; i < 24; ++i) if(mask & (1 << i)) showkat.push_back(i);
	for(int i = 1; i < showkat.size(); ++i) ans = min(ans, showkat[i] - showkat[i - 1]);
	if(showkat.size() == 1) return 0;
	ans = min(ans, 24 - showkat.back() + showkat[0]);
	return ans;
}

void subha(int ans){
	cout << ans << endl;
	exit(0);
}

int main(){
	cin >> n;
	n += 1;
	cnt[0] += 1;
	for(int i = 2; i <= n; ++i){
		cin >> D[i];
		cnt[D[i]] += 1;
	}
	vector <int> F;
	for(int i = 0; i <= 12; ++i){
		if(cnt[i] > 2) subha(0);
		if(cnt[i] == 2 && i == 0) subha(0);
		if(cnt[i] == 2 || i == 0){
			mask |= 1 << i;
			mask |= 1 << (24 - i);
		}
		else if(cnt[i] == 1) F.push_back(i);
	}
	int gap = 0;
	n = F.size();
	for(int naz = 0; naz < (1 << n); ++naz){
		for(int i = 0; i < n; ++i){
			if(naz & (1 << i)) mask ^= 1 << F[i];
			else mask ^= 1 << (24 - F[i]);
		}
		gap = max(gap, calc());
		for(int i = 0; i < n; ++i){
			if(naz & (1 << i)) mask ^= 1 << F[i];
			else mask ^= 1 << (24 - F[i]);
		}
	}
	cout << gap << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io;
fn main(){
    let mut line1 = String::new();
    io::stdin().read_line(&mut line1);
    
    let mut line2 = String::new();
    io::stdin().read_line(&mut line2).ok();
    let xs = line2.trim().split_whitespace()
        .map(|e| e.parse::<i64>().ok().unwrap());
    
	let mut min = 1000000;
	let mut max = -1000000;
	let mut sum = 0;
	for x in xs {
		if x < min { min = x; }
		if max < x { max = x; }
		sum += x;
	}
	println!("{} {} {}", min, max, sum)
}


Measured memory_bytes: 5040
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    if(i%3!=0&&i%5!=0)
      ans+=i;
  }
  cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 3804
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

int main(void){
int X,N,p[1000];
  scanf("%d%d",&X,&N);
  for(int i=1;i<=N;i++){
  scanf("%d",&p[i]);
  }

  bool icchi=false;
  for(int j=0;j<=101;j++){
    for(int i=1;i<=N;i++){
      if(p[i]==X-j) icchi=true;
    }
    if(!(icchi)) {
      printf("%d",X-j);
      return 0; 
    }
    icchi=false;

    for(int i=1;i<=N;i++){
      if(p[i]==X+j) icchi=true;
    }
    if(!(icchi)) {
      printf("%d",X+j);
      return 0; 
    }
    icchi=false;
  }
  printf("hi");
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1){}
    void init(int n) {par.assign(n, -1);}

    //再帰的に辿ることで親を調べる
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    //親が同じならば同じ集合に属する
    bool same(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        //新しい要素を加えた時に、rootに対して辺を張る(merge technique)
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    //新しいノードを集合に加えた時に、-1をrootに加算するため、
    //rootには、集合に属するノードの数に負符号を付加したものが保存されている。
    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n, k, l;
    cin >> n >> k >> l;

    UnionFind r(n+1);
    UnionFind t(n+1);

    rep(i, k){
        int p, q;
        cin >> p >> q;
        r.merge(p, q);
    }

    rep(i, l){
        int a, b;
        cin >> a >> b;
        t.merge(a, b);
    }

    using P = pair<int, int>;
    map<P, int> ma;
    for(int i=1; i<=n; i++){
        ma[P(r.root(i), t.root(i))]++;
    }

    for(int i=1; i<=n; i++){
        cout << ma[P(r.root(i), t.root(i))] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 13568
import sys
input = sys.stdin.readline


def main():
    H, W = [int(x) for x in input().split()]
    A = [input().strip() for _ in range(H)]

    ansh = []
    for i, a in enumerate(A):
        if a.count("#") == 0:
            ansh.append(i)

    answ = []
    for i, a in enumerate(zip(*A)):
        if a.count("#") == 0:
            answ.append(i)

    for j in range(H):
        if j in ansh:
            continue
        for i in range(W):
            if i in answ:
                continue
            else:
                print(A[j][i], end="")
        print("")

    
    
    


if __name__ == '__main__':
    main()



Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define int long long

vector<vector<int>> G;
vector<int> ans;

void bfs() {
  queue<pair<int,int>> que;
  que.emplace(0, 0);
  while(!que.empty()) {
    int from = que.front().first;
    int cur = que.front().second;
    que.pop();

    for (auto to : G[cur]) {
      if(ans[to] == -1) {
        ans[to] = cur;
        que.emplace(cur, to);
      }
    }
  }
}

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

  int n,m;
  cin >> n >> m;

  G.resize(n);
  ans.resize(n, -1);
  for (int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    a--, b--;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  bfs();
  cout << "Yes" << '\n';
  for (int i = 1; i < n; i++) {
    cout << ans[i] + 1 << '\n';
  }

}

Measured memory_bytes: 13648
#include<iostream>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	//上半分はBを背景として、ぽつぽつとWがある感じ
	//下半分はその逆
	cout << 100 << " " << 100 << endl;
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 100; j++) {
			if (A >= 2 && i % 2 == 1 && j % 2 == 1) {
				cout << ".";
				A--;
			}
			else cout << "#";
		}
		cout << endl;
	}
	for (int i = 50; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (B >= 2 && i % 2 == 1 && j % 2 == 1) {
				cout << "#";
				B--;
			}
			else cout << ".";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S, T[10000], U, V, W, X; int n, cnt;

void solve(string A, string B) {
	if (cnt == 0) { T[cnt] = A + B; cnt++; }
	else {
		for (int i = 0; i < cnt; i++) {
			if (A + B == T[i]) {
				goto E;
			}
		}
		T[cnt] = A + B;
		cnt++;
	E:;
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cnt = 0;
		for (int j = 0; j < 10000; j++) { T[j] = ""; }
		cin >> S;
		for (int j = 1; j < S.size(); j++) {
			W = "", X = "";
			U = S.substr(0, j);
			V = S.substr(j, S.size() - j);
			for (int k = U.size() - 1; k >= 0; k--) {
				W += U[k];
			}
			for (int k = V.size() - 1; k >= 0; k--) {
				X += V[k];
			}
			solve(U, V);
			solve(V, U);
			solve(U, X);
			solve(X, U);
			solve(V, W);
			solve(W, V);
			solve(W, X);
			solve(X, W);
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1352